From c87901dd730fbd4cf56f4c742b407730e45d6707 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BF=A0=20/=20green?= Date: Wed, 3 Apr 2024 13:08:29 +0900 Subject: [PATCH 01/45] docs: add `@shikiji/vitepress-twoslash` (#5445) * docs: add `@shikiji/vitepress-twoslash` * docs: add prettier-ignore where needed * docs: fix output.format Co-authored-by: Lukas Taegert-Atkinson * docs: fix format --------- Co-authored-by: Lukas Taegert-Atkinson --- docs/.vitepress/config.ts | 23 + docs/.vitepress/theme/index.ts | 4 + docs/command-line-interface/index.md | 66 +- docs/configuration-options/index.md | 332 ++++--- docs/faqs/index.md | 10 +- docs/javascript-api/index.md | 271 +++--- docs/plugin-development/index.md | 168 +++- docs/tools/index.md | 24 +- docs/troubleshooting/index.md | 22 +- docs/tsconfig.json | 6 +- docs/tutorial/index.md | 15 +- package-lock.json | 1253 ++++++++++++++++++++++++-- package.json | 1 + 13 files changed, 1832 insertions(+), 363 deletions(-) diff --git a/docs/.vitepress/config.ts b/docs/.vitepress/config.ts index b592b2f2f..f9b8e1f00 100644 --- a/docs/.vitepress/config.ts +++ b/docs/.vitepress/config.ts @@ -1,4 +1,5 @@ import alias from '@rollup/plugin-alias'; +import { transformerTwoslash } from '@shikijs/vitepress-twoslash'; import type { Plugin } from 'vite'; import { defineConfig } from 'vitepress'; import { moduleAliases } from '../../build-plugins/aliases'; @@ -35,6 +36,28 @@ export default defineConfig({ callback, level: 2 }, + codeTransformers: [ + transformerTwoslash({ + langs: [ + // defaults + 'ts', + 'tsx', + 'js', + 'jsx', + 'json', + 'vue', + // custom + 'javascript', + 'typescript' + ], + twoslashOptions: { + compilerOptions: { + moduleResolution: 100, // bundler + types: ['node'] + } + } + }) + ], config(md) { transposeTables(md); }, diff --git a/docs/.vitepress/theme/index.ts b/docs/.vitepress/theme/index.ts index 23dae1156..e881e50d6 100644 --- a/docs/.vitepress/theme/index.ts +++ b/docs/.vitepress/theme/index.ts @@ -1,3 +1,6 @@ +// eslint-disable-next-line import/no-unresolved +import TwoslashFloatingVue from '@shikijs/vitepress-twoslash/client'; +import '@shikijs/vitepress-twoslash/style.css'; import { createPinia } from 'pinia'; // eslint-disable-next-line import/no-unresolved import defaultTheme from 'vitepress/theme'; @@ -8,6 +11,7 @@ const theme: typeof defaultTheme = { ...defaultTheme, enhanceApp(context) { context.app.use(pinia); + context.app.use(TwoslashFloatingVue); } }; diff --git a/docs/command-line-interface/index.md b/docs/command-line-interface/index.md index 47f8da4de..c0bb9608a 100755 --- a/docs/command-line-interface/index.md +++ b/docs/command-line-interface/index.md @@ -12,7 +12,9 @@ Rollup should typically be used from the command line. You can provide an option Rollup configuration files are optional, but they are powerful and convenient and thus **recommended**. A config file is an ES module that exports a default object with the desired options: -```javascript +```javascript twoslash +/** @type {import('rollup').RollupOptions} */ +// ---cut--- export default { input: 'src/main.js', output: { @@ -36,10 +38,13 @@ Using the `--configPlugin` option will always force your config file to be trans Config files support the options listed below. Consult the [big list of options](../configuration-options/index.md) for details on each option: -```javascript +```javascript twoslash // rollup.config.js // can be an array (for multiple inputs) +// ---cut-start--- +/** @type {import('rollup').RollupOptions} */ +// ---cut-end--- export default { // core input options external, @@ -139,9 +144,12 @@ export default { You can export an **array** from your config file to build bundles from several unrelated inputs at once, even in watch mode. To build different bundles with the same input, you supply an array of output options for each input: -```javascript +```javascript twoslash // rollup.config.js (building more than one bundle) +// ---cut-start--- +/** @type {import('rollup').RollupOptions[]} */ +// ---cut-end--- export default [ { input: 'main-a.js', @@ -196,11 +204,14 @@ rollup --config You can also export a function that returns any of the above configuration formats. This function will be passed the current command line arguments so that you can dynamically adapt your configuration to respect e.g. [`--silent`](#silent). You can even define your own command line options if you prefix them with `config`: -```javascript +```javascript twoslash // rollup.config.js import defaultConfig from './rollup.default.config.js'; import debugConfig from './rollup.debug.config.js'; +// ---cut-start--- +/** @type {import('rollup').RollupOptionsFunction} */ +// ---cut-end--- export default commandLineArgs => { if (commandLineArgs.configDebug === true) { return debugConfig; @@ -213,25 +224,30 @@ If you now run `rollup --config --configDebug`, the debug configuration will be By default, command line arguments will always override the respective values exported from a config file. If you want to change this behaviour, you can make Rollup ignore command line arguments by deleting them from the `commandLineArgs` object: -```javascript +```javascript twoslash // rollup.config.js +// ---cut-start--- +/** @type {import('rollup').RollupOptionsFunction} */ +// ---cut-end--- export default commandLineArgs => { - const inputBase = commandLineArgs.input || 'main.js'; - - // this will make Rollup ignore the CLI argument - delete commandLineArgs.input; - return { - input: 'src/entries/' + inputBase, - output: { ... } - } -} + const inputBase = commandLineArgs.input || 'main.js'; + + // this will make Rollup ignore the CLI argument + delete commandLineArgs.input; + return { + input: 'src/entries/' + inputBase, + output: { + /* ... */ + } + }; +}; ``` ### Config Intellisense Since Rollup ships with TypeScript typings, you can leverage your IDE's Intellisense with JSDoc type hints: -```javascript +```javascript twoslash // rollup.config.js /** * @type {import('rollup').RollupOptions} @@ -244,7 +260,7 @@ export default config; Alternatively you can use the `defineConfig` helper, which should provide Intellisense without the need for JSDoc annotations: -```javascript +```javascript twoslash // rollup.config.js import { defineConfig } from 'rollup'; @@ -261,7 +277,7 @@ Besides `RollupOptions` and the `defineConfig` helper that encapsulates this typ You can also directly write your config in TypeScript via the [`--configPlugin`](#configplugin-plugin) option. With TypeScript, you can import the `RollupOptions` type directly: -```typescript +```typescript twoslash import type { RollupOptions } from 'rollup'; const config: RollupOptions = { @@ -298,14 +314,14 @@ Especially when upgrading from an older Rollup version, there are some things yo With CommonJS files, people often use `__dirname` to access the current directory and resolve relative paths to absolute paths. This is not supported for native ES modules. Instead, we recommend the following approach e.g. to generate an absolute id for an external module: -```js +```js twoslash // rollup.config.js -import { fileURLToPath } from 'node:url' +import { fileURLToPath } from 'node:url'; export default { - ..., - // generates an absolute path for /src/some-file.js - external: [fileURLToPath(new URL('src/some-file.js', import.meta.url))] + /* ..., */ + // generates an absolute path for /src/some-file.js + external: [fileURLToPath(new URL('src/some-file.js', import.meta.url))] }; ``` @@ -315,7 +331,7 @@ It can be useful to import your package file to e.g. mark your dependencies as " - For Node 17.5+, you can use an import assertion - ```js + ```js twoslash import pkg from './package.json' assert { type: 'json' }; export default { @@ -327,7 +343,7 @@ It can be useful to import your package file to e.g. mark your dependencies as " - For older Node versions, you can use `createRequire` - ```js + ```js twoslash import { createRequire } from 'node:module'; const require = createRequire(import.meta.url); const pkg = require('./package.json'); @@ -337,7 +353,7 @@ It can be useful to import your package file to e.g. mark your dependencies as " - Or just directly read and parse the file from disk - ```js + ```js twoslash // rollup.config.mjs import { readFileSync } from 'node:fs'; diff --git a/docs/configuration-options/index.md b/docs/configuration-options/index.md index e517af4e5..f6248db14 100755 --- a/docs/configuration-options/index.md +++ b/docs/configuration-options/index.md @@ -20,10 +20,13 @@ Either a function that takes an `id` and returns `true` (external) or `false` (n 1. the name of an external dependency, exactly the way it is written in the import statement. I.e. to mark `import "dependency.js"` as external, use `"dependency.js"` while to mark `import "dependency"` as external, use `"dependency"`. 2. a resolved ID (like an absolute path to a file). -```js +```js twoslash // rollup.config.js import { fileURLToPath } from 'node:url'; +// ---cut-start--- +/** @type {import('rollup').RollupOptions} */ +// ---cut-end--- export default { //..., external: [ @@ -91,24 +94,34 @@ The bundle's entry point(s) (e.g. your `main.js` or `app.js` or `index.js`). If Note that it is possible when using the object form to put entry points into different sub-folders by adding a `/` to the name. The following will generate at least two entry chunks with the names `entry-a.js` and `entry-b/index.js`, i.e. the file `index.js` is placed in the folder `entry-b`: -```js +```js twoslash // rollup.config.js +// ---cut-start--- +/** @type {import('rollup').RollupOptions} */ +// ---cut-end--- export default { - ..., - input: { - a: 'src/main-a.js', - 'b/index': 'src/main-b.js' - }, - output: { - ..., - entryFileNames: 'entry-[name].js' - } + // ... + input: { + a: 'src/main-a.js', + 'b/index': 'src/main-b.js' + }, + output: { + // ... + entryFileNames: 'entry-[name].js' + } }; ``` If you want to convert a set of files to another format while maintaining the file structure and export signatures, the recommended way—instead of using [`output.preserveModules`](#output-preservemodules) that may tree-shake exports as well as emit virtual files created by plugins—is to turn every file into an entry point. You can do so dynamically e.g. via the `glob` package: -```js +```ts twoslash +// @filename: glob.d.ts +declare module 'glob' { + export function globSync(pattern: string): string[]; +} + +// @filename: index.js +// ---cut--- import { globSync } from 'glob'; import path from 'node:path'; import { fileURLToPath } from 'node:url'; @@ -206,18 +219,21 @@ import $ from 'jquery'; …we want to tell Rollup that `jquery` is external and the `jquery` module ID equates to the global `$` variable: -```js +```js twoslash // rollup.config.js +// ---cut-start--- +/** @type {import('rollup').RollupOptions} */ +// ---cut-end--- export default { - ..., - external: ['jquery'], - output: { - format: 'iife', - name: 'MyBundle', - globals: { - jquery: '$' - } - } + // ... + external: ['jquery'], + output: { + format: 'iife', + name: 'MyBundle', + globals: { + jquery: '$' + } + } }; /* @@ -237,7 +253,7 @@ rollup -i src/main.js ... -g jquery:$,underscore:_ To tell Rollup that a local file should be replaced by a global variable, use an absolute id: -```js +```js twoslash // rollup.config.js import { fileURLToPath } from 'node:url'; const externalId = fileURLToPath( @@ -247,6 +263,9 @@ const externalId = fileURLToPath( ) ); +// ---cut-start--- +/** @type {import('rollup').RollupOptions} */ +// ---cut-end--- export default { //..., external: [externalId], @@ -269,15 +288,18 @@ export default { Necessary for `iife`/`umd` bundles that exports values in which case it is the global variable name representing your bundle. Other scripts on the same page can use this variable name to access the exports of your bundle. -```js +```js twoslash // rollup.config.js +// ---cut-start--- +/** @type {import('rollup').RollupOptions} */ +// ---cut-end--- export default { - ..., - output: { - file: 'bundle.js', - format: 'iife', - name: 'MyBundle' - } + // ... + output: { + file: 'bundle.js', + format: 'iife', + name: 'MyBundle' + } }; // var MyBundle = (function () {... @@ -307,10 +329,13 @@ Not every plugin can be used here. `output.plugins` is limited to plugins that o The following will add minification to one of the outputs: -```js +```js twoslash // rollup.config.js import terser from '@rollup/plugin-terser'; +// ---cut-start--- +/** @type {import('rollup').RollupOptions} */ +// ---cut-end--- export default { input: 'main.js', output: [ @@ -335,13 +360,16 @@ export default { See [Using plugins](../tutorial/index.md#using-plugins) for more information on how to use plugins and [Plugins](../plugin-development/index.md) on how to write your own (try it out, it's not as difficult as it may sound and very much extends what you can do with Rollup). For plugins imported from packages, remember to call the imported plugin function (i.e. `commonjs()`, not just `commonjs`). Falsy plugins will be ignored, which can be used to easily activate or deactivate plugins. Nested plugins will be flattened. Async plugins will be awaited and resolved. -```js +```js twoslash // rollup.config.js import resolve from '@rollup/plugin-node-resolve'; import commonjs from '@rollup/plugin-commonjs'; const isProduction = process.env.NODE_ENV === 'production'; +// ---cut-start--- +/** @type {Promise} */ +// ---cut-end--- export default (async () => ({ input: 'main.js', plugins: [ @@ -369,8 +397,11 @@ export default (async () => ({ The `cache` property of a previous bundle. Use it to speed up subsequent builds in watch mode — Rollup will only reanalyse the modules that have changed. Setting this option explicitly to `false` will prevent generating the `cache` property on the bundle and also deactivate caching for plugins. -```js +```js twoslash const rollup = require('rollup'); +// ---cut-start--- +/** @type {import('rollup').RollupCache | undefined} */ +// ---cut-end--- let cache; async function buildWithCache() { @@ -481,8 +512,11 @@ The function receives three arguments: the log level, the log object and the def If the default handler is not invoked, the log will not be printed to the console. Moreover, you can change the log level by invoking the default handler with a different level. Using the additional level `"error"` will turn the log into a thrown error that has all properties of the log attached. -```js +```js twoslash // rollup.config.js +// ---cut-start--- +/** @type {import('rollup').RollupOptions} */ +// ---cut-end--- export default { //... onLog(level, log, handler) { @@ -502,8 +536,11 @@ This handler will not be invoked if logs are filtered out by the [`logLevel`](#l Some logs also have a `loc` property and a `frame` allowing you to locate the source of the log: -```js +```js twoslash // rollup.config.js +// ---cut-start--- +/** @type {import('rollup').RollupOptions} */ +// ---cut-end--- export default { //... onLog(level, { loc, frame, message }) { @@ -560,15 +597,18 @@ If you supply a function, `chunk` contains additional information about the chun `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`. -```js +```js twoslash // rollup.config.js +// ---cut-start--- +/** @type {import('rollup').RollupOptions} */ +// ---cut-end--- export default { - ..., - output: { - ..., - banner: '/* my-library version ' + version + ' */', - footer: '/* follow me on Twitter! @rich_harris */' - } + // ... + output: { + // ... + banner: '/* my-library version ' + version + ' */', + footer: '/* follow me on Twitter! @rich_harris */' + } }; ``` @@ -610,7 +650,7 @@ This will minify the wrapper code generated by rollup. Note that this does not a While CommonJS output originally supported only `require(…)` to import dependencies, recent Node versions also started to support `import(…)`, which is the only way to import ES modules from CommonJS files. If this option is `true`, which is the default, Rollup will keep external dynamic imports as `import(…)` expressions in CommonJS output. Set this to `false` to rewrite dynamic imports using `require(…)` syntax. -```js +```js twoslash // input import('external').then(console.log); @@ -721,7 +761,7 @@ Whether to use arrow functions for auto-generated code snippets. Note that in ce This will use `const` instead of `var` in certain places and helper functions. This will allow Rollup to generate more efficient helpers due to block scoping. -```js +```js twoslash // input export * from 'external'; @@ -760,7 +800,7 @@ for (const k in external) { Allows the use of shorthand notation in objects when the property name matches the value. -```javascript +```javascript twoslash // input const foo = 1; export { foo, foo as bar }; @@ -797,7 +837,10 @@ System.register('bundle', [], function (exports) { Allows choosing one of the presets listed above while overriding some options. -```js +```js twoslash +// ---cut-start--- +/** @type {import('rollup').RollupOptions} */ +// ---cut-end--- export default { // ... output: { @@ -919,7 +962,7 @@ Keep in mind that for Rollup, `import * as ext_namespace from 'external'; consol - `"default"` assumes that the required value should be treated as the default export of the imported module, just like when importing CommonJS from an ES module context in NodeJS. Named imports are supported as well, which are treated as properties of the default import. To create the namespace object, Rollup injects these helpers: - ```js + ```js twoslash var external = require('external1'); function _interopNamespaceDefault(e) { @@ -973,7 +1016,7 @@ Keep in mind that for Rollup, `import * as ext_namespace from 'external'; consol - `"auto"` combines both `"esModule"` and `"default"` by injecting helpers that contain code that detects at runtime if the required value contains the [`__esModule` property](#output-esmodule). Adding this property is a hack implemented by TypeScript `esModuleInterop`, Babel and other tools to signify that the required value is the namespace of a transpiled ES module.: - ```js + ```js twoslash var external = require('external1'); function _interopNamespace(e) { @@ -1035,7 +1078,7 @@ Keep in mind that for Rollup, `import * as ext_namespace from 'external'; consol - `compat` is equivalent to `"auto"` except that it uses a slightly different helper for the default export that checks for the presence of a `default` property instead of the `__esModule` property. Except for the rare situation where a CommonJS module exports a property `"default"` that should not be the default export, this often helps to make interop "just work" as it does not rely on idiosyncratic hacks but instead uses duck-typing: - ```js + ```js twoslash var external = require('external1'); function _interopNamespaceCompat(e) { @@ -1131,11 +1174,14 @@ Keep in mind that for Rollup, `import * as ext_namespace from 'external'; consol As an example if all dependencies are CommonJs, the following config will ensure that named imports are only permitted from Node builtins: - ```js + ```js twoslash // rollup.config.js import builtins from 'builtins'; const nodeBuiltins = new Set(builtins()); + // ---cut-start--- + /** @type {import('rollup').RollupOptions} */ + // ---cut-end--- export default { // ... output: { @@ -1164,7 +1210,10 @@ There are some additional options that have an effect on the generated interop c Similar to [`output.banner/output.footer`](#output-banner-output-footer), except that the code goes _inside_ any format-specific wrapper. -```js +```js twoslash +// ---cut-start--- +/** @type {import('rollup').RollupOptions} */ +// ---cut-end--- export default { //..., output: { @@ -1196,7 +1245,10 @@ will put all lodash modules into a manual chunk even if you are only using impor When using the function form, each resolved module id will be passed to the function. If a string is returned, the module and all its dependency will be added to the manual chunk with the given name. For instance this will create a `vendor` chunk containing all dependencies inside `node_modules`: -```javascript +```javascript twoslash +// ---cut-start--- +/** @type {import('rollup').GetManualChunk} */ +// ---cut-end--- function manualChunks(id) { if (id.includes('node_modules')) { return 'vendor'; @@ -1228,11 +1280,18 @@ If a lot of such components are used together, this will result in a lot of dyna The following code will merge all files of the same language that are only used by a single entry point: -```js + +```js twoslash +// ---cut-start--- +/** @type {import('rollup').GetManualChunk} */ +// ---cut-end--- function manualChunks(id, { getModuleInfo }) { const match = /.*\.strings\.(\w+)\.js/.exec(id); if (match) { const language = match[1]; // e.g. "en" +// ---cut-start--- + /** @type {string[]} */ +// ---cut-end--- const dependentEntryPoints = []; // we use a Set here so we handle each module at most once. This @@ -1240,6 +1299,9 @@ function manualChunks(id, { getModuleInfo }) { const idsToHandle = new Set(getModuleInfo(id).dynamicImporters); for (const moduleId of idsToHandle) { +// ---cut-start--- + /** @type {import('rollup').ModuleInfo} */ +// ---cut-end--- const { isEntry, dynamicImporters, importers } = getModuleInfo(moduleId); if (isEntry || dynamicImporters.length > 0) @@ -1264,6 +1326,7 @@ function manualChunks(id, { getModuleInfo }) { } } ``` + ### output.minifyInternalExports @@ -1336,13 +1399,16 @@ Even though it appears that setting this option to `true` makes the output large Maps external module IDs to paths. External ids are ids that [cannot be resolved](../troubleshooting/index.md#warning-treating-module-as-external-dependency) or ids explicitly provided by the [`external`](#external) option. Paths supplied by `output.paths` will be used in the generated bundle instead of the module ID, allowing you to, for example, load dependencies from a CDN: -```js +```js twoslash // app.js import { selectAll } from 'd3'; selectAll('p').style('color', 'purple'); // ... // rollup.config.js +// ---cut-start--- +/** @type {import('rollup').RollupOptions} */ +// ---cut-end--- export default { input: 'app.js', external: ['d3'], @@ -1426,7 +1492,10 @@ A directory path to input modules that should be stripped away from [`output.dir For example, given the following configuration: -```javascript +```javascript twoslash +// ---cut-start--- +/** @type {import('rollup').RollupOptions} */ +// ---cut-end--- export default { input: ['src/module.js', `src/another/module.js`], output: [ @@ -1508,8 +1577,11 @@ Forward slashes `/` can be used to place files in sub-directories. When using a A predicate to decide whether or not to ignore-list source files in a sourcemap, used to populate the [`x_google_ignoreList` source map extension](https://developer.chrome.com/articles/x-google-ignore-list/). `relativeSourcePath` is a relative path from the generated `.map` file to the corresponding source file while `sourcemapPath` is the fully resolved path of the generated sourcemap file. -```js +```js twoslash import path from 'node:path'; +// ---cut-start--- +/** @type {import('rollup').RollupOptions} */ +// ---cut-end--- export default { input: 'src/main', output: [ @@ -1536,8 +1608,11 @@ When you don't specify this option explicitly, by default it will put all files A transformation to apply to each path in a sourcemap. `relativeSourcePath` is a relative path from the generated `.map` file to the corresponding source file while `sourcemapPath` is the fully resolved path of the generated sourcemap file. -```js +```js twoslash import path from 'node:path'; +// ---cut-start--- +/** @type {import('rollup').RollupOptions} */ +// ---cut-end--- export default { input: 'src/main', output: [ @@ -1702,14 +1777,19 @@ Note `id` can only be used for single-file builds, and cannot be combined with ` An ID to use for AMD/UMD bundles: -```js +```js twoslash // rollup.config.js +// ---cut-start--- +/** @type {import('rollup').RollupOptions} */ +// ---cut-end--- export default { - ..., - format: 'amd', - amd: { - id: 'my-bundle' - } + // ... + output: { + format: 'amd', + amd: { + id: 'my-bundle' + } + } }; // -> define('my-bundle', ['dependency'], ... @@ -1724,14 +1804,19 @@ export default { Set the ID to the chunk ID (with the '.js' extension removed). -```js +```js twoslash // rollup.config.js +// ---cut-start--- +/** @type {import('rollup').RollupOptions} */ +// ---cut-end--- export default { - ..., - format: 'amd', - amd: { - autoId: true - } + // ... + output: { + format: 'amd', + amd: { + autoId: true + } + } }; // -> define('main', ['dependency'], ... @@ -1749,15 +1834,20 @@ The path that will be prepended to the auto generated ID. This is useful if the Only valid with [`output.amd.autoId`](#output-amd-autoid). -```js +```js twoslash // rollup.config.js +// ---cut-start--- +/** @type {import('rollup').RollupOptions} */ +// ---cut-end--- export default { - ..., - format: 'amd', - amd: { - autoId: true, - basePath: 'some/where' - } + // ... + output: { + format: 'amd', + amd: { + autoId: true, + basePath: 'some/where' + } + } }; // -> define('some/where/main', ['dependency'], ... @@ -1773,14 +1863,19 @@ export default { A function name to use instead of `define`: -```js +```js twoslash // rollup.config.js +// ---cut-start--- +/** @type {import('rollup').RollupOptions} */ +// ---cut-end--- export default { - ..., - format: 'amd', - amd: { - define: 'def' - } + // ... + output: { + format: 'amd', + amd: { + define: 'def' + } + } }; // -> def(['dependency'],... @@ -1796,14 +1891,19 @@ export default { Add `.js` extension for imports of generated chunks and local AMD modules: -```js +```js twoslash // rollup.config.js +// ---cut-start--- +/** @type {import('rollup').RollupOptions} */ +// ---cut-end--- export default { - ..., - format: 'amd', - amd: { - forceJsExtensionForImports: true - } + // ... + output: { + format: 'amd', + amd: { + forceJsExtensionForImports: true + } + } }; // -> define(['./chunk-or-local-file.js', 'dependency', 'third/dependency'],... @@ -1938,14 +2038,17 @@ Whether to `Object.freeze()` namespace import objects (i.e. `import * as namespa The indent string to use, for formats that require code to be indented (`amd`, `iife`, `umd`, `system`). Can also be `false` (no indent), or `true` (the default – auto-indent) -```js +```js twoslash // rollup.config.js +// ---cut-start--- +/** @type {import('rollup').RollupOptions} */ +// ---cut-end--- export default { - ..., - output: { - ..., - indent: false - } + // ... + output: { + // ... + indent: false + } }; ``` @@ -2217,8 +2320,11 @@ This can not only help with dead code removal, but can also improve JavaScript c Besides any functions matching that name, any properties on a pure function and any functions returned from a pure functions will also be considered pure functions, and accessing any properties is not checked for side effects. -```js +```js twoslash // rollup.config.js +// ---cut-start--- +/** @type {import('rollup').RollupOptions} */ +// ---cut-end--- export default { treeshake: { preset: 'smallest', @@ -2339,7 +2445,10 @@ Note that despite the name, this option does not "add" side effects to modules t Allows choosing one of the presets listed above while overriding some options. -```js +```js twoslash +// ---cut-start--- +/** @type {import('rollup').RollupOptions} */ +// ---cut-end--- export default { treeshake: { preset: 'smallest', @@ -2526,8 +2635,11 @@ interface WatcherOptions { Specify options for watch mode or prevent this configuration from being watched. Specifying `false` is only really useful when an array of configurations is used. In that case, this configuration will not be built or rebuilt on change in watch mode, but it will be built when running Rollup regularly: -```js +```js twoslash // rollup.config.js +// ---cut-start--- +/** @type {import('rollup').RollupOptions[]} */ +// ---cut-end--- export default [ { input: 'main.js', @@ -2580,13 +2692,16 @@ Whether to clear the screen when a rebuild is triggered. Prevent files from being watched: -```js +```js twoslash // rollup.config.js +// ---cut-start--- +/** @type {import('rollup').RollupOptions} */ +// ---cut-end--- export default { - ..., - watch: { - exclude: 'node_modules/**' - } + // ... + watch: { + exclude: 'node_modules/**' + } }; ``` @@ -2599,13 +2714,16 @@ export default { Limit the file-watching to certain files. Note that this only filters the module graph but does not allow adding additional watch files: -```js +```js twoslash +// ---cut-start--- +/** @type {import('rollup').RollupOptions} */ +// ---cut-end--- // rollup.config.js export default { - ..., - watch: { - include: 'src/**' - } + // ... + watch: { + include: 'src/**' + } }; ``` diff --git a/docs/faqs/index.md b/docs/faqs/index.md index f48a19b0a..87f32463b 100755 --- a/docs/faqs/index.md +++ b/docs/faqs/index.md @@ -134,7 +134,10 @@ and for the UMD build which will create a global variable `window.rollup`. As the browser build cannot access the file system, you need to provide plugins that resolve and load all modules you want to bundle. Here is a contrived example that does this: -```js +```js twoslash +/** @type {import('rollup')} */ +var rollup; +// ---cut--- const modules = { 'main.js': "import foo from 'foo.js'; console.log(foo);", 'foo.js': 'export default 42;' @@ -165,7 +168,10 @@ rollup This example only supports two imports, `"main.js"` and `"foo.js"`, and no relative imports. Here is another example that uses absolute URLs as entry points and supports relative imports. In that case, we are just re-bundling Rollup itself, but it could be used on any other URL that exposes an ES module: -```js +```js twoslash +/** @type {import('rollup')} */ +var rollup; +// ---cut--- rollup .rollup({ input: 'https://unpkg.com/rollup/dist/es/rollup.js', diff --git a/docs/javascript-api/index.md b/docs/javascript-api/index.md index 3bc04b762..3ac58d4b2 100755 --- a/docs/javascript-api/index.md +++ b/docs/javascript-api/index.md @@ -18,98 +18,124 @@ Once you're finished with the `bundle` object, you should call `bundle.close()`, If an error occurs at either stage, it will return a Promise rejected with an Error, which you can identify via their `code` property. Besides `code` and `message`, many errors have additional properties you can use for custom reporting, see [`utils/logs.ts`](https://github.com/rollup/rollup/blob/master/src/utils/logs.ts) for a complete list of errors and logs together with their codes and properties. -```javascript + +```javascript twoslash import { rollup } from 'rollup'; // see below for details on these options -const inputOptions = {...}; +// ---cut-start--- +/** @type {import('rollup').InputOptions} */ +// ---cut-end--- +const inputOptions = { + /* ... */ +}; // you can create multiple outputs from the same input to generate e.g. // different formats like CommonJS and ESM -const outputOptionsList = [{...}, {...}]; +// ---cut-start--- +/** @type {import('rollup').OutputOptions[]} */ +// ---cut-end--- +const outputOptionsList = [ + { + /* ... */ + }, + { + /* ... */ + } +]; build(); async function build() { - let bundle; - let buildFailed = false; - try { - // create a bundle - bundle = await rollup(inputOptions); - - // an array of file names this bundle depends on - console.log(bundle.watchFiles); - - await generateOutputs(bundle); - } catch (error) { - buildFailed = true; - // do some error reporting - console.error(error); - } - if (bundle) { - // closes the bundle - await bundle.close(); - } - process.exit(buildFailed ? 1 : 0); +// ---cut-start--- + /** @type {import('rollup').RollupBuild} */ +// ---cut-end--- + let bundle; + let buildFailed = false; + try { + // create a bundle + bundle = await rollup(inputOptions); + + // an array of file names this bundle depends on + console.log(bundle.watchFiles); + + await generateOutputs(bundle); + } catch (error) { + buildFailed = true; + // do some error reporting + console.error(error); + } + if (bundle) { + // closes the bundle + await bundle.close(); + } + process.exit(buildFailed ? 1 : 0); } +// ---cut-start--- +/** @param {import('rollup').RollupBuild} [bundle] */ +// ---cut-end--- async function generateOutputs(bundle) { - for (const outputOptions of outputOptionsList) { - // generate output specific code in-memory - // you can call this function multiple times on the same bundle object - // replace bundle.generate with bundle.write to directly write to disk - const { output } = await bundle.generate(outputOptions); - - for (const chunkOrAsset of output) { - if (chunkOrAsset.type === 'asset') { - // For assets, this contains - // { - // fileName: string, // the asset file name - // source: string | Uint8Array // the asset source - // type: 'asset' // signifies that this is an asset - // } - console.log('Asset', chunkOrAsset); - } else { - // For chunks, this contains - // { - // code: string, // the generated JS code - // dynamicImports: string[], // external modules imported dynamically by the chunk - // exports: string[], // exported variable names - // facadeModuleId: string | null, // the id of a module that this chunk corresponds to - // fileName: string, // the chunk file name - // implicitlyLoadedBefore: string[]; // entries that should only be loaded after this chunk - // imports: string[], // external modules imported statically by the chunk - // importedBindings: {[imported: string]: string[]} // imported bindings per dependency - // isDynamicEntry: boolean, // is this chunk a dynamic entry point - // isEntry: boolean, // is this chunk a static entry point - // isImplicitEntry: boolean, // should this chunk only be loaded after other chunks - // map: string | null, // sourcemaps if present - // modules: { // information about the modules in this chunk - // [id: string]: { - // renderedExports: string[]; // exported variable names that were included - // removedExports: string[]; // exported variable names that were removed - // renderedLength: number; // the length of the remaining code in this module - // originalLength: number; // the original length of the code in this module - // code: string | null; // remaining code in this module - // }; - // }, - // name: string // the name of this chunk as used in naming patterns - // preliminaryFileName: string // the preliminary file name of this chunk with hash placeholders - // referencedFiles: string[] // files referenced via import.meta.ROLLUP_FILE_URL_ - // type: 'chunk', // signifies that this is a chunk - // } - console.log('Chunk', chunkOrAsset.modules); - } - } - } + for (const outputOptions of outputOptionsList) { + // generate output specific code in-memory + // you can call this function multiple times on the same bundle object + // replace bundle.generate with bundle.write to directly write to disk + const { output } = await bundle.generate(outputOptions); + + for (const chunkOrAsset of output) { + if (chunkOrAsset.type === 'asset') { + // For assets, this contains + // { + // fileName: string, // the asset file name + // source: string | Uint8Array // the asset source + // type: 'asset' // signifies that this is an asset + // } + console.log('Asset', chunkOrAsset); + } else { + // For chunks, this contains + // { + // code: string, // the generated JS code + // dynamicImports: string[], // external modules imported dynamically by the chunk + // exports: string[], // exported variable names + // facadeModuleId: string | null, // the id of a module that this chunk corresponds to + // fileName: string, // the chunk file name + // implicitlyLoadedBefore: string[]; // entries that should only be loaded after this chunk + // imports: string[], // external modules imported statically by the chunk + // importedBindings: {[imported: string]: string[]} // imported bindings per dependency + // isDynamicEntry: boolean, // is this chunk a dynamic entry point + // isEntry: boolean, // is this chunk a static entry point + // isImplicitEntry: boolean, // should this chunk only be loaded after other chunks + // map: string | null, // sourcemaps if present + // modules: { // information about the modules in this chunk + // [id: string]: { + // renderedExports: string[]; // exported variable names that were included + // removedExports: string[]; // exported variable names that were removed + // renderedLength: number; // the length of the remaining code in this module + // originalLength: number; // the original length of the code in this module + // code: string | null; // remaining code in this module + // }; + // }, + // name: string // the name of this chunk as used in naming patterns + // preliminaryFileName: string // the preliminary file name of this chunk with hash placeholders + // referencedFiles: string[] // files referenced via import.meta.ROLLUP_FILE_URL_ + // type: 'chunk', // signifies that this is a chunk + // } + console.log('Chunk', chunkOrAsset.modules); + } + } + } } ``` + ### inputOptions object The `inputOptions` object can contain the following properties (see the [big list of options](../configuration-options/index.md) for full details on these): -```js +```js twoslash +// ---cut-start--- +/** @type {import('rollup').InputOptions} */ +// ---cut-end--- const inputOptions = { // core input options external, @@ -144,7 +170,10 @@ const inputOptions = { The `outputOptions` object can contain the following properties (see the [big list of options](../configuration-options/index.md) for full details on these): -```js +```js twoslash +// ---cut-start--- +/** @type {import('rollup').OutputOptions} */ +// ---cut-end--- const outputOptions = { // core output options dir, @@ -207,55 +236,66 @@ const outputOptions = { Rollup also provides a `rollup.watch` function that rebuilds your bundle when it detects that the individual modules have changed on disk. It is used internally when you run Rollup from the command line with the `--watch` flag. Note that when using watch mode via the JavaScript API, it is your responsibility to call `event.result.close()` in response to the `BUNDLE_END` event to allow plugins to clean up resources in the [`closeBundle`](../plugin-development/index.md#closebundle) hook, see below. -```js +```js twoslash const rollup = require('rollup'); -const watchOptions = {...}; +// ---cut-start--- +/** @type {import('rollup').RollupWatchOptions} */ +// ---cut-end--- +const watchOptions = { + /*...*/ +}; const watcher = rollup.watch(watchOptions); watcher.on('event', event => { - // event.code can be one of: - // START — the watcher is (re)starting - // BUNDLE_START — building an individual bundle - // * event.input will be the input options object if present - // * event.output contains an array of the "file" or - // "dir" option values of the generated outputs - // BUNDLE_END — finished building a bundle - // * event.input will be the input options object if present - // * event.output contains an array of the "file" or - // "dir" option values of the generated outputs - // * event.duration is the build duration in milliseconds - // * event.result contains the bundle object that can be - // used to generate additional outputs by calling - // bundle.generate or bundle.write. This is especially - // important when the watch.skipWrite option is used. - // You should call "event.result.close()" once you are done - // generating outputs, or if you do not generate outputs. - // This will allow plugins to clean up resources via the - // "closeBundle" hook. - // END — finished building all bundles - // ERROR — encountered an error while bundling - // * event.error contains the error that was thrown - // * event.result is null for build errors and contains the - // bundle object for output generation errors. As with - // "BUNDLE_END", you should call "event.result.close()" if - // present once you are done. - // If you return a Promise from your event handler, Rollup will wait until the - // Promise is resolved before continuing. + // event.code can be one of: + // START — the watcher is (re)starting + // BUNDLE_START — building an individual bundle + // * event.input will be the input options object if present + // * event.output contains an array of the "file" or + // "dir" option values of the generated outputs + // BUNDLE_END — finished building a bundle + // * event.input will be the input options object if present + // * event.output contains an array of the "file" or + // "dir" option values of the generated outputs + // * event.duration is the build duration in milliseconds + // * event.result contains the bundle object that can be + // used to generate additional outputs by calling + // bundle.generate or bundle.write. This is especially + // important when the watch.skipWrite option is used. + // You should call "event.result.close()" once you are done + // generating outputs, or if you do not generate outputs. + // This will allow plugins to clean up resources via the + // "closeBundle" hook. + // END — finished building all bundles + // ERROR — encountered an error while bundling + // * event.error contains the error that was thrown + // * event.result is null for build errors and contains the + // bundle object for output generation errors. As with + // "BUNDLE_END", you should call "event.result.close()" if + // present once you are done. + // If you return a Promise from your event handler, Rollup will wait until the + // Promise is resolved before continuing. }); // This will make sure that bundles are properly closed after each run watcher.on('event', ({ result }) => { - if (result) { - result.close(); - } + if (result) { + result.close(); + } }); // Additionally, you can hook into the following. Again, return a Promise to // make Rollup wait at that stage: -watcher.on('change', (id, { event }) => { /* a file was modified */ }) -watcher.on('restart', () => { /* a new run was triggered */ }) -watcher.on('close', () => { /* the watcher was closed, see below */ }) +watcher.on('change', (id, { event }) => { + /* a file was modified */ +}); +watcher.on('restart', () => { + /* a new run was triggered */ +}); +watcher.on('close', () => { + /* the watcher was closed, see below */ +}); // to stop watching watcher.close(); @@ -265,7 +305,10 @@ watcher.close(); The `watchOptions` argument is a config (or an array of configs) that you would export from a config file. -```js +```js twoslash +// ---cut-start--- +/** @type {import('rollup').RollupWatchOptions} */ +// ---cut-end--- const watchOptions = { ...inputOptions, output: [outputOptions], @@ -286,7 +329,7 @@ See above for details on `inputOptions` and `outputOptions`, or consult the [big In order to aid in generating such a config, rollup exposes the helper it uses to load config files in its command line interface via a separate entry-point. This helper receives a resolved `fileName` and optionally an object containing command line parameters: -```js +```js twoslash const { loadConfigFile } = require('rollup/loadConfigFile'); const path = require('node:path'); const rollup = require('rollup'); @@ -322,7 +365,7 @@ loadConfigFile(path.resolve(__dirname, 'rollup.config.js'), { While the command line interface provides a powerful way to filter logs via the [`--filterLogs`](../command-line-interface/index.md#filterlogs-filter) flag, this functionality is not directly available when using the JavaScript API. However, Rollup exposes a helper `getLogFilter` to generate filters using the same syntax as the CLI. This is useful when specifying a custom `onLog` handler and for third party systems that want to provide a similar filtering experience as Rollup CLI. This function accepts an array of strings. Note that it does not split up comma-separated lists of filters like the CLI does. -```js +```js twoslash // rollup.config.mjs import { getLogFilter } from 'rollup/getLogFilter'; @@ -343,7 +386,7 @@ export default { In order to parse arbitrary code using Rollup's parser, plugins can use [`this.parse`](../plugin-development/index.md#this-parse). To use this functionality outside the context of a Rollup build, the parser is also exposed as a separate export. It has the same signature as `this.parse`: -```js +```js twoslash import { parseAst } from 'rollup/parseAst'; import assert from 'node:assert'; @@ -374,7 +417,7 @@ assert.deepEqual( There is also an asynchronous version that parses in a different thread in the non-wasm builds of Rollup: -```js +```js twoslash import { parseAstAsync } from 'rollup/parseAst'; import assert from 'node:assert'; diff --git a/docs/plugin-development/index.md b/docs/plugin-development/index.md index 929d62e21..a82d72d97 100644 --- a/docs/plugin-development/index.md +++ b/docs/plugin-development/index.md @@ -18,8 +18,11 @@ A List of Plugins may be found at [github.com/rollup/awesome](https://github.com The following plugin will intercept any imports of `virtual-module` without accessing the file system. This is for instance necessary if you want to use Rollup in a browser. It can even be used to replace entry points as shown in the example. -```js -// rollup-plugin-my-example.js +```js twoslash +// @filename: rollup-plugin-my-example.js +// ---cut-start--- +/** @returns {import('rollup').Plugin} */ +// ---cut-end--- export default function myExample () { return { name: 'my-example', // this name will show up in logs and errors @@ -41,7 +44,7 @@ export default function myExample () { }; } -// rollup.config.js +// @filename: rollup.config.js import myExample from './rollup-plugin-my-example.js'; export default ({ input: 'virtual-module', // resolved by our plugin @@ -94,7 +97,10 @@ Instead of a function, hooks can also be objects. In that case, the actual hook - `order: "pre" | "post" | null`
If there are several plugins implementing this hook, either run this plugin first (`"pre"`), last (`"post"`), or in the user-specified position (no value or `null`). - ```js + ```js twoslash + // ---cut-start--- + /** @returns {import('rollup').Plugin} */ + // ---cut-end--- export default function resolveFirst() { return { name: 'resolve-first', @@ -117,10 +123,13 @@ Instead of a function, hooks can also be objects. In that case, the actual hook This can be useful when you need to run several command line tools in different [`writeBundle`](#writebundle) hooks that depend on each other (note that if possible, it is recommended to add/remove files in the sequential [`generateBundle`](#generatebundle) hook, though, which is faster, works with pure in-memory builds and permits other in-memory build plugins to see the files). You can combine this option with `order` for additional sorting. - ```js + ```js twoslash import { resolve } from 'node:path'; import { readdir } from 'node:fs/promises'; + // ---cut-start--- + /** @returns {import('rollup').Plugin} */ + // ---cut-end--- export default function getFilesOnDisk() { return { name: 'getFilesOnDisk', @@ -352,7 +361,10 @@ A function that receives and filters logs and warnings generated by Rollup and p 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 +```js twoslash +// ---cut-start--- +/** @returns {import('rollup').Plugin} */ +// ---cut-end--- function plugin1() { return { name: 'plugin1', @@ -371,6 +383,9 @@ function plugin1() { }; } +// ---cut-start--- +/** @returns {import('rollup').Plugin} */ +// ---cut-end--- function plugin2() { return { name: 'plugin2', @@ -490,12 +505,15 @@ For those cases, the `isEntry` option will tell you if we are resolving a user d 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 +```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', @@ -566,7 +584,10 @@ Returning `null` defers to other `resolveId` functions and eventually the defaul 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 +```js twoslash +// ---cut-start--- +/** @returns {import('rollup').Plugin} */ +// ---cut-end--- function externalizeDependencyPlugin() { return { name: 'externalize-dependency', @@ -823,7 +844,10 @@ Can be used to augment the hash of individual chunks. Called for each Rollup out The following plugin will invalidate the hash of chunk `foo` with the current timestamp: -```js +```js twoslash +// ---cut-start--- +/** @returns {import('rollup').Plugin} */ +// ---cut-end--- function augmentWithDatePlugin() { return { name: 'augment-with-date', @@ -1017,7 +1041,10 @@ This hook provides fine-grained control over how dynamic imports are rendered by 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 +```js twoslash +// ---cut-start--- +/** @returns {import('rollup').Plugin} */ +// ---cut-end--- function dynamicImportPolyfillPlugin() { return { name: 'dynamic-import-polyfill', @@ -1039,7 +1066,10 @@ 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 +```js twoslash +// ---cut-start--- +/** @returns {import('rollup').Plugin} */ +// ---cut-end--- function retainImportExpressionPlugin() { return { name: 'retain-import-expression', @@ -1116,7 +1146,10 @@ For that, all formats except CommonJS and UMD assume that they run in a browser The following plugin will always resolve all files relative to the current document: -```js +```js twoslash +// ---cut-start--- +/** @returns {import('rollup').Plugin} */ +// ---cut-end--- function resolveToDocumentPlugin() { return { name: 'resolve-to-document', @@ -1142,7 +1175,10 @@ By default, for formats other than ES modules, Rollup replaces `import.meta.url` 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 +```js twoslash +// ---cut-start--- +/** @returns {import('rollup').Plugin} */ +// ---cut-end--- function importMetaUrlCurrentModulePlugin() { return { name: 'import-meta-url-current-module', @@ -1198,7 +1234,10 @@ Generate a `"debug"` log. See [`this.warn`](#this-warn) for details. Debug logs 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 +```js twoslash +// ---cut-start--- +/** @returns {import('rollup').Plugin} */ +// ---cut-end--- function plugin() { return { name: 'test', @@ -1265,10 +1304,25 @@ This will not result in duplicate modules in the graph, instead if necessary, ex 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 + +```js twoslash // rollup.config.js +// ---cut-start--- +/** @returns {import('rollup').Plugin} */ +// ---cut-end--- function generateHtmlPlugin() { - let ref1, ref2, ref3; +// ---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() { @@ -1309,6 +1363,9 @@ function generateHtmlPlugin() { }; } +// ---cut-start--- +/** @returns {import('rollup').RollupOptions} */ +// ---cut-end--- export default { input: [], preserveEntrySignatures: false, @@ -1319,6 +1376,7 @@ export default { } }; ``` + 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. @@ -1328,7 +1386,10 @@ If the `type` is `prebuilt-chunk`, it emits a chunk with fixed contents provided 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 +```js twoslash +// ---cut-start--- +/** @returns {import('rollup').Plugin} */ +// ---cut-end--- function emitPrebuiltChunkPlugin() { return { name: 'emit-prebuilt-chunk', @@ -1376,7 +1437,10 @@ In all hooks except the [`onLog`](#onlog) hook, the error will be augmented with 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 +```js twoslash +// ---cut-start--- +/** @returns {import('rollup').Plugin} */ +// ---cut-end--- function myPlugin() { return { name: 'my-plugin', @@ -1523,7 +1587,10 @@ The returned Promise will resolve once the module has been fully transformed and 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 +```js twoslash +// ---cut-start--- +/** @returns {import('rollup').Plugin} */ +// ---cut-end--- export default function addProxyPlugin() { return { async resolveId(source, importer, options) { @@ -1574,11 +1641,14 @@ While it is safe to use `this.load` in a `resolveId` hook, you should be very ca 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 +```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', @@ -1762,7 +1832,10 @@ To reference a file URL reference from within JS code, use the `import.meta.ROLL 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 +```js twoslash +// ---cut-start--- +/** @returns {import('rollup').Plugin} */ +// ---cut-end--- function svgResolverPlugin() { return { name: 'svg-resolver', @@ -1807,7 +1880,10 @@ if (COMPILER_FLAG) { 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 +```js twoslash +// ---cut-start--- +/** @returns {import('rollup').Plugin} */ +// ---cut-end--- function svgResolverPlugin() { return { /* ... */ @@ -1832,9 +1908,12 @@ Similar to assets, emitted chunks can be referenced from within JS code via `imp 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 +```js twoslash const REGISTER_WORKLET = 'register-paint-worklet:'; +// ---cut-start--- +/** @returns {import('rollup').Plugin} */ +// ---cut-end--- function registerPaintWorkletPlugin() { return { name: 'register-paint-worklet', @@ -1905,9 +1984,12 @@ The `transform` hook, if returning an object, can also include an `ast` property (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 +```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); @@ -1996,7 +2078,10 @@ The problem here, however, is that this proxy id may or may not cause unintended 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 +```js twoslash +// ---cut-start--- +/** @returns {import('rollup').Plugin} */ +// ---cut-end--- function requestingPlugin() { return { name: 'requesting', @@ -2009,6 +2094,9 @@ function requestingPlugin() { }; } +// ---cut-start--- +/** @returns {import('rollup').Plugin} */ +// ---cut-end--- function resolvingPlugin() { return { name: 'resolving', @@ -2028,7 +2116,10 @@ Note the convention that custom options should be added using a property corresp 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 +```js twoslash +// ---cut-start--- +/** @returns {import('rollup').Plugin} */ +// ---cut-end--- function annotatingPlugin() { return { name: 'annotating', @@ -2040,6 +2131,9 @@ function annotatingPlugin() { }; } +// ---cut-start--- +/** @returns {import('rollup').Plugin} */ +// ---cut-end--- function readingPlugin() { let parentApi; return { @@ -2060,7 +2154,10 @@ If several plugins add meta-data or meta-data is added in different hooks, then 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 +```js twoslash +// ---cut-start--- +/** @returns {import('rollup').Plugin} */ +// ---cut-end--- function plugin() { return { name: 'test', @@ -2083,7 +2180,12 @@ function plugin() { 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 + +```js twoslash +/** @typedef {{ doSomething(...args: any[]): void }} ParentPluginApi */ + +/** @returns {import('rollup').Plugin} */ +// ---cut--- function parentPlugin() { return { name: 'parent', @@ -2097,12 +2199,21 @@ function parentPlugin() { }; } +// ---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 ); @@ -2123,3 +2234,4 @@ function dependentPlugin() { }; } ``` + diff --git a/docs/tools/index.md b/docs/tools/index.md index 9d3acd1a6..bb01487dd 100755 --- a/docs/tools/index.md +++ b/docs/tools/index.md @@ -54,10 +54,13 @@ npm install --save-dev @rollup/plugin-node-resolve …and add it to your config file: -```js +```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: { @@ -91,10 +94,13 @@ You can finely tune which imports are bundled and which are treated as external. Here is the config file: -```js +```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: { @@ -116,7 +122,10 @@ Voilà, `lodash` will now be treated as external, and not be bundled with your l 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 +```js twoslash +// ---cut-start--- +/** @type {import('rollup').RollupOptions} */ +// ---cut-end--- export default { // ... external: id => /lodash/.test(id) @@ -143,11 +152,14 @@ npm i -D @rollup/plugin-babel @rollup/plugin-node-resolve Add it to `rollup.config.js`: -```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: { @@ -205,7 +217,7 @@ Rollup returns Promises which are understood by gulp so integration is relativel 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 +```js twoslash const gulp = require('gulp'); const rollup = require('rollup'); const rollupTypescript = require('@rollup/plugin-typescript'); @@ -229,7 +241,7 @@ gulp.task('build', () => { You may also use the `async/await` syntax: -```js +```js twoslash const gulp = require('gulp'); const rollup = require('rollup'); const rollupTypescript = require('@rollup/plugin-typescript'); diff --git a/docs/troubleshooting/index.md b/docs/troubleshooting/index.md index 13a161bd7..fbadba6a4 100644 --- a/docs/troubleshooting/index.md +++ b/docs/troubleshooting/index.md @@ -78,8 +78,11 @@ 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 +```js twoslash // rollup.config.js +// ---cut-start--- +/** @type {import('rollup').RollupOptions} */ +// ---cut-end--- export default { entry: 'src/index.js', dest: 'bundle.js', @@ -96,15 +99,18 @@ Some modules, like `events` or `util`, are built in to Node.js. If you want to i 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 +```js twoslash // rollup.config.js +// ---cut-start--- +/** @type {import('rollup').RollupOptions} */ +// ---cut-end--- export default { - ..., - watch: { - chokidar: { - useFsEvents: false - } - } + /* ..., */ + watch: { + chokidar: { + useFsEvents: false + } + } }; ``` diff --git a/docs/tsconfig.json b/docs/tsconfig.json index 547357894..e733497a0 100644 --- a/docs/tsconfig.json +++ b/docs/tsconfig.json @@ -10,7 +10,9 @@ "jsx": "preserve", "lib": ["ESNext", "DOM"], "types": ["vite/client"], - "isolatedModules": true + "isolatedModules": true, + "noEmit": true }, - "exclude": ["**/node_modules/**", "**/dist/**"] + "include": ["**/*"], + "exclude": ["**/node_modules/**", "**/dist/**", ".vitepress/cache/**", ".vitepress/dist/**"] } diff --git a/docs/tutorial/index.md b/docs/tutorial/index.md index 204b961e0..987b32f2f 100755 --- a/docs/tutorial/index.md +++ b/docs/tutorial/index.md @@ -96,8 +96,11 @@ To save repeating ourselves, we can create a config file containing all the opti Create a file in the project root called `rollup.config.mjs`, and add the following code: -```js +```js twoslash // rollup.config.mjs +// ---cut-start--- +/** @type {import('rollup').RollupOptions} */ +// ---cut-end--- export default { input: 'src/main.js', output: { @@ -212,10 +215,13 @@ export default function () { Edit your `rollup.config.mjs` file to include the JSON plugin: -```js +```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: { @@ -254,11 +260,14 @@ 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 +```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: [ diff --git a/package-lock.json b/package-lock.json index a3c677778..834169191 100644 --- a/package-lock.json +++ b/package-lock.json @@ -33,6 +33,7 @@ "@rollup/plugin-terser": "^0.4.4", "@rollup/plugin-typescript": "^11.1.6", "@rollup/pluginutils": "^5.1.0", + "@shikijs/vitepress-twoslash": "^1.2.1", "@types/eslint": "^8.56.6", "@types/inquirer": "^9.0.7", "@types/mocha": "^10.0.6", @@ -1294,6 +1295,30 @@ "node": "^12.22.0 || ^14.17.0 || >=16.0.0" } }, + "node_modules/@floating-ui/core": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/@floating-ui/core/-/core-1.6.0.tgz", + "integrity": "sha512-PcF++MykgmTj3CIyOQbKA/hDzOAiqI3mhuoN44WRCopIs1sgoDoU4oty4Jtqaj/y3oDU6fnVSm4QG0a3t5i0+g==", + "dev": true, + "dependencies": { + "@floating-ui/utils": "^0.2.1" + } + }, + "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, + "dependencies": { + "@floating-ui/core": "^1.1.0" + } + }, + "node_modules/@floating-ui/utils": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/@floating-ui/utils/-/utils-0.2.1.tgz", + "integrity": "sha512-9TANp6GPoMtYzQdt54kfAyMmz1+osLlXdg2ENroU7zzrtflTLrrC/lgrIfaSe+Wu0b89GKccT7vxXA0MoAIO+Q==", + "dev": true + }, "node_modules/@humanwhocodes/config-array": { "version": "0.11.14", "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.14.tgz", @@ -2112,6 +2137,54 @@ "shiki": "1.2.1" } }, + "node_modules/@shikijs/twoslash": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/@shikijs/twoslash/-/twoslash-1.2.1.tgz", + "integrity": "sha512-QyrBtKhIXjByPbC2dS/8LAqCLfoVmZHgNqc4eqLVIkOxZp6AAkAak1A3E+oiMP9vLaMY9qQI1pnV45c8FB5PRw==", + "dev": true, + "dependencies": { + "@shikijs/core": "1.2.1", + "twoslash": "^0.2.5" + } + }, + "node_modules/@shikijs/twoslash/node_modules/@shikijs/core": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/@shikijs/core/-/core-1.2.1.tgz", + "integrity": "sha512-KaIS0H4EQ3KI2d++TjYqRNgwp8E3M/68e9veR4QtInzA7kKFgcjeiJqb80fuXW+blDy5fmd11PN9g9soz/3ANQ==", + "dev": true + }, + "node_modules/@shikijs/vitepress-twoslash": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/@shikijs/vitepress-twoslash/-/vitepress-twoslash-1.2.1.tgz", + "integrity": "sha512-+fY8fa6B2q2AIygdSP2KDayb86wFcWBqMP4nAPdXSOb3ZbnYjrE3J1G1xZwTBFLgLAWbR545tu8aIy1JETYWuA==", + "dev": true, + "dependencies": { + "@shikijs/twoslash": "1.2.1", + "floating-vue": "^5.2.2", + "mdast-util-from-markdown": "^2.0.0", + "mdast-util-gfm": "^3.0.0", + "mdast-util-to-hast": "^13.1.0", + "shiki": "1.2.1", + "twoslash": "^0.2.5", + "twoslash-vue": "^0.2.5", + "vue": "^3.4.21" + } + }, + "node_modules/@shikijs/vitepress-twoslash/node_modules/@shikijs/core": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/@shikijs/core/-/core-1.2.1.tgz", + "integrity": "sha512-KaIS0H4EQ3KI2d++TjYqRNgwp8E3M/68e9veR4QtInzA7kKFgcjeiJqb80fuXW+blDy5fmd11PN9g9soz/3ANQ==", + "dev": true + }, + "node_modules/@shikijs/vitepress-twoslash/node_modules/shiki": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/shiki/-/shiki-1.2.1.tgz", + "integrity": "sha512-u+XW6o0vCkUNlneZb914dLO+AayEIwK5tI62WeS//R5HIXBFiYaj/Hc5xcq27Yh83Grr4JbNtUBV8W6zyK4hWg==", + "dev": true, + "dependencies": { + "@shikijs/core": "1.2.1" + } + }, "node_modules/@types/buble": { "version": "0.19.2", "resolved": "https://registry.npmjs.org/@types/buble/-/buble-0.19.2.tgz", @@ -2130,6 +2203,15 @@ "sourcemap-codec": "^1.4.8" } }, + "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, + "dependencies": { + "@types/ms": "*" + } + }, "node_modules/@types/eslint": { "version": "8.56.6", "resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-8.56.6.tgz", @@ -2170,6 +2252,15 @@ "integrity": "sha512-K0VQKziLUWkVKiRVrx4a40iPaxTUefQmjtkQofBkYRcoaaL/8rhwDWww9qWbrgicNOgnpIsMxyNIUM4+n6dUIA==", "dev": true }, + "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, + "dependencies": { + "@types/unist": "*" + } + }, "node_modules/@types/inquirer": { "version": "9.0.7", "resolved": "https://registry.npmjs.org/@types/inquirer/-/inquirer-9.0.7.tgz", @@ -2208,6 +2299,15 @@ "@types/mdurl": "*" } }, + "node_modules/@types/mdast": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/@types/mdast/-/mdast-4.0.3.tgz", + "integrity": "sha512-LsjtqsyF+d2/yFOYaN22dHZI1Cpwkrj+g06G8+qtUKlhovPW89YhqSnfKtMbkgmEtYpH2gydRNULd6y8mciAFg==", + "dev": true, + "dependencies": { + "@types/unist": "*" + } + }, "node_modules/@types/mdurl": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/@types/mdurl/-/mdurl-1.0.5.tgz", @@ -2226,6 +2326,12 @@ "integrity": "sha512-dJvrYWxP/UcXm36Qn36fxhUKu8A/xMRXVT2cliFF1Z7UA9liG5Psj3ezNSZw+5puH2czDXRLcXQxf8JbJt0ejg==", "dev": true }, + "node_modules/@types/ms": { + "version": "0.7.34", + "resolved": "https://registry.npmjs.org/@types/ms/-/ms-0.7.34.tgz", + "integrity": "sha512-nG96G3Wp6acyAgJqGasjODb+acrI7KltPiRxzHPXnP3NgI28bpQDRv53olbqGXbfcgF5aiiHmO3xpwEpS5Ld9g==", + "dev": true + }, "node_modules/@types/node": { "version": "18.18.14", "resolved": "https://registry.npmjs.org/@types/node/-/node-18.18.14.tgz", @@ -2272,6 +2378,12 @@ "@types/node": "*" } }, + "node_modules/@types/unist": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/@types/unist/-/unist-3.0.2.tgz", + "integrity": "sha512-dqId9J8K/vGi5Zr7oo212BGii5m3q5Hxlkwy3WpYuKPklmBEvsbMYYyLxAQpSffdLl/gdW0XUpKWFvYmyoWCoQ==", + "dev": true + }, "node_modules/@types/web-bluetooth": { "version": "0.0.20", "resolved": "https://registry.npmjs.org/@types/web-bluetooth/-/web-bluetooth-0.0.20.tgz", @@ -2484,6 +2596,15 @@ "url": "https://opencollective.com/typescript-eslint" } }, + "node_modules/@typescript/vfs": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/@typescript/vfs/-/vfs-1.5.0.tgz", + "integrity": "sha512-AJS307bPgbsZZ9ggCT3wwpg3VbTKMFNHfaY/uF0ahSkYYrPF2dSSKDNIDIQAHm9qJqbLvCsSJH7yN4Vs/CsMMg==", + "dev": true, + "dependencies": { + "debug": "^4.1.1" + } + }, "node_modules/@ungap/structured-clone": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/@ungap/structured-clone/-/structured-clone-1.2.0.tgz", @@ -2503,6 +2624,24 @@ "vue": "^3.2.25" } }, + "node_modules/@volar/language-core": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/@volar/language-core/-/language-core-1.11.1.tgz", + "integrity": "sha512-dOcNn3i9GgZAcJt43wuaEykSluAuOkQgzni1cuxLxTV0nJKanQztp7FxyswdRILaKH+P2XZMPRp2S4MV/pElCw==", + "dev": true, + "dependencies": { + "@volar/source-map": "1.11.1" + } + }, + "node_modules/@volar/source-map": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/@volar/source-map/-/source-map-1.11.1.tgz", + "integrity": "sha512-hJnOnwZ4+WT5iupLRnuzbULZ42L7BWWPMmruzwtLhJfpDVoZLjNBxHDi2sY2bgZXCKlpU5XcsMFoYrsQmPhfZg==", + "dev": true, + "dependencies": { + "muggle-string": "^0.3.1" + } + }, "node_modules/@vue/compiler-core": { "version": "3.4.21", "resolved": "https://registry.npmjs.org/@vue/compiler-core/-/compiler-core-3.4.21.tgz", @@ -2628,6 +2767,31 @@ } } }, + "node_modules/@vue/language-core": { + "version": "1.8.27", + "resolved": "https://registry.npmjs.org/@vue/language-core/-/language-core-1.8.27.tgz", + "integrity": "sha512-L8Kc27VdQserNaCUNiSFdDl9LWT24ly8Hpwf1ECy3aFb9m6bDhBGQYOujDm21N7EW3moKIOKEanQwe1q5BK+mA==", + "dev": true, + "dependencies": { + "@volar/language-core": "~1.11.1", + "@volar/source-map": "~1.11.1", + "@vue/compiler-dom": "^3.3.0", + "@vue/shared": "^3.3.0", + "computeds": "^0.0.1", + "minimatch": "^9.0.3", + "muggle-string": "^0.3.1", + "path-browserify": "^1.0.1", + "vue-template-compiler": "^2.7.14" + }, + "peerDependencies": { + "typescript": "*" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, "node_modules/@vue/reactivity": { "version": "3.4.21", "resolved": "https://registry.npmjs.org/@vue/reactivity/-/reactivity-3.4.21.tgz", @@ -3565,6 +3729,16 @@ } ] }, + "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, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, "node_modules/chalk": { "version": "5.3.0", "resolved": "https://registry.npmjs.org/chalk/-/chalk-5.3.0.tgz", @@ -3577,6 +3751,16 @@ "url": "https://github.com/chalk/chalk?sponsor=1" } }, + "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, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, "node_modules/chardet": { "version": "0.7.0", "resolved": "https://registry.npmjs.org/chardet/-/chardet-0.7.0.tgz", @@ -3896,6 +4080,12 @@ "integrity": "sha512-W9pAhw0ja1Edb5GVdIF1mjZw/ASI0AlShXM83UUGe2DVr5TdAPEA1OA8m/g8zWp9x6On7gqufY+FatDbC3MDQg==", "dev": true }, + "node_modules/computeds": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/computeds/-/computeds-0.0.1.tgz", + "integrity": "sha512-7CEBgcMjVmitjYo5q8JTJVra6X5mQ20uTThdK+0kR7UEaDrAWEQcRiBtWJzga4eRpP6afNwwLsX2SET2JhVB1Q==", + "dev": true + }, "node_modules/concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", @@ -4167,6 +4357,12 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/de-indent": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/de-indent/-/de-indent-1.0.2.tgz", + "integrity": "sha512-e/1zu3xH5MQryN2zdVaF0OrdNLUbvWxzMbi+iNA6Bky7l1RoP8a2fIbRocyHclXt/arDrrR6lL3TqFD9pMQTsg==", + "dev": true + }, "node_modules/debug": { "version": "4.3.4", "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", @@ -4193,6 +4389,19 @@ "node": ">=0.10.0" } }, + "node_modules/decode-named-character-reference": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/decode-named-character-reference/-/decode-named-character-reference-1.0.2.tgz", + "integrity": "sha512-O8x12RzrUF8xyVcY0KJowWsmaJxQbmy0/EtnNtHRpsOcT7dFk5W598coHqBVpmWo1oQQfsCqfCmkZN5DJrZVdg==", + "dev": true, + "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", @@ -4278,6 +4487,28 @@ "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, + "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, + "dependencies": { + "dequal": "^2.0.0" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, "node_modules/devtools-protocol": { "version": "0.0.1107588", "resolved": "https://registry.npmjs.org/devtools-protocol/-/devtools-protocol-0.0.1107588.tgz", @@ -5328,6 +5559,25 @@ "integrity": "sha512-X8cqMLLie7KsNUDSdzeN8FYK9rEt4Dt67OsG/DNGnYTSDBG4uFAJFBnUeiV+zCVAvwFy56IjM9sH51jVaEhNxw==", "dev": true }, + "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, + "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/flru": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/flru/-/flru-1.0.2.tgz", @@ -7168,6 +7418,16 @@ "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, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, "node_modules/lru-cache": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz", @@ -7210,6 +7470,16 @@ "integrity": "sha512-1I+1qpDt4idfgLQG+BNWmrqku+7/2bi5nLf4YwF8y8zXvmfiTBY3PV3ZibfrjBueCByROpuBjLLFCajqkgYoLQ==", "dev": true }, + "node_modules/markdown-table": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/markdown-table/-/markdown-table-3.0.3.tgz", + "integrity": "sha512-Z1NL3Tb1M9wH4XESsCDEksWoKTdlUafKc4pt0GRwjUyXaCFZ+dc3g2erqB6zm3szA2IUSi7VnPI+o/9jnxh9hw==", + "dev": true, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, "node_modules/matcher-collection": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/matcher-collection/-/matcher-collection-2.0.1.tgz", @@ -7245,113 +7515,776 @@ "node": "*" } }, - "node_modules/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/mdast-util-find-and-replace": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/mdast-util-find-and-replace/-/mdast-util-find-and-replace-3.0.1.tgz", + "integrity": "sha512-SG21kZHGC3XRTSUhtofZkBzZTJNM5ecCi0SK2IMKmSXR8vO3peL+kb1O0z7Zl83jKtutG4k5Wv/W7V3/YHvzPA==", + "dev": true, + "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/merge2": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz", - "integrity": "sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==", + "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, "engines": { - "node": ">= 8" + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/micromatch": { - "version": "4.0.5", - "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.5.tgz", - "integrity": "sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==", + "node_modules/mdast-util-from-markdown": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/mdast-util-from-markdown/-/mdast-util-from-markdown-2.0.0.tgz", + "integrity": "sha512-n7MTOr/z+8NAX/wmhhDji8O3bRvPTV/U0oTCaZJkjhPSKTPhS3xufVhKGF8s1pJ7Ox4QgoIU7KHseh09S+9rTA==", "dev": true, "dependencies": { - "braces": "^3.0.2", - "picomatch": "^2.3.1" + "@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" }, - "engines": { - "node": ">=8.6" + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" } }, - "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==", + "node_modules/mdast-util-gfm": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/mdast-util-gfm/-/mdast-util-gfm-3.0.0.tgz", + "integrity": "sha512-dgQEX5Amaq+DuUqf26jJqSK9qgixgd6rYDHAv4aTBuA92cTknZlKpPfa86Z/s8Dj8xsAQpFfBmPUHWJBWqS4Bw==", "dev": true, - "engines": { - "node": ">= 0.6" + "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/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==", + "node_modules/mdast-util-gfm-autolink-literal": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/mdast-util-gfm-autolink-literal/-/mdast-util-gfm-autolink-literal-2.0.0.tgz", + "integrity": "sha512-FyzMsduZZHSc3i0Px3PQcBT4WJY/X/RCtEJKuybiC6sjPqLv7h1yqAkmILZtuxMSsUyaLUWNp71+vQH2zqp5cg==", "dev": true, "dependencies": { - "mime-db": "1.52.0" + "@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" }, - "engines": { - "node": ">= 0.6" + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" } }, - "node_modules/mimic-fn": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-4.0.0.tgz", - "integrity": "sha512-vqiC06CuhBTUdZH+RYl8sFrL096vA45Ok5ISO6sE/Mr1jRbGH4Csnhi8f3wKVl7x8mO4Au7Ir9D3Oyv1VYMFJw==", + "node_modules/mdast-util-gfm-footnote": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/mdast-util-gfm-footnote/-/mdast-util-gfm-footnote-2.0.0.tgz", + "integrity": "sha512-5jOT2boTSVkMnQ7LTrd6n/18kqwjmuYqo7JUPe+tRCY6O7dAuTFMtTPauYYrMPpox9hlN0uOx/FL8XvEfG9/mQ==", "dev": true, - "engines": { - "node": ">=12" + "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": { - "url": "https://github.com/sponsors/sindresorhus" + "type": "opencollective", + "url": "https://opencollective.com/unified" } }, - "node_modules/min-indent": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/min-indent/-/min-indent-1.0.1.tgz", - "integrity": "sha512-I9jwMn07Sy/IwOj3zVkVik2JTvgpaykDZEigL6Rx6N9LbMywwUSMtxET+7lVoDLLd3O3IXwJwvuuns8UB/HeAg==", + "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, - "engines": { - "node": ">=4" + "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/minimatch": { - "version": "9.0.3", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.3.tgz", - "integrity": "sha512-RHiac9mvaRw0x3AYRgDC1CxAP7HTcNrrECeA8YYJeWnpo+2Q5CegtZjaotWTWxDG3UeGA1coE05iH1mPjT/2mg==", + "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, "dependencies": { - "brace-expansion": "^2.0.1" - }, - "engines": { - "node": ">=16 || 14 >=14.17" + "@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": { - "url": "https://github.com/sponsors/isaacs" + "type": "opencollective", + "url": "https://opencollective.com/unified" } }, - "node_modules/minimist": { - "version": "1.2.8", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz", - "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==", + "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, + "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": { - "url": "https://github.com/sponsors/ljharb" + "type": "opencollective", + "url": "https://opencollective.com/unified" } }, - "node_modules/minipass": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/minipass/-/minipass-5.0.0.tgz", - "integrity": "sha512-3FnjYuehv9k6ovOEbyOswadCDPX1piCfhV8ncmYtHOjuPwylVWsghTLo7rabjC3Rx5xD4HDx8Wm1xnMF7S5qFQ==", + "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, - "engines": { - "node": ">=8" + "dependencies": { + "@types/mdast": "^4.0.0", + "unist-util-is": "^6.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" } }, - "node_modules/minisearch": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/minisearch/-/minisearch-6.3.0.tgz", - "integrity": "sha512-ihFnidEeU8iXzcVHy74dhkxh/dn8Dc08ERl0xwoMMGqp4+LvRSCgicb+zGqWthVokQKvCSxITlh3P08OzdTYCQ==", + "node_modules/mdast-util-to-hast": { + "version": "13.1.0", + "resolved": "https://registry.npmjs.org/mdast-util-to-hast/-/mdast-util-to-hast-13.1.0.tgz", + "integrity": "sha512-/e2l/6+OdGp/FB+ctrJ9Avz71AN/GRH3oi/3KAx/kMnoUsD6q0woXlDT8lLEeViVKE7oZxE7RXzvO3T8kF2/sA==", + "dev": true, + "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.0", + "resolved": "https://registry.npmjs.org/mdast-util-to-markdown/-/mdast-util-to-markdown-2.1.0.tgz", + "integrity": "sha512-SR2VnIEdVNCJbP6y7kVTJgPLifdr8WEU440fQec7qHoHOUz/oJ2jmNRqdDQ3rbiStOXb2mCDGTuwsK5OPUgYlQ==", + "dev": true, + "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-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, + "dependencies": { + "@types/mdast": "^4.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/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/merge2": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz", + "integrity": "sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==", + "dev": true, + "engines": { + "node": ">= 8" + } + }, + "node_modules/micromark": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/micromark/-/micromark-4.0.0.tgz", + "integrity": "sha512-o/sd0nMof8kYff+TqcDx3VSrgBTcZpSvYcAHIfHhv5VAuNmisCxjhx6YmxS8PFEpb9z5WKWKPdzf0jM23ro3RQ==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "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.0", + "resolved": "https://registry.npmjs.org/micromark-core-commonmark/-/micromark-core-commonmark-2.0.0.tgz", + "integrity": "sha512-jThOz/pVmAYUtkroV3D5c1osFXAMv9e0ypGDOIZuCeAe91/sD6BoE2Sjzt30yuXtwOYUmySOhMas/PVyh02itA==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "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.0", + "resolved": "https://registry.npmjs.org/micromark-factory-destination/-/micromark-factory-destination-2.0.0.tgz", + "integrity": "sha512-j9DGrQLm/Uhl2tCzcbLhy5kXsgkHUrjJHg4fFAeoMRwJmJerT9aw4FEhIbZStWN8A3qMwOp1uzHr4UL8AInxtA==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "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.0", + "resolved": "https://registry.npmjs.org/micromark-factory-label/-/micromark-factory-label-2.0.0.tgz", + "integrity": "sha512-RR3i96ohZGde//4WSe/dJsxOX6vxIg9TimLAS3i4EhBAFx8Sm5SmqVfR8E87DPSR31nEAjZfbt91OMZWcNgdZw==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "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.0", + "resolved": "https://registry.npmjs.org/micromark-factory-space/-/micromark-factory-space-2.0.0.tgz", + "integrity": "sha512-TKr+LIDX2pkBJXFLzpyPyljzYK3MtmllMUMODTQJIUfDGncESaqB90db9IAUcz4AZAJFdd8U9zOp9ty1458rxg==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "dependencies": { + "micromark-util-character": "^2.0.0", + "micromark-util-types": "^2.0.0" + } + }, + "node_modules/micromark-factory-title": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/micromark-factory-title/-/micromark-factory-title-2.0.0.tgz", + "integrity": "sha512-jY8CSxmpWLOxS+t8W+FG3Xigc0RDQA9bKMY/EwILvsesiRniiVMejYTE4wumNc2f4UbAa4WsHqe3J1QS1sli+A==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "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.0", + "resolved": "https://registry.npmjs.org/micromark-factory-whitespace/-/micromark-factory-whitespace-2.0.0.tgz", + "integrity": "sha512-28kbwaBjc5yAI1XadbdPYHX/eDnqaUFVikLwrO7FDnKG7lpgxnvk/XGRhX/PN0mOZ+dBSZ+LgunHS+6tYQAzhA==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "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.0", + "resolved": "https://registry.npmjs.org/micromark-util-character/-/micromark-util-character-2.1.0.tgz", + "integrity": "sha512-KvOVV+X1yLBfs9dCBSopq/+G1PcgT3lAK07mC4BzXi5E7ahzMAF8oIupDDJ6mievI6F+lAATkbQQlQixJfT3aQ==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "dependencies": { + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0" + } + }, + "node_modules/micromark-util-chunked": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/micromark-util-chunked/-/micromark-util-chunked-2.0.0.tgz", + "integrity": "sha512-anK8SWmNphkXdaKgz5hJvGa7l00qmcaUQoMYsBwDlSKFKjc6gjGXPDw3FNL3Nbwq5L8gE+RCbGqTw49FK5Qyvg==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "dependencies": { + "micromark-util-symbol": "^2.0.0" + } + }, + "node_modules/micromark-util-classify-character": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/micromark-util-classify-character/-/micromark-util-classify-character-2.0.0.tgz", + "integrity": "sha512-S0ze2R9GH+fu41FA7pbSqNWObo/kzwf8rN/+IGlW/4tC6oACOs8B++bh+i9bVyNnwCcuksbFwsBme5OCKXCwIw==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "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.0", + "resolved": "https://registry.npmjs.org/micromark-util-combine-extensions/-/micromark-util-combine-extensions-2.0.0.tgz", + "integrity": "sha512-vZZio48k7ON0fVS3CUgFatWHoKbbLTK/rT7pzpJ4Bjp5JjkZeasRfrS9wsBdDJK2cJLHMckXZdzPSSr1B8a4oQ==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "dependencies": { + "micromark-util-chunked": "^2.0.0", + "micromark-util-types": "^2.0.0" + } + }, + "node_modules/micromark-util-decode-numeric-character-reference": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-util-decode-numeric-character-reference/-/micromark-util-decode-numeric-character-reference-2.0.1.tgz", + "integrity": "sha512-bmkNc7z8Wn6kgjZmVHOX3SowGmVdhYS7yBpMnuMnPzDq/6xwVA604DuOXMZTO1lvq01g+Adfa0pE2UKGlxL1XQ==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "dependencies": { + "micromark-util-symbol": "^2.0.0" + } + }, + "node_modules/micromark-util-decode-string": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/micromark-util-decode-string/-/micromark-util-decode-string-2.0.0.tgz", + "integrity": "sha512-r4Sc6leeUTn3P6gk20aFMj2ntPwn6qpDZqWvYmAG6NgvFTIlj4WtrAudLi65qYoaGdXYViXYw2pkmn7QnIFasA==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "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.0", + "resolved": "https://registry.npmjs.org/micromark-util-encode/-/micromark-util-encode-2.0.0.tgz", + "integrity": "sha512-pS+ROfCXAGLWCOc8egcBvT0kf27GoWMqtdarNfDcjb6YLuV5cM3ioG45Ys2qOVqeqSbjaKg72vU+Wby3eddPsA==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ] + }, + "node_modules/micromark-util-html-tag-name": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/micromark-util-html-tag-name/-/micromark-util-html-tag-name-2.0.0.tgz", + "integrity": "sha512-xNn4Pqkj2puRhKdKTm8t1YHC/BAjx6CEwRFXntTaRf/x16aqka6ouVoutm+QdkISTlT7e2zU7U4ZdlDLJd2Mcw==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ] + }, + "node_modules/micromark-util-normalize-identifier": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/micromark-util-normalize-identifier/-/micromark-util-normalize-identifier-2.0.0.tgz", + "integrity": "sha512-2xhYT0sfo85FMrUPtHcPo2rrp1lwbDEEzpx7jiH2xXJLqBuy4H0GgXk5ToU8IEwoROtXuL8ND0ttVa4rNqYK3w==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "dependencies": { + "micromark-util-symbol": "^2.0.0" + } + }, + "node_modules/micromark-util-resolve-all": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/micromark-util-resolve-all/-/micromark-util-resolve-all-2.0.0.tgz", + "integrity": "sha512-6KU6qO7DZ7GJkaCgwBNtplXCvGkJToU86ybBAUdavvgsCiG8lSSvYxr9MhwmQ+udpzywHsl4RpGJsYWG1pDOcA==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "dependencies": { + "micromark-util-types": "^2.0.0" + } + }, + "node_modules/micromark-util-sanitize-uri": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/micromark-util-sanitize-uri/-/micromark-util-sanitize-uri-2.0.0.tgz", + "integrity": "sha512-WhYv5UEcZrbAtlsnPuChHUAsu/iBPOVaEVsntLBIdpibO0ddy8OzavZz3iL2xVvBZOpolujSliP65Kq0/7KIYw==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "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.0.0", + "resolved": "https://registry.npmjs.org/micromark-util-subtokenize/-/micromark-util-subtokenize-2.0.0.tgz", + "integrity": "sha512-vc93L1t+gpR3p8jxeVdaYlbV2jTYteDje19rNSS/H5dlhxUYll5Fy6vJ2cDwP8RnsXi818yGty1ayP55y3W6fg==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "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.0", + "resolved": "https://registry.npmjs.org/micromark-util-symbol/-/micromark-util-symbol-2.0.0.tgz", + "integrity": "sha512-8JZt9ElZ5kyTnO94muPxIGS8oyElRJaiJO8EzV6ZSyGQ1Is8xwl4Q45qU5UOg+bGH4AikWziz0iN4sFLWs8PGw==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ] + }, + "node_modules/micromark-util-types": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/micromark-util-types/-/micromark-util-types-2.0.0.tgz", + "integrity": "sha512-oNh6S2WMHWRZrmutsRmDDfkzKtxF+bc2VxLC9dvtrDIRFln627VsFP6fLMgTryGDljgLPjkrzQSDcPrjPyDJ5w==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ] + }, + "node_modules/micromatch": { + "version": "4.0.5", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.5.tgz", + "integrity": "sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==", + "dev": true, + "dependencies": { + "braces": "^3.0.2", + "picomatch": "^2.3.1" + }, + "engines": { + "node": ">=8.6" + } + }, + "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, + "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, + "dependencies": { + "mime-db": "1.52.0" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mimic-fn": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-4.0.0.tgz", + "integrity": "sha512-vqiC06CuhBTUdZH+RYl8sFrL096vA45Ok5ISO6sE/Mr1jRbGH4Csnhi8f3wKVl7x8mO4Au7Ir9D3Oyv1VYMFJw==", + "dev": true, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/min-indent": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/min-indent/-/min-indent-1.0.1.tgz", + "integrity": "sha512-I9jwMn07Sy/IwOj3zVkVik2JTvgpaykDZEigL6Rx6N9LbMywwUSMtxET+7lVoDLLd3O3IXwJwvuuns8UB/HeAg==", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/minimatch": { + "version": "9.0.3", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.3.tgz", + "integrity": "sha512-RHiac9mvaRw0x3AYRgDC1CxAP7HTcNrrECeA8YYJeWnpo+2Q5CegtZjaotWTWxDG3UeGA1coE05iH1mPjT/2mg==", + "dev": true, + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/minimist": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz", + "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==", + "dev": true, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/minipass": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-5.0.0.tgz", + "integrity": "sha512-3FnjYuehv9k6ovOEbyOswadCDPX1piCfhV8ncmYtHOjuPwylVWsghTLo7rabjC3Rx5xD4HDx8Wm1xnMF7S5qFQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/minisearch": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/minisearch/-/minisearch-6.3.0.tgz", + "integrity": "sha512-ihFnidEeU8iXzcVHy74dhkxh/dn8Dc08ERl0xwoMMGqp4+LvRSCgicb+zGqWthVokQKvCSxITlh3P08OzdTYCQ==", "dev": true }, "node_modules/minizlib": { @@ -7604,6 +8537,12 @@ "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", "dev": true }, + "node_modules/muggle-string": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/muggle-string/-/muggle-string-0.3.1.tgz", + "integrity": "sha512-ckmWDJjphvd/FvZawgygcUeQCxzvohjFO5RxTjj4eq8kw359gFF3E1brjfI+viLMxss5JrHTDRHZvu2/tuy0Qg==", + "dev": true + }, "node_modules/mute-stream": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-1.0.0.tgz", @@ -8293,6 +9232,12 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "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 + }, "node_modules/path-exists": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", @@ -10273,6 +11218,16 @@ "tree-kill": "cli.js" } }, + "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, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, "node_modules/ts-api-utils": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-1.3.0.tgz", @@ -10324,6 +11279,42 @@ "integrity": "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==", "dev": true }, + "node_modules/twoslash": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/twoslash/-/twoslash-0.2.5.tgz", + "integrity": "sha512-U8rqsfVh8jQMO1NJekUtglb52b7xD9+FrzeFrgzpHsRTKl8IQgqnZP6ld4PeKaHXhLfoZPuju9K50NXJ7wom8g==", + "dev": true, + "dependencies": { + "@typescript/vfs": "1.5.0", + "twoslash-protocol": "0.2.5" + }, + "peerDependencies": { + "typescript": "*" + } + }, + "node_modules/twoslash-protocol": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/twoslash-protocol/-/twoslash-protocol-0.2.5.tgz", + "integrity": "sha512-oUr5ZAn37CgNa6p1mrCuuR/pINffsnGCee2aS170Uj1IObxCjsHzu6sgdPUdxGLLn6++gd/qjNH1/iR6RrfLeg==", + "dev": true + }, + "node_modules/twoslash-vue": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/twoslash-vue/-/twoslash-vue-0.2.5.tgz", + "integrity": "sha512-Tai45V/1G/jEJQIbDe/DIkJCgOqtA/ZHxx4TgC5EM/nnyTP6zbZNtvKOlzMjFgXFdk6rebWEl2Mi/RHKs/sbDQ==", + "dev": true, + "dependencies": { + "@vue/language-core": "^1.8.27", + "twoslash": "0.2.5", + "twoslash-protocol": "0.2.5" + }, + "funding": { + "url": "https://github.com/sponsors/antfu" + }, + "peerDependencies": { + "typescript": "*" + } + }, "node_modules/type-check": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", @@ -10514,6 +11505,74 @@ "node": ">=4" } }, + "node_modules/unist-util-is": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-6.0.0.tgz", + "integrity": "sha512-2qCTHimwdxLfz+YzdGfkqNlH0tLi9xjTnHddPmJwtIG9MGsdbutfTc4P+haPD7l7Cjxf/WZj+we5qfVPvvxfYw==", + "dev": true, + "dependencies": { + "@types/unist": "^3.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "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, + "dependencies": { + "@types/unist": "^3.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "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, + "dependencies": { + "@types/unist": "^3.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "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, + "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" + } + }, + "node_modules/unist-util-visit-parents": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-6.0.1.tgz", + "integrity": "sha512-L/PqWzfTP9lzzEa6CKs0k2nARxTdZduw3zyh8d2NVBnsyvHjSX4TWse388YrrQKbvI8w20fGjGlhgT96WwKykw==", + "dev": true, + "dependencies": { + "@types/unist": "^3.0.0", + "unist-util-is": "^6.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, "node_modules/universalify": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.1.tgz", @@ -10593,6 +11652,35 @@ "spdx-expression-parse": "^3.0.0" } }, + "node_modules/vfile": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/vfile/-/vfile-6.0.1.tgz", + "integrity": "sha512-1bYqc7pt6NIADBJ98UiG0Bn/CHIVOoZ/IyEkqIruLg0mE1BKzkOXY2D6CSqQIcKqgadppE5lrxgWXJmXd7zZJw==", + "dev": true, + "dependencies": { + "@types/unist": "^3.0.0", + "unist-util-stringify-position": "^4.0.0", + "vfile-message": "^4.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/vfile-message": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/vfile-message/-/vfile-message-4.0.2.tgz", + "integrity": "sha512-jRDZ1IMLttGj41KcZvlrYAaI3CfqpLpfpf+Mfig13viT6NKvRzWZ+lXz0Y5D60w6uJIBAOGq9mSHf0gktF0duw==", + "dev": true, + "dependencies": { + "@types/unist": "^3.0.0", + "unist-util-stringify-position": "^4.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, "node_modules/vite": { "version": "5.2.6", "resolved": "https://registry.npmjs.org/vite/-/vite-5.2.6.tgz", @@ -10740,6 +11828,25 @@ "eslint": ">=6.0.0" } }, + "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, + "peerDependencies": { + "vue": "^3.0.0" + } + }, + "node_modules/vue-template-compiler": { + "version": "2.7.16", + "resolved": "https://registry.npmjs.org/vue-template-compiler/-/vue-template-compiler-2.7.16.tgz", + "integrity": "sha512-AYbUWAJHLGGQM7+cNTELw+KsOG9nl2CnSv467WobS5Cv9uk3wFcnr1Etsz2sEIHEZvw1U+o9mRlEO6QbZvUPGQ==", + "dev": true, + "dependencies": { + "de-indent": "^1.0.2", + "he": "^1.2.0" + } + }, "node_modules/w3c-keyname": { "version": "2.2.8", "resolved": "https://registry.npmjs.org/w3c-keyname/-/w3c-keyname-2.2.8.tgz", @@ -11107,6 +12214,16 @@ "funding": { "url": "https://github.com/sponsors/sindresorhus" } + }, + "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, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } } } } diff --git a/package.json b/package.json index de7ad1da6..4dea224d2 100644 --- a/package.json +++ b/package.json @@ -130,6 +130,7 @@ "@rollup/plugin-terser": "^0.4.4", "@rollup/plugin-typescript": "^11.1.6", "@rollup/pluginutils": "^5.1.0", + "@shikijs/vitepress-twoslash": "^1.2.1", "@types/eslint": "^8.56.6", "@types/inquirer": "^9.0.7", "@types/mocha": "^10.0.6", From 8521d29c3ab86b99e6f0d32820e6d786d251834b Mon Sep 17 00:00:00 2001 From: XiaoPi <530257315@qq.com> Date: Wed, 3 Apr 2024 12:13:49 +0800 Subject: [PATCH 02/45] feat: support explicit-resource-management (#5444) * feat: support using keyword * Tweak test, update swc_ecma_parser version * Detect 'using' in VariableDeclaration --- rust/parse_ast/src/convert_ast/converter.rs | 70 ++++++++++++------- .../convert_ast/converter/string_constants.rs | 2 + rust/parse_ast/src/lib.rs | 1 + src/ast/nodes/Identifier.ts | 12 ++-- src/ast/nodes/VariableDeclaration.ts | 5 +- src/ast/nodes/VariableDeclarator.ts | 8 ++- src/ast/nodes/shared/VariableKinds.ts | 2 +- src/utils/convert-ast-strings.ts | 5 +- .../samples/support-using-keyword/_config.js | 4 ++ .../support-using-keyword/_expected.js | 22 ++++++ .../samples/support-using-keyword/main.js | 25 +++++++ 11 files changed, 118 insertions(+), 38 deletions(-) create mode 100644 test/form/samples/support-using-keyword/_config.js create mode 100644 test/form/samples/support-using-keyword/_expected.js create mode 100644 test/form/samples/support-using-keyword/main.js diff --git a/rust/parse_ast/src/convert_ast/converter.rs b/rust/parse_ast/src/convert_ast/converter.rs index 41415f680..b57c34c7c 100644 --- a/rust/parse_ast/src/convert_ast/converter.rs +++ b/rust/parse_ast/src/convert_ast/converter.rs @@ -16,7 +16,7 @@ use swc_ecma_ast::{ PropName, PropOrSpread, Regex, RestPat, ReturnStmt, SeqExpr, SetterProp, SimpleAssignTarget, SpreadElement, StaticBlock, Stmt, Str, Super, SuperProp, SuperPropExpr, SwitchCase, SwitchStmt, TaggedTpl, ThisExpr, ThrowStmt, Tpl, TplElement, TryStmt, UnaryExpr, UnaryOp, UpdateExpr, - UpdateOp, VarDecl, VarDeclKind, VarDeclOrExpr, VarDeclarator, WhileStmt, YieldExpr, + UpdateOp, UsingDecl, VarDecl, VarDeclKind, VarDeclOrExpr, VarDeclarator, WhileStmt, YieldExpr, }; use crate::convert_ast::annotations::{AnnotationKind, AnnotationWithType}; @@ -259,14 +259,18 @@ impl<'a> AstConverter<'a> { fn convert_declaration(&mut self, declaration: &Decl) { match declaration { - Decl::Var(variable_declaration) => self.convert_variable_declaration(variable_declaration), + Decl::Var(variable_declaration) => { + self.convert_variable_declaration(&VariableDeclaration::Var(variable_declaration)) + } Decl::Fn(function_declaration) => self.convert_function( &function_declaration.function, &TYPE_FUNCTION_DECLARATION_INLINED_ANNOTATIONS, Some(&function_declaration.ident), ), Decl::Class(class_declaration) => self.convert_class_declaration(class_declaration), - Decl::Using(_) => unimplemented!("Cannot convert Decl::Using"), + Decl::Using(using_declaration) => { + self.convert_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"), @@ -527,12 +531,14 @@ impl<'a> AstConverter<'a> { fn convert_for_head(&mut self, for_head: &ForHead) { match for_head { ForHead::VarDecl(variable_declaration) => { - self.convert_variable_declaration(variable_declaration) + self.convert_variable_declaration(&VariableDeclaration::Var(variable_declaration)) } ForHead::Pat(pattern) => { self.convert_pattern(pattern); } - ForHead::UsingDecl(_) => unimplemented!("Cannot convert ForHead::UsingDecl"), + ForHead::UsingDecl(using_declaration) => { + self.convert_variable_declaration(&VariableDeclaration::Using(using_declaration)) + } } } @@ -995,7 +1001,7 @@ impl<'a> AstConverter<'a> { ) { match variable_declaration_or_expression { VarDeclOrExpr::VarDecl(variable_declaration) => { - self.convert_variable_declaration(variable_declaration); + self.convert_variable_declaration(&VariableDeclaration::Var(variable_declaration)); } VarDeclOrExpr::Expr(expression) => { self.convert_expression(expression); @@ -2942,32 +2948,43 @@ impl<'a> AstConverter<'a> { self.add_end(end_position, &update_expression.span); } - fn convert_variable_declaration(&mut self, variable_declaration: &VarDecl) { + fn convert_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_INLINED_DECLARATIONS, - &variable_declaration.span, + &span, VARIABLE_DECLARATION_RESERVED_BYTES, - matches!(variable_declaration.kind, VarDeclKind::Const), + kind == &STRING_CONST, ); // declarations - self.convert_item_list( - &variable_declaration.decls, - |ast_converter, variable_declarator| { - ast_converter.convert_variable_declarator(variable_declarator); - true - }, - ); + self.convert_item_list(decls, |ast_converter, variable_declarator| { + ast_converter.convert_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( - match variable_declaration.kind { - VarDeclKind::Var => &STRING_VAR, - VarDeclKind::Let => &STRING_LET, - VarDeclKind::Const => &STRING_CONST, - }, - ); + self.buffer[kind_position..kind_position + 4].copy_from_slice(kind); // end - self.add_end(end_position, &variable_declaration.span); + self.add_end(end_position, &span); } fn convert_variable_declarator(&mut self, variable_declarator: &VarDeclarator) { @@ -3065,6 +3082,11 @@ pub fn convert_string(buffer: &mut Vec, string: &str) { buffer.resize(buffer.len() + additional_length, 0); } +enum VariableDeclaration<'a> { + Var(&'a VarDecl), + Using(&'a UsingDecl), +} + enum StoredCallee<'a> { Expression(&'a Expr), Super(&'a Super), diff --git a/rust/parse_ast/src/convert_ast/converter/string_constants.rs b/rust/parse_ast/src/convert_ast/converter/string_constants.rs index 5163c0242..6c5788ca9 100644 --- a/rust/parse_ast/src/convert_ast/converter/string_constants.rs +++ b/rust/parse_ast/src/convert_ast/converter/string_constants.rs @@ -60,3 +60,5 @@ 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/lib.rs b/rust/parse_ast/src/lib.rs index 9012c9aea..4d334a666 100644 --- a/rust/parse_ast/src/lib.rs +++ b/rust/parse_ast/src/lib.rs @@ -25,6 +25,7 @@ pub fn parse_ast(code: String, allow_return_outside_function: bool) -> Vec { let syntax = Syntax::Es(EsConfig { allow_return_outside_function, import_attributes: true, + explicit_resource_management: true, ..Default::default() }); diff --git a/src/ast/nodes/Identifier.ts b/src/ast/nodes/Identifier.ts index b230e7ea5..11147f3fb 100644 --- a/src/ast/nodes/Identifier.ts +++ b/src/ast/nodes/Identifier.ts @@ -33,13 +33,7 @@ import type { VariableKind } from './shared/VariableKinds'; export type IdentifierWithVariable = Identifier & { variable: Variable }; -const tdzVariableKinds = { - __proto__: null, - class: true, - const: true, - let: true, - var: true -}; +const tdzVariableKinds = new Set(['class', 'const', 'let', 'var', 'using', 'await using']); export default class Identifier extends NodeBase implements PatternNode { declare name: string; @@ -92,6 +86,8 @@ export default class Identifier extends NodeBase implements PatternNode { } case 'let': case 'const': + case 'using': + case 'await using': case 'class': { variable = this.scope.addDeclaration(this, this.scope.context, init, kind); break; @@ -221,7 +217,7 @@ export default class Identifier extends NodeBase implements PatternNode { !( this.variable instanceof LocalVariable && this.variable.kind && - this.variable.kind in tdzVariableKinds && + tdzVariableKinds.has(this.variable.kind) && // we ignore possible TDZs due to circular module dependencies as // otherwise we get many false positives this.variable.module === this.scope.context.module diff --git a/src/ast/nodes/VariableDeclaration.ts b/src/ast/nodes/VariableDeclaration.ts index 2405aa617..dd787ab79 100644 --- a/src/ast/nodes/VariableDeclaration.ts +++ b/src/ast/nodes/VariableDeclaration.ts @@ -45,6 +45,7 @@ export default class VariableDeclaration extends NodeBase { declare declarations: readonly VariableDeclarator[]; declare kind: VariableDeclarationKind; declare type: NodeType.tVariableDeclaration; + declare isUsingDeclaration: boolean; deoptimizePath(): void { for (const declarator of this.declarations) { @@ -82,8 +83,9 @@ export default class VariableDeclaration extends NodeBase { initialise(): void { super.initialise(); + this.isUsingDeclaration = this.kind === 'await using' || this.kind === 'using'; for (const declarator of this.declarations) { - declarator.declareDeclarator(this.kind); + declarator.declareDeclarator(this.kind, this.isUsingDeclaration); } } @@ -97,6 +99,7 @@ export default class VariableDeclaration extends NodeBase { nodeRenderOptions: NodeRenderOptions = BLANK ): void { if ( + this.isUsingDeclaration || areAllDeclarationsIncludedAndNotExported(this.declarations, options.exportNamesByVariable) ) { for (const declarator of this.declarations) { diff --git a/src/ast/nodes/VariableDeclarator.ts b/src/ast/nodes/VariableDeclarator.ts index 297b87dbc..2a96aba44 100644 --- a/src/ast/nodes/VariableDeclarator.ts +++ b/src/ast/nodes/VariableDeclarator.ts @@ -20,8 +20,10 @@ export default class VariableDeclarator extends NodeBase { declare id: PatternNode; declare init: ExpressionNode | null; declare type: NodeType.tVariableDeclarator; + declare isUsingDeclaration: boolean; - declareDeclarator(kind: VariableKind): void { + declareDeclarator(kind: VariableKind, isUsingDeclaration: boolean): void { + this.isUsingDeclaration = isUsingDeclaration; this.id.declare(kind, this.init || UNDEFINED_EXPRESSION); } @@ -33,7 +35,7 @@ export default class VariableDeclarator extends NodeBase { if (!this.deoptimized) this.applyDeoptimizations(); const initEffect = this.init?.hasEffects(context); this.id.markDeclarationReached(); - return initEffect || this.id.hasEffects(context); + return initEffect || this.id.hasEffects(context) || this.isUsingDeclaration; } include(context: InclusionContext, includeChildrenRecursively: IncludeChildren): void { @@ -57,7 +59,7 @@ export default class VariableDeclarator extends NodeBase { snippets: { _, getPropertyAccess } } = options; const { end, id, init, start } = this; - const renderId = id.included; + const renderId = id.included || this.isUsingDeclaration; if (renderId) { id.render(code, options); } else { diff --git a/src/ast/nodes/shared/VariableKinds.ts b/src/ast/nodes/shared/VariableKinds.ts index f963f0332..e62e17154 100644 --- a/src/ast/nodes/shared/VariableKinds.ts +++ b/src/ast/nodes/shared/VariableKinds.ts @@ -1,2 +1,2 @@ -export type VariableDeclarationKind = 'var' | 'let' | 'const'; +export type VariableDeclarationKind = 'var' | 'let' | 'const' | 'using' | 'await using'; export type VariableKind = VariableDeclarationKind | 'function' | 'class' | 'parameter' | 'other'; diff --git a/src/utils/convert-ast-strings.ts b/src/utils/convert-ast-strings.ts index 381bb3743..3a7f5330e 100644 --- a/src/utils/convert-ast-strings.ts +++ b/src/utils/convert-ast-strings.ts @@ -58,5 +58,8 @@ export const FIXED_STRINGS = [ '||=', '??=', 'pure', - 'noSideEffects' + 'noSideEffects', + 'sourcemap', + 'using', + 'await using' ]; 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 000000000..8aa754729 --- /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 000000000..128941df8 --- /dev/null +++ b/test/form/samples/support-using-keyword/_expected.js @@ -0,0 +1,22 @@ +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 000000000..8ad41bdd3 --- /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(); From 5301dec8d5319e31e19b7ef14cff7161170be06b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=98=A4=EB=8B=A4=ED=98=9C?= Date: Wed, 3 Apr 2024 14:10:39 +0900 Subject: [PATCH 03/45] feat: show all cause in Error (#5422) * feat: show all cause in Error * test: sample to test stderr cause * Add indentation --------- Co-authored-by: Lukas Taegert-Atkinson Co-authored-by: Lukas Taegert-Atkinson --- cli/logging.ts | 17 +++++++++++++++++ .../cli/samples/handles-errors-cause/_config.js | 14 ++++++++++++++ test/cli/samples/handles-errors-cause/main.js | 1 + .../handles-errors-cause/rollup.config.mjs | 14 ++++++++++++++ 4 files changed, 46 insertions(+) create mode 100644 test/cli/samples/handles-errors-cause/_config.js create mode 100644 test/cli/samples/handles-errors-cause/main.js create mode 100644 test/cli/samples/handles-errors-cause/rollup.config.mjs diff --git a/cli/logging.ts b/cli/logging.ts index 46579dc03..58cb474f5 100644 --- a/cli/logging.ts +++ b/cli/logging.ts @@ -35,6 +35,23 @@ export function handleError(error: RollupError, recover = false): void { outputLines.push(dim(error.stack?.replace(`${nameSection}${error.message}\n`, ''))); } + // 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'))); + } + outputLines.push('', ''); stderr(outputLines.join('\n')); 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 000000000..14e35b6ec --- /dev/null +++ b/test/cli/samples/handles-errors-cause/_config.js @@ -0,0 +1,14 @@ +const { assertIncludes } = require('../../../utils.js'); + +module.exports = defineTest({ + description: 'prints error cause', + command: 'rollup --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 000000000..de87bba67 --- /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 000000000..8e783b3d3 --- /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") + }) + }); + } + } + ] +}; From 5abe71bd5bae3423b4e2ee80207c871efde20253 Mon Sep 17 00:00:00 2001 From: Lukas Taegert-Atkinson Date: Wed, 3 Apr 2024 07:12:42 +0200 Subject: [PATCH 04/45] 4.14.0 --- CHANGELOG.md | 17 +++++++++++++++++ browser/package.json | 2 +- package-lock.json | 4 ++-- package.json | 2 +- 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8da23f4c9..0967d5b77 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,22 @@ # rollup changelog +## 4.14.0 + +_2024-04-03_ + +### Features + +- Display error causes in Rollup CLI (#5422) +- Add basic support for explicit resource management via "using" and "await using" (#5423) + +### Pull Requests + +- [#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]) + ## 4.13.2 _2024-03-28_ diff --git a/browser/package.json b/browser/package.json index 326289b2e..4e9d9071a 100644 --- a/browser/package.json +++ b/browser/package.json @@ -1,6 +1,6 @@ { "name": "@rollup/browser", - "version": "4.13.2", + "version": "4.14.0", "description": "Next-generation ES module bundler browser build", "main": "dist/rollup.browser.js", "module": "dist/es/rollup.browser.js", diff --git a/package-lock.json b/package-lock.json index 834169191..c6bb86b74 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "rollup", - "version": "4.13.2", + "version": "4.14.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "rollup", - "version": "4.13.2", + "version": "4.14.0", "license": "MIT", "dependencies": { "@types/estree": "1.0.5" diff --git a/package.json b/package.json index 4dea224d2..32f3b187e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rollup", - "version": "4.13.2", + "version": "4.14.0", "description": "Next-generation ES module bundler", "main": "dist/rollup.js", "module": "dist/es/rollup.js", From 459bfe1b336814199b5c643e212390f6979de83d Mon Sep 17 00:00:00 2001 From: XiaoPi <530257315@qq.com> Date: Thu, 4 Apr 2024 12:43:43 +0800 Subject: [PATCH 05/45] chore: generate string constants from config (#5451) --- .../convert_ast/converter/string_constants.rs | 5 +- scripts/generate-ast-converters.js | 1 + scripts/generate-buffer-parsers.js | 6 +- scripts/generate-buffer-to-ast.js | 6 +- scripts/generate-child-node-keys.js | 4 +- scripts/generate-rust-constants.js | 5 +- scripts/generate-string-constants.js | 101 ++++++++++++++++++ scripts/helpers.js | 10 +- src/ast/bufferParsers.ts | 2 +- src/utils/astConverterHelpers.ts | 2 +- src/utils/bufferToAst.ts | 2 +- src/utils/convert-ast-strings.ts | 4 +- 12 files changed, 130 insertions(+), 18 deletions(-) create mode 100644 scripts/generate-string-constants.js diff --git a/rust/parse_ast/src/convert_ast/converter/string_constants.rs b/rust/parse_ast/src/convert_ast/converter/string_constants.rs index 6c5788ca9..c6f8e0a46 100644 --- a/rust/parse_ast/src/convert_ast/converter/string_constants.rs +++ b/rust/parse_ast/src/convert_ast/converter/string_constants.rs @@ -1,4 +1,5 @@ -// These need to correspond to the positions in convert-ast-strings.ts +// This file is generated by scripts/generate-string-constant.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 @@ -49,7 +50,7 @@ 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_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(); // &= diff --git a/scripts/generate-ast-converters.js b/scripts/generate-ast-converters.js index 44ca0ca99..0a13a8670 100644 --- a/scripts/generate-ast-converters.js +++ b/scripts/generate-ast-converters.js @@ -4,3 +4,4 @@ import './generate-rust-constants.js'; import './generate-buffer-to-ast.js'; import './generate-child-node-keys.js'; import './generate-buffer-parsers.js'; +import './generate-string-constants.js'; diff --git a/scripts/generate-buffer-parsers.js b/scripts/generate-buffer-parsers.js index 041e3c13f..6e498f366 100644 --- a/scripts/generate-buffer-parsers.js +++ b/scripts/generate-buffer-parsers.js @@ -1,7 +1,7 @@ import { writeFile } from 'node:fs/promises'; import { AST_NODES, astNodeNamesWithFieldOrder } from './ast-types.js'; import { getNode } from './generate-buffer-to-ast.js'; -import { firstLetterLowercase, lintFile } from './helpers.js'; +import { firstLetterLowercase, lintTsFile } from './helpers.js'; const bufferParsersFile = new URL('../src/ast/bufferParsers.ts', import.meta.url); @@ -187,7 +187,7 @@ import type * as estree from 'estree'; import type { AstContext } from '../Module'; import { convertAnnotations, convertString } from '../utils/astConverterHelpers'; import { convertNode as convertJsonNode } from '../utils/bufferToAst'; -import { FIXED_STRINGS } from '../utils/convert-ast-strings'; +import FIXED_STRINGS from '../utils/convert-ast-strings'; import type { ReadString } from '../utils/getReadStringFunction'; import getReadStringFunction from '../utils/getReadStringFunction'; ${nodeTypeImports.join('\n')} @@ -253,4 +253,4 @@ function convertNodeList(parent: Node | { context: AstContext; type: string }, p `; await writeFile(bufferParsersFile, bufferParsers); -await lintFile(bufferParsersFile); +await lintTsFile(bufferParsersFile); diff --git a/scripts/generate-buffer-to-ast.js b/scripts/generate-buffer-to-ast.js index 926784c5e..0fa8d6136 100644 --- a/scripts/generate-buffer-to-ast.js +++ b/scripts/generate-buffer-to-ast.js @@ -1,6 +1,6 @@ import { writeFile } from 'node:fs/promises'; import { AST_NODES, astNodeNamesWithFieldOrder } from './ast-types.js'; -import { firstLetterLowercase, lintFile } from './helpers.js'; +import { firstLetterLowercase, lintTsFile } from './helpers.js'; const bufferToJsAstFile = new URL('../src/utils/bufferToAst.ts', import.meta.url); @@ -190,7 +190,7 @@ import { convertString, INVALID_ANNOTATION_KEY } from './astConverterHelpers'; -import { FIXED_STRINGS } from './convert-ast-strings'; +import FIXED_STRINGS from './convert-ast-strings'; import type { ReadString } from './getReadStringFunction'; import { error, getRollupError, logParseError } from './logs'; @@ -239,4 +239,4 @@ function convertNodeList(position: number, buffer: Uint32Array, readString: Read `; await writeFile(bufferToJsAstFile, bufferToJsAst); -await lintFile(bufferToJsAstFile); +await lintTsFile(bufferToJsAstFile); diff --git a/scripts/generate-child-node-keys.js b/scripts/generate-child-node-keys.js index ac9b93731..104b186d1 100644 --- a/scripts/generate-child-node-keys.js +++ b/scripts/generate-child-node-keys.js @@ -1,6 +1,6 @@ import { writeFile } from 'node:fs/promises'; import { AST_NODES } from './ast-types.js'; -import { lintFile } from './helpers.js'; +import { lintTsFile } from './helpers.js'; const childNodeKeysFile = new URL('../src/ast/childNodeKeys.ts', import.meta.url); @@ -30,4 +30,4 @@ export const childNodeKeys: Record = { `; await writeFile(childNodeKeysFile, childNodeKeys); -await lintFile(childNodeKeysFile); +await lintTsFile(childNodeKeysFile); diff --git a/scripts/generate-rust-constants.js b/scripts/generate-rust-constants.js index 90db76d05..1ea928efa 100644 --- a/scripts/generate-rust-constants.js +++ b/scripts/generate-rust-constants.js @@ -1,7 +1,6 @@ import { writeFile } from 'node:fs/promises'; -import { fileURLToPath } from 'node:url'; import { AST_NODES, astNodeNamesWithFieldOrder } from './ast-types.js'; -import { runWithEcho, toScreamingSnakeCase } from './helpers.js'; +import { lintRustFile, toScreamingSnakeCase } from './helpers.js'; const BYTES_PER_U32 = 4; @@ -79,4 +78,4 @@ ${reservedBytesAndOffsets} `; await writeFile(astConstantsFile, astConstants); -await runWithEcho('rustfmt', [fileURLToPath(astConstantsFile)]); +await lintRustFile(astConstantsFile); diff --git a/scripts/generate-string-constants.js b/scripts/generate-string-constants.js new file mode 100644 index 000000000..11f7dbc01 --- /dev/null +++ b/scripts/generate-string-constants.js @@ -0,0 +1,101 @@ +import { writeFile } from 'node:fs/promises'; +import { lintRustFile, lintTsFile } from './helpers.js'; + +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 tipComment = `// This file is generated by scripts/generate-string-constant.js. +// Do not edit this file directly.\n`; + +const rustCode = + tipComment + + stringConstantsTemplate + .map( + ([variableName, value], index) => + `pub const ${variableName}: [u8; 4] = ${index}u32.to_ne_bytes(); // ${value}` + ) + .join('\n'); + +const tsCode = + tipComment + + `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 index 842cd5281..67f0534cd 100644 --- a/scripts/helpers.js +++ b/scripts/helpers.js @@ -80,7 +80,7 @@ export async function readJson(file) { * @param {URL} file * @return {Promise} */ -export async function lintFile(file) { +export async function lintTsFile(file) { const eslint = new ESLint({ fix: true }); const results = await eslint.lintFiles([fileURLToPath(file)]); await ESLint.outputFixes(results); @@ -89,6 +89,14 @@ export async function lintFile(file) { console.log(resultText); } +/** + * @param {URL} file + * @return {Promise} + */ +export function lintRustFile(file) { + return runWithEcho('rustfmt', [fileURLToPath(file)]); +} + /** * @param {string} string * @returns {string} diff --git a/src/ast/bufferParsers.ts b/src/ast/bufferParsers.ts index f902359ca..35be3c7b0 100644 --- a/src/ast/bufferParsers.ts +++ b/src/ast/bufferParsers.ts @@ -5,7 +5,7 @@ import type * as estree from 'estree'; import type { AstContext } from '../Module'; import { convertAnnotations, convertString } from '../utils/astConverterHelpers'; import { convertNode as convertJsonNode } from '../utils/bufferToAst'; -import { FIXED_STRINGS } from '../utils/convert-ast-strings'; +import FIXED_STRINGS from '../utils/convert-ast-strings'; import type { ReadString } from '../utils/getReadStringFunction'; import getReadStringFunction from '../utils/getReadStringFunction'; import ArrayExpression from './nodes/ArrayExpression'; diff --git a/src/utils/astConverterHelpers.ts b/src/utils/astConverterHelpers.ts index 5772ae7ed..96bea8535 100644 --- a/src/utils/astConverterHelpers.ts +++ b/src/utils/astConverterHelpers.ts @@ -1,4 +1,4 @@ -import { FIXED_STRINGS } from './convert-ast-strings'; +import FIXED_STRINGS from './convert-ast-strings'; import type { ReadString } from './getReadStringFunction'; export const ANNOTATION_KEY = '_rollupAnnotations'; diff --git a/src/utils/bufferToAst.ts b/src/utils/bufferToAst.ts index 04c6520e5..88e41268a 100644 --- a/src/utils/bufferToAst.ts +++ b/src/utils/bufferToAst.ts @@ -11,7 +11,7 @@ import { convertString, INVALID_ANNOTATION_KEY } from './astConverterHelpers'; -import { FIXED_STRINGS } from './convert-ast-strings'; +import FIXED_STRINGS from './convert-ast-strings'; import type { ReadString } from './getReadStringFunction'; import { error, getRollupError, logParseError } from './logs'; diff --git a/src/utils/convert-ast-strings.ts b/src/utils/convert-ast-strings.ts index 3a7f5330e..0ce8fdeca 100644 --- a/src/utils/convert-ast-strings.ts +++ b/src/utils/convert-ast-strings.ts @@ -1,4 +1,6 @@ -export const FIXED_STRINGS = [ +// This file is generated by scripts/generate-string-constant.js. +// Do not edit this file directly. +export default [ 'var', 'let', 'const', From 66a0de1d52f07318f4ee8968ca1fe104bb950142 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 5 Apr 2024 02:29:02 +0000 Subject: [PATCH 06/45] chore(deps): lock file maintenance minor/patch updates (#5452) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- package-lock.json | 419 ++++++++++++++++++-------------------- package.json | 22 +- rust/Cargo.lock | 85 ++++---- rust/parse_ast/Cargo.toml | 10 +- 4 files changed, 266 insertions(+), 270 deletions(-) diff --git a/package-lock.json b/package-lock.json index c6bb86b74..da69d844c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -20,7 +20,7 @@ "@codemirror/language": "^6.10.1", "@codemirror/search": "^6.5.6", "@codemirror/state": "^6.4.1", - "@codemirror/view": "^6.26.0", + "@codemirror/view": "^6.26.1", "@jridgewell/sourcemap-codec": "^1.4.15", "@mermaid-js/mermaid-cli": "^10.8.0", "@napi-rs/cli": "^2.18.0", @@ -33,14 +33,14 @@ "@rollup/plugin-terser": "^0.4.4", "@rollup/plugin-typescript": "^11.1.6", "@rollup/pluginutils": "^5.1.0", - "@shikijs/vitepress-twoslash": "^1.2.1", - "@types/eslint": "^8.56.6", + "@shikijs/vitepress-twoslash": "^1.2.3", + "@types/eslint": "^8.56.7", "@types/inquirer": "^9.0.7", "@types/mocha": "^10.0.6", "@types/node": "~18.18.14", "@types/yargs-parser": "^21.0.3", - "@typescript-eslint/eslint-plugin": "^7.4.0", - "@typescript-eslint/parser": "^7.4.0", + "@typescript-eslint/eslint-plugin": "^7.5.0", + "@typescript-eslint/parser": "^7.5.0", "@vue/eslint-config-prettier": "^9.0.0", "@vue/eslint-config-typescript": "^13.0.0", "acorn": "^8.11.3", @@ -65,19 +65,19 @@ "fs-extra": "^11.2.0", "github-api": "^3.4.0", "husky": "^9.0.11", - "inquirer": "^9.2.16", + "inquirer": "^9.2.17", "is-reference": "^3.0.2", "lint-staged": "^15.2.2", "locate-character": "^3.0.0", "magic-string": "^0.30.8", - "mocha": "^10.3.0", + "mocha": "^10.4.0", "nyc": "^15.1.0", "pinia": "^2.1.7", "prettier": "^3.2.5", "pretty-bytes": "^6.1.1", "pretty-ms": "^9.0.0", "requirejs": "^2.3.6", - "rollup": "^4.13.0", + "rollup": "^4.13.2", "rollup-plugin-license": "^3.3.1", "rollup-plugin-string": "^3.0.0", "semver": "^7.6.0", @@ -86,11 +86,11 @@ "source-map": "^0.7.4", "source-map-support": "^0.5.21", "systemjs": "^6.14.3", - "terser": "^5.29.2", + "terser": "^5.30.1", "tslib": "^2.6.2", "typescript": "^5.4.3", - "vite": "^5.2.6", - "vitepress": "^1.0.1", + "vite": "^5.2.7", + "vitepress": "^1.0.2", "vue": "^3.4.21", "wasm-pack": "^0.12.1", "weak-napi": "^2.0.2", @@ -333,27 +333,27 @@ } }, "node_modules/@babel/compat-data": { - "version": "7.24.1", - "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.24.1.tgz", - "integrity": "sha512-Pc65opHDliVpRHuKfzI+gSA4zcgr65O4cl64fFJIWEEh8JoHIHh0Oez1Eo8Arz8zq/JhgKodQaxEwUPRtZylVA==", + "version": "7.24.4", + "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.24.4.tgz", + "integrity": "sha512-vg8Gih2MLK+kOkHJp4gBEIkyaIi00jgWot2D9QOmmfLC8jINSOzmCLta6Bvz/JSBCqnegV0L80jhxkol5GWNfQ==", "dev": true, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/core": { - "version": "7.24.3", - "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.24.3.tgz", - "integrity": "sha512-5FcvN1JHw2sHJChotgx8Ek0lyuh4kCKelgMTTqhYJJtloNvUfpAFMeNQUtdlIaktwrSV9LtCdqwk48wL2wBacQ==", + "version": "7.24.4", + "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.24.4.tgz", + "integrity": "sha512-MBVlMXP+kkl5394RBLSxxk/iLTeVGuXTV3cIDXavPpMMqnSnt6apKgan/U8O3USWZCWZT/TbgfEpKa4uMgN4Dg==", "dev": true, "dependencies": { "@ampproject/remapping": "^2.2.0", "@babel/code-frame": "^7.24.2", - "@babel/generator": "^7.24.1", + "@babel/generator": "^7.24.4", "@babel/helper-compilation-targets": "^7.23.6", "@babel/helper-module-transforms": "^7.23.3", - "@babel/helpers": "^7.24.1", - "@babel/parser": "^7.24.1", + "@babel/helpers": "^7.24.4", + "@babel/parser": "^7.24.4", "@babel/template": "^7.24.0", "@babel/traverse": "^7.24.1", "@babel/types": "^7.24.0", @@ -378,9 +378,9 @@ "dev": true }, "node_modules/@babel/generator": { - "version": "7.24.1", - "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.24.1.tgz", - "integrity": "sha512-DfCRfZsBcrPEHUfuBMgbJ1Ut01Y/itOs+hY2nFLgqsqXd52/iSiVq5TITtUasIUgm+IIKdY2/1I7auiQOEeC9A==", + "version": "7.24.4", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.24.4.tgz", + "integrity": "sha512-Xd6+v6SnjWVx/nus+y0l1sxMOTOMBkyL4+BIdbALyatQnAe/SRVjANeDPSCYaX+i1iJmuGSKf3Z+E+V/va1Hvw==", "dev": true, "dependencies": { "@babel/types": "^7.24.0", @@ -537,9 +537,9 @@ } }, "node_modules/@babel/helpers": { - "version": "7.24.1", - "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.24.1.tgz", - "integrity": "sha512-BpU09QqEe6ZCHuIHFphEFgvNSrubve1FtyMton26ekZ85gRGi6LrTF7zArARp2YvyFxloeiRmtSCq5sjh1WqIg==", + "version": "7.24.4", + "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.24.4.tgz", + "integrity": "sha512-FewdlZbSiwaVGlgT1DPANDuCHaDMiOo+D/IDYRFYjHOuv66xMSJ7fQwwODwRNAPkADIO/z1EoF/l2BCWlWABDw==", "dev": true, "dependencies": { "@babel/template": "^7.24.0", @@ -622,9 +622,9 @@ } }, "node_modules/@babel/parser": { - "version": "7.24.1", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.24.1.tgz", - "integrity": "sha512-Zo9c7N3xdOIQrNip7Lc9wvRPzlRtovHVE4lkz8WEDr7uYh/GMQhSiIgFxGIArRHYdJE5kxtZjAf8rT0xhdLCzg==", + "version": "7.24.4", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.24.4.tgz", + "integrity": "sha512-zTvEBcghmeBma9QIGunWevvBAp4/Qu9Bdq+2k0Ot4fVMD6v3dsC9WOcRSKk7tRRyBM/53yKMJko9xOatGQAwSg==", "dev": true, "bin": { "parser": "bin/babel-parser.js" @@ -634,9 +634,9 @@ } }, "node_modules/@babel/runtime": { - "version": "7.24.1", - "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.24.1.tgz", - "integrity": "sha512-+BIznRzyqBf+2wCTxcKE3wDjfGeCoVE61KSHGpkzqrLi8qxqFwBeUFyId2cxkTmm55fzDGnm0+yCxaxygrLUnQ==", + "version": "7.24.4", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.24.4.tgz", + "integrity": "sha512-dkxf7+hn8mFBwKjs9bvBlArzLVxVbS8usaPUDd5p2a9JCL9tB8OaOVN1isD4+Xyk4ns89/xeOmbQvgdK7IIVdA==", "dev": true, "dependencies": { "regenerator-runtime": "^0.14.0" @@ -1369,9 +1369,9 @@ } }, "node_modules/@humanwhocodes/object-schema": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-2.0.2.tgz", - "integrity": "sha512-6EwiSjwWYP7pTckG6I5eyFANjPhmPjUX9JRLUSfNPC7FX7zK9gyZAfUEaECL6ALTpGX5AjnBq3C9XmVWPitNpw==", + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-2.0.3.tgz", + "integrity": "sha512-93zYdMES/c1D69yZiKDBj0V24vqNzB/koF26KPaagAfd3P/4gUlh3Dys5ogAK+Exi9QyzlD8x/08Zt7wIKcDcA==", "dev": true }, "node_modules/@istanbuljs/load-nyc-config": { @@ -1556,9 +1556,9 @@ } }, "node_modules/@lezer/javascript": { - "version": "1.4.13", - "resolved": "https://registry.npmjs.org/@lezer/javascript/-/javascript-1.4.13.tgz", - "integrity": "sha512-5IBr8LIO3xJdJH1e9aj/ZNLE4LSbdsx25wFmGRAZsj2zSmwAYjx26JyU/BYOCpRQlu1jcv1z3vy4NB9+UkfRow==", + "version": "1.4.14", + "resolved": "https://registry.npmjs.org/@lezer/javascript/-/javascript-1.4.14.tgz", + "integrity": "sha512-GEdUyspTRgc5dwIGebUk+f3BekvqEWVIYsIuAC3pA8e8wcikGwBZRWRa450L0s8noGWuULwnmi4yjxTnYz9PpA==", "dev": true, "dependencies": { "@lezer/common": "^1.2.0", @@ -1928,9 +1928,9 @@ } }, "node_modules/@rollup/rollup-android-arm-eabi": { - "version": "4.13.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.13.2.tgz", - "integrity": "sha512-3XFIDKWMFZrMnao1mJhnOT1h2g0169Os848NhhmGweEcfJ4rCi+3yMCOLG4zA61rbJdkcrM/DjVZm9Hg5p5w7g==", + "version": "4.14.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.14.0.tgz", + "integrity": "sha512-jwXtxYbRt1V+CdQSy6Z+uZti7JF5irRKF8hlKfEnF/xJpcNGuuiZMBvuoYM+x9sr9iWGnzrlM0+9hvQ1kgkf1w==", "cpu": [ "arm" ], @@ -1941,9 +1941,9 @@ ] }, "node_modules/@rollup/rollup-android-arm64": { - "version": "4.13.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.13.2.tgz", - "integrity": "sha512-GdxxXbAuM7Y/YQM9/TwwP+L0omeE/lJAR1J+olu36c3LqqZEBdsIWeQ91KBe6nxwOnb06Xh7JS2U5ooWU5/LgQ==", + "version": "4.14.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.14.0.tgz", + "integrity": "sha512-fI9nduZhCccjzlsA/OuAwtFGWocxA4gqXGTLvOyiF8d+8o0fZUeSztixkYjcGq1fGZY3Tkq4yRvHPFxU+jdZ9Q==", "cpu": [ "arm64" ], @@ -1954,9 +1954,9 @@ ] }, "node_modules/@rollup/rollup-darwin-arm64": { - "version": "4.13.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.13.2.tgz", - "integrity": "sha512-mCMlpzlBgOTdaFs83I4XRr8wNPveJiJX1RLfv4hggyIVhfB5mJfN4P8Z6yKh+oE4Luz+qq1P3kVdWrCKcMYrrA==", + "version": "4.14.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.14.0.tgz", + "integrity": "sha512-BcnSPRM76/cD2gQC+rQNGBN6GStBs2pl/FpweW8JYuz5J/IEa0Fr4AtrPv766DB/6b2MZ/AfSIOSGw3nEIP8SA==", "cpu": [ "arm64" ], @@ -1967,9 +1967,9 @@ ] }, "node_modules/@rollup/rollup-darwin-x64": { - "version": "4.13.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.13.2.tgz", - "integrity": "sha512-yUoEvnH0FBef/NbB1u6d3HNGyruAKnN74LrPAfDQL3O32e3k3OSfLrPgSJmgb3PJrBZWfPyt6m4ZhAFa2nZp2A==", + "version": "4.14.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.14.0.tgz", + "integrity": "sha512-LDyFB9GRolGN7XI6955aFeI3wCdCUszFWumWU0deHA8VpR3nWRrjG6GtGjBrQxQKFevnUTHKCfPR4IvrW3kCgQ==", "cpu": [ "x64" ], @@ -1980,9 +1980,9 @@ ] }, "node_modules/@rollup/rollup-linux-arm-gnueabihf": { - "version": "4.13.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.13.2.tgz", - "integrity": "sha512-GYbLs5ErswU/Xs7aGXqzc3RrdEjKdmoCrgzhJWyFL0r5fL3qd1NPcDKDowDnmcoSiGJeU68/Vy+OMUluRxPiLQ==", + "version": "4.14.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.14.0.tgz", + "integrity": "sha512-ygrGVhQP47mRh0AAD0zl6QqCbNsf0eTo+vgwkY6LunBcg0f2Jv365GXlDUECIyoXp1kKwL5WW6rsO429DBY/bA==", "cpu": [ "arm" ], @@ -1993,9 +1993,9 @@ ] }, "node_modules/@rollup/rollup-linux-arm64-gnu": { - "version": "4.13.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.13.2.tgz", - "integrity": "sha512-L1+D8/wqGnKQIlh4Zre9i4R4b4noxzH5DDciyahX4oOz62CphY7WDWqJoQ66zNR4oScLNOqQJfNSIAe/6TPUmQ==", + "version": "4.14.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.14.0.tgz", + "integrity": "sha512-x+uJ6MAYRlHGe9wi4HQjxpaKHPM3d3JjqqCkeC5gpnnI6OWovLdXTpfa8trjxPLnWKyBsSi5kne+146GAxFt4A==", "cpu": [ "arm64" ], @@ -2006,9 +2006,9 @@ ] }, "node_modules/@rollup/rollup-linux-arm64-musl": { - "version": "4.13.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.13.2.tgz", - "integrity": "sha512-tK5eoKFkXdz6vjfkSTCupUzCo40xueTOiOO6PeEIadlNBkadH1wNOH8ILCPIl8by/Gmb5AGAeQOFeLev7iZDOA==", + "version": "4.14.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.14.0.tgz", + "integrity": "sha512-nrRw8ZTQKg6+Lttwqo6a2VxR9tOroa2m91XbdQ2sUUzHoedXlsyvY1fN4xWdqz8PKmf4orDwejxXHjh7YBGUCA==", "cpu": [ "arm64" ], @@ -2019,9 +2019,9 @@ ] }, "node_modules/@rollup/rollup-linux-powerpc64le-gnu": { - "version": "4.13.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-powerpc64le-gnu/-/rollup-linux-powerpc64le-gnu-4.13.2.tgz", - "integrity": "sha512-zvXvAUGGEYi6tYhcDmb9wlOckVbuD+7z3mzInCSTACJ4DQrdSLPNUeDIcAQW39M3q6PDquqLWu7pnO39uSMRzQ==", + "version": "4.14.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-powerpc64le-gnu/-/rollup-linux-powerpc64le-gnu-4.14.0.tgz", + "integrity": "sha512-xV0d5jDb4aFu84XKr+lcUJ9y3qpIWhttO3Qev97z8DKLXR62LC3cXT/bMZXrjLF9X+P5oSmJTzAhqwUbY96PnA==", "cpu": [ "ppc64le" ], @@ -2032,9 +2032,9 @@ ] }, "node_modules/@rollup/rollup-linux-riscv64-gnu": { - "version": "4.13.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.13.2.tgz", - "integrity": "sha512-C3GSKvMtdudHCN5HdmAMSRYR2kkhgdOfye4w0xzyii7lebVr4riCgmM6lRiSCnJn2w1Xz7ZZzHKuLrjx5620kw==", + "version": "4.14.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.14.0.tgz", + "integrity": "sha512-SDDhBQwZX6LPRoPYjAZWyL27LbcBo7WdBFWJi5PI9RPCzU8ijzkQn7tt8NXiXRiFMJCVpkuMkBf4OxSxVMizAw==", "cpu": [ "riscv64" ], @@ -2045,9 +2045,9 @@ ] }, "node_modules/@rollup/rollup-linux-s390x-gnu": { - "version": "4.13.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.13.2.tgz", - "integrity": "sha512-l4U0KDFwzD36j7HdfJ5/TveEQ1fUTjFFQP5qIt9gBqBgu1G8/kCaq5Ok05kd5TG9F8Lltf3MoYsUMw3rNlJ0Yg==", + "version": "4.14.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.14.0.tgz", + "integrity": "sha512-RxB/qez8zIDshNJDufYlTT0ZTVut5eCpAZ3bdXDU9yTxBzui3KhbGjROK2OYTTor7alM7XBhssgoO3CZ0XD3qA==", "cpu": [ "s390x" ], @@ -2058,9 +2058,9 @@ ] }, "node_modules/@rollup/rollup-linux-x64-gnu": { - "version": "4.13.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.13.2.tgz", - "integrity": "sha512-xXMLUAMzrtsvh3cZ448vbXqlUa7ZL8z0MwHp63K2IIID2+DeP5iWIT6g1SN7hg1VxPzqx0xZdiDM9l4n9LRU1A==", + "version": "4.14.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.14.0.tgz", + "integrity": "sha512-C6y6z2eCNCfhZxT9u+jAM2Fup89ZjiG5pIzZIDycs1IwESviLxwkQcFRGLjnDrP+PT+v5i4YFvlcfAs+LnreXg==", "cpu": [ "x64" ], @@ -2071,9 +2071,9 @@ ] }, "node_modules/@rollup/rollup-linux-x64-musl": { - "version": "4.13.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.13.2.tgz", - "integrity": "sha512-M/JYAWickafUijWPai4ehrjzVPKRCyDb1SLuO+ZyPfoXgeCEAlgPkNXewFZx0zcnoIe3ay4UjXIMdXQXOZXWqA==", + "version": "4.14.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.14.0.tgz", + "integrity": "sha512-i0QwbHYfnOMYsBEyjxcwGu5SMIi9sImDVjDg087hpzXqhBSosxkE7gyIYFHgfFl4mr7RrXksIBZ4DoLoP4FhJg==", "cpu": [ "x64" ], @@ -2084,9 +2084,9 @@ ] }, "node_modules/@rollup/rollup-win32-arm64-msvc": { - "version": "4.13.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.13.2.tgz", - "integrity": "sha512-2YWwoVg9KRkIKaXSh0mz3NmfurpmYoBBTAXA9qt7VXk0Xy12PoOP40EFuau+ajgALbbhi4uTj3tSG3tVseCjuA==", + "version": "4.14.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.14.0.tgz", + "integrity": "sha512-Fq52EYb0riNHLBTAcL0cun+rRwyZ10S9vKzhGKKgeD+XbwunszSY0rVMco5KbOsTlwovP2rTOkiII/fQ4ih/zQ==", "cpu": [ "arm64" ], @@ -2097,9 +2097,9 @@ ] }, "node_modules/@rollup/rollup-win32-ia32-msvc": { - "version": "4.13.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.13.2.tgz", - "integrity": "sha512-2FSsE9aQ6OWD20E498NYKEQLneShWes0NGMPQwxWOdws35qQXH+FplabOSP5zEe1pVjurSDOGEVCE2agFwSEsw==", + "version": "4.14.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.14.0.tgz", + "integrity": "sha512-e/PBHxPdJ00O9p5Ui43+vixSgVf4NlLsmV6QneGERJ3lnjIua/kim6PRFe3iDueT1rQcgSkYP8ZBBXa/h4iPvw==", "cpu": [ "ia32" ], @@ -2110,9 +2110,9 @@ ] }, "node_modules/@rollup/rollup-win32-x64-msvc": { - "version": "4.13.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.13.2.tgz", - "integrity": "sha512-7h7J2nokcdPePdKykd8wtc8QqqkqxIrUz7MHj6aNr8waBRU//NLDVnNjQnqQO6fqtjrtCdftpbTuOKAyrAQETQ==", + "version": "4.14.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.14.0.tgz", + "integrity": "sha512-aGg7iToJjdklmxlUlJh/PaPNa4PmqHfyRMLunbL3eaMO0gp656+q1zOKkpJ/CVe9CryJv6tAN1HDoR8cNGzkag==", "cpu": [ "x64" ], @@ -2123,68 +2123,47 @@ ] }, "node_modules/@shikijs/core": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/@shikijs/core/-/core-1.2.1.tgz", - "integrity": "sha512-KaIS0H4EQ3KI2d++TjYqRNgwp8E3M/68e9veR4QtInzA7kKFgcjeiJqb80fuXW+blDy5fmd11PN9g9soz/3ANQ==", + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/@shikijs/core/-/core-1.2.4.tgz", + "integrity": "sha512-ClaUWpt8oTzjcF0MM1P81AeWyzc1sNSJlAjMG80CbwqbFqXSNz+NpQVUC0icobt3sZn43Sn27M4pHD/Jmp3zHw==", "dev": true }, "node_modules/@shikijs/transformers": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/@shikijs/transformers/-/transformers-1.2.1.tgz", - "integrity": "sha512-H7cVtrdv6BW2kx83t2IQgP5ri1IA50mE3QnzgJ0AvOKCGtCEieXu0JIP3245cgjNLrL+LBwb8DtTXdky1iQL9Q==", + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/@shikijs/transformers/-/transformers-1.2.4.tgz", + "integrity": "sha512-ysGkpsHxRxLmz8nGKeFdV+gKj1NXt+88sM/34kfKVWTWIXg5gsFOJxJBbG7k+fUR5JlD6sNh65W9qPXrbVE1wQ==", "dev": true, "dependencies": { - "shiki": "1.2.1" + "shiki": "1.2.4" } }, "node_modules/@shikijs/twoslash": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/@shikijs/twoslash/-/twoslash-1.2.1.tgz", - "integrity": "sha512-QyrBtKhIXjByPbC2dS/8LAqCLfoVmZHgNqc4eqLVIkOxZp6AAkAak1A3E+oiMP9vLaMY9qQI1pnV45c8FB5PRw==", + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/@shikijs/twoslash/-/twoslash-1.2.4.tgz", + "integrity": "sha512-4F2gNlCFN9HY0jV3J/IBfqkI7w2HBwycwUBx9fLYGYxzbfu0gYRJdQYWtvJC/sG2rYTYlJrS5BpWdXYoMHwbXw==", "dev": true, "dependencies": { - "@shikijs/core": "1.2.1", + "@shikijs/core": "1.2.4", "twoslash": "^0.2.5" } }, - "node_modules/@shikijs/twoslash/node_modules/@shikijs/core": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/@shikijs/core/-/core-1.2.1.tgz", - "integrity": "sha512-KaIS0H4EQ3KI2d++TjYqRNgwp8E3M/68e9veR4QtInzA7kKFgcjeiJqb80fuXW+blDy5fmd11PN9g9soz/3ANQ==", - "dev": true - }, "node_modules/@shikijs/vitepress-twoslash": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/@shikijs/vitepress-twoslash/-/vitepress-twoslash-1.2.1.tgz", - "integrity": "sha512-+fY8fa6B2q2AIygdSP2KDayb86wFcWBqMP4nAPdXSOb3ZbnYjrE3J1G1xZwTBFLgLAWbR545tu8aIy1JETYWuA==", + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/@shikijs/vitepress-twoslash/-/vitepress-twoslash-1.2.4.tgz", + "integrity": "sha512-LI8Q8A08dRQpEEiespjTBGcT2i+0Uf3Z03FE+okBlObd4Wf+Sq/YNiLR6ga/7V2z/vhktRwcb/2O3+UZMRiEKg==", "dev": true, "dependencies": { - "@shikijs/twoslash": "1.2.1", + "@shikijs/twoslash": "1.2.4", "floating-vue": "^5.2.2", "mdast-util-from-markdown": "^2.0.0", "mdast-util-gfm": "^3.0.0", "mdast-util-to-hast": "^13.1.0", - "shiki": "1.2.1", + "shiki": "1.2.4", "twoslash": "^0.2.5", "twoslash-vue": "^0.2.5", "vue": "^3.4.21" } }, - "node_modules/@shikijs/vitepress-twoslash/node_modules/@shikijs/core": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/@shikijs/core/-/core-1.2.1.tgz", - "integrity": "sha512-KaIS0H4EQ3KI2d++TjYqRNgwp8E3M/68e9veR4QtInzA7kKFgcjeiJqb80fuXW+blDy5fmd11PN9g9soz/3ANQ==", - "dev": true - }, - "node_modules/@shikijs/vitepress-twoslash/node_modules/shiki": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/shiki/-/shiki-1.2.1.tgz", - "integrity": "sha512-u+XW6o0vCkUNlneZb914dLO+AayEIwK5tI62WeS//R5HIXBFiYaj/Hc5xcq27Yh83Grr4JbNtUBV8W6zyK4hWg==", - "dev": true, - "dependencies": { - "@shikijs/core": "1.2.1" - } - }, "node_modules/@types/buble": { "version": "0.19.2", "resolved": "https://registry.npmjs.org/@types/buble/-/buble-0.19.2.tgz", @@ -2213,9 +2192,9 @@ } }, "node_modules/@types/eslint": { - "version": "8.56.6", - "resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-8.56.6.tgz", - "integrity": "sha512-ymwc+qb1XkjT/gfoQwxIeHZ6ixH23A+tCT2ADSA/DPVKzAjwYkTXBMCQ/f6fe4wEa85Lhp26VPeUxI7wMhAi7A==", + "version": "8.56.7", + "resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-8.56.7.tgz", + "integrity": "sha512-SjDvI/x3zsZnOkYZ3lCt9lOZWZLB2jIlNKz+LBgCtDurK0JZcwucxYHn1w2BJkD34dgX9Tjnak0txtq4WTggEA==", "dev": true, "dependencies": { "@types/estree": "*", @@ -2407,16 +2386,16 @@ } }, "node_modules/@typescript-eslint/eslint-plugin": { - "version": "7.4.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-7.4.0.tgz", - "integrity": "sha512-yHMQ/oFaM7HZdVrVm/M2WHaNPgyuJH4WelkSVEWSSsir34kxW2kDJCxlXRhhGWEsMN0WAW/vLpKfKVcm8k+MPw==", + "version": "7.5.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-7.5.0.tgz", + "integrity": "sha512-HpqNTH8Du34nLxbKgVMGljZMG0rJd2O9ecvr2QLYp+7512ty1j42KnsFwspPXg1Vh8an9YImf6CokUBltisZFQ==", "dev": true, "dependencies": { "@eslint-community/regexpp": "^4.5.1", - "@typescript-eslint/scope-manager": "7.4.0", - "@typescript-eslint/type-utils": "7.4.0", - "@typescript-eslint/utils": "7.4.0", - "@typescript-eslint/visitor-keys": "7.4.0", + "@typescript-eslint/scope-manager": "7.5.0", + "@typescript-eslint/type-utils": "7.5.0", + "@typescript-eslint/utils": "7.5.0", + "@typescript-eslint/visitor-keys": "7.5.0", "debug": "^4.3.4", "graphemer": "^1.4.0", "ignore": "^5.2.4", @@ -2442,15 +2421,15 @@ } }, "node_modules/@typescript-eslint/parser": { - "version": "7.4.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-7.4.0.tgz", - "integrity": "sha512-ZvKHxHLusweEUVwrGRXXUVzFgnWhigo4JurEj0dGF1tbcGh6buL+ejDdjxOQxv6ytcY1uhun1p2sm8iWStlgLQ==", + "version": "7.5.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-7.5.0.tgz", + "integrity": "sha512-cj+XGhNujfD2/wzR1tabNsidnYRaFfEkcULdcIyVBYcXjBvBKOes+mpMBP7hMpOyk+gBcfXsrg4NBGAStQyxjQ==", "dev": true, "dependencies": { - "@typescript-eslint/scope-manager": "7.4.0", - "@typescript-eslint/types": "7.4.0", - "@typescript-eslint/typescript-estree": "7.4.0", - "@typescript-eslint/visitor-keys": "7.4.0", + "@typescript-eslint/scope-manager": "7.5.0", + "@typescript-eslint/types": "7.5.0", + "@typescript-eslint/typescript-estree": "7.5.0", + "@typescript-eslint/visitor-keys": "7.5.0", "debug": "^4.3.4" }, "engines": { @@ -2470,13 +2449,13 @@ } }, "node_modules/@typescript-eslint/scope-manager": { - "version": "7.4.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-7.4.0.tgz", - "integrity": "sha512-68VqENG5HK27ypafqLVs8qO+RkNc7TezCduYrx8YJpXq2QGZ30vmNZGJJJC48+MVn4G2dCV8m5ZTVnzRexTVtw==", + "version": "7.5.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-7.5.0.tgz", + "integrity": "sha512-Z1r7uJY0MDeUlql9XJ6kRVgk/sP11sr3HKXn268HZyqL7i4cEfrdFuSSY/0tUqT37l5zT0tJOsuDP16kio85iA==", "dev": true, "dependencies": { - "@typescript-eslint/types": "7.4.0", - "@typescript-eslint/visitor-keys": "7.4.0" + "@typescript-eslint/types": "7.5.0", + "@typescript-eslint/visitor-keys": "7.5.0" }, "engines": { "node": "^18.18.0 || >=20.0.0" @@ -2487,13 +2466,13 @@ } }, "node_modules/@typescript-eslint/type-utils": { - "version": "7.4.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-7.4.0.tgz", - "integrity": "sha512-247ETeHgr9WTRMqHbbQdzwzhuyaJ8dPTuyuUEMANqzMRB1rj/9qFIuIXK7l0FX9i9FXbHeBQl/4uz6mYuCE7Aw==", + "version": "7.5.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-7.5.0.tgz", + "integrity": "sha512-A021Rj33+G8mx2Dqh0nMO9GyjjIBK3MqgVgZ2qlKf6CJy51wY/lkkFqq3TqqnH34XyAHUkq27IjlUkWlQRpLHw==", "dev": true, "dependencies": { - "@typescript-eslint/typescript-estree": "7.4.0", - "@typescript-eslint/utils": "7.4.0", + "@typescript-eslint/typescript-estree": "7.5.0", + "@typescript-eslint/utils": "7.5.0", "debug": "^4.3.4", "ts-api-utils": "^1.0.1" }, @@ -2514,9 +2493,9 @@ } }, "node_modules/@typescript-eslint/types": { - "version": "7.4.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-7.4.0.tgz", - "integrity": "sha512-mjQopsbffzJskos5B4HmbsadSJQWaRK0UxqQ7GuNA9Ga4bEKeiO6b2DnB6cM6bpc8lemaPseh0H9B/wyg+J7rw==", + "version": "7.5.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-7.5.0.tgz", + "integrity": "sha512-tv5B4IHeAdhR7uS4+bf8Ov3k793VEVHd45viRRkehIUZxm0WF82VPiLgHzA/Xl4TGPg1ZD49vfxBKFPecD5/mg==", "dev": true, "engines": { "node": "^18.18.0 || >=20.0.0" @@ -2527,13 +2506,13 @@ } }, "node_modules/@typescript-eslint/typescript-estree": { - "version": "7.4.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-7.4.0.tgz", - "integrity": "sha512-A99j5AYoME/UBQ1ucEbbMEmGkN7SE0BvZFreSnTd1luq7yulcHdyGamZKizU7canpGDWGJ+Q6ZA9SyQobipePg==", + "version": "7.5.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-7.5.0.tgz", + "integrity": "sha512-YklQQfe0Rv2PZEueLTUffiQGKQneiIEKKnfIqPIOxgM9lKSZFCjT5Ad4VqRKj/U4+kQE3fa8YQpskViL7WjdPQ==", "dev": true, "dependencies": { - "@typescript-eslint/types": "7.4.0", - "@typescript-eslint/visitor-keys": "7.4.0", + "@typescript-eslint/types": "7.5.0", + "@typescript-eslint/visitor-keys": "7.5.0", "debug": "^4.3.4", "globby": "^11.1.0", "is-glob": "^4.0.3", @@ -2555,17 +2534,17 @@ } }, "node_modules/@typescript-eslint/utils": { - "version": "7.4.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-7.4.0.tgz", - "integrity": "sha512-NQt9QLM4Tt8qrlBVY9lkMYzfYtNz8/6qwZg8pI3cMGlPnj6mOpRxxAm7BMJN9K0AiY+1BwJ5lVC650YJqYOuNg==", + "version": "7.5.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-7.5.0.tgz", + "integrity": "sha512-3vZl9u0R+/FLQcpy2EHyRGNqAS/ofJ3Ji8aebilfJe+fobK8+LbIFmrHciLVDxjDoONmufDcnVSF38KwMEOjzw==", "dev": true, "dependencies": { "@eslint-community/eslint-utils": "^4.4.0", "@types/json-schema": "^7.0.12", "@types/semver": "^7.5.0", - "@typescript-eslint/scope-manager": "7.4.0", - "@typescript-eslint/types": "7.4.0", - "@typescript-eslint/typescript-estree": "7.4.0", + "@typescript-eslint/scope-manager": "7.5.0", + "@typescript-eslint/types": "7.5.0", + "@typescript-eslint/typescript-estree": "7.5.0", "semver": "^7.5.4" }, "engines": { @@ -2580,12 +2559,12 @@ } }, "node_modules/@typescript-eslint/visitor-keys": { - "version": "7.4.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-7.4.0.tgz", - "integrity": "sha512-0zkC7YM0iX5Y41homUUeW1CHtZR01K3ybjM1l6QczoMuay0XKtrb93kv95AxUGwdjGr64nNqnOCwmEl616N8CA==", + "version": "7.5.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-7.5.0.tgz", + "integrity": "sha512-mcuHM/QircmA6O7fy6nn2w/3ditQkj+SgtOc8DW3uQ10Yfj42amm2i+6F2K4YAOPNNTmE6iM1ynM6lrSwdendA==", "dev": true, "dependencies": { - "@typescript-eslint/types": "7.4.0", + "@typescript-eslint/types": "7.5.0", "eslint-visitor-keys": "^3.4.1" }, "engines": { @@ -3710,9 +3689,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001600", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001600.tgz", - "integrity": "sha512-+2S9/2JFhYmYaDpZvo0lKkfvuKIglrx68MwOBqMGHhQsNkLjB5xtc/TGoEPs+MxjSyN/72qer2g97nzR641mOQ==", + "version": "1.0.30001605", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001605.tgz", + "integrity": "sha512-nXwGlFWo34uliI9z3n6Qc0wZaf7zaZWA1CPZ169La5mV3I/gem7bst0vr5XQH5TJXZIMfDeZyOrZnSlVzKxxHQ==", "dev": true, "funding": [ { @@ -4549,9 +4528,9 @@ } }, "node_modules/electron-to-chromium": { - "version": "1.4.720", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.720.tgz", - "integrity": "sha512-5zwcKNkOj3GN0jBzpcpGonNPkn667VJpQwRYWdo/TiJEHTQswZyA/vALhZFiAXgL5NuK9UarX1tbdvXu3hG6Yw==", + "version": "1.4.728", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.728.tgz", + "integrity": "sha512-Ud1v7hJJYIqehlUJGqR6PF1Ek8l80zWwxA6nGxigBsGJ9f9M2fciHyrIiNMerSHSH3p+0/Ia7jIlnDkt41h5cw==", "dev": true }, "node_modules/emoji-regex": { @@ -4597,9 +4576,9 @@ } }, "node_modules/es-abstract": { - "version": "1.23.2", - "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.23.2.tgz", - "integrity": "sha512-60s3Xv2T2p1ICykc7c+DNDPLDMm9t4QxCOUU0K9JxiLjM3C1zB9YVdN7tjxrFd4+AkZ8CdX1ovUga4P2+1e+/w==", + "version": "1.23.3", + "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.23.3.tgz", + "integrity": "sha512-e+HfNH61Bj1X9/jLc5v1owaLYuHdeHHSQlkhCBiTK8rBvKaULl/beGMxwrMXjpYrv4pz22BlY570vVePA2ho4A==", "dev": true, "dependencies": { "array-buffer-byte-length": "^1.0.1", @@ -4641,11 +4620,11 @@ "safe-regex-test": "^1.0.3", "string.prototype.trim": "^1.2.9", "string.prototype.trimend": "^1.0.8", - "string.prototype.trimstart": "^1.0.7", + "string.prototype.trimstart": "^1.0.8", "typed-array-buffer": "^1.0.2", "typed-array-byte-length": "^1.0.1", "typed-array-byte-offset": "^1.0.2", - "typed-array-length": "^1.0.5", + "typed-array-length": "^1.0.6", "unbox-primitive": "^1.0.2", "which-typed-array": "^1.1.15" }, @@ -6312,9 +6291,9 @@ "dev": true }, "node_modules/inquirer": { - "version": "9.2.16", - "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-9.2.16.tgz", - "integrity": "sha512-qzgbB+yNjgSzk2omeqMDtO9IgJet/UL67luT1MaaggRpGK73DBQct5Q4pipwFQcIKK1GbMODYd4UfsRCkSP1DA==", + "version": "9.2.17", + "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-9.2.17.tgz", + "integrity": "sha512-Vr3Ia2ud5sGnioURkE69endl4SkeJcMzTF6SosKcX5GALJfId7C+JvO5ZZb6y1LOXnEofCPbwzoQ1q0e8Gaduw==", "dev": true, "dependencies": { "@ljharb/through": "^2.3.13", @@ -7438,9 +7417,9 @@ } }, "node_modules/magic-string": { - "version": "0.30.8", - "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.8.tgz", - "integrity": "sha512-ISQTe55T2ao7XtlAStud6qwYPZjE4GK1S/BeVPus4jrq6JuOnQ00YKQC581RWhR122W7msZV263KzVeLoqidyQ==", + "version": "0.30.9", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.9.tgz", + "integrity": "sha512-S1+hd+dIrC8EZqKyT9DstTH/0Z+f76kmmvZnkfQVmOpDEF9iVgdYif3Q/pIWHmCoo59bQVGW0kVL3e2nl+9+Sw==", "dev": true, "dependencies": { "@jridgewell/sourcemap-codec": "^1.4.15" @@ -10130,9 +10109,9 @@ } }, "node_modules/rollup": { - "version": "4.13.2", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.13.2.tgz", - "integrity": "sha512-MIlLgsdMprDBXC+4hsPgzWUasLO9CE4zOkj/u6j+Z6j5A4zRY+CtiXAdJyPtgCsc42g658Aeh1DlrdVEJhsL2g==", + "version": "4.14.0", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.14.0.tgz", + "integrity": "sha512-Qe7w62TyawbDzB4yt32R0+AbIo6m1/sqO7UPzFS8Z/ksL5mrfhA0v4CavfdmFav3D+ub4QeAgsGEe84DoWe/nQ==", "dev": true, "dependencies": { "@types/estree": "1.0.5" @@ -10145,21 +10124,21 @@ "npm": ">=8.0.0" }, "optionalDependencies": { - "@rollup/rollup-android-arm-eabi": "4.13.2", - "@rollup/rollup-android-arm64": "4.13.2", - "@rollup/rollup-darwin-arm64": "4.13.2", - "@rollup/rollup-darwin-x64": "4.13.2", - "@rollup/rollup-linux-arm-gnueabihf": "4.13.2", - "@rollup/rollup-linux-arm64-gnu": "4.13.2", - "@rollup/rollup-linux-arm64-musl": "4.13.2", - "@rollup/rollup-linux-powerpc64le-gnu": "4.13.2", - "@rollup/rollup-linux-riscv64-gnu": "4.13.2", - "@rollup/rollup-linux-s390x-gnu": "4.13.2", - "@rollup/rollup-linux-x64-gnu": "4.13.2", - "@rollup/rollup-linux-x64-musl": "4.13.2", - "@rollup/rollup-win32-arm64-msvc": "4.13.2", - "@rollup/rollup-win32-ia32-msvc": "4.13.2", - "@rollup/rollup-win32-x64-msvc": "4.13.2", + "@rollup/rollup-android-arm-eabi": "4.14.0", + "@rollup/rollup-android-arm64": "4.14.0", + "@rollup/rollup-darwin-arm64": "4.14.0", + "@rollup/rollup-darwin-x64": "4.14.0", + "@rollup/rollup-linux-arm-gnueabihf": "4.14.0", + "@rollup/rollup-linux-arm64-gnu": "4.14.0", + "@rollup/rollup-linux-arm64-musl": "4.14.0", + "@rollup/rollup-linux-powerpc64le-gnu": "4.14.0", + "@rollup/rollup-linux-riscv64-gnu": "4.14.0", + "@rollup/rollup-linux-s390x-gnu": "4.14.0", + "@rollup/rollup-linux-x64-gnu": "4.14.0", + "@rollup/rollup-linux-x64-musl": "4.14.0", + "@rollup/rollup-win32-arm64-msvc": "4.14.0", + "@rollup/rollup-win32-ia32-msvc": "4.14.0", + "@rollup/rollup-win32-x64-msvc": "4.14.0", "fsevents": "~2.3.2" } }, @@ -10541,12 +10520,12 @@ } }, "node_modules/shiki": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/shiki/-/shiki-1.2.1.tgz", - "integrity": "sha512-u+XW6o0vCkUNlneZb914dLO+AayEIwK5tI62WeS//R5HIXBFiYaj/Hc5xcq27Yh83Grr4JbNtUBV8W6zyK4hWg==", + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/shiki/-/shiki-1.2.4.tgz", + "integrity": "sha512-Q9n9jKiOjJCRPztA9POn3/uZXNySHDNKAsPNpmtHDcFyi6ZQhx5vQKZW3Nhrwn8TWW3RudSRk66zqY603EZDeg==", "dev": true, "dependencies": { - "@shikijs/core": "1.2.1" + "@shikijs/core": "1.2.4" } }, "node_modules/shx": { @@ -10624,9 +10603,9 @@ } }, "node_modules/smob": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/smob/-/smob-1.4.1.tgz", - "integrity": "sha512-9LK+E7Hv5R9u4g4C3p+jjLstaLe11MDsL21UpYaCNmapvMkYhqCV4A/f/3gyH8QjMyh6l68q9xC85vihY9ahMQ==", + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/smob/-/smob-1.5.0.tgz", + "integrity": "sha512-g6T+p7QO8npa+/hNx9ohv1E5pVCmWrVCUzUXJyLdMmftX6ER0oiWY/w9knEonLpnOp6b6FenKnMfR8gqwWdwig==", "dev": true }, "node_modules/source-map": { @@ -11067,9 +11046,9 @@ "dev": true }, "node_modules/terser": { - "version": "5.30.0", - "resolved": "https://registry.npmjs.org/terser/-/terser-5.30.0.tgz", - "integrity": "sha512-Y/SblUl5kEyEFzhMAQdsxVHh+utAxd4IuRNJzKywY/4uzSogh3G219jqbDDxYu4MXO9CzY3tSEqmZvW6AoEDJw==", + "version": "5.30.3", + "resolved": "https://registry.npmjs.org/terser/-/terser-5.30.3.tgz", + "integrity": "sha512-STdUgOUx8rLbMGO9IOwHLpCqolkDITFFQSMYYwKE1N2lY6MVSaeoi10z/EhWxRc6ybqoVmKSkhKYH/XUpl7vSA==", "dev": true, "dependencies": { "@jridgewell/source-map": "^0.3.3", @@ -11422,9 +11401,9 @@ } }, "node_modules/typescript": { - "version": "5.4.3", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.4.3.tgz", - "integrity": "sha512-KrPd3PKaCLr78MalgiwJnA25Nm8HAmdwN3mYUYZgG/wizIo9EainNVQI9/yDavtVFRN2h3k8uf3GLHuhDMgEHg==", + "version": "5.4.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.4.4.tgz", + "integrity": "sha512-dGE2Vv8cpVvw28v8HCPqyb08EzbBURxDpuhJvTrusShUfGnhHBafDsLdS1EhhxyL6BJQE+2cT3dDPAv+MQ6oLw==", "dev": true, "bin": { "tsc": "bin/tsc", @@ -11682,13 +11661,13 @@ } }, "node_modules/vite": { - "version": "5.2.6", - "resolved": "https://registry.npmjs.org/vite/-/vite-5.2.6.tgz", - "integrity": "sha512-FPtnxFlSIKYjZ2eosBQamz4CbyrTizbZ3hnGJlh/wMtCrlp1Hah6AzBLjGI5I2urTfNnpovpHdrL6YRuBOPnCA==", + "version": "5.2.8", + "resolved": "https://registry.npmjs.org/vite/-/vite-5.2.8.tgz", + "integrity": "sha512-OyZR+c1CE8yeHw5V5t59aXsUPPVTHMDjEZz8MgguLL/Q7NblxhZUlTu9xSPqlsUO/y+X7dlU05jdhvyycD55DA==", "dev": true, "dependencies": { "esbuild": "^0.20.1", - "postcss": "^8.4.36", + "postcss": "^8.4.38", "rollup": "^4.13.0" }, "bin": { @@ -11737,9 +11716,9 @@ } }, "node_modules/vitepress": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/vitepress/-/vitepress-1.0.1.tgz", - "integrity": "sha512-eNr5pOBppYUUjEhv8S0S2t9Tv95LQ6mMeHj6ivaGwfHxpov70Vduuwl/QQMDRznKDSaP0WKV7a82Pb4JVOaqEw==", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/vitepress/-/vitepress-1.0.2.tgz", + "integrity": "sha512-bEj9yTEdWyewJFOhEREZF+mXuAgOq27etuJZT6DZSp+J3XpQstXMJc5piSVwhZBtuj8OfA0iXy+jdP1c71KMYQ==", "dev": true, "dependencies": { "@docsearch/css": "^3.6.0", diff --git a/package.json b/package.json index 32f3b187e..856bbb5e5 100644 --- a/package.json +++ b/package.json @@ -117,7 +117,7 @@ "@codemirror/language": "^6.10.1", "@codemirror/search": "^6.5.6", "@codemirror/state": "^6.4.1", - "@codemirror/view": "^6.26.0", + "@codemirror/view": "^6.26.1", "@jridgewell/sourcemap-codec": "^1.4.15", "@mermaid-js/mermaid-cli": "^10.8.0", "@napi-rs/cli": "^2.18.0", @@ -130,14 +130,14 @@ "@rollup/plugin-terser": "^0.4.4", "@rollup/plugin-typescript": "^11.1.6", "@rollup/pluginutils": "^5.1.0", - "@shikijs/vitepress-twoslash": "^1.2.1", - "@types/eslint": "^8.56.6", + "@shikijs/vitepress-twoslash": "^1.2.3", + "@types/eslint": "^8.56.7", "@types/inquirer": "^9.0.7", "@types/mocha": "^10.0.6", "@types/node": "~18.18.14", "@types/yargs-parser": "^21.0.3", - "@typescript-eslint/eslint-plugin": "^7.4.0", - "@typescript-eslint/parser": "^7.4.0", + "@typescript-eslint/eslint-plugin": "^7.5.0", + "@typescript-eslint/parser": "^7.5.0", "@vue/eslint-config-prettier": "^9.0.0", "@vue/eslint-config-typescript": "^13.0.0", "acorn": "^8.11.3", @@ -162,19 +162,19 @@ "fs-extra": "^11.2.0", "github-api": "^3.4.0", "husky": "^9.0.11", - "inquirer": "^9.2.16", + "inquirer": "^9.2.17", "is-reference": "^3.0.2", "lint-staged": "^15.2.2", "locate-character": "^3.0.0", "magic-string": "^0.30.8", - "mocha": "^10.3.0", + "mocha": "^10.4.0", "nyc": "^15.1.0", "pinia": "^2.1.7", "prettier": "^3.2.5", "pretty-bytes": "^6.1.1", "pretty-ms": "^9.0.0", "requirejs": "^2.3.6", - "rollup": "^4.13.0", + "rollup": "^4.13.2", "rollup-plugin-license": "^3.3.1", "rollup-plugin-string": "^3.0.0", "semver": "^7.6.0", @@ -183,11 +183,11 @@ "source-map": "^0.7.4", "source-map-support": "^0.5.21", "systemjs": "^6.14.3", - "terser": "^5.29.2", + "terser": "^5.30.1", "tslib": "^2.6.2", "typescript": "^5.4.3", - "vite": "^5.2.6", - "vitepress": "^1.0.1", + "vite": "^5.2.7", + "vitepress": "^1.0.2", "vue": "^3.4.21", "wasm-pack": "^0.12.1", "weak-napi": "^2.0.2", diff --git a/rust/Cargo.lock b/rust/Cargo.lock index b91d88948..e16163536 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -284,15 +284,16 @@ checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" [[package]] name = "hstr" -version = "0.2.7" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17fafeca18cf0927e23ea44d7a5189c10536279dfe9094e0dfa953053fbb5377" +checksum = "b0f5356d62012374578cd3a5c013d6586de3efbca3b53379fc1edfbb95c9db14" dependencies = [ + "hashbrown", "new_debug_unreachable", "once_cell", "phf", "rustc-hash", - "smallvec", + "triomphe", ] [[package]] @@ -629,9 +630,9 @@ dependencies = [ [[package]] name = "pin-project-lite" -version = "0.2.13" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" +checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" [[package]] name = "proc-macro2" @@ -850,9 +851,9 @@ dependencies = [ [[package]] name = "sourcemap" -version = "8.0.0" +version = "8.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf0b8c0d9d32f81aa0ab2b68ab634d9bbce287423606656fddb456ac8601aec3" +checksum = "208d40b9e8cad9f93613778ea295ed8f3c2b1824217c6cfc7219d3f6f45b96d4" dependencies = [ "base64-simd", "bitvec", @@ -867,6 +868,12 @@ dependencies = [ "url", ] +[[package]] +name = "stable_deref_trait" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" + [[package]] name = "stacker" version = "0.1.15" @@ -900,9 +907,9 @@ dependencies = [ [[package]] name = "swc_atoms" -version = "0.6.5" +version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d538eaaa6f085161d088a04cf0a3a5a52c5a7f2b3bd9b83f73f058b0ed357c0" +checksum = "04d9d1941a7d24fc503efa29c53f88dd61e6a15cc371947a75cca3b48d564b5b" dependencies = [ "hstr", "once_cell", @@ -912,9 +919,9 @@ dependencies = [ [[package]] name = "swc_cached" -version = "0.3.19" +version = "0.3.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "630c761c74ac8021490b78578cc2223aa4a568241e26505c27bf0e4fd4ad8ec2" +checksum = "83406221c501860fce9c27444f44125eafe9e598b8b81be7563d7036784cd05c" dependencies = [ "ahash", "anyhow", @@ -926,9 +933,9 @@ dependencies = [ [[package]] name = "swc_common" -version = "0.33.21" +version = "0.33.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89598a0dfe7311750e6fad8464cafcec8ee010c649c2e04531b25e32362fdec7" +checksum = "a8f91d53367db183e55ecaa090c9a2b6e62ddbd1258aa2ac6c6925772eec9e2b" dependencies = [ "ahash", "ast_node", @@ -954,9 +961,9 @@ dependencies = [ [[package]] name = "swc_compiler_base" -version = "0.7.19" +version = "0.7.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66405c58d5241ae020b0522a08bdc284da52b13742a58e3023e09cc2e0fb9e8c" +checksum = "8d7a0a78d52886c01786246fad54aa614cc145154d18607ddda72a180d1cb56c" dependencies = [ "anyhow", "base64", @@ -1004,9 +1011,9 @@ dependencies = [ [[package]] name = "swc_ecma_ast" -version = "0.112.6" +version = "0.112.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70656acd47c91918635f1e8589963428cb3170975b71d786c79fb7a25605f687" +checksum = "6bcd97ee367b48444f90416ea56e71d761600f816bcae9df4f99293d1fa36bd5" dependencies = [ "bitflags 2.5.0", "is-macro", @@ -1017,14 +1024,14 @@ dependencies = [ "string_enum", "swc_atoms", "swc_common", - "unicode-id", + "unicode-id-start", ] [[package]] name = "swc_ecma_codegen" -version = "0.148.13" +version = "0.148.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9ae864cb69934f8753b9cbbad803a0ee1b0759f5b87c219db0a12e8d03fa86a" +checksum = "a1e318142ff1297c1d3d8f230b4f3eda8454d1420341fb098a9d9edbc373ef3c" dependencies = [ "memchr", "num-bigint", @@ -1053,9 +1060,9 @@ dependencies = [ [[package]] name = "swc_ecma_minifier" -version = "0.192.19" +version = "0.192.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3acd953ba8fd935428003d015cc119ddb31a510537bf2ef06294c52bacffa67" +checksum = "2025b1b4fb4bff8502378ecf37fe63726e6dfbd0ee3429abcda341edebcfb06a" dependencies = [ "arrayvec", "indexmap", @@ -1086,9 +1093,9 @@ dependencies = [ [[package]] name = "swc_ecma_parser" -version = "0.143.11" +version = "0.143.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "192482230498a24c2e7c9c580ba334a80dc43b3899366e54aa548f8d7b0f12cd" +checksum = "b6fc7ab256f83a9491b37a510dd1cba9d81bb306faf3cff1dacdbc897fa4869f" dependencies = [ "either", "new_debug_unreachable", @@ -1108,9 +1115,9 @@ dependencies = [ [[package]] name = "swc_ecma_transforms_base" -version = "0.137.16" +version = "0.137.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69e9a23d6af398b6efd17bbdad2cfa580102f6c560611f85c63b48f76ffe8f0c" +checksum = "66b5818db80d8d9fcbc1d3453f1d246a7f56ea708ba136717a84a8caf0977afd" dependencies = [ "better_scoped_tls", "bitflags 2.5.0", @@ -1143,9 +1150,9 @@ dependencies = [ [[package]] name = "swc_ecma_transforms_optimization" -version = "0.198.17" +version = "0.198.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86789174146707d78c086cee25868624bdfef924bb535ea3fc42f53fa426d4c0" +checksum = "aa1a53995a9199fa11343506646d0cdce69e612a5dad47897169cf4fdf8b7fcb" dependencies = [ "dashmap", "indexmap", @@ -1184,9 +1191,9 @@ dependencies = [ [[package]] name = "swc_ecma_utils" -version = "0.127.15" +version = "0.127.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68f83263f449935d33f86b8ab17c88a13bc175a87a742752ebcc94be2006ab25" +checksum = "b693d3fd413b76be123d2ce899a9788db8f85ca6127a1b1d743ed9cb8a68fdcc" dependencies = [ "indexmap", "num_cpus", @@ -1259,9 +1266,9 @@ dependencies = [ [[package]] name = "swc_visit" -version = "0.5.10" +version = "0.5.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f5b3e8d1269a7cb95358fed3412645d9c15aa0eb1f4ca003a25a38ef2f30f1b" +checksum = "c6af31bfc7b5b7405eb0cfb5158a40f12e827af9db74ce93b0cf8b838ee1c100" dependencies = [ "either", "swc_visit_macros", @@ -1282,9 +1289,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.55" +version = "2.0.58" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "002a1b3dbf967edfafc32655d0f377ab0bb7b994aa1d32c8cc7e9b8bf3ebb8f0" +checksum = "44cfb93f38070beee36b3fef7d4f5a16f27751d94b187b666a5cc5e9b0d30687" dependencies = [ "proc-macro2", "quote", @@ -1343,6 +1350,16 @@ dependencies = [ "once_cell", ] +[[package]] +name = "triomphe" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "859eb650cfee7434994602c3a68b25d77ad9e68c8a6cd491616ef86661382eb3" +dependencies = [ + "serde", + "stable_deref_trait", +] + [[package]] name = "typed-arena" version = "2.0.2" diff --git a/rust/parse_ast/Cargo.toml b/rust/parse_ast/Cargo.toml index 623e061ae..1312be487 100644 --- a/rust/parse_ast/Cargo.toml +++ b/rust/parse_ast/Cargo.toml @@ -7,9 +7,9 @@ edition = "2021" [dependencies] anyhow = "1.0.81" -swc_atoms = "0.6.5" -swc_compiler_base = "0.7.19" -swc_common = { version = "0.33.21", features = ["ahash", "parking_lot"] } -swc_ecma_ast = "0.112.6" -swc_ecma_parser = "0.143.11" +swc_atoms = "0.6.6" +swc_compiler_base = "0.7.20" +swc_common = { version = "0.33.22", features = ["ahash", "parking_lot"] } +swc_ecma_ast = "0.112.7" +swc_ecma_parser = "0.143.12" parking_lot = "0.12.1" From 1b85663fde96d84fceaa2360dba246d3cb92789b Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 5 Apr 2024 02:56:16 +0000 Subject: [PATCH 07/45] chore(deps): lock file maintenance (#5453) chore(deps): lock file maintenance minor/patch updates Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> From edc15046604580beba92072da905d2a0d4c16a24 Mon Sep 17 00:00:00 2001 From: Lukas Taegert-Atkinson Date: Sun, 7 Apr 2024 09:21:53 +0200 Subject: [PATCH 08/45] Remove inlining logic in AST (de-)serializer (#5455) * Do not inline attributes to reduce complexity * If the reference of a list is 0, treat it as an empty list * Extend zero logic to stateful lists * Inline reference position update into string conversions * Unify how flags are added * Lint imports --- rust/parse_ast/src/convert_ast/converter.rs | 622 +++++++++++------- .../convert_ast/converter/ast_constants.rs | 388 ++++++----- rust/parse_ast/src/error_emit.rs | 15 +- rust/parse_ast/src/lib.rs | 20 +- scripts/ast-types.js | 84 +-- scripts/generate-buffer-parsers.js | 146 ++-- scripts/generate-buffer-to-ast.js | 132 ++-- scripts/generate-rust-constants.js | 10 +- src/ast/bufferParsers.ts | 257 ++++---- src/ast/nodes/Program.ts | 2 +- src/ast/nodes/shared/FunctionBase.ts | 8 +- src/ast/nodes/shared/Node.ts | 4 +- src/utils/astConverterHelpers.ts | 7 +- src/utils/bufferToAst.ts | 204 +++--- 14 files changed, 1015 insertions(+), 884 deletions(-) diff --git a/rust/parse_ast/src/convert_ast/converter.rs b/rust/parse_ast/src/convert_ast/converter.rs index b57c34c7c..739f2d823 100644 --- a/rust/parse_ast/src/convert_ast/converter.rs +++ b/rust/parse_ast/src/convert_ast/converter.rs @@ -88,7 +88,7 @@ impl<'a> AstConverter<'a> { // start self .buffer - .extend_from_slice(&(self.index_converter.convert(start, false)).to_ne_bytes()); + .extend_from_slice(&self.index_converter.convert(start, false).to_ne_bytes()); // end let end_position = self.buffer.len(); // reserved bytes @@ -97,19 +97,28 @@ impl<'a> AstConverter<'a> { } 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()); + self.buffer[end_position..end_position + 4].copy_from_slice( + &self + .index_converter + .convert(span.hi.0 - 1, false) + .to_ne_bytes(), + ); } 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()); + .copy_from_slice(&self.index_converter.convert(end, false).to_ne_bytes()); } - fn convert_item_list(&mut self, item_list: &[T], convert_item: F) + fn convert_item_list(&mut self, item_list: &[T], reference_position: usize, convert_item: F) where F: Fn(&mut AstConverter, &T) -> bool, { + // for an empty list, we leave the referenced position at zero + if item_list.is_empty() { + return; + } + self.update_reference_position(reference_position); // store number of items in first position self .buffer @@ -133,10 +142,16 @@ impl<'a> AstConverter<'a> { &mut self, item_list: &[T], state: &mut S, + reference_position: usize, convert_item: F, ) where F: Fn(&mut AstConverter, &T, &mut S) -> bool, { + // for an empty list, we leave the referenced position at zero + if item_list.is_empty() { + return; + } + self.update_reference_position(reference_position); // store number of items in first position self .buffer @@ -157,7 +172,8 @@ impl<'a> AstConverter<'a> { } // TODO SWC deduplicate strings and see if we can easily compare atoms - fn convert_string(&mut self, string: &str) { + fn convert_string(&mut self, string: &str, reference_position: usize) { + self.update_reference_position(reference_position); convert_string(&mut self.buffer, string); } @@ -264,7 +280,7 @@ impl<'a> AstConverter<'a> { } Decl::Fn(function_declaration) => self.convert_function( &function_declaration.function, - &TYPE_FUNCTION_DECLARATION_INLINED_ANNOTATIONS, + &TYPE_FUNCTION_DECLARATION, Some(&function_declaration.ident), ), Decl::Class(class_declaration) => self.convert_class_declaration(class_declaration), @@ -383,7 +399,7 @@ impl<'a> AstConverter<'a> { Expr::Fn(function_expression) => { self.convert_function( &function_expression.function, - &TYPE_FUNCTION_EXPRESSION_INLINED_ANNOTATIONS, + &TYPE_FUNCTION_EXPRESSION, function_expression.ident.as_ref(), ); None @@ -580,19 +596,23 @@ impl<'a> AstConverter<'a> { ); } - fn store_import_attributes(&mut self, with: &Option>) { + fn store_import_attributes(&mut self, with: &Option>, reference_position: usize) { match with { Some(ref with) => { - self.convert_item_list(&with.props, |ast_converter, prop| match prop { - PropOrSpread::Prop(prop) => match &**prop { - Prop::KeyValue(key_value_property) => { - ast_converter.convert_import_attribute(key_value_property); - true - } - _ => panic!("Non key-value property in import declaration attributes"), + 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.convert_import_attribute(key_value_property); + true + } + _ => panic!("Non key-value property in import declaration attributes"), + }, + PropOrSpread::Spread(_) => panic!("Spread in import declaration attributes"), }, - PropOrSpread::Spread(_) => panic!("Spread in import declaration attributes"), - }); + ); } None => self.buffer.resize(self.buffer.len() + 4, 0), } @@ -1012,7 +1032,7 @@ impl<'a> AstConverter<'a> { // === nodes fn convert_array_literal(&mut self, array_literal: &ArrayLit) { let end_position = self.add_type_and_start( - &TYPE_ARRAY_EXPRESSION_INLINED_ELEMENTS, + &TYPE_ARRAY_EXPRESSION, &array_literal.span, ARRAY_EXPRESSION_RESERVED_BYTES, false, @@ -1020,6 +1040,7 @@ impl<'a> AstConverter<'a> { // 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); @@ -1034,7 +1055,7 @@ impl<'a> AstConverter<'a> { fn convert_array_pattern(&mut self, array_pattern: &ArrayPat) { let end_position = self.add_type_and_start( - &TYPE_ARRAY_PATTERN_INLINED_ELEMENTS, + &TYPE_ARRAY_PATTERN, &array_pattern.span, ARRAY_PATTERN_RESERVED_BYTES, false, @@ -1042,6 +1063,7 @@ impl<'a> AstConverter<'a> { // 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); @@ -1056,7 +1078,7 @@ impl<'a> AstConverter<'a> { fn convert_arrow_expression(&mut self, arrow_expression: &ArrowExpr) { let end_position = self.add_type_and_start( - &TYPE_ARROW_FUNCTION_EXPRESSION_INLINED_ANNOTATIONS, + &TYPE_ARROW_FUNCTION_EXPRESSION, &arrow_expression.span, ARROW_FUNCTION_EXPRESSION_RESERVED_BYTES, false, @@ -1065,16 +1087,21 @@ impl<'a> AstConverter<'a> { let annotations = self .index_converter .take_collected_annotations(AnnotationKind::NoSideEffects); - self.convert_item_list(&annotations, |ast_converter, annotation| { - convert_annotation(&mut ast_converter.buffer, annotation); - true - }); + 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 - let mut flags = if arrow_expression.is_async { - ARROW_FUNCTION_EXPRESSION_ASYNC_FLAG - } else { - 0u32 - }; + let mut flags = 0u32; + if arrow_expression.is_async { + flags |= ARROW_FUNCTION_EXPRESSION_ASYNC_FLAG; + } if arrow_expression.is_generator { flags |= ARROW_FUNCTION_EXPRESSION_GENERATOR_FLAG; } @@ -1084,11 +1111,14 @@ impl<'a> AstConverter<'a> { let flags_position = end_position + ARROW_FUNCTION_EXPRESSION_FLAGS_OFFSET; self.buffer[flags_position..flags_position + 4].copy_from_slice(&flags.to_ne_bytes()); // params - self.update_reference_position(end_position + ARROW_FUNCTION_EXPRESSION_PARAMS_OFFSET); - self.convert_item_list(&arrow_expression.params, |ast_converter, param| { - ast_converter.convert_pattern(param); - true - }); + 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 { @@ -1105,12 +1135,13 @@ impl<'a> AstConverter<'a> { fn convert_assignment_expression(&mut self, assignment_expression: &AssignExpr) { let end_position = self.add_type_and_start( - &TYPE_ASSIGNMENT_EXPRESSION_INLINED_LEFT, + &TYPE_ASSIGNMENT_EXPRESSION, &assignment_expression.span, ASSIGNMENT_EXPRESSION_RESERVED_BYTES, false, ); // left + self.update_reference_position(end_position + ASSIGNMENT_EXPRESSION_LEFT_OFFSET); self.convert_pattern_or_expression(&assignment_expression.left); // operator let operator_position = end_position + ASSIGNMENT_EXPRESSION_OPERATOR_OFFSET; @@ -1148,12 +1179,13 @@ impl<'a> AstConverter<'a> { right: &Expr, ) -> u32 { let end_position = self.add_type_and_start( - &TYPE_ASSIGNMENT_PATTERN_INLINED_LEFT, + &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) => { @@ -1171,12 +1203,13 @@ impl<'a> AstConverter<'a> { fn convert_await_expression(&mut self, await_expression: &AwaitExpr) { let end_position = self.add_type_and_start( - &TYPE_AWAIT_EXPRESSION_INLINED_ARGUMENT, + &TYPE_AWAIT_EXPRESSION, &await_expression.span, AWAIT_EXPRESSION_RESERVED_BYTES, false, ); // argument + self.update_reference_position(end_position + AWAIT_EXPRESSION_ARGUMENT_OFFSET); self.convert_expression(&await_expression.arg); // end self.add_end(end_position, &await_expression.span); @@ -1186,15 +1219,16 @@ impl<'a> AstConverter<'a> { let end_position = self.add_type_and_start( match binary_expression.op { BinaryOp::LogicalOr | BinaryOp::LogicalAnd | BinaryOp::NullishCoalescing => { - &TYPE_LOGICAL_EXPRESSION_INLINED_LEFT + &TYPE_LOGICAL_EXPRESSION } - _ => &TYPE_BINARY_EXPRESSION_INLINED_LEFT, + _ => &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; @@ -1236,7 +1270,7 @@ impl<'a> AstConverter<'a> { fn convert_block_statement(&mut self, block_statement: &BlockStmt, check_directive: bool) { let end_position = self.add_type_and_start( - &TYPE_BLOCK_STATEMENT_INLINED_BODY, + &TYPE_BLOCK_STATEMENT, &block_statement.span, BLOCK_STATEMENT_RESERVED_BYTES, false, @@ -1246,6 +1280,7 @@ impl<'a> AstConverter<'a> { self.convert_item_list_with_state( &block_statement.stmts, &mut keep_checking_directives, + end_position + BLOCK_STATEMENT_BODY_OFFSET, |ast_converter, statement, can_be_directive| { if *can_be_directive { if let Stmt::Expr(expression) = statement { @@ -1289,7 +1324,7 @@ impl<'a> AstConverter<'a> { is_chained: bool, ) { let end_position = self.add_type_and_start( - &TYPE_CALL_EXPRESSION_INLINED_ANNOTATIONS, + &TYPE_CALL_EXPRESSION, span, CALL_EXPRESSION_RESERVED_BYTES, false, @@ -1298,15 +1333,20 @@ impl<'a> AstConverter<'a> { let annotations = self .index_converter .take_collected_annotations(AnnotationKind::Pure); - self.convert_item_list(&annotations, |ast_converter, annotation| { - convert_annotation(&mut ast_converter.buffer, annotation); - true - }); + 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 - let flags = if is_optional { - CALL_EXPRESSION_OPTIONAL_FLAG - } else { - 0u32 + let mut flags = 0u32; + if is_optional { + flags |= CALL_EXPRESSION_OPTIONAL_FLAG; }; let flags_position = end_position + CALL_EXPRESSION_FLAGS_OFFSET; self.buffer[flags_position..flags_position + 4].copy_from_slice(&flags.to_ne_bytes()); @@ -1328,11 +1368,14 @@ impl<'a> AstConverter<'a> { StoredCallee::Super(callee_super) => self.convert_super(callee_super), } // arguments - self.update_reference_position(end_position + CALL_EXPRESSION_ARGUMENTS_OFFSET); - self.convert_item_list(arguments, |ast_converter, argument| { - ast_converter.convert_expression_or_spread(argument); - true - }); + 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); } @@ -1368,12 +1411,13 @@ impl<'a> AstConverter<'a> { ); } else { let end_position = self.add_type_and_start( - &TYPE_CHAIN_EXPRESSION_INLINED_EXPRESSION, + &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, @@ -1384,20 +1428,21 @@ impl<'a> AstConverter<'a> { } fn convert_class_body(&mut self, class_members: &[ClassMember], start: u32, end: u32) { - let end_position = self.add_type_and_explicit_start( - &TYPE_CLASS_BODY_INLINED_BODY, - start, - CLASS_BODY_RESERVED_BYTES, - ); + 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, |ast_converter, class_member| { - ast_converter.convert_class_member(class_member); - true - }); + 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); } @@ -1433,12 +1478,13 @@ impl<'a> AstConverter<'a> { fn convert_conditional_expression(&mut self, conditional_expression: &CondExpr) { let end_position = self.add_type_and_start( - &TYPE_CONDITIONAL_EXPRESSION_INLINED_TEST, + &TYPE_CONDITIONAL_EXPRESSION, &conditional_expression.span, CONDITIONAL_EXPRESSION_RESERVED_BYTES, false, ); // test + self.update_reference_position(end_position + CONDITIONAL_EXPRESSION_TEST_OFFSET); self.convert_expression(&conditional_expression.test); // consequent self.update_reference_position(end_position + CONDITIONAL_EXPRESSION_CONSEQUENT_OFFSET); @@ -1478,13 +1524,13 @@ impl<'a> AstConverter<'a> { fn convert_directive(&mut self, expression_statement: &ExprStmt, directive: &JsWord) { let end_position = self.add_type_and_start( - &TYPE_DIRECTIVE_INLINED_DIRECTIVE, + &TYPE_DIRECTIVE, &expression_statement.span, DIRECTIVE_RESERVED_BYTES, false, ); // directive - self.convert_string(directive); + self.convert_string(directive, end_position + DIRECTIVE_DIRECTIVE_OFFSET); // expression self.update_reference_position(end_position + DIRECTIVE_EXPRESSION_OFFSET); self.convert_expression(&expression_statement.expr); @@ -1494,12 +1540,13 @@ impl<'a> AstConverter<'a> { fn convert_do_while_statement(&mut self, do_while_statement: &DoWhileStmt) { let end_position = self.add_type_and_start( - &TYPE_DO_WHILE_STATEMENT_INLINED_BODY, + &TYPE_DO_WHILE_STATEMENT, &do_while_statement.span, DO_WHILE_STATEMENT_RESERVED_BYTES, false, ); // body + self.update_reference_position(end_position + DO_WHILE_STATEMENT_BODY_OFFSET); self.convert_statement(&do_while_statement.body); // test self.update_reference_position(end_position + DO_WHILE_STATEMENT_TEST_OFFSET); @@ -1540,8 +1587,10 @@ impl<'a> AstConverter<'a> { self.update_reference_position(end_position + EXPORT_ALL_DECLARATION_SOURCE_OFFSET); self.convert_literal_string(source); // attributes - self.update_reference_position(end_position + EXPORT_ALL_DECLARATION_ATTRIBUTES_OFFSET); - self.store_import_attributes(attributes); + self.store_import_attributes( + attributes, + end_position + EXPORT_ALL_DECLARATION_ATTRIBUTES_OFFSET, + ); // end self.add_end(end_position, span); } @@ -1552,7 +1601,7 @@ impl<'a> AstConverter<'a> { expression: StoredDefaultExportExpression, ) { let end_position = self.add_type_and_start( - &TYPE_EXPORT_DEFAULT_DECLARATION_INLINED_DECLARATION, + &TYPE_EXPORT_DEFAULT_DECLARATION, span, EXPORT_DEFAULT_DECLARATION_RESERVED_BYTES, matches!( @@ -1562,6 +1611,7 @@ impl<'a> AstConverter<'a> { ), ); // declaration + self.update_reference_position(end_position + EXPORT_DEFAULT_DECLARATION_DECLARATION_OFFSET); match expression { StoredDefaultExportExpression::Expression(expression) => { self.convert_expression(expression); @@ -1571,7 +1621,7 @@ impl<'a> AstConverter<'a> { } StoredDefaultExportExpression::Function(function_expression) => self.convert_function( &function_expression.function, - &TYPE_FUNCTION_DECLARATION_INLINED_ANNOTATIONS, + &TYPE_FUNCTION_DECLARATION, function_expression.ident.as_ref(), ), } @@ -1588,7 +1638,7 @@ impl<'a> AstConverter<'a> { with: &Option>, ) { let end_position = self.add_type_and_start( - &TYPE_EXPORT_NAMED_DECLARATION_INLINED_SPECIFIERS, + &TYPE_EXPORT_NAMED_DECLARATION, span, EXPORT_NAMED_DECLARATION_RESERVED_BYTES, match declaration { @@ -1598,10 +1648,14 @@ impl<'a> AstConverter<'a> { }, ); // specifiers - self.convert_item_list(specifiers, |ast_converter, specifier| { - ast_converter.convert_export_specifier(specifier); - true - }); + 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); @@ -1613,20 +1667,23 @@ impl<'a> AstConverter<'a> { self.convert_literal_string(src); } // attributes - self.update_reference_position(end_position + EXPORT_NAMED_DECLARATION_ATTRIBUTES_OFFSET); - self.store_import_attributes(with); + self.store_import_attributes( + with, + end_position + EXPORT_NAMED_DECLARATION_ATTRIBUTES_OFFSET, + ); // end self.add_end(end_position, span); } fn convert_export_named_specifier(&mut self, export_named_specifier: &ExportNamedSpecifier) { let end_position = self.add_type_and_start( - &TYPE_EXPORT_SPECIFIER_INLINED_LOCAL, + &TYPE_EXPORT_SPECIFIER, &export_named_specifier.span, EXPORT_SPECIFIER_RESERVED_BYTES, false, ); // local + self.update_reference_position(end_position + EXPORT_SPECIFIER_LOCAL_OFFSET); self.convert_module_export_name(&export_named_specifier.orig); // exported if let Some(exported) = export_named_specifier.exported.as_ref() { @@ -1639,12 +1696,13 @@ impl<'a> AstConverter<'a> { fn convert_expression_statement(&mut self, expression_statement: &ExprStmt) { let end_position = self.add_type_and_start( - &TYPE_EXPRESSION_STATEMENT_INLINED_EXPRESSION, + &TYPE_EXPRESSION_STATEMENT, &expression_statement.span, EXPRESSION_STATEMENT_RESERVED_BYTES, false, ); // expression + self.update_reference_position(end_position + EXPRESSION_STATEMENT_EXPRESSION_OFFSET); self.convert_expression(&expression_statement.expr); // end self.add_end(end_position, &expression_statement.span); @@ -1652,12 +1710,13 @@ impl<'a> AstConverter<'a> { fn convert_for_in_statement(&mut self, for_in_statement: &ForInStmt) { let end_position = self.add_type_and_start( - &TYPE_FOR_IN_STATEMENT_INLINED_LEFT, + &TYPE_FOR_IN_STATEMENT, &for_in_statement.span, FOR_IN_STATEMENT_RESERVED_BYTES, false, ); // left + self.update_reference_position(end_position + FOR_IN_STATEMENT_LEFT_OFFSET); self.convert_for_head(&for_in_statement.left); // right self.update_reference_position(end_position + FOR_IN_STATEMENT_RIGHT_OFFSET); @@ -1671,20 +1730,20 @@ impl<'a> AstConverter<'a> { fn convert_for_of_statement(&mut self, for_of_statement: &ForOfStmt) { let end_position = self.add_type_and_start( - &TYPE_FOR_OF_STATEMENT_INLINED_LEFT, + &TYPE_FOR_OF_STATEMENT, &for_of_statement.span, FOR_OF_STATEMENT_RESERVED_BYTES, false, ); // flags - let flags = if for_of_statement.is_await { - FOR_OF_STATEMENT_AWAIT_FLAG - } else { - 0u32 + let mut flags = 0u32; + if for_of_statement.is_await { + flags |= FOR_OF_STATEMENT_AWAIT_FLAG; }; let flags_position = end_position + FOR_OF_STATEMENT_FLAGS_OFFSET; self.buffer[flags_position..flags_position + 4].copy_from_slice(&flags.to_ne_bytes()); // left + self.update_reference_position(end_position + FOR_OF_STATEMENT_LEFT_OFFSET); self.convert_for_head(&for_of_statement.left); // right self.update_reference_position(end_position + FOR_OF_STATEMENT_RIGHT_OFFSET); @@ -1741,10 +1800,9 @@ impl<'a> AstConverter<'a> { let end_position = self.add_type_and_explicit_start(node_type, start, FUNCTION_DECLARATION_RESERVED_BYTES); // flags - let mut flags = if is_async { - FUNCTION_DECLARATION_ASYNC_FLAG - } else { - 0u32 + let mut flags = 0u32; + if is_async { + flags |= FUNCTION_DECLARATION_ASYNC_FLAG }; if is_generator { flags |= FUNCTION_DECLARATION_GENERATOR_FLAG; @@ -1756,12 +1814,16 @@ impl<'a> AstConverter<'a> { let annotations = self .index_converter .take_collected_annotations(AnnotationKind::NoSideEffects); - self.convert_item_list(&annotations, |ast_converter, annotation| { - convert_annotation(&mut ast_converter.buffer, annotation); - true - }); - } else { - self.buffer.extend_from_slice(&0u32.to_ne_bytes()); + 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 { @@ -1769,11 +1831,14 @@ impl<'a> AstConverter<'a> { self.convert_identifier(ident); } // params - self.update_reference_position(end_position + FUNCTION_DECLARATION_PARAMS_OFFSET); - self.convert_item_list(parameters, |ast_converter, param| { - ast_converter.convert_pattern(param); - true - }); + 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.convert_block_statement(body, true); @@ -1782,25 +1847,23 @@ impl<'a> AstConverter<'a> { } fn store_identifier(&mut self, start: u32, end: u32, name: &str) { - let end_position = self.add_type_and_explicit_start( - &TYPE_IDENTIFIER_INLINED_NAME, - start, - IDENTIFIER_RESERVED_BYTES, - ); + let end_position = + self.add_type_and_explicit_start(&TYPE_IDENTIFIER, start, IDENTIFIER_RESERVED_BYTES); // name - self.convert_string(name); + self.convert_string(name, end_position + IDENTIFIER_NAME_OFFSET); // end self.add_explicit_end(end_position, end); } fn convert_if_statement(&mut self, if_statement: &IfStmt) { let end_position = self.add_type_and_start( - &TYPE_IF_STATEMENT_INLINED_TEST, + &TYPE_IF_STATEMENT, &if_statement.span, IF_STATEMENT_RESERVED_BYTES, false, ); // test + self.update_reference_position(end_position + IF_STATEMENT_TEST_OFFSET); self.convert_expression(&if_statement.test); // consequent self.update_reference_position(end_position + IF_STATEMENT_CONSEQUENT_OFFSET); @@ -1816,9 +1879,7 @@ impl<'a> AstConverter<'a> { fn convert_import_attribute(&mut self, key_value_property: &KeyValueProp) { // type - self - .buffer - .extend_from_slice(&TYPE_IMPORT_ATTRIBUTE_INLINED_KEY); + self.buffer.extend_from_slice(&TYPE_IMPORT_ATTRIBUTE); let start_position = self.buffer.len(); let end_position = start_position + 4; // reserved bytes @@ -1826,6 +1887,7 @@ impl<'a> AstConverter<'a> { .buffer .resize(end_position + IMPORT_ATTRIBUTE_RESERVED_BYTES, 0); // key + self.update_reference_position(end_position + IMPORT_ATTRIBUTE_KEY_OFFSET); let key_position = self.buffer.len(); let key_boundaries = self.convert_property_name(&key_value_property.key); let start_bytes: [u8; 4] = match key_boundaries { @@ -1856,7 +1918,7 @@ impl<'a> AstConverter<'a> { fn convert_import_declaration(&mut self, import_declaration: &ImportDecl) { let end_position = self.add_type_and_start( - &TYPE_IMPORT_DECLARATION_INLINED_SPECIFIERS, + &TYPE_IMPORT_DECLARATION, &import_declaration.span, IMPORT_DECLARATION_RESERVED_BYTES, false, @@ -1864,6 +1926,7 @@ impl<'a> AstConverter<'a> { // 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 @@ -1873,8 +1936,10 @@ impl<'a> AstConverter<'a> { self.update_reference_position(end_position + IMPORT_DECLARATION_SOURCE_OFFSET); self.convert_literal_string(&import_declaration.src); // attributes - self.update_reference_position(end_position + IMPORT_DECLARATION_ATTRIBUTES_OFFSET); - self.store_import_attributes(&import_declaration.with); + self.store_import_attributes( + &import_declaration.with, + end_position + IMPORT_DECLARATION_ATTRIBUTES_OFFSET, + ); // end self.add_end(end_position, &import_declaration.span); } @@ -1884,12 +1949,13 @@ impl<'a> AstConverter<'a> { import_default_specifier: &ImportDefaultSpecifier, ) { let end_position = self.add_type_and_start( - &TYPE_IMPORT_DEFAULT_SPECIFIER_INLINED_LOCAL, + &TYPE_IMPORT_DEFAULT_SPECIFIER, &import_default_specifier.span, IMPORT_DEFAULT_SPECIFIER_RESERVED_BYTES, false, ); // local + self.update_reference_position(end_position + IMPORT_DEFAULT_SPECIFIER_LOCAL_OFFSET); self.convert_identifier(&import_default_specifier.local); // end self.add_end(end_position, &import_default_specifier.span); @@ -1897,12 +1963,13 @@ impl<'a> AstConverter<'a> { fn store_import_expression(&mut self, span: &Span, arguments: &[ExprOrSpread]) { let end_position = self.add_type_and_start( - &TYPE_IMPORT_EXPRESSION_INLINED_SOURCE, + &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) { @@ -1918,12 +1985,13 @@ impl<'a> AstConverter<'a> { import_namespace_specifier: &ImportStarAsSpecifier, ) { let end_position = self.add_type_and_start( - &TYPE_IMPORT_NAMESPACE_SPECIFIER_INLINED_LOCAL, + &TYPE_IMPORT_NAMESPACE_SPECIFIER, &import_namespace_specifier.span, IMPORT_NAMESPACE_SPECIFIER_RESERVED_BYTES, false, ); // local + self.update_reference_position(end_position + IMPORT_NAMESPACE_SPECIFIER_LOCAL_OFFSET); self.convert_identifier(&import_namespace_specifier.local); // end self.add_end(end_position, &import_namespace_specifier.span); @@ -1950,12 +2018,13 @@ impl<'a> AstConverter<'a> { fn convert_labeled_statement(&mut self, labeled_statement: &LabeledStmt) { let end_position = self.add_type_and_start( - &TYPE_LABELED_STATEMENT_INLINED_LABEL, + &TYPE_LABELED_STATEMENT, &labeled_statement.span, LABELED_STATEMENT_RESERVED_BYTES, false, ); // label + self.update_reference_position(end_position + LABELED_STATEMENT_LABEL_OFFSET); self.convert_identifier(&labeled_statement.label); // body self.update_reference_position(end_position + LABELED_STATEMENT_BODY_OFFSET); @@ -1966,16 +2035,21 @@ impl<'a> AstConverter<'a> { fn convert_literal_bigint(&mut self, bigint: &BigInt) { let end_position = self.add_type_and_start( - &TYPE_LITERAL_BIG_INT_INLINED_BIGINT, + &TYPE_LITERAL_BIG_INT, &bigint.span, LITERAL_BIG_INT_RESERVED_BYTES, false, ); // bigint - self.convert_string(&bigint.value.to_str_radix(10)); + self.convert_string( + &bigint.value.to_str_radix(10), + end_position + LITERAL_BIG_INT_BIGINT_OFFSET, + ); // raw - self.update_reference_position(end_position + LITERAL_BIG_INT_RAW_OFFSET); - self.convert_string(bigint.raw.as_ref().unwrap()); + self.convert_string( + bigint.raw.as_ref().unwrap(), + end_position + LITERAL_BIG_INT_RAW_OFFSET, + ); // end self.add_end(end_position, &bigint.span); } @@ -1987,10 +2061,9 @@ impl<'a> AstConverter<'a> { LITERAL_BOOLEAN_RESERVED_BYTES, false, ); - let flags = if literal.value { - LITERAL_BOOLEAN_VALUE_FLAG - } else { - 0u32 + let mut flags = 0u32; + if literal.value { + flags |= LITERAL_BOOLEAN_VALUE_FLAG }; let flags_position = end_position + LITERAL_BOOLEAN_FLAGS_OFFSET; self.buffer[flags_position..flags_position + 4].copy_from_slice(&flags.to_ne_bytes()); @@ -2019,8 +2092,7 @@ impl<'a> AstConverter<'a> { self.buffer[value_position..value_position + 8].copy_from_slice(&literal.value.to_le_bytes()); // raw if let Some(raw) = literal.raw.as_ref() { - self.update_reference_position(end_position + LITERAL_NUMBER_RAW_OFFSET); - self.convert_string(raw); + self.convert_string(raw, end_position + LITERAL_NUMBER_RAW_OFFSET); } // end self.add_end(end_position, &literal.span); @@ -2028,33 +2100,31 @@ impl<'a> AstConverter<'a> { fn convert_literal_regex(&mut self, regex: &Regex) { let end_position = self.add_type_and_start( - &TYPE_LITERAL_REG_EXP_INLINED_FLAGS, + &TYPE_LITERAL_REG_EXP, ®ex.span, LITERAL_REG_EXP_RESERVED_BYTES, false, ); // flags - self.convert_string(®ex.flags); + self.convert_string(®ex.flags, end_position + LITERAL_REG_EXP_FLAGS_OFFSET); // pattern - self.update_reference_position(end_position + LITERAL_REG_EXP_PATTERN_OFFSET); - self.convert_string(®ex.exp); + self.convert_string(®ex.exp, end_position + LITERAL_REG_EXP_PATTERN_OFFSET); // end self.add_end(end_position, ®ex.span); } fn convert_literal_string(&mut self, literal: &Str) { let end_position = self.add_type_and_start( - &TYPE_LITERAL_STRING_INLINED_VALUE, + &TYPE_LITERAL_STRING, &literal.span, LITERAL_STRING_RESERVED_BYTES, false, ); // value - self.convert_string(&literal.value); + self.convert_string(&literal.value, end_position + LITERAL_STRING_VALUE_OFFSET); // raw if let Some(raw) = literal.raw.as_ref() { - self.update_reference_position(end_position + LITERAL_STRING_RAW_OFFSET); - self.convert_string(raw); + self.convert_string(raw, end_position + LITERAL_STRING_RAW_OFFSET); } // end self.add_end(end_position, &literal.span); @@ -2069,12 +2139,13 @@ impl<'a> AstConverter<'a> { is_chained: bool, ) { let end_position = self.add_type_and_start( - &TYPE_MEMBER_EXPRESSION_INLINED_OBJECT, + &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.convert_optional_chain_expression(optional_chain_expression, is_chained); @@ -2115,7 +2186,7 @@ impl<'a> AstConverter<'a> { fn convert_meta_property(&mut self, meta_property_expression: &MetaPropExpr) { let end_position = self.add_type_and_start( - &TYPE_META_PROPERTY_INLINED_META, + &TYPE_META_PROPERTY, &meta_property_expression.span, META_PROPERTY_RESERVED_BYTES, false, @@ -2123,6 +2194,7 @@ impl<'a> AstConverter<'a> { 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, @@ -2138,6 +2210,7 @@ impl<'a> AstConverter<'a> { } 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, @@ -2159,12 +2232,13 @@ impl<'a> AstConverter<'a> { // TODO SWC can this become a store_method_definition? fn convert_constructor(&mut self, constructor: &Constructor) { let end_position = self.add_type_and_start( - &TYPE_METHOD_DEFINITION_INLINED_KEY, + &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, method definitions are neither static nor computed let flags_position = end_position + METHOD_DEFINITION_FLAGS_OFFSET; @@ -2187,7 +2261,7 @@ impl<'a> AstConverter<'a> { }) .collect(); self.store_function_node( - &TYPE_FUNCTION_EXPRESSION_INLINED_ANNOTATIONS, + &TYPE_FUNCTION_EXPRESSION, function_start, block_statement.span.hi.0 - 1, false, @@ -2216,28 +2290,15 @@ impl<'a> AstConverter<'a> { function: &Function, ) { let end_position = self.add_type_and_start( - &TYPE_METHOD_DEFINITION_INLINED_KEY, + &TYPE_METHOD_DEFINITION, span, METHOD_DEFINITION_RESERVED_BYTES, false, ); - // key - let key_end = match key { - PropOrPrivateName::PropName(prop_name) => { - self.convert_property_name(prop_name); - self.get_property_name_span(prop_name).hi.0 - 1 - } - PropOrPrivateName::PrivateName(private_name) => { - self.convert_private_name(private_name); - private_name.id.span.hi.0 - 1 - } - }; - let function_start = find_first_occurrence_outside_comment(self.code, b'(', key_end); // flags - let mut flags = if is_static { - METHOD_DEFINITION_STATIC_FLAG - } else { - 0u32 + let mut flags = 0u32; + if is_static { + flags |= METHOD_DEFINITION_STATIC_FLAG }; if is_computed { flags |= METHOD_DEFINITION_COMPUTED_FLAG; @@ -2251,11 +2312,24 @@ impl<'a> AstConverter<'a> { 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); + self.get_property_name_span(prop_name).hi.0 - 1 + } + PropOrPrivateName::PrivateName(private_name) => { + self.convert_private_name(private_name); + private_name.id.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_INLINED_ANNOTATIONS, + &TYPE_FUNCTION_EXPRESSION, function_start, function.span.hi.0 - 1, function.is_async, @@ -2271,29 +2345,35 @@ impl<'a> AstConverter<'a> { fn convert_new_expression(&mut self, new_expression: &NewExpr) { let end_position = self.add_type_and_start( - &TYPE_NEW_EXPRESSION_INLINED_ANNOTATIONS, + &TYPE_NEW_EXPRESSION, &new_expression.span, NEW_EXPRESSION_RESERVED_BYTES, false, ); + // annotations let annotations = self .index_converter .take_collected_annotations(AnnotationKind::Pure); - // annotations - self.convert_item_list(&annotations, |ast_converter, annotation| { - convert_annotation(&mut ast_converter.buffer, annotation); - true - }); + 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.update_reference_position(end_position + NEW_EXPRESSION_ARGUMENTS_OFFSET); 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 @@ -2305,7 +2385,7 @@ impl<'a> AstConverter<'a> { fn convert_object_literal(&mut self, object_literal: &ObjectLit) { let end_position = self.add_type_and_start( - &TYPE_OBJECT_EXPRESSION_INLINED_PROPERTIES, + &TYPE_OBJECT_EXPRESSION, &object_literal.span, OBJECT_EXPRESSION_RESERVED_BYTES, false, @@ -2313,6 +2393,7 @@ impl<'a> AstConverter<'a> { // properties self.convert_item_list( &object_literal.props, + end_position + OBJECT_EXPRESSION_PROPERTIES_OFFSET, |ast_converter, property_or_spread| { ast_converter.convert_property_or_spread(property_or_spread); true @@ -2324,7 +2405,7 @@ impl<'a> AstConverter<'a> { fn convert_object_pattern(&mut self, object_pattern: &ObjectPat) { let end_position = self.add_type_and_start( - &TYPE_OBJECT_PATTERN_INLINED_PROPERTIES, + &TYPE_OBJECT_PATTERN, &object_pattern.span, OBJECT_PATTERN_RESERVED_BYTES, false, @@ -2332,6 +2413,7 @@ impl<'a> AstConverter<'a> { // properties self.convert_item_list( &object_pattern.props, + end_position + OBJECT_PATTERN_PROPERTIES_OFFSET, |ast_converter, object_pattern_property| { ast_converter.convert_object_pattern_property(object_pattern_property); true @@ -2343,20 +2425,23 @@ impl<'a> AstConverter<'a> { fn convert_private_name(&mut self, private_name: &PrivateName) { let end_position = self.add_type_and_start( - &TYPE_PRIVATE_IDENTIFIER_INLINED_NAME, + &TYPE_PRIVATE_IDENTIFIER, &private_name.span, PRIVATE_IDENTIFIER_RESERVED_BYTES, false, ); - // id - self.convert_string(&private_name.id.sym); + // name + self.convert_string( + &private_name.id.sym, + end_position + PRIVATE_IDENTIFIER_NAME_OFFSET, + ); // end self.add_end(end_position, &private_name.span); } fn store_program(&mut self, body: ModuleItemsOrStatements) { let end_position = - self.add_type_and_explicit_start(&TYPE_PROGRAM_INLINED_BODY, 0u32, PROGRAM_RESERVED_BYTES); + self.add_type_and_explicit_start(&TYPE_PROGRAM, 0u32, PROGRAM_RESERVED_BYTES); // body let mut keep_checking_directives = true; match body { @@ -2364,6 +2449,7 @@ impl<'a> AstConverter<'a> { self.convert_item_list_with_state( module_items, &mut keep_checking_directives, + end_position + PROGRAM_BODY_OFFSET, |ast_converter, module_item, can_be_directive| { if *can_be_directive { if let ModuleItem::Stmt(Stmt::Expr(expression)) = module_item { @@ -2383,6 +2469,7 @@ impl<'a> AstConverter<'a> { self.convert_item_list_with_state( statements, &mut keep_checking_directives, + end_position + PROGRAM_BODY_OFFSET, |ast_converter, statement, can_be_directive| { if *can_be_directive { if let Stmt::Expr(expression) = statement { @@ -2403,13 +2490,18 @@ impl<'a> AstConverter<'a> { 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.update_reference_position(end_position + PROGRAM_INVALID_ANNOTATIONS_OFFSET); self.index_converter.invalidate_collected_annotations(); let invalid_annotations = self.index_converter.take_invalid_annotations(); - self.convert_item_list(&invalid_annotations, |ast_converter, annotation| { - convert_annotation(&mut ast_converter.buffer, annotation); - true - }); + 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 + }, + ); + } } // TODO SWC property has many different formats that should be merged if possible @@ -2423,10 +2515,9 @@ impl<'a> AstConverter<'a> { self.update_reference_position(end_position + PROPERTY_KEY_OFFSET); self.convert_property_name(property_name); // flags, method and shorthand are always false - let flags = if matches!(property_name, PropName::Computed(_)) { - PROPERTY_COMPUTED_FLAG - } else { - 0u32 + let mut flags = 0u32; + if matches!(property_name, PropName::Computed(_)) { + flags |= PROPERTY_COMPUTED_FLAG }; let flags_position = end_position + PROPERTY_FLAGS_OFFSET; self.buffer[flags_position..flags_position + 4].copy_from_slice(&flags.to_ne_bytes()); @@ -2470,10 +2561,9 @@ impl<'a> AstConverter<'a> { self.convert_property_name(key); let key_end = self.get_property_name_span(key).hi.0 - 1; // flags, method and shorthand are always false - let flags = if matches!(key, PropName::Computed(_)) { - PROPERTY_COMPUTED_FLAG - } else { - 0u32 + let mut flags = 0u32; + if matches!(key, PropName::Computed(_)) { + flags |= PROPERTY_COMPUTED_FLAG; }; let flags_position = end_position + PROPERTY_FLAGS_OFFSET; self.buffer[flags_position..flags_position + 4].copy_from_slice(&flags.to_ne_bytes()); @@ -2488,7 +2578,7 @@ impl<'a> AstConverter<'a> { None => vec![], }; self.store_function_node( - &TYPE_FUNCTION_EXPRESSION_INLINED_ANNOTATIONS, + &TYPE_FUNCTION_EXPRESSION, find_first_occurrence_outside_comment(self.code, b'(', key_end), block_statement.span.hi.0 - 1, false, @@ -2529,7 +2619,7 @@ impl<'a> AstConverter<'a> { let function = &method_property.function; let parameters: Vec<&Pat> = function.params.iter().map(|param| ¶m.pat).collect(); self.store_function_node( - &TYPE_FUNCTION_EXPRESSION_INLINED_ANNOTATIONS, + &TYPE_FUNCTION_EXPRESSION, function_start, function.span.hi.0 - 1, function.is_async, @@ -2590,12 +2680,13 @@ impl<'a> AstConverter<'a> { value: &Option<&Expr>, ) { let end_position = self.add_type_and_start( - &TYPE_PROPERTY_DEFINITION_INLINED_KEY, + &TYPE_PROPERTY_DEFINITION, span, PROPERTY_DEFINITION_RESERVED_BYTES, false, ); // key + self.update_reference_position(end_position + PROPERTY_DEFINITION_KEY_OFFSET); match key { PropOrPrivateName::PropName(prop_name) => { self.convert_property_name(prop_name); @@ -2603,11 +2694,10 @@ impl<'a> AstConverter<'a> { PropOrPrivateName::PrivateName(private_name) => self.convert_private_name(private_name), } // flags - let mut flags = if is_static { - PROPERTY_DEFINITION_STATIC_FLAG - } else { - 0u32 - }; + let mut flags = 0u32; + if is_static { + flags |= PROPERTY_DEFINITION_STATIC_FLAG; + } if is_computed { flags |= PROPERTY_DEFINITION_COMPUTED_FLAG; } @@ -2624,11 +2714,12 @@ impl<'a> AstConverter<'a> { fn convert_rest_pattern(&mut self, rest_pattern: &RestPat) { let end_position = self.add_type_and_explicit_start( - &TYPE_REST_ELEMENT_INLINED_ARGUMENT, + &TYPE_REST_ELEMENT, rest_pattern.dot3_token.lo.0 - 1, REST_ELEMENT_RESERVED_BYTES, ); // argument + self.update_reference_position(end_position + REST_ELEMENT_ARGUMENT_OFFSET); self.convert_pattern(&rest_pattern.arg); // end self.add_explicit_end(end_position, rest_pattern.span.hi.0 - 1); @@ -2652,23 +2743,27 @@ impl<'a> AstConverter<'a> { fn convert_sequence_expression(&mut self, sequence_expression: &SeqExpr) { let end_position = self.add_type_and_start( - &TYPE_SEQUENCE_EXPRESSION_INLINED_EXPRESSIONS, + &TYPE_SEQUENCE_EXPRESSION, &sequence_expression.span, SEQUENCE_EXPRESSION_RESERVED_BYTES, false, ); // expressions - self.convert_item_list(&sequence_expression.exprs, |ast_converter, expression| { - ast_converter.convert_expression(expression); - true - }); + self.convert_item_list( + &sequence_expression.exprs, + end_position + SEQUENCE_EXPRESSION_EXPRESSIONS_OFFSET, + |ast_converter, expression| { + ast_converter.convert_expression(expression); + true + }, + ); // end self.add_end(end_position, &sequence_expression.span); } fn store_spread_element(&mut self, dot_span: &Span, argument: &Expr) { let end_position = self.add_type_and_start( - &TYPE_SPREAD_ELEMENT_INLINED_ARGUMENT, + &TYPE_SPREAD_ELEMENT, dot_span, SPREAD_ELEMENT_RESERVED_BYTES, false, @@ -2676,6 +2771,7 @@ impl<'a> AstConverter<'a> { // we need to set the end position to that of the expression let argument_position = self.buffer.len(); // argument + self.update_reference_position(end_position + SPREAD_ELEMENT_ARGUMENT_OFFSET); self.convert_expression(argument); let expression_end: [u8; 4] = self.buffer[argument_position + 8..argument_position + 12] .try_into() @@ -2685,16 +2781,20 @@ impl<'a> AstConverter<'a> { fn convert_static_block(&mut self, static_block: &StaticBlock) { let end_position = self.add_type_and_start( - &TYPE_STATIC_BLOCK_INLINED_BODY, + &TYPE_STATIC_BLOCK, &static_block.span, STATIC_BLOCK_RESERVED_BYTES, false, ); // body - self.convert_item_list(&static_block.body.stmts, |ast_converter, statement| { - ast_converter.convert_statement(statement); - true - }); + self.convert_item_list( + &static_block.body.stmts, + end_position + STATIC_BLOCK_BODY_OFFSET, + |ast_converter, statement| { + ast_converter.convert_statement(statement); + true + }, + ); // end self.add_end(end_position, &static_block.span); } @@ -2723,42 +2823,50 @@ impl<'a> AstConverter<'a> { self.convert_expression(expression) }); // consequent - self.update_reference_position(end_position + SWITCH_CASE_CONSEQUENT_OFFSET); - self.convert_item_list(&switch_case.cons, |ast_converter, statement| { - ast_converter.convert_statement(statement); - true - }); + self.convert_item_list( + &switch_case.cons, + end_position + SWITCH_CASE_CONSEQUENT_OFFSET, + |ast_converter, statement| { + ast_converter.convert_statement(statement); + true + }, + ); // end self.add_end(end_position, &switch_case.span); } fn convert_switch_statement(&mut self, switch_statement: &SwitchStmt) { let end_position = self.add_type_and_start( - &TYPE_SWITCH_STATEMENT_INLINED_DISCRIMINANT, + &TYPE_SWITCH_STATEMENT, &switch_statement.span, SWITCH_STATEMENT_RESERVED_BYTES, false, ); // discriminant + self.update_reference_position(end_position + SWITCH_STATEMENT_DISCRIMINANT_OFFSET); self.convert_expression(&switch_statement.discriminant); // cases - self.update_reference_position(end_position + SWITCH_STATEMENT_CASES_OFFSET); - self.convert_item_list(&switch_statement.cases, |ast_converter, switch_case| { - ast_converter.convert_switch_case(switch_case); - true - }); + self.convert_item_list( + &switch_statement.cases, + end_position + SWITCH_STATEMENT_CASES_OFFSET, + |ast_converter, switch_case| { + ast_converter.convert_switch_case(switch_case); + true + }, + ); // end self.add_end(end_position, &switch_statement.span); } fn convert_tagged_template_expression(&mut self, tagged_template: &TaggedTpl) { let end_position = self.add_type_and_start( - &TYPE_TAGGED_TEMPLATE_EXPRESSION_INLINED_TAG, + &TYPE_TAGGED_TEMPLATE_EXPRESSION, &tagged_template.span, TAGGED_TEMPLATE_EXPRESSION_RESERVED_BYTES, false, ); // tag + self.update_reference_position(end_position + TAGGED_TEMPLATE_EXPRESSION_TAG_OFFSET); self.convert_expression(&tagged_template.tag); // quasi self.update_reference_position(end_position + TAGGED_TEMPLATE_EXPRESSION_QUASI_OFFSET); @@ -2769,25 +2877,26 @@ impl<'a> AstConverter<'a> { fn convert_template_element(&mut self, template_element: &TplElement) { let end_position = self.add_type_and_start( - &TYPE_TEMPLATE_ELEMENT_INLINED_RAW, + &TYPE_TEMPLATE_ELEMENT, &template_element.span, TEMPLATE_ELEMENT_RESERVED_BYTES, false, ); // flags - let flags = if template_element.tail { - TEMPLATE_ELEMENT_TAIL_FLAG - } else { - 0u32 - }; + let mut flags = 0u32; + if template_element.tail { + flags |= TEMPLATE_ELEMENT_TAIL_FLAG + } let flags_position = end_position + TEMPLATE_ELEMENT_FLAGS_OFFSET; self.buffer[flags_position..flags_position + 4].copy_from_slice(&flags.to_ne_bytes()); // raw - self.convert_string(&template_element.raw); + self.convert_string( + &template_element.raw, + end_position + TEMPLATE_ELEMENT_RAW_OFFSET, + ); // cooked if let Some(cooked) = template_element.cooked.as_ref() { - self.update_reference_position(end_position + TEMPLATE_ELEMENT_COOKED_OFFSET); - self.convert_string(cooked); + self.convert_string(cooked, end_position + TEMPLATE_ELEMENT_COOKED_OFFSET); } // end self.add_end(end_position, &template_element.span); @@ -2795,12 +2904,13 @@ impl<'a> AstConverter<'a> { fn convert_template_literal(&mut self, template_literal: &Tpl) { let end_position = self.add_type_and_start( - &TYPE_TEMPLATE_LITERAL_INLINED_QUASIS, + &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()); @@ -2859,12 +2969,13 @@ impl<'a> AstConverter<'a> { fn convert_throw_statement(&mut self, throw_statement: &ThrowStmt) { let end_position = self.add_type_and_start( - &TYPE_THROW_STATEMENT_INLINED_ARGUMENT, + &TYPE_THROW_STATEMENT, &throw_statement.span, THROW_STATEMENT_RESERVED_BYTES, false, ); // argument + self.update_reference_position(end_position + THROW_STATEMENT_ARGUMENT_OFFSET); self.convert_expression(&throw_statement.arg); // end self.add_end(end_position, &throw_statement.span); @@ -2872,12 +2983,13 @@ impl<'a> AstConverter<'a> { fn convert_try_statement(&mut self, try_statement: &TryStmt) { let end_position = self.add_type_and_start( - &TYPE_TRY_STATEMENT_INLINED_BLOCK, + &TYPE_TRY_STATEMENT, &try_statement.span, TRY_STATEMENT_RESERVED_BYTES, false, ); // block + self.update_reference_position(end_position + TRY_STATEMENT_BLOCK_OFFSET); self.convert_block_statement(&try_statement.block, false); // handler if let Some(catch_clause) = try_statement.handler.as_ref() { @@ -2895,12 +3007,13 @@ impl<'a> AstConverter<'a> { fn convert_unary_expression(&mut self, unary_expression: &UnaryExpr) { let end_position = self.add_type_and_start( - &TYPE_UNARY_EXPRESSION_INLINED_ARGUMENT, + &TYPE_UNARY_EXPRESSION, &unary_expression.span, UNARY_EXPRESSION_RESERVED_BYTES, false, ); // argument + self.update_reference_position(end_position + UNARY_EXPRESSION_ARGUMENT_OFFSET); self.convert_expression(&unary_expression.arg); // operator let operator_position = end_position + UNARY_EXPRESSION_OPERATOR_OFFSET; @@ -2921,19 +3034,19 @@ impl<'a> AstConverter<'a> { fn convert_update_expression(&mut self, update_expression: &UpdateExpr) { let end_position = self.add_type_and_start( - &TYPE_UPDATE_EXPRESSION_INLINED_ARGUMENT, + &TYPE_UPDATE_EXPRESSION, &update_expression.span, UPDATE_EXPRESSION_RESERVED_BYTES, false, ); // argument + self.update_reference_position(end_position + UPDATE_EXPRESSION_ARGUMENT_OFFSET); self.convert_expression(&update_expression.arg); // flags - let flags = if update_expression.prefix { - UPDATE_EXPRESSION_PREFIX_FLAG - } else { - 0u32 - }; + let mut flags = 0u32; + if update_expression.prefix { + flags |= UPDATE_EXPRESSION_PREFIX_FLAG; + } let flags_position = end_position + UPDATE_EXPRESSION_FLAGS_OFFSET; self.buffer[flags_position..flags_position + 4].copy_from_slice(&flags.to_ne_bytes()); // operator @@ -2970,16 +3083,20 @@ impl<'a> AstConverter<'a> { ), }; let end_position = self.add_type_and_start( - &TYPE_VARIABLE_DECLARATION_INLINED_DECLARATIONS, + &TYPE_VARIABLE_DECLARATION, &span, VARIABLE_DECLARATION_RESERVED_BYTES, kind == &STRING_CONST, ); // declarations - self.convert_item_list(decls, |ast_converter, variable_declarator| { - ast_converter.convert_variable_declarator(variable_declarator); - true - }); + self.convert_item_list( + decls, + end_position + VARIABLE_DECLARATION_DECLARATIONS_OFFSET, + |ast_converter, variable_declarator| { + ast_converter.convert_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); @@ -2989,7 +3106,7 @@ impl<'a> AstConverter<'a> { fn convert_variable_declarator(&mut self, variable_declarator: &VarDeclarator) { let end_position = self.add_type_and_start( - &TYPE_VARIABLE_DECLARATOR_INLINED_ID, + &TYPE_VARIABLE_DECLARATOR, &variable_declarator.span, VARIABLE_DECLARATOR_RESERVED_BYTES, false, @@ -3007,6 +3124,7 @@ impl<'a> AstConverter<'a> { 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 { @@ -3022,12 +3140,13 @@ impl<'a> AstConverter<'a> { fn convert_while_statement(&mut self, while_statement: &WhileStmt) { let end_position = self.add_type_and_start( - &TYPE_WHILE_STATEMENT_INLINED_TEST, + &TYPE_WHILE_STATEMENT, &while_statement.span, WHILE_STATEMENT_RESERVED_BYTES, false, ); // test + self.update_reference_position(end_position + WHILE_STATEMENT_TEST_OFFSET); self.convert_expression(&while_statement.test); // body self.update_reference_position(end_position + WHILE_STATEMENT_BODY_OFFSET); @@ -3044,11 +3163,10 @@ impl<'a> AstConverter<'a> { false, ); // flags - let flags = if yield_expression.delegate { - YIELD_EXPRESSION_DELEGATE_FLAG - } else { - 0u32 - }; + let mut flags = 0u32; + if yield_expression.delegate { + flags |= YIELD_EXPRESSION_DELEGATE_FLAG; + } let flags_position = end_position + YIELD_EXPRESSION_FLAGS_OFFSET; self.buffer[flags_position..flags_position + 4].copy_from_slice(&flags.to_ne_bytes()); // argument @@ -3082,6 +3200,12 @@ pub fn convert_string(buffer: &mut Vec, string: &str) { buffer.resize(buffer.len() + additional_length, 0); } +pub fn update_reference_position(buffer: &mut Vec, 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()); +} + enum VariableDeclaration<'a> { Var(&'a VarDecl), Using(&'a UsingDecl), diff --git a/rust/parse_ast/src/convert_ast/converter/ast_constants.rs b/rust/parse_ast/src/convert_ast/converter/ast_constants.rs index d61fd9a03..8e28edc72 100644 --- a/rust/parse_ast/src/convert_ast/converter/ast_constants.rs +++ b/rust/parse_ast/src/convert_ast/converter/ast_constants.rs @@ -1,153 +1,169 @@ // This file is generated by scripts/generate-ast-converters.js. // Do not edit this file directly. -pub const TYPE_PANIC_ERROR_INLINED_MESSAGE: [u8; 4] = 0u32.to_ne_bytes(); -pub const TYPE_PARSE_ERROR_INLINED_MESSAGE: [u8; 4] = 1u32.to_ne_bytes(); -pub const TYPE_ARRAY_EXPRESSION_INLINED_ELEMENTS: [u8; 4] = 2u32.to_ne_bytes(); -pub const TYPE_ARRAY_PATTERN_INLINED_ELEMENTS: [u8; 4] = 3u32.to_ne_bytes(); -pub const TYPE_ARROW_FUNCTION_EXPRESSION_INLINED_ANNOTATIONS: [u8; 4] = 4u32.to_ne_bytes(); -pub const TYPE_ASSIGNMENT_EXPRESSION_INLINED_LEFT: [u8; 4] = 5u32.to_ne_bytes(); -pub const TYPE_ASSIGNMENT_PATTERN_INLINED_LEFT: [u8; 4] = 6u32.to_ne_bytes(); -pub const TYPE_AWAIT_EXPRESSION_INLINED_ARGUMENT: [u8; 4] = 7u32.to_ne_bytes(); -pub const TYPE_BINARY_EXPRESSION_INLINED_LEFT: [u8; 4] = 8u32.to_ne_bytes(); -pub const TYPE_BLOCK_STATEMENT_INLINED_BODY: [u8; 4] = 9u32.to_ne_bytes(); +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_EXPRESSION: [u8; 4] = 5u32.to_ne_bytes(); +pub const TYPE_ASSIGNMENT_PATTERN: [u8; 4] = 6u32.to_ne_bytes(); +pub const TYPE_AWAIT_EXPRESSION: [u8; 4] = 7u32.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_BREAK_STATEMENT: [u8; 4] = 10u32.to_ne_bytes(); -pub const TYPE_CALL_EXPRESSION_INLINED_ANNOTATIONS: [u8; 4] = 11u32.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_INLINED_EXPRESSION: [u8; 4] = 13u32.to_ne_bytes(); -pub const TYPE_CLASS_BODY_INLINED_BODY: [u8; 4] = 14u32.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_CONDITIONAL_EXPRESSION_INLINED_TEST: [u8; 4] = 17u32.to_ne_bytes(); +pub const TYPE_CONDITIONAL_EXPRESSION: [u8; 4] = 17u32.to_ne_bytes(); pub const TYPE_CONTINUE_STATEMENT: [u8; 4] = 18u32.to_ne_bytes(); pub const TYPE_DEBUGGER_STATEMENT: [u8; 4] = 19u32.to_ne_bytes(); -pub const TYPE_DIRECTIVE_INLINED_DIRECTIVE: [u8; 4] = 20u32.to_ne_bytes(); -pub const TYPE_DO_WHILE_STATEMENT_INLINED_BODY: [u8; 4] = 21u32.to_ne_bytes(); +pub const TYPE_DIRECTIVE: [u8; 4] = 20u32.to_ne_bytes(); +pub const TYPE_DO_WHILE_STATEMENT: [u8; 4] = 21u32.to_ne_bytes(); pub const TYPE_EMPTY_STATEMENT: [u8; 4] = 22u32.to_ne_bytes(); pub const TYPE_EXPORT_ALL_DECLARATION: [u8; 4] = 23u32.to_ne_bytes(); -pub const TYPE_EXPORT_DEFAULT_DECLARATION_INLINED_DECLARATION: [u8; 4] = 24u32.to_ne_bytes(); -pub const TYPE_EXPORT_NAMED_DECLARATION_INLINED_SPECIFIERS: [u8; 4] = 25u32.to_ne_bytes(); -pub const TYPE_EXPORT_SPECIFIER_INLINED_LOCAL: [u8; 4] = 26u32.to_ne_bytes(); -pub const TYPE_EXPRESSION_STATEMENT_INLINED_EXPRESSION: [u8; 4] = 27u32.to_ne_bytes(); -pub const TYPE_FOR_IN_STATEMENT_INLINED_LEFT: [u8; 4] = 28u32.to_ne_bytes(); -pub const TYPE_FOR_OF_STATEMENT_INLINED_LEFT: [u8; 4] = 29u32.to_ne_bytes(); +pub const TYPE_EXPORT_DEFAULT_DECLARATION: [u8; 4] = 24u32.to_ne_bytes(); +pub const TYPE_EXPORT_NAMED_DECLARATION: [u8; 4] = 25u32.to_ne_bytes(); +pub const TYPE_EXPORT_SPECIFIER: [u8; 4] = 26u32.to_ne_bytes(); +pub const TYPE_EXPRESSION_STATEMENT: [u8; 4] = 27u32.to_ne_bytes(); +pub const TYPE_FOR_IN_STATEMENT: [u8; 4] = 28u32.to_ne_bytes(); +pub const TYPE_FOR_OF_STATEMENT: [u8; 4] = 29u32.to_ne_bytes(); pub const TYPE_FOR_STATEMENT: [u8; 4] = 30u32.to_ne_bytes(); -pub const TYPE_FUNCTION_DECLARATION_INLINED_ANNOTATIONS: [u8; 4] = 31u32.to_ne_bytes(); -pub const TYPE_FUNCTION_EXPRESSION_INLINED_ANNOTATIONS: [u8; 4] = 32u32.to_ne_bytes(); -pub const TYPE_IDENTIFIER_INLINED_NAME: [u8; 4] = 33u32.to_ne_bytes(); -pub const TYPE_IF_STATEMENT_INLINED_TEST: [u8; 4] = 34u32.to_ne_bytes(); -pub const TYPE_IMPORT_ATTRIBUTE_INLINED_KEY: [u8; 4] = 35u32.to_ne_bytes(); -pub const TYPE_IMPORT_DECLARATION_INLINED_SPECIFIERS: [u8; 4] = 36u32.to_ne_bytes(); -pub const TYPE_IMPORT_DEFAULT_SPECIFIER_INLINED_LOCAL: [u8; 4] = 37u32.to_ne_bytes(); -pub const TYPE_IMPORT_EXPRESSION_INLINED_SOURCE: [u8; 4] = 38u32.to_ne_bytes(); -pub const TYPE_IMPORT_NAMESPACE_SPECIFIER_INLINED_LOCAL: [u8; 4] = 39u32.to_ne_bytes(); +pub const TYPE_FUNCTION_DECLARATION: [u8; 4] = 31u32.to_ne_bytes(); +pub const TYPE_FUNCTION_EXPRESSION: [u8; 4] = 32u32.to_ne_bytes(); +pub const TYPE_IDENTIFIER: [u8; 4] = 33u32.to_ne_bytes(); +pub const TYPE_IF_STATEMENT: [u8; 4] = 34u32.to_ne_bytes(); +pub const TYPE_IMPORT_ATTRIBUTE: [u8; 4] = 35u32.to_ne_bytes(); +pub const TYPE_IMPORT_DECLARATION: [u8; 4] = 36u32.to_ne_bytes(); +pub const TYPE_IMPORT_DEFAULT_SPECIFIER: [u8; 4] = 37u32.to_ne_bytes(); +pub const TYPE_IMPORT_EXPRESSION: [u8; 4] = 38u32.to_ne_bytes(); +pub const TYPE_IMPORT_NAMESPACE_SPECIFIER: [u8; 4] = 39u32.to_ne_bytes(); pub const TYPE_IMPORT_SPECIFIER: [u8; 4] = 40u32.to_ne_bytes(); -pub const TYPE_LABELED_STATEMENT_INLINED_LABEL: [u8; 4] = 41u32.to_ne_bytes(); -pub const TYPE_LITERAL_BIG_INT_INLINED_BIGINT: [u8; 4] = 42u32.to_ne_bytes(); +pub const TYPE_LABELED_STATEMENT: [u8; 4] = 41u32.to_ne_bytes(); +pub const TYPE_LITERAL_BIG_INT: [u8; 4] = 42u32.to_ne_bytes(); pub const TYPE_LITERAL_BOOLEAN: [u8; 4] = 43u32.to_ne_bytes(); pub const TYPE_LITERAL_NULL: [u8; 4] = 44u32.to_ne_bytes(); pub const TYPE_LITERAL_NUMBER: [u8; 4] = 45u32.to_ne_bytes(); -pub const TYPE_LITERAL_REG_EXP_INLINED_FLAGS: [u8; 4] = 46u32.to_ne_bytes(); -pub const TYPE_LITERAL_STRING_INLINED_VALUE: [u8; 4] = 47u32.to_ne_bytes(); -pub const TYPE_LOGICAL_EXPRESSION_INLINED_LEFT: [u8; 4] = 48u32.to_ne_bytes(); -pub const TYPE_MEMBER_EXPRESSION_INLINED_OBJECT: [u8; 4] = 49u32.to_ne_bytes(); -pub const TYPE_META_PROPERTY_INLINED_META: [u8; 4] = 50u32.to_ne_bytes(); -pub const TYPE_METHOD_DEFINITION_INLINED_KEY: [u8; 4] = 51u32.to_ne_bytes(); -pub const TYPE_NEW_EXPRESSION_INLINED_ANNOTATIONS: [u8; 4] = 52u32.to_ne_bytes(); -pub const TYPE_OBJECT_EXPRESSION_INLINED_PROPERTIES: [u8; 4] = 53u32.to_ne_bytes(); -pub const TYPE_OBJECT_PATTERN_INLINED_PROPERTIES: [u8; 4] = 54u32.to_ne_bytes(); -pub const TYPE_PRIVATE_IDENTIFIER_INLINED_NAME: [u8; 4] = 55u32.to_ne_bytes(); -pub const TYPE_PROGRAM_INLINED_BODY: [u8; 4] = 56u32.to_ne_bytes(); +pub const TYPE_LITERAL_REG_EXP: [u8; 4] = 46u32.to_ne_bytes(); +pub const TYPE_LITERAL_STRING: [u8; 4] = 47u32.to_ne_bytes(); +pub const TYPE_LOGICAL_EXPRESSION: [u8; 4] = 48u32.to_ne_bytes(); +pub const TYPE_MEMBER_EXPRESSION: [u8; 4] = 49u32.to_ne_bytes(); +pub const TYPE_META_PROPERTY: [u8; 4] = 50u32.to_ne_bytes(); +pub const TYPE_METHOD_DEFINITION: [u8; 4] = 51u32.to_ne_bytes(); +pub const TYPE_NEW_EXPRESSION: [u8; 4] = 52u32.to_ne_bytes(); +pub const TYPE_OBJECT_EXPRESSION: [u8; 4] = 53u32.to_ne_bytes(); +pub const TYPE_OBJECT_PATTERN: [u8; 4] = 54u32.to_ne_bytes(); +pub const TYPE_PRIVATE_IDENTIFIER: [u8; 4] = 55u32.to_ne_bytes(); +pub const TYPE_PROGRAM: [u8; 4] = 56u32.to_ne_bytes(); pub const TYPE_PROPERTY: [u8; 4] = 57u32.to_ne_bytes(); -pub const TYPE_PROPERTY_DEFINITION_INLINED_KEY: [u8; 4] = 58u32.to_ne_bytes(); -pub const TYPE_REST_ELEMENT_INLINED_ARGUMENT: [u8; 4] = 59u32.to_ne_bytes(); +pub const TYPE_PROPERTY_DEFINITION: [u8; 4] = 58u32.to_ne_bytes(); +pub const TYPE_REST_ELEMENT: [u8; 4] = 59u32.to_ne_bytes(); pub const TYPE_RETURN_STATEMENT: [u8; 4] = 60u32.to_ne_bytes(); -pub const TYPE_SEQUENCE_EXPRESSION_INLINED_EXPRESSIONS: [u8; 4] = 61u32.to_ne_bytes(); -pub const TYPE_SPREAD_ELEMENT_INLINED_ARGUMENT: [u8; 4] = 62u32.to_ne_bytes(); -pub const TYPE_STATIC_BLOCK_INLINED_BODY: [u8; 4] = 63u32.to_ne_bytes(); +pub const TYPE_SEQUENCE_EXPRESSION: [u8; 4] = 61u32.to_ne_bytes(); +pub const TYPE_SPREAD_ELEMENT: [u8; 4] = 62u32.to_ne_bytes(); +pub const TYPE_STATIC_BLOCK: [u8; 4] = 63u32.to_ne_bytes(); pub const TYPE_SUPER_ELEMENT: [u8; 4] = 64u32.to_ne_bytes(); pub const TYPE_SWITCH_CASE: [u8; 4] = 65u32.to_ne_bytes(); -pub const TYPE_SWITCH_STATEMENT_INLINED_DISCRIMINANT: [u8; 4] = 66u32.to_ne_bytes(); -pub const TYPE_TAGGED_TEMPLATE_EXPRESSION_INLINED_TAG: [u8; 4] = 67u32.to_ne_bytes(); -pub const TYPE_TEMPLATE_ELEMENT_INLINED_RAW: [u8; 4] = 68u32.to_ne_bytes(); -pub const TYPE_TEMPLATE_LITERAL_INLINED_QUASIS: [u8; 4] = 69u32.to_ne_bytes(); +pub const TYPE_SWITCH_STATEMENT: [u8; 4] = 66u32.to_ne_bytes(); +pub const TYPE_TAGGED_TEMPLATE_EXPRESSION: [u8; 4] = 67u32.to_ne_bytes(); +pub const TYPE_TEMPLATE_ELEMENT: [u8; 4] = 68u32.to_ne_bytes(); +pub const TYPE_TEMPLATE_LITERAL: [u8; 4] = 69u32.to_ne_bytes(); pub const TYPE_THIS_EXPRESSION: [u8; 4] = 70u32.to_ne_bytes(); -pub const TYPE_THROW_STATEMENT_INLINED_ARGUMENT: [u8; 4] = 71u32.to_ne_bytes(); -pub const TYPE_TRY_STATEMENT_INLINED_BLOCK: [u8; 4] = 72u32.to_ne_bytes(); -pub const TYPE_UNARY_EXPRESSION_INLINED_ARGUMENT: [u8; 4] = 73u32.to_ne_bytes(); -pub const TYPE_UPDATE_EXPRESSION_INLINED_ARGUMENT: [u8; 4] = 74u32.to_ne_bytes(); -pub const TYPE_VARIABLE_DECLARATION_INLINED_DECLARATIONS: [u8; 4] = 75u32.to_ne_bytes(); -pub const TYPE_VARIABLE_DECLARATOR_INLINED_ID: [u8; 4] = 76u32.to_ne_bytes(); -pub const TYPE_WHILE_STATEMENT_INLINED_TEST: [u8; 4] = 77u32.to_ne_bytes(); +pub const TYPE_THROW_STATEMENT: [u8; 4] = 71u32.to_ne_bytes(); +pub const TYPE_TRY_STATEMENT: [u8; 4] = 72u32.to_ne_bytes(); +pub const TYPE_UNARY_EXPRESSION: [u8; 4] = 73u32.to_ne_bytes(); +pub const TYPE_UPDATE_EXPRESSION: [u8; 4] = 74u32.to_ne_bytes(); +pub const TYPE_VARIABLE_DECLARATION: [u8; 4] = 75u32.to_ne_bytes(); +pub const TYPE_VARIABLE_DECLARATOR: [u8; 4] = 76u32.to_ne_bytes(); +pub const TYPE_WHILE_STATEMENT: [u8; 4] = 77u32.to_ne_bytes(); pub const TYPE_YIELD_EXPRESSION: [u8; 4] = 78u32.to_ne_bytes(); -pub const PANIC_ERROR_RESERVED_BYTES: usize = 4; +pub const PANIC_ERROR_RESERVED_BYTES: usize = 8; +pub const PANIC_ERROR_MESSAGE_OFFSET: usize = 4; -pub const PARSE_ERROR_RESERVED_BYTES: 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 = 4; +pub const ARRAY_EXPRESSION_RESERVED_BYTES: usize = 8; +pub const ARRAY_EXPRESSION_ELEMENTS_OFFSET: usize = 4; -pub const ARRAY_PATTERN_RESERVED_BYTES: 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 = 16; +pub const ARROW_FUNCTION_EXPRESSION_RESERVED_BYTES: usize = 20; pub const ARROW_FUNCTION_EXPRESSION_FLAGS_OFFSET: usize = 4; pub const ARROW_FUNCTION_EXPRESSION_ASYNC_FLAG: u32 = 1; pub const ARROW_FUNCTION_EXPRESSION_EXPRESSION_FLAG: u32 = 2; pub const ARROW_FUNCTION_EXPRESSION_GENERATOR_FLAG: u32 = 4; -pub const ARROW_FUNCTION_EXPRESSION_PARAMS_OFFSET: usize = 8; -pub const ARROW_FUNCTION_EXPRESSION_BODY_OFFSET: usize = 12; +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_EXPRESSION_RESERVED_BYTES: usize = 12; +pub const ASSIGNMENT_EXPRESSION_RESERVED_BYTES: usize = 16; pub const ASSIGNMENT_EXPRESSION_OPERATOR_OFFSET: usize = 4; -pub const ASSIGNMENT_EXPRESSION_RIGHT_OFFSET: usize = 8; +pub const ASSIGNMENT_EXPRESSION_LEFT_OFFSET: usize = 8; +pub const ASSIGNMENT_EXPRESSION_RIGHT_OFFSET: usize = 12; -pub const ASSIGNMENT_PATTERN_RESERVED_BYTES: usize = 8; -pub const ASSIGNMENT_PATTERN_RIGHT_OFFSET: usize = 4; +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 AWAIT_EXPRESSION_RESERVED_BYTES: usize = 4; +pub const AWAIT_EXPRESSION_RESERVED_BYTES: usize = 8; +pub const AWAIT_EXPRESSION_ARGUMENT_OFFSET: usize = 4; -pub const BINARY_EXPRESSION_RESERVED_BYTES: usize = 12; +pub const BINARY_EXPRESSION_RESERVED_BYTES: usize = 16; pub const BINARY_EXPRESSION_OPERATOR_OFFSET: usize = 4; -pub const BINARY_EXPRESSION_RIGHT_OFFSET: usize = 8; +pub const BINARY_EXPRESSION_LEFT_OFFSET: usize = 8; +pub const BINARY_EXPRESSION_RIGHT_OFFSET: usize = 12; -pub const BLOCK_STATEMENT_RESERVED_BYTES: usize = 4; +pub const BLOCK_STATEMENT_RESERVED_BYTES: usize = 8; +pub const BLOCK_STATEMENT_BODY_OFFSET: usize = 4; pub const BREAK_STATEMENT_RESERVED_BYTES: usize = 8; pub const BREAK_STATEMENT_LABEL_OFFSET: usize = 4; -pub const CALL_EXPRESSION_RESERVED_BYTES: usize = 16; +pub const CALL_EXPRESSION_RESERVED_BYTES: usize = 20; pub const CALL_EXPRESSION_FLAGS_OFFSET: usize = 4; pub const CALL_EXPRESSION_OPTIONAL_FLAG: u32 = 1; -pub const CALL_EXPRESSION_CALLEE_OFFSET: usize = 8; -pub const CALL_EXPRESSION_ARGUMENTS_OFFSET: usize = 12; +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 = 4; +pub const CHAIN_EXPRESSION_RESERVED_BYTES: usize = 8; +pub const CHAIN_EXPRESSION_EXPRESSION_OFFSET: usize = 4; -pub const CLASS_BODY_RESERVED_BYTES: 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 = 16; pub const CLASS_DECLARATION_ID_OFFSET: usize = 4; pub const CLASS_DECLARATION_SUPER_CLASS_OFFSET: usize = 8; pub const CLASS_DECLARATION_BODY_OFFSET: usize = 12; -pub const CONDITIONAL_EXPRESSION_RESERVED_BYTES: usize = 12; -pub const CONDITIONAL_EXPRESSION_CONSEQUENT_OFFSET: usize = 4; -pub const CONDITIONAL_EXPRESSION_ALTERNATE_OFFSET: usize = 8; +pub const CONDITIONAL_EXPRESSION_RESERVED_BYTES: usize = 16; +pub const CONDITIONAL_EXPRESSION_TEST_OFFSET: usize = 4; +pub const CONDITIONAL_EXPRESSION_CONSEQUENT_OFFSET: usize = 8; +pub const CONDITIONAL_EXPRESSION_ALTERNATE_OFFSET: usize = 12; pub const CONTINUE_STATEMENT_RESERVED_BYTES: usize = 8; pub const CONTINUE_STATEMENT_LABEL_OFFSET: usize = 4; pub const DEBUGGER_STATEMENT_RESERVED_BYTES: usize = 4; -pub const DIRECTIVE_RESERVED_BYTES: usize = 8; -pub const DIRECTIVE_EXPRESSION_OFFSET: usize = 4; +pub const DIRECTIVE_RESERVED_BYTES: usize = 12; +pub const DIRECTIVE_DIRECTIVE_OFFSET: usize = 4; +pub const DIRECTIVE_EXPRESSION_OFFSET: usize = 8; -pub const DO_WHILE_STATEMENT_RESERVED_BYTES: usize = 8; -pub const DO_WHILE_STATEMENT_TEST_OFFSET: usize = 4; +pub const DO_WHILE_STATEMENT_RESERVED_BYTES: usize = 12; +pub const DO_WHILE_STATEMENT_BODY_OFFSET: usize = 4; +pub const DO_WHILE_STATEMENT_TEST_OFFSET: usize = 8; pub const EMPTY_STATEMENT_RESERVED_BYTES: usize = 4; @@ -156,27 +172,33 @@ 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 = 4; +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 = 16; -pub const EXPORT_NAMED_DECLARATION_SOURCE_OFFSET: usize = 4; -pub const EXPORT_NAMED_DECLARATION_ATTRIBUTES_OFFSET: usize = 8; -pub const EXPORT_NAMED_DECLARATION_DECLARATION_OFFSET: usize = 12; +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 EXPORT_SPECIFIER_RESERVED_BYTES: usize = 8; -pub const EXPORT_SPECIFIER_EXPORTED_OFFSET: usize = 4; +pub const EXPORT_SPECIFIER_RESERVED_BYTES: usize = 12; +pub const EXPORT_SPECIFIER_LOCAL_OFFSET: usize = 4; +pub const EXPORT_SPECIFIER_EXPORTED_OFFSET: usize = 8; -pub const EXPRESSION_STATEMENT_RESERVED_BYTES: usize = 4; +pub const EXPRESSION_STATEMENT_RESERVED_BYTES: usize = 8; +pub const EXPRESSION_STATEMENT_EXPRESSION_OFFSET: usize = 4; -pub const FOR_IN_STATEMENT_RESERVED_BYTES: usize = 12; -pub const FOR_IN_STATEMENT_RIGHT_OFFSET: usize = 4; -pub const FOR_IN_STATEMENT_BODY_OFFSET: usize = 8; +pub const FOR_IN_STATEMENT_RESERVED_BYTES: usize = 16; +pub const FOR_IN_STATEMENT_LEFT_OFFSET: usize = 4; +pub const FOR_IN_STATEMENT_RIGHT_OFFSET: usize = 8; +pub const FOR_IN_STATEMENT_BODY_OFFSET: usize = 12; -pub const FOR_OF_STATEMENT_RESERVED_BYTES: usize = 16; +pub const FOR_OF_STATEMENT_RESERVED_BYTES: usize = 20; pub const FOR_OF_STATEMENT_FLAGS_OFFSET: usize = 4; pub const FOR_OF_STATEMENT_AWAIT_FLAG: u32 = 1; -pub const FOR_OF_STATEMENT_RIGHT_OFFSET: usize = 8; -pub const FOR_OF_STATEMENT_BODY_OFFSET: usize = 12; +pub const FOR_OF_STATEMENT_LEFT_OFFSET: usize = 8; +pub const FOR_OF_STATEMENT_RIGHT_OFFSET: usize = 12; +pub const FOR_OF_STATEMENT_BODY_OFFSET: usize = 16; pub const FOR_STATEMENT_RESERVED_BYTES: usize = 20; pub const FOR_STATEMENT_INIT_OFFSET: usize = 4; @@ -184,43 +206,53 @@ pub const FOR_STATEMENT_TEST_OFFSET: usize = 8; pub const FOR_STATEMENT_UPDATE_OFFSET: usize = 12; pub const FOR_STATEMENT_BODY_OFFSET: usize = 16; -pub const FUNCTION_DECLARATION_RESERVED_BYTES: usize = 20; +pub const FUNCTION_DECLARATION_RESERVED_BYTES: usize = 24; pub const FUNCTION_DECLARATION_FLAGS_OFFSET: usize = 4; pub const FUNCTION_DECLARATION_ASYNC_FLAG: u32 = 1; pub const FUNCTION_DECLARATION_GENERATOR_FLAG: u32 = 2; -pub const FUNCTION_DECLARATION_ID_OFFSET: usize = 8; -pub const FUNCTION_DECLARATION_PARAMS_OFFSET: usize = 12; -pub const FUNCTION_DECLARATION_BODY_OFFSET: usize = 16; +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 = 4; +pub const IDENTIFIER_RESERVED_BYTES: usize = 8; +pub const IDENTIFIER_NAME_OFFSET: usize = 4; -pub const IF_STATEMENT_RESERVED_BYTES: usize = 12; -pub const IF_STATEMENT_CONSEQUENT_OFFSET: usize = 4; -pub const IF_STATEMENT_ALTERNATE_OFFSET: usize = 8; +pub const IF_STATEMENT_RESERVED_BYTES: usize = 16; +pub const IF_STATEMENT_TEST_OFFSET: usize = 4; +pub const IF_STATEMENT_CONSEQUENT_OFFSET: usize = 8; +pub const IF_STATEMENT_ALTERNATE_OFFSET: usize = 12; -pub const IMPORT_ATTRIBUTE_RESERVED_BYTES: usize = 8; -pub const IMPORT_ATTRIBUTE_VALUE_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 = 12; -pub const IMPORT_DECLARATION_SOURCE_OFFSET: usize = 4; -pub const IMPORT_DECLARATION_ATTRIBUTES_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_DEFAULT_SPECIFIER_RESERVED_BYTES: usize = 4; +pub const IMPORT_DEFAULT_SPECIFIER_RESERVED_BYTES: usize = 8; +pub const IMPORT_DEFAULT_SPECIFIER_LOCAL_OFFSET: usize = 4; -pub const IMPORT_EXPRESSION_RESERVED_BYTES: usize = 8; -pub const IMPORT_EXPRESSION_OPTIONS_OFFSET: usize = 4; +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 IMPORT_NAMESPACE_SPECIFIER_RESERVED_BYTES: usize = 4; +pub const IMPORT_NAMESPACE_SPECIFIER_RESERVED_BYTES: usize = 8; +pub const IMPORT_NAMESPACE_SPECIFIER_LOCAL_OFFSET: usize = 4; pub const IMPORT_SPECIFIER_RESERVED_BYTES: usize = 12; pub const IMPORT_SPECIFIER_IMPORTED_OFFSET: usize = 4; pub const IMPORT_SPECIFIER_LOCAL_OFFSET: usize = 8; -pub const LABELED_STATEMENT_RESERVED_BYTES: usize = 8; -pub const LABELED_STATEMENT_BODY_OFFSET: usize = 4; +pub const LABELED_STATEMENT_RESERVED_BYTES: usize = 12; +pub const LABELED_STATEMENT_LABEL_OFFSET: usize = 4; +pub const LABELED_STATEMENT_BODY_OFFSET: usize = 8; -pub const LITERAL_BIG_INT_RESERVED_BYTES: usize = 8; -pub const LITERAL_BIG_INT_RAW_OFFSET: usize = 4; +pub const LITERAL_BIG_INT_RESERVED_BYTES: usize = 12; +pub const LITERAL_BIG_INT_BIGINT_OFFSET: usize = 4; +pub const LITERAL_BIG_INT_RAW_OFFSET: usize = 8; pub const LITERAL_BOOLEAN_RESERVED_BYTES: usize = 8; pub const LITERAL_BOOLEAN_FLAGS_OFFSET: usize = 4; @@ -232,40 +264,50 @@ pub const LITERAL_NUMBER_RESERVED_BYTES: usize = 16; pub const LITERAL_NUMBER_RAW_OFFSET: usize = 4; pub const LITERAL_NUMBER_VALUE_OFFSET: usize = 8; -pub const LITERAL_REG_EXP_RESERVED_BYTES: usize = 8; -pub const LITERAL_REG_EXP_PATTERN_OFFSET: usize = 4; +pub const LITERAL_REG_EXP_RESERVED_BYTES: usize = 12; +pub const LITERAL_REG_EXP_FLAGS_OFFSET: usize = 4; +pub const LITERAL_REG_EXP_PATTERN_OFFSET: usize = 8; -pub const LITERAL_STRING_RESERVED_BYTES: usize = 8; -pub const LITERAL_STRING_RAW_OFFSET: usize = 4; +pub const LITERAL_STRING_RESERVED_BYTES: usize = 12; +pub const LITERAL_STRING_VALUE_OFFSET: usize = 4; +pub const LITERAL_STRING_RAW_OFFSET: usize = 8; -pub const MEMBER_EXPRESSION_RESERVED_BYTES: usize = 12; +pub const MEMBER_EXPRESSION_RESERVED_BYTES: usize = 16; pub const MEMBER_EXPRESSION_FLAGS_OFFSET: usize = 4; pub const MEMBER_EXPRESSION_COMPUTED_FLAG: u32 = 1; pub const MEMBER_EXPRESSION_OPTIONAL_FLAG: u32 = 2; -pub const MEMBER_EXPRESSION_PROPERTY_OFFSET: usize = 8; +pub const MEMBER_EXPRESSION_OBJECT_OFFSET: usize = 8; +pub const MEMBER_EXPRESSION_PROPERTY_OFFSET: usize = 12; -pub const META_PROPERTY_RESERVED_BYTES: usize = 8; -pub const META_PROPERTY_PROPERTY_OFFSET: usize = 4; +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 = 16; +pub const METHOD_DEFINITION_RESERVED_BYTES: usize = 20; pub const METHOD_DEFINITION_FLAGS_OFFSET: usize = 4; pub const METHOD_DEFINITION_STATIC_FLAG: u32 = 1; pub const METHOD_DEFINITION_COMPUTED_FLAG: u32 = 2; -pub const METHOD_DEFINITION_VALUE_OFFSET: usize = 8; -pub const METHOD_DEFINITION_KIND_OFFSET: usize = 12; +pub const METHOD_DEFINITION_KEY_OFFSET: usize = 8; +pub const METHOD_DEFINITION_VALUE_OFFSET: usize = 12; +pub const METHOD_DEFINITION_KIND_OFFSET: usize = 16; -pub const NEW_EXPRESSION_RESERVED_BYTES: usize = 12; -pub const NEW_EXPRESSION_CALLEE_OFFSET: usize = 4; -pub const NEW_EXPRESSION_ARGUMENTS_OFFSET: usize = 8; +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 OBJECT_EXPRESSION_RESERVED_BYTES: usize = 4; +pub const OBJECT_EXPRESSION_RESERVED_BYTES: usize = 8; +pub const OBJECT_EXPRESSION_PROPERTIES_OFFSET: usize = 4; -pub const OBJECT_PATTERN_RESERVED_BYTES: usize = 4; +pub const OBJECT_PATTERN_RESERVED_BYTES: usize = 8; +pub const OBJECT_PATTERN_PROPERTIES_OFFSET: usize = 4; -pub const PRIVATE_IDENTIFIER_RESERVED_BYTES: usize = 4; +pub const PRIVATE_IDENTIFIER_RESERVED_BYTES: usize = 8; +pub const PRIVATE_IDENTIFIER_NAME_OFFSET: usize = 4; -pub const PROGRAM_RESERVED_BYTES: usize = 8; -pub const PROGRAM_INVALID_ANNOTATIONS_OFFSET: usize = 4; +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_FLAGS_OFFSET: usize = 4; @@ -276,22 +318,27 @@ 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 = 12; +pub const PROPERTY_DEFINITION_RESERVED_BYTES: usize = 16; pub const PROPERTY_DEFINITION_FLAGS_OFFSET: usize = 4; pub const PROPERTY_DEFINITION_STATIC_FLAG: u32 = 1; pub const PROPERTY_DEFINITION_COMPUTED_FLAG: u32 = 2; -pub const PROPERTY_DEFINITION_VALUE_OFFSET: usize = 8; +pub const PROPERTY_DEFINITION_KEY_OFFSET: usize = 8; +pub const PROPERTY_DEFINITION_VALUE_OFFSET: usize = 12; -pub const REST_ELEMENT_RESERVED_BYTES: usize = 4; +pub const REST_ELEMENT_RESERVED_BYTES: usize = 8; +pub const REST_ELEMENT_ARGUMENT_OFFSET: usize = 4; pub const RETURN_STATEMENT_RESERVED_BYTES: usize = 8; pub const RETURN_STATEMENT_ARGUMENT_OFFSET: usize = 4; -pub const SEQUENCE_EXPRESSION_RESERVED_BYTES: usize = 4; +pub const SEQUENCE_EXPRESSION_RESERVED_BYTES: usize = 8; +pub const SEQUENCE_EXPRESSION_EXPRESSIONS_OFFSET: usize = 4; -pub const SPREAD_ELEMENT_RESERVED_BYTES: usize = 4; +pub const SPREAD_ELEMENT_RESERVED_BYTES: usize = 8; +pub const SPREAD_ELEMENT_ARGUMENT_OFFSET: usize = 4; -pub const STATIC_BLOCK_RESERVED_BYTES: usize = 4; +pub const STATIC_BLOCK_RESERVED_BYTES: usize = 8; +pub const STATIC_BLOCK_BODY_OFFSET: usize = 4; pub const SUPER_ELEMENT_RESERVED_BYTES: usize = 4; @@ -299,44 +346,55 @@ pub const SWITCH_CASE_RESERVED_BYTES: usize = 12; pub const SWITCH_CASE_TEST_OFFSET: usize = 4; pub const SWITCH_CASE_CONSEQUENT_OFFSET: usize = 8; -pub const SWITCH_STATEMENT_RESERVED_BYTES: usize = 8; -pub const SWITCH_STATEMENT_CASES_OFFSET: usize = 4; +pub const SWITCH_STATEMENT_RESERVED_BYTES: usize = 12; +pub const SWITCH_STATEMENT_DISCRIMINANT_OFFSET: usize = 4; +pub const SWITCH_STATEMENT_CASES_OFFSET: usize = 8; -pub const TAGGED_TEMPLATE_EXPRESSION_RESERVED_BYTES: usize = 8; -pub const TAGGED_TEMPLATE_EXPRESSION_QUASI_OFFSET: usize = 4; +pub const TAGGED_TEMPLATE_EXPRESSION_RESERVED_BYTES: usize = 12; +pub const TAGGED_TEMPLATE_EXPRESSION_TAG_OFFSET: usize = 4; +pub const TAGGED_TEMPLATE_EXPRESSION_QUASI_OFFSET: usize = 8; -pub const TEMPLATE_ELEMENT_RESERVED_BYTES: usize = 12; +pub const TEMPLATE_ELEMENT_RESERVED_BYTES: usize = 16; pub const TEMPLATE_ELEMENT_FLAGS_OFFSET: usize = 4; pub const TEMPLATE_ELEMENT_TAIL_FLAG: u32 = 1; pub const TEMPLATE_ELEMENT_COOKED_OFFSET: usize = 8; +pub const TEMPLATE_ELEMENT_RAW_OFFSET: usize = 12; -pub const TEMPLATE_LITERAL_RESERVED_BYTES: usize = 8; -pub const TEMPLATE_LITERAL_EXPRESSIONS_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 THIS_EXPRESSION_RESERVED_BYTES: usize = 4; -pub const THROW_STATEMENT_RESERVED_BYTES: usize = 4; +pub const THROW_STATEMENT_RESERVED_BYTES: usize = 8; +pub const THROW_STATEMENT_ARGUMENT_OFFSET: usize = 4; -pub const TRY_STATEMENT_RESERVED_BYTES: usize = 12; -pub const TRY_STATEMENT_HANDLER_OFFSET: usize = 4; -pub const TRY_STATEMENT_FINALIZER_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 UNARY_EXPRESSION_RESERVED_BYTES: usize = 8; +pub const UNARY_EXPRESSION_RESERVED_BYTES: usize = 12; pub const UNARY_EXPRESSION_OPERATOR_OFFSET: usize = 4; +pub const UNARY_EXPRESSION_ARGUMENT_OFFSET: usize = 8; -pub const UPDATE_EXPRESSION_RESERVED_BYTES: usize = 12; +pub const UPDATE_EXPRESSION_RESERVED_BYTES: usize = 16; pub const UPDATE_EXPRESSION_FLAGS_OFFSET: usize = 4; pub const UPDATE_EXPRESSION_PREFIX_FLAG: u32 = 1; pub const UPDATE_EXPRESSION_OPERATOR_OFFSET: usize = 8; +pub const UPDATE_EXPRESSION_ARGUMENT_OFFSET: usize = 12; -pub const VARIABLE_DECLARATION_RESERVED_BYTES: usize = 8; +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 = 8; -pub const VARIABLE_DECLARATOR_INIT_OFFSET: usize = 4; +pub const VARIABLE_DECLARATOR_RESERVED_BYTES: usize = 12; +pub const VARIABLE_DECLARATOR_ID_OFFSET: usize = 4; +pub const VARIABLE_DECLARATOR_INIT_OFFSET: usize = 8; -pub const WHILE_STATEMENT_RESERVED_BYTES: usize = 8; -pub const WHILE_STATEMENT_BODY_OFFSET: usize = 4; +pub const WHILE_STATEMENT_RESERVED_BYTES: usize = 12; +pub const WHILE_STATEMENT_TEST_OFFSET: usize = 4; +pub const WHILE_STATEMENT_BODY_OFFSET: usize = 8; pub const YIELD_EXPRESSION_RESERVED_BYTES: usize = 12; pub const YIELD_EXPRESSION_FLAGS_OFFSET: usize = 4; diff --git a/rust/parse_ast/src/error_emit.rs b/rust/parse_ast/src/error_emit.rs index 6de0043e7..a2af3f6e7 100644 --- a/rust/parse_ast/src/error_emit.rs +++ b/rust/parse_ast/src/error_emit.rs @@ -5,9 +5,10 @@ use parking_lot::Mutex; use swc_common::errors::{DiagnosticBuilder, Emitter, Handler, Level, HANDLER}; use swc_ecma_ast::Program; +use crate::convert_ast::converter::ast_constants::PARSE_ERROR_MESSAGE_OFFSET; use crate::convert_ast::converter::{ - ast_constants::{PARSE_ERROR_RESERVED_BYTES, TYPE_PARSE_ERROR_INLINED_MESSAGE}, - convert_string, + ast_constants::{PARSE_ERROR_RESERVED_BYTES, TYPE_PARSE_ERROR}, + convert_string, update_reference_position, }; #[derive(Clone, Default)] @@ -68,22 +69,26 @@ where } fn create_error_buffer(wr: &Writer, code: &str) -> Vec { - let mut buffer = TYPE_PARSE_ERROR_INLINED_MESSAGE.to_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; } + // type + let mut buffer = TYPE_PARSE_ERROR.to_vec(); // start buffer.extend_from_slice(&utf_16_pos.to_ne_bytes()); // end - buffer.resize(buffer.len() + PARSE_ERROR_RESERVED_BYTES, 0); - // message + 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/lib.rs b/rust/parse_ast/src/lib.rs index 4d334a666..469251e13 100644 --- a/rust/parse_ast/src/lib.rs +++ b/rust/parse_ast/src/lib.rs @@ -1,9 +1,5 @@ use std::panic::{catch_unwind, AssertUnwindSafe}; -use convert_ast::converter::ast_constants::{ - PANIC_ERROR_RESERVED_BYTES, TYPE_PANIC_ERROR_INLINED_MESSAGE, -}; -use convert_ast::converter::{convert_string, AstConverter}; use swc_common::sync::Lrc; use swc_common::{FileName, FilePathMapping, Globals, SourceMap, GLOBALS}; use swc_compiler_base::parse_js; @@ -11,12 +7,16 @@ use swc_compiler_base::IsModule; use swc_ecma_ast::EsVersion; use swc_ecma_parser::{EsConfig, Syntax}; +use convert_ast::converter::ast_constants::{PANIC_ERROR_RESERVED_BYTES, TYPE_PANIC_ERROR}; +use convert_ast::converter::{convert_string, AstConverter}; +use error_emit::try_with_handler; + use crate::convert_ast::annotations::SequentialComments; +use crate::convert_ast::converter::ast_constants::PANIC_ERROR_MESSAGE_OFFSET; +use crate::convert_ast::converter::update_reference_position; mod convert_ast; -use error_emit::try_with_handler; - mod error_emit; pub fn parse_ast(code: String, allow_return_outside_function: bool) -> Vec { @@ -63,9 +63,13 @@ pub fn parse_ast(code: String, allow_return_outside_function: bool) -> Vec { } else { "Unknown rust panic message" }; - let mut buffer = TYPE_PANIC_ERROR_INLINED_MESSAGE.to_vec(); + // type + let mut buffer = TYPE_PANIC_ERROR.to_vec(); // reserve for start and end even though they are unused - buffer.resize(buffer.len() + 4 + PANIC_ERROR_RESERVED_BYTES, 0); + 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, msg); buffer }) diff --git a/scripts/ast-types.js b/scripts/ast-types.js index 820d525a0..8191fa3b1 100644 --- a/scripts/ast-types.js +++ b/scripts/ast-types.js @@ -158,19 +158,22 @@ export const AST_NODES = { ClassBody: { fields: [['body', 'NodeList']], scriptedFields: { - body: `const length = buffer[$position]; + body: ` const bodyPosition = $position; const body: (MethodDefinition | PropertyDefinition)[] = (node.body = []); - for (let index = 0; index < length; index++) { - const nodePosition = buffer[$position + 1 + index]; - body.push( - convertNode( - node, - (buffer[nodePosition + 3] & 1) === 0 ? scope.instanceScope : scope, - nodePosition, - buffer, - readString - ) - ); + if (bodyPosition) { + const length = buffer[bodyPosition]; + for (let index = 0; index < length; index++) { + const nodePosition = buffer[bodyPosition + 1 + index]; + body.push( + convertNode( + node, + (buffer[nodePosition + 3] & 1) === 0 ? scope.instanceScope : scope, + nodePosition, + buffer, + readString + ) + ); + } }` } }, @@ -638,56 +641,15 @@ export const AST_NODES = { } }; -export const astNodeNamesWithFieldOrder = Object.entries(AST_NODES).map(([name, node]) => { - /** @type {FieldWithType[]} */ - const fields = - (node.hasSameFieldsAs ? AST_NODES[node.hasSameFieldsAs].fields : node.fields) || []; - /** @type {FieldWithType[]} */ - const allFields = []; - /** @type {FieldWithType[]} */ - const reservedFields = []; - /** @type {FieldWithType|null|undefined} */ - let inlinedVariableField = undefined; - for (const field of fields) { - allFields.push(field); - switch (field[1]) { - case 'Annotations': - case 'InvalidAnnotations': - case 'String': - case 'NodeList': - case 'Node': { - if (inlinedVariableField === undefined) { - inlinedVariableField = field; - } else { - reservedFields.push(field); - } - break; - } - case 'OptionalNode': { - // Optional nodes cannot be inlined, but they also cannot be parsed - // out-of-order, so nothing is inlined as the inlined node is always - // parsed first. - if (inlinedVariableField === undefined) { - inlinedVariableField = null; - } - reservedFields.push(field); - break; - } - case 'OptionalString': - case 'FixedString': - case 'Float': { - reservedFields.push(field); - break; - } - default: { - throw new Error(`Unknown field type ${field[0]}`); - } - } - } +/** @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 { - allFields, - inlinedVariableField, + fields: node.fields || [], name, - reservedFields + node, + originalNode }; }); diff --git a/scripts/generate-buffer-parsers.js b/scripts/generate-buffer-parsers.js index 6e498f366..4faa9e7c7 100644 --- a/scripts/generate-buffer-parsers.js +++ b/scripts/generate-buffer-parsers.js @@ -1,96 +1,84 @@ import { writeFile } from 'node:fs/promises'; -import { AST_NODES, astNodeNamesWithFieldOrder } from './ast-types.js'; -import { getNode } from './generate-buffer-to-ast.js'; +import { astNodeNamesWithFieldOrder } from './ast-types.js'; import { firstLetterLowercase, lintTsFile } from './helpers.js'; const bufferParsersFile = new URL('../src/ast/bufferParsers.ts', import.meta.url); -const nodeTypes = astNodeNamesWithFieldOrder.map(({ name }) => getNode(name).astType || name); +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, inlinedVariableField, reservedFields, allFields }) => { - const node = getNode(name); - const readStringArgument = allFields.some(([, fieldType]) => - ['Node', 'OptionalNode', 'NodeList', 'String', 'FixedString', 'OptionalString'].includes( - fieldType - ) +const jsConverters = astNodeNamesWithFieldOrder.map(({ name, fields, node, originalNode }) => { + const readStringArgument = fields.some(([, fieldType]) => + ['Node', 'OptionalNode', 'NodeList', 'String', 'FixedString', 'OptionalString'].includes( + fieldType ) - ? ', readString' - : ''; - /** @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 reservedFields.entries()) { - const fieldDefinition = getFieldDefinition(field, name, offset + index, false); - needsBuffer = true; - needsScope ||= fieldDefinition.needsScope; - definitions.push(`${fieldDefinition.definition}\n`); - } - offset += reservedFields.length; - if (inlinedVariableField) { - const fieldDefinition = getFieldDefinition(inlinedVariableField, name, offset, true); - needsBuffer = true; - needsScope ||= fieldDefinition.needsScope; - definitions.push(`${fieldDefinition.definition}\n`); - } - 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, readString);\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${readStringArgument}`); - } + ) + ? ', readString' + : ''; + /** @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, readString);\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${readStringArgument}`); } - return `function ${firstLetterLowercase(name)} (${parameters.join(', ')}) { - ${definitions.join('')}}`; } -); + return `function ${firstLetterLowercase(name)} (${parameters.join(', ')}) { + ${definitions.join('')}}`; +}); /** - * @param {import('./ast-types.js').FieldWithType} field - * @param {string} 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 - * @param {boolean} isInlined * @returns {{definition: string, needsScope: boolean}} */ -function getFieldDefinition([fieldName, fieldType], name, offset, isInlined) { - const originalNode = AST_NODES[name]; - const node = getNode(name); +function getFieldDefinition([fieldName, fieldType], node, originalNode, offset) { const getPosition = offset > 0 ? `position + ${offset}` : 'position'; - const dataStart = isInlined ? getPosition : `buffer[${getPosition}]`; + const dataStart = `buffer[${getPosition}]`; if (node.scriptedFields?.[fieldName]) { return { definition: node.scriptedFields?.[fieldName].replace(/\$position/g, dataStart), @@ -114,7 +102,7 @@ function getFieldDefinition([fieldName, fieldType], name, offset, isInlined) { }; } case 'OptionalNode': { - let definition = `const ${fieldName}Position = buffer[${getPosition}];`; + let definition = `const ${fieldName}Position = ${dataStart};`; let needsScope = false; if (!node.optionalFallback?.[fieldName]) { needsScope = true; @@ -158,13 +146,13 @@ function getFieldDefinition([fieldName, fieldType], name, offset, isInlined) { } case 'OptionalString': { return { - definition: `const ${fieldName}Position = buffer[${getPosition}];\n${assignmentLeftHand}${fieldName}Position === 0 ? undefined : convertString(${fieldName}Position, buffer, readString)${typeCastString};`, + definition: `const ${fieldName}Position = ${dataStart};\n${assignmentLeftHand}${fieldName}Position === 0 ? undefined : convertString(${fieldName}Position, buffer, readString)${typeCastString};`, needsScope: false }; } case 'FixedString': { return { - definition: `${assignmentLeftHand}FIXED_STRINGS[buffer[${getPosition}]]${typeCastString};`, + definition: `${assignmentLeftHand}FIXED_STRINGS[${dataStart}]${typeCastString};`, needsScope: false }; } @@ -186,6 +174,7 @@ const bufferParsers = `// This file is generated by scripts/generate-ast-convert import type * as estree from 'estree'; import type { AstContext } from '../Module'; import { convertAnnotations, convertString } 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 { ReadString } from '../utils/getReadStringFunction'; @@ -242,6 +231,7 @@ function convertNode(parent: Node | { context: AstContext; type: string }, paren } function convertNodeList(parent: Node | { context: AstContext; type: string }, parentScope: ChildScope, position: number, buffer: Uint32Array, readString: ReadString): any[] { + if (position === 0) return EMPTY_ARRAY as never[]; const length = buffer[position++]; const list: any[] = []; for (let index = 0; index < length; index++) { diff --git a/scripts/generate-buffer-to-ast.js b/scripts/generate-buffer-to-ast.js index 0fa8d6136..78c3dbf35 100644 --- a/scripts/generate-buffer-to-ast.js +++ b/scripts/generate-buffer-to-ast.js @@ -1,55 +1,48 @@ import { writeFile } from 'node:fs/promises'; -import { AST_NODES, astNodeNamesWithFieldOrder } from './ast-types.js'; +import { astNodeNamesWithFieldOrder } from './ast-types.js'; import { firstLetterLowercase, lintTsFile } from './helpers.js'; const bufferToJsAstFile = new URL('../src/utils/bufferToAst.ts', import.meta.url); -const jsConverters = astNodeNamesWithFieldOrder.map( - ({ name, inlinedVariableField, reservedFields, allFields }) => { - const node = getNode(name); - const readStringArgument = allFields.some(([, fieldType]) => - ['Node', 'OptionalNode', 'NodeList', 'String', 'FixedString', 'OptionalString'].includes( - fieldType - ) +const jsConverters = astNodeNamesWithFieldOrder.map(({ name, fields, node, originalNode }) => { + const readStringArgument = fields.some(([, fieldType]) => + ['Node', 'OptionalNode', 'NodeList', 'String', 'FixedString', 'OptionalString'].includes( + fieldType ) - ? ', readString' - : ''; - /** @type {string[]} */ - const definitions = []; - if (node.flags) { - definitions.push( - 'const flags = buffer[position++];\n', - ...node.flags.map( - (name, index) => - `const ${node.variableNames?.[name] || name} = (flags & ${1 << index}) === ${ - 1 << index - };` - ) - ); - } - for (const [index, field] of reservedFields.entries()) { - definitions.push( - `${getFieldDefinition(field, name, false, index === allFields.length - 1)}\n` - ); - } - if (inlinedVariableField) { - definitions.push(`${getFieldDefinition(inlinedVariableField, name, true, true)}\n`); - } - /** @type {string[]} */ - const properties = [ - ...(node.flags || []).map(name => { - const alternativeVariableName = node.variableNames?.[name]; - return alternativeVariableName ? `${name}: ${alternativeVariableName}` : name; - }), - ...allFields - .filter(([fieldName]) => !node.hiddenFields?.includes(fieldName)) - .map(field => getFieldProperty(field, node)), - ...getFixedProperties(node), - ...Object.entries(node.additionalFields || []).map(([key, value]) => `${key}: ${value}`) - ]; - return `function ${firstLetterLowercase( - name - )} (position, buffer${readStringArgument}): ${name}Node { + ) + ? ', readString' + : ''; + /** @type {string[]} */ + const definitions = []; + if (node.flags) { + definitions.push( + 'const flags = buffer[position++];\n', + ...node.flags.map( + (name, index) => + `const ${node.variableNames?.[name] || name} = (flags & ${1 << index}) === ${1 << index};` + ) + ); + } + for (const [index, field] of fields.entries()) { + definitions.push( + `${getFieldDefinition(field, node, originalNode, index === fields.length - 1)}\n` + ); + } + /** @type {string[]} */ + const properties = [ + ...(node.flags || []).map(name => { + const alternativeVariableName = node.variableNames?.[name]; + return alternativeVariableName ? `${name}: ${alternativeVariableName}` : name; + }), + ...fields + .filter(([fieldName]) => !node.hiddenFields?.includes(fieldName)) + .map(field => getFieldProperty(field, node)), + ...getFixedProperties(node), + ...Object.entries(node.additionalFields || []).map(([key, value]) => `${key}: ${value}`) + ]; + return `function ${firstLetterLowercase( + name + )} (position, buffer${readStringArgument}): ${name}Node { const start = buffer[position++]; const end = buffer[position++]; ${definitions.join('')}return { @@ -59,41 +52,27 @@ const jsConverters = astNodeNamesWithFieldOrder.map( ${properties.join(',\n')} }; }`; - } -); - -/** - * @param {string} name - * @return {import("./ast-types.js").NodeDescription} - */ -export function getNode(name) { - const referencedNode = AST_NODES[name]; - return referencedNode.hasSameFieldsAs - ? AST_NODES[referencedNode.hasSameFieldsAs] - : referencedNode; -} +}); /** - * @param {import('./ast-types.js').FieldWithType} field - * @param {string} name - * @param {boolean} isInlined + * @param {import("./ast-types.js").FieldWithType} field + * @param {import("./ast-types.js").NodeDescription} node + * @param {import("./ast-types.js").NodeDescription} originalNode * @param {boolean} isLastField * @returns {string} */ -function getFieldDefinition([fieldName, fieldType], name, isInlined, isLastField) { - const originalNode = AST_NODES[name]; - const node = getNode(name); +function getFieldDefinition([fieldName, fieldType], node, originalNode, isLastField) { const typeCast = originalNode.fieldTypes?.[fieldName] || node.fieldTypes?.[fieldName]; const typeCastString = typeCast ? ` as ${typeCast}` : ''; const getAndUpdatePosition = isLastField ? 'position' : 'position++'; - const dataStart = isInlined ? getAndUpdatePosition : `buffer[${getAndUpdatePosition}]`; + const dataStart = `buffer[${getAndUpdatePosition}]`; const variableName = node.variableNames?.[fieldName] || fieldName; switch (fieldType) { case 'Node': { return `const ${variableName} = convertNode(${dataStart}, buffer, readString)${typeCastString};`; } case 'OptionalNode': { - let definition = `const ${fieldName}Position = buffer[${getAndUpdatePosition}];`; + let definition = `const ${fieldName}Position = ${dataStart};`; if (!node.optionalFallback?.[fieldName]) { definition += `\nconst ${variableName} = ${fieldName}Position === 0 ? null : convertNode(${fieldName}Position, buffer, readString)${typeCastString};`; } @@ -110,10 +89,10 @@ function getFieldDefinition([fieldName, fieldType], name, isInlined, isLastField return `const ${variableName} = convertString(${dataStart}, buffer, readString)${typeCastString};`; } case 'OptionalString': { - return `const ${fieldName}Position = buffer[${getAndUpdatePosition}];\nconst ${variableName} = ${fieldName}Position === 0 ? undefined : convertString(${fieldName}Position, buffer, readString)${typeCastString};`; + return `const ${fieldName}Position = ${dataStart};\nconst ${variableName} = ${fieldName}Position === 0 ? undefined : convertString(${fieldName}Position, buffer, readString)${typeCastString};`; } case 'FixedString': { - return `const ${variableName} = FIXED_STRINGS[buffer[${getAndUpdatePosition}]]${typeCastString};`; + return `const ${variableName} = FIXED_STRINGS[${dataStart}]${typeCastString};`; } case 'Float': { return `const ${variableName} = new DataView(buffer.buffer).getFloat64(${getAndUpdatePosition} << 2, true);`; @@ -125,8 +104,8 @@ function getFieldDefinition([fieldName, fieldType], name, isInlined, isLastField } /** - * @param {import('./ast-types.js').FieldWithType} field - * @param {import('./ast-types.js').NodeDescription} node + * @param {import("./ast-types.js").FieldWithType} field + * @param {import("./ast-types.js").NodeDescription} node * @returns {string} */ function getFieldProperty([fieldName, fieldType], node) { @@ -149,23 +128,22 @@ function getFieldProperty([fieldName, fieldType], node) { } /** - * @param {import('./ast-types.js').NodeDescription} node + * @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 }) => { - const node = getNode(name); +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]?: RollupAnnotation[]'); + additionalFieldTypes.push('[ANNOTATION_KEY]?: readonly RollupAnnotation[]'); } if ((node.fields || []).some(([, fieldType]) => fieldType === 'InvalidAnnotations')) { - additionalFieldTypes.push('[INVALID_ANNOTATION_KEY]?: RollupAnnotation[]'); + additionalFieldTypes.push('[INVALID_ANNOTATION_KEY]?: readonly RollupAnnotation[]'); } const fixedProperties = getFixedProperties(node); if (fixedProperties.length > 0) { @@ -190,6 +168,7 @@ import { convertString, INVALID_ANNOTATION_KEY } from './astConverterHelpers'; +import { EMPTY_ARRAY } from '../utils/blank'; import FIXED_STRINGS from './convert-ast-strings'; import type { ReadString } from './getReadStringFunction'; import { error, getRollupError, logParseError } from './logs'; @@ -228,6 +207,7 @@ export function convertNode(position: number, buffer: Uint32Array, readString: R } function convertNodeList(position: number, buffer: Uint32Array, readString: ReadString): any[] { + if (position === 0) return EMPTY_ARRAY as never[]; const length = buffer[position++]; const list: any[] = []; for (let index = 0; index < length; index++) { diff --git a/scripts/generate-rust-constants.js b/scripts/generate-rust-constants.js index 1ea928efa..f7c84365e 100644 --- a/scripts/generate-rust-constants.js +++ b/scripts/generate-rust-constants.js @@ -15,15 +15,13 @@ const astConstantsFile = new URL( const nodeTypes = astNodeNamesWithFieldOrder .map( - ({ name, inlinedVariableField }, index) => - `pub const TYPE_${toScreamingSnakeCase(name)}${ - inlinedVariableField ? `_INLINED_${toScreamingSnakeCase(inlinedVariableField[0])}` : '' - }: [u8; 4] = ${index}u32.to_ne_bytes();` + ({ name }, index) => + `pub const TYPE_${toScreamingSnakeCase(name)}: [u8; 4] = ${index}u32.to_ne_bytes();` ) .join('\n'); const reservedBytesAndOffsets = astNodeNamesWithFieldOrder - .map(({ name, reservedFields }) => { + .map(({ name, fields }) => { const { flags, hasSameFieldsAs } = AST_NODES[name]; if (hasSameFieldsAs) { return ''; @@ -46,7 +44,7 @@ const reservedBytesAndOffsets = astNodeNamesWithFieldOrder ); } } - for (const [fieldName, fieldType] of reservedFields) { + for (const [fieldName, fieldType] of fields) { lines.push( `pub const ${toScreamingSnakeCase(name)}_${toScreamingSnakeCase( fieldName diff --git a/src/ast/bufferParsers.ts b/src/ast/bufferParsers.ts index 35be3c7b0..04da5938a 100644 --- a/src/ast/bufferParsers.ts +++ b/src/ast/bufferParsers.ts @@ -4,6 +4,7 @@ import type * as estree from 'estree'; import type { AstContext } from '../Module'; import { convertAnnotations, convertString } 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 { ReadString } from '../utils/getReadStringFunction'; @@ -273,18 +274,18 @@ const bufferParsers: (( readString: ReadString ) => void)[] = [ function panicError(node: PanicError, position, buffer, readString) { - node.message = convertString(position, buffer, readString); + node.message = convertString(buffer[position], buffer, readString); }, function parseError(node: ParseError, position, buffer, readString) { - node.message = convertString(position, buffer, readString); + node.message = convertString(buffer[position], buffer, readString); }, function arrayExpression(node: ArrayExpression, position, buffer, readString) { const { scope } = node; - node.elements = convertNodeList(node, scope, position, buffer, readString); + node.elements = convertNodeList(node, scope, buffer[position], buffer, readString); }, function arrayPattern(node: ArrayPattern, position, buffer, readString) { const { scope } = node; - node.elements = convertNodeList(node, scope, position, buffer, readString); + node.elements = convertNodeList(node, scope, buffer[position], buffer, readString); }, function arrowFunctionExpression(node: ArrowFunctionExpression, position, buffer, readString) { const { scope } = node; @@ -292,10 +293,12 @@ const bufferParsers: (( 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 + 1], + buffer[position + 2], buffer, readString )); @@ -305,34 +308,32 @@ const bufferParsers: (( ), parameters[parameters.length - 1] instanceof RestElement ); - node.body = convertNode(node, scope.bodyScope, buffer[position + 2], buffer, readString); - const annotations = (node.annotations = convertAnnotations(position + 3, buffer)); - node.annotationNoSideEffects = annotations.some(comment => comment.type === 'noSideEffects'); + node.body = convertNode(node, scope.bodyScope, buffer[position + 3], buffer, readString); }, function assignmentExpression(node: AssignmentExpression, position, buffer, readString) { const { scope } = node; node.operator = FIXED_STRINGS[buffer[position]] as estree.AssignmentOperator; - node.right = convertNode(node, scope, buffer[position + 1], buffer, readString); - node.left = convertNode(node, scope, position + 2, buffer, readString); + node.left = convertNode(node, scope, buffer[position + 1], buffer, readString); + node.right = convertNode(node, scope, buffer[position + 2], buffer, readString); }, function assignmentPattern(node: AssignmentPattern, position, buffer, readString) { const { scope } = node; - node.right = convertNode(node, scope, buffer[position], buffer, readString); - node.left = convertNode(node, scope, position + 1, buffer, readString); + node.left = convertNode(node, scope, buffer[position], buffer, readString); + node.right = convertNode(node, scope, buffer[position + 1], buffer, readString); }, function awaitExpression(node: AwaitExpression, position, buffer, readString) { const { scope } = node; - node.argument = convertNode(node, scope, position, buffer, readString); + node.argument = convertNode(node, scope, buffer[position], buffer, readString); }, function binaryExpression(node: BinaryExpression, position, buffer, readString) { const { scope } = node; node.operator = FIXED_STRINGS[buffer[position]] as estree.BinaryOperator; - node.right = convertNode(node, scope, buffer[position + 1], buffer, readString); - node.left = convertNode(node, scope, position + 2, buffer, readString); + node.left = convertNode(node, scope, buffer[position + 1], buffer, readString); + node.right = convertNode(node, scope, buffer[position + 2], buffer, readString); }, function blockStatement(node: BlockStatement, position, buffer, readString) { const { scope } = node; - node.body = convertNodeList(node, scope, position, buffer, readString); + node.body = convertNodeList(node, scope, buffer[position], buffer, readString); }, function breakStatement(node: BreakStatement, position, buffer, readString) { const { scope } = node; @@ -344,9 +345,9 @@ const bufferParsers: (( const { scope } = node; const flags = buffer[position]; node.optional = (flags & 1) === 1; - node.callee = convertNode(node, scope, buffer[position + 1], buffer, readString); - node.arguments = convertNodeList(node, scope, buffer[position + 2], buffer, readString); - node.annotations = convertAnnotations(position + 3, buffer); + node.annotations = convertAnnotations(buffer[position + 1], buffer); + node.callee = convertNode(node, scope, buffer[position + 2], buffer, readString); + node.arguments = convertNodeList(node, scope, buffer[position + 3], buffer, readString); }, function catchClause(node: CatchClause, position, buffer, readString) { const { scope } = node; @@ -360,23 +361,26 @@ const bufferParsers: (( }, function chainExpression(node: ChainExpression, position, buffer, readString) { const { scope } = node; - node.expression = convertNode(node, scope, position, buffer, readString); + node.expression = convertNode(node, scope, buffer[position], buffer, readString); }, function classBody(node: ClassBody, position, buffer, readString) { const { scope } = node; - const length = buffer[position]; + const bodyPosition = buffer[position]; const body: (MethodDefinition | PropertyDefinition)[] = (node.body = []); - for (let index = 0; index < length; index++) { - const nodePosition = buffer[position + 1 + index]; - body.push( - convertNode( - node, - (buffer[nodePosition + 3] & 1) === 0 ? scope.instanceScope : scope, - nodePosition, - buffer, - readString - ) - ); + if (bodyPosition) { + const length = buffer[bodyPosition]; + for (let index = 0; index < length; index++) { + const nodePosition = buffer[bodyPosition + 1 + index]; + body.push( + convertNode( + node, + (buffer[nodePosition + 3] & 1) === 0 ? scope.instanceScope : scope, + nodePosition, + buffer, + readString + ) + ); + } } }, function classDeclaration(node: ClassDeclaration, position, buffer, readString) { @@ -406,9 +410,9 @@ const bufferParsers: (( }, function conditionalExpression(node: ConditionalExpression, position, buffer, readString) { const { scope } = node; - node.consequent = convertNode(node, scope, buffer[position], buffer, readString); - node.alternate = convertNode(node, scope, buffer[position + 1], buffer, readString); - node.test = convertNode(node, scope, position + 2, buffer, readString); + node.test = convertNode(node, scope, buffer[position], buffer, readString); + node.consequent = convertNode(node, scope, buffer[position + 1], buffer, readString); + node.alternate = convertNode(node, scope, buffer[position + 2], buffer, readString); }, function continueStatement(node: ContinueStatement, position, buffer, readString) { const { scope } = node; @@ -419,13 +423,13 @@ const bufferParsers: (( function debuggerStatement() {}, function directive(node: ExpressionStatement, position, buffer, readString) { const { scope } = node; - node.expression = convertNode(node, scope, buffer[position], buffer, readString); - node.directive = convertString(position + 1, buffer, readString); + node.directive = convertString(buffer[position], buffer, readString); + node.expression = convertNode(node, scope, buffer[position + 1], buffer, readString); }, function doWhileStatement(node: DoWhileStatement, position, buffer, readString) { const { scope } = node; - node.test = convertNode(node, scope, buffer[position], buffer, readString); - node.body = convertNode(node, scope, position + 1, buffer, readString); + node.body = convertNode(node, scope, buffer[position], buffer, readString); + node.test = convertNode(node, scope, buffer[position + 1], buffer, readString); }, function emptyStatement() {}, function exportAllDeclaration(node: ExportAllDeclaration, position, buffer, readString) { @@ -440,25 +444,25 @@ const bufferParsers: (( }, function exportDefaultDeclaration(node: ExportDefaultDeclaration, position, buffer, readString) { const { scope } = node; - node.declaration = convertNode(node, scope, position, buffer, readString); + node.declaration = convertNode(node, scope, buffer[position], buffer, readString); }, function exportNamedDeclaration(node: ExportNamedDeclaration, position, buffer, readString) { const { scope } = node; - const sourcePosition = buffer[position]; + node.specifiers = convertNodeList(node, scope, buffer[position], buffer, readString); + const sourcePosition = buffer[position + 1]; node.source = sourcePosition === 0 ? null : convertNode(node, scope, sourcePosition, buffer, readString); - node.attributes = convertNodeList(node, scope, buffer[position + 1], buffer, readString); - const declarationPosition = buffer[position + 2]; + node.attributes = convertNodeList(node, scope, buffer[position + 2], buffer, readString); + const declarationPosition = buffer[position + 3]; node.declaration = declarationPosition === 0 ? null : convertNode(node, scope, declarationPosition, buffer, readString); - node.specifiers = convertNodeList(node, scope, position + 3, buffer, readString); }, function exportSpecifier(node: ExportSpecifier, position, buffer, readString) { const { scope } = node; - const exportedPosition = buffer[position]; - node.local = convertNode(node, scope, position + 1, buffer, readString); + node.local = convertNode(node, scope, buffer[position], buffer, readString); + const exportedPosition = buffer[position + 1]; node.exported = exportedPosition === 0 ? node.local @@ -466,21 +470,21 @@ const bufferParsers: (( }, function expressionStatement(node: ExpressionStatement, position, buffer, readString) { const { scope } = node; - node.expression = convertNode(node, scope, position, buffer, readString); + node.expression = convertNode(node, scope, buffer[position], buffer, readString); }, function forInStatement(node: ForInStatement, position, buffer, readString) { const { scope } = node; - node.right = convertNode(node, scope, buffer[position], buffer, readString); - node.body = convertNode(node, scope, buffer[position + 1], buffer, readString); - node.left = convertNode(node, scope, position + 2, buffer, readString); + node.left = convertNode(node, scope, buffer[position], buffer, readString); + node.right = convertNode(node, scope, buffer[position + 1], buffer, readString); + node.body = convertNode(node, scope, buffer[position + 2], buffer, readString); }, function forOfStatement(node: ForOfStatement, position, buffer, readString) { const { scope } = node; const flags = buffer[position]; node.await = (flags & 1) === 1; - node.right = convertNode(node, scope, buffer[position + 1], buffer, readString); - node.body = convertNode(node, scope, buffer[position + 2], buffer, readString); - node.left = convertNode(node, scope, position + 3, buffer, readString); + node.left = convertNode(node, scope, buffer[position + 1], buffer, readString); + node.right = convertNode(node, scope, buffer[position + 2], buffer, readString); + node.body = convertNode(node, scope, buffer[position + 3], buffer, readString); }, function forStatement(node: ForStatement, position, buffer, readString) { const { scope } = node; @@ -500,7 +504,9 @@ const bufferParsers: (( const flags = buffer[position]; node.async = (flags & 1) === 1; node.generator = (flags & 2) === 2; - const idPosition = buffer[position + 1]; + 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 @@ -508,7 +514,7 @@ const bufferParsers: (( const parameters = (node.params = convertNodeList( node, scope, - buffer[position + 2], + buffer[position + 3], buffer, readString )); @@ -518,22 +524,22 @@ const bufferParsers: (( ), parameters[parameters.length - 1] instanceof RestElement ); - node.body = convertNode(node, scope.bodyScope, buffer[position + 3], buffer, readString); - const annotations = (node.annotations = convertAnnotations(position + 4, buffer)); - node.annotationNoSideEffects = annotations.some(comment => comment.type === 'noSideEffects'); + node.body = convertNode(node, scope.bodyScope, buffer[position + 4], buffer, readString); }, function functionExpression(node: FunctionExpression, position, buffer, readString) { const { scope } = node; const flags = buffer[position]; node.async = (flags & 1) === 1; node.generator = (flags & 2) === 2; - const idPosition = buffer[position + 1]; + 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, readString); const parameters = (node.params = convertNodeList( node, scope, - buffer[position + 2], + buffer[position + 3], buffer, readString )); @@ -543,23 +549,22 @@ const bufferParsers: (( ), parameters[parameters.length - 1] instanceof RestElement ); - node.body = convertNode(node, scope.bodyScope, buffer[position + 3], buffer, readString); - const annotations = (node.annotations = convertAnnotations(position + 4, buffer)); - node.annotationNoSideEffects = annotations.some(comment => comment.type === 'noSideEffects'); + node.body = convertNode(node, scope.bodyScope, buffer[position + 4], buffer, readString); }, function identifier(node: Identifier, position, buffer, readString) { - node.name = convertString(position, buffer, readString); + node.name = convertString(buffer[position], buffer, readString); }, function ifStatement(node: IfStatement, position, buffer, readString) { const { scope } = node; + node.test = convertNode(node, scope, buffer[position], buffer, readString); node.consequent = convertNode( node, (node.consequentScope = new TrackingScope(scope)), - buffer[position], + buffer[position + 1], buffer, readString ); - const alternatePosition = buffer[position + 1]; + const alternatePosition = buffer[position + 2]; node.alternate = alternatePosition === 0 ? null @@ -570,34 +575,33 @@ const bufferParsers: (( buffer, readString ); - node.test = convertNode(node, scope, position + 2, buffer, readString); }, function importAttribute(node: ImportAttribute, position, buffer, readString) { const { scope } = node; - node.value = convertNode(node, scope, buffer[position], buffer, readString); - node.key = convertNode(node, scope, position + 1, buffer, readString); + node.key = convertNode(node, scope, buffer[position], buffer, readString); + node.value = convertNode(node, scope, buffer[position + 1], buffer, readString); }, function importDeclaration(node: ImportDeclaration, position, buffer, readString) { const { scope } = node; - node.source = convertNode(node, scope, buffer[position], buffer, readString); - node.attributes = convertNodeList(node, scope, buffer[position + 1], buffer, readString); - node.specifiers = convertNodeList(node, scope, position + 2, buffer, readString); + node.specifiers = convertNodeList(node, scope, buffer[position], buffer, readString); + node.source = convertNode(node, scope, buffer[position + 1], buffer, readString); + node.attributes = convertNodeList(node, scope, buffer[position + 2], buffer, readString); }, function importDefaultSpecifier(node: ImportDefaultSpecifier, position, buffer, readString) { const { scope } = node; - node.local = convertNode(node, scope, position, buffer, readString); + node.local = convertNode(node, scope, buffer[position], buffer, readString); }, function importExpression(node: ImportExpression, position, buffer, readString) { const { scope } = node; - const optionsPosition = buffer[position]; + node.source = convertNode(node, scope, buffer[position], buffer, readString); + node.sourceAstNode = convertJsonNode(buffer[position], buffer, readString); + const optionsPosition = buffer[position + 1]; node.options = optionsPosition === 0 ? null : convertNode(node, scope, optionsPosition, buffer, readString); - node.source = convertNode(node, scope, position + 1, buffer, readString); - node.sourceAstNode = convertJsonNode(position + 1, buffer, readString); }, function importNamespaceSpecifier(node: ImportNamespaceSpecifier, position, buffer, readString) { const { scope } = node; - node.local = convertNode(node, scope, position, buffer, readString); + node.local = convertNode(node, scope, buffer[position], buffer, readString); }, function importSpecifier(node: ImportSpecifier, position, buffer, readString) { const { scope } = node; @@ -610,12 +614,12 @@ const bufferParsers: (( }, function labeledStatement(node: LabeledStatement, position, buffer, readString) { const { scope } = node; - node.body = convertNode(node, scope, buffer[position], buffer, readString); - node.label = convertNode(node, scope, position + 1, buffer, readString); + node.label = convertNode(node, scope, buffer[position], buffer, readString); + node.body = convertNode(node, scope, buffer[position + 1], buffer, readString); }, function literalBigInt(node: Literal, position, buffer, readString) { - node.raw = convertString(buffer[position], buffer, readString); - const bigint = (node.bigint = convertString(position + 1, buffer, readString)); + const bigint = (node.bigint = convertString(buffer[position], buffer, readString)); + node.raw = convertString(buffer[position + 1], buffer, readString); node.value = BigInt(bigint); }, function literalBoolean(node: Literal, position, buffer) { @@ -632,66 +636,66 @@ const bufferParsers: (( node.value = new DataView(buffer.buffer).getFloat64((position + 1) << 2, true); }, function literalRegExp(node: Literal, position, buffer, readString) { - const pattern = convertString(buffer[position], buffer, readString); - const flags = convertString(position + 1, buffer, readString); + const flags = convertString(buffer[position], buffer, readString); + const pattern = convertString(buffer[position + 1], buffer, readString); node.raw = `/${pattern}/${flags}`; node.regex = { flags, pattern }; node.value = new RegExp(pattern, flags); }, function literalString(node: Literal, position, buffer, readString) { - const rawPosition = buffer[position]; + node.value = convertString(buffer[position], buffer, readString); + const rawPosition = buffer[position + 1]; node.raw = rawPosition === 0 ? undefined : convertString(rawPosition, buffer, readString); - node.value = convertString(position + 1, buffer, readString); }, function logicalExpression(node: LogicalExpression, position, buffer, readString) { const { scope } = node; node.operator = FIXED_STRINGS[buffer[position]] as estree.LogicalOperator; - node.right = convertNode(node, scope, buffer[position + 1], buffer, readString); - node.left = convertNode(node, scope, position + 2, buffer, readString); + node.left = convertNode(node, scope, buffer[position + 1], buffer, readString); + node.right = convertNode(node, scope, buffer[position + 2], buffer, readString); }, function memberExpression(node: MemberExpression, position, buffer, readString) { const { scope } = node; const flags = buffer[position]; node.computed = (flags & 1) === 1; node.optional = (flags & 2) === 2; - node.property = convertNode(node, scope, buffer[position + 1], buffer, readString); - node.object = convertNode(node, scope, position + 2, buffer, readString); + node.object = convertNode(node, scope, buffer[position + 1], buffer, readString); + node.property = convertNode(node, scope, buffer[position + 2], buffer, readString); }, function metaProperty(node: MetaProperty, position, buffer, readString) { const { scope } = node; - node.property = convertNode(node, scope, buffer[position], buffer, readString); - node.meta = convertNode(node, scope, position + 1, buffer, readString); + node.meta = convertNode(node, scope, buffer[position], buffer, readString); + node.property = convertNode(node, scope, buffer[position + 1], buffer, readString); }, function methodDefinition(node: MethodDefinition, position, buffer, readString) { const { scope } = node; const flags = buffer[position]; node.static = (flags & 1) === 1; node.computed = (flags & 2) === 2; - node.value = convertNode(node, scope, buffer[position + 1], buffer, readString); - node.kind = FIXED_STRINGS[buffer[position + 2]] as estree.MethodDefinition['kind']; - node.key = convertNode(node, scope, position + 3, buffer, readString); + node.key = convertNode(node, scope, buffer[position + 1], buffer, readString); + node.value = convertNode(node, scope, buffer[position + 2], buffer, readString); + node.kind = FIXED_STRINGS[buffer[position + 3]] as estree.MethodDefinition['kind']; }, function newExpression(node: NewExpression, position, buffer, readString) { const { scope } = node; - node.callee = convertNode(node, scope, buffer[position], buffer, readString); - node.arguments = convertNodeList(node, scope, buffer[position + 1], buffer, readString); - node.annotations = convertAnnotations(position + 2, buffer); + node.annotations = convertAnnotations(buffer[position], buffer); + node.callee = convertNode(node, scope, buffer[position + 1], buffer, readString); + node.arguments = convertNodeList(node, scope, buffer[position + 2], buffer, readString); }, function objectExpression(node: ObjectExpression, position, buffer, readString) { const { scope } = node; - node.properties = convertNodeList(node, scope, position, buffer, readString); + node.properties = convertNodeList(node, scope, buffer[position], buffer, readString); }, function objectPattern(node: ObjectPattern, position, buffer, readString) { const { scope } = node; - node.properties = convertNodeList(node, scope, position, buffer, readString); + node.properties = convertNodeList(node, scope, buffer[position], buffer, readString); }, function privateIdentifier(node: PrivateIdentifier, position, buffer, readString) { - node.name = convertString(position, buffer, readString); + node.name = convertString(buffer[position], buffer, readString); }, function program(node: Program, position, buffer, readString) { const { scope } = node; - node.invalidAnnotations = convertAnnotations(buffer[position], buffer); - node.body = convertNodeList(node, scope, position + 1, buffer, readString); + node.body = convertNodeList(node, scope, buffer[position], buffer, readString); + node.invalidAnnotations = convertAnnotations(buffer[position + 1], buffer); }, function property(node: Property, position, buffer, readString) { const { scope } = node; @@ -710,14 +714,14 @@ const bufferParsers: (( const flags = buffer[position]; node.static = (flags & 1) === 1; node.computed = (flags & 2) === 2; - const valuePosition = buffer[position + 1]; + node.key = convertNode(node, scope, buffer[position + 1], buffer, readString); + const valuePosition = buffer[position + 2]; node.value = valuePosition === 0 ? null : convertNode(node, scope, valuePosition, buffer, readString); - node.key = convertNode(node, scope, position + 2, buffer, readString); }, function restElement(node: RestElement, position, buffer, readString) { const { scope } = node; - node.argument = convertNode(node, scope, position, buffer, readString); + node.argument = convertNode(node, scope, buffer[position], buffer, readString); }, function returnStatement(node: ReturnStatement, position, buffer, readString) { const { scope } = node; @@ -729,15 +733,15 @@ const bufferParsers: (( }, function sequenceExpression(node: SequenceExpression, position, buffer, readString) { const { scope } = node; - node.expressions = convertNodeList(node, scope, position, buffer, readString); + node.expressions = convertNodeList(node, scope, buffer[position], buffer, readString); }, function spreadElement(node: SpreadElement, position, buffer, readString) { const { scope } = node; - node.argument = convertNode(node, scope, position, buffer, readString); + node.argument = convertNode(node, scope, buffer[position], buffer, readString); }, function staticBlock(node: StaticBlock, position, buffer, readString) { const { scope } = node; - node.body = convertNodeList(node, scope, position, buffer, readString); + node.body = convertNodeList(node, scope, buffer[position], buffer, readString); }, function superElement() {}, function switchCase(node: SwitchCase, position, buffer, readString) { @@ -749,13 +753,13 @@ const bufferParsers: (( }, function switchStatement(node: SwitchStatement, position, buffer, readString) { const { scope } = node; - node.cases = convertNodeList(node, scope, buffer[position], buffer, readString); - node.discriminant = convertNode(node, node.parentScope, position + 1, buffer, readString); + node.discriminant = convertNode(node, node.parentScope, buffer[position], buffer, readString); + node.cases = convertNodeList(node, scope, buffer[position + 1], buffer, readString); }, function taggedTemplateExpression(node: TaggedTemplateExpression, position, buffer, readString) { const { scope } = node; - node.quasi = convertNode(node, scope, buffer[position], buffer, readString); - node.tag = convertNode(node, scope, position + 1, buffer, readString); + node.tag = convertNode(node, scope, buffer[position], buffer, readString); + node.quasi = convertNode(node, scope, buffer[position + 1], buffer, readString); }, function templateElement(node: TemplateElement, position, buffer, readString) { const flags = buffer[position]; @@ -763,59 +767,59 @@ const bufferParsers: (( const cookedPosition = buffer[position + 1]; const cooked = cookedPosition === 0 ? undefined : convertString(cookedPosition, buffer, readString); - const raw = convertString(position + 2, buffer, readString); + const raw = convertString(buffer[position + 2], buffer, readString); node.value = { cooked, raw }; }, function templateLiteral(node: TemplateLiteral, position, buffer, readString) { const { scope } = node; - node.expressions = convertNodeList(node, scope, buffer[position], buffer, readString); - node.quasis = convertNodeList(node, scope, position + 1, buffer, readString); + node.quasis = convertNodeList(node, scope, buffer[position], buffer, readString); + node.expressions = convertNodeList(node, scope, buffer[position + 1], buffer, readString); }, function thisExpression() {}, function throwStatement(node: ThrowStatement, position, buffer, readString) { const { scope } = node; - node.argument = convertNode(node, scope, position, buffer, readString); + node.argument = convertNode(node, scope, buffer[position], buffer, readString); }, function tryStatement(node: TryStatement, position, buffer, readString) { const { scope } = node; - const handlerPosition = buffer[position]; + node.block = convertNode(node, scope, buffer[position], buffer, readString); + const handlerPosition = buffer[position + 1]; node.handler = handlerPosition === 0 ? null : convertNode(node, scope, handlerPosition, buffer, readString); - const finalizerPosition = buffer[position + 1]; + const finalizerPosition = buffer[position + 2]; node.finalizer = finalizerPosition === 0 ? null : convertNode(node, scope, finalizerPosition, buffer, readString); - node.block = convertNode(node, scope, position + 2, buffer, readString); }, function unaryExpression(node: UnaryExpression, position, buffer, readString) { const { scope } = node; node.operator = FIXED_STRINGS[buffer[position]] as estree.UnaryOperator; - node.argument = convertNode(node, scope, position + 1, buffer, readString); + node.argument = convertNode(node, scope, buffer[position + 1], buffer, readString); }, function updateExpression(node: UpdateExpression, position, buffer, readString) { 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, position + 2, buffer, readString); + node.argument = convertNode(node, scope, buffer[position + 2], buffer, readString); }, function variableDeclaration(node: VariableDeclaration, position, buffer, readString) { const { scope } = node; node.kind = FIXED_STRINGS[buffer[position]] as estree.VariableDeclaration['kind']; - node.declarations = convertNodeList(node, scope, position + 1, buffer, readString); + node.declarations = convertNodeList(node, scope, buffer[position + 1], buffer, readString); }, function variableDeclarator(node: VariableDeclarator, position, buffer, readString) { const { scope } = node; - const initPosition = buffer[position]; + node.id = convertNode(node, scope, buffer[position], buffer, readString); + const initPosition = buffer[position + 1]; node.init = initPosition === 0 ? null : convertNode(node, scope, initPosition, buffer, readString); - node.id = convertNode(node, scope, position + 1, buffer, readString); }, function whileStatement(node: WhileStatement, position, buffer, readString) { const { scope } = node; - node.body = convertNode(node, scope, buffer[position], buffer, readString); - node.test = convertNode(node, scope, position + 1, buffer, readString); + node.test = convertNode(node, scope, buffer[position], buffer, readString); + node.body = convertNode(node, scope, buffer[position + 1], buffer, readString); }, function yieldExpression(node: YieldExpression, position, buffer, readString) { const { scope } = node; @@ -859,6 +863,7 @@ function convertNodeList( buffer: Uint32Array, readString: ReadString ): any[] { + if (position === 0) return EMPTY_ARRAY as never[]; const length = buffer[position++]; const list: any[] = []; for (let index = 0; index < length; index++) { diff --git a/src/ast/nodes/Program.ts b/src/ast/nodes/Program.ts index 4f577d554..0441eb8b9 100644 --- a/src/ast/nodes/Program.ts +++ b/src/ast/nodes/Program.ts @@ -17,7 +17,7 @@ export default class Program extends NodeBase { declare body: readonly StatementNode[]; declare sourceType: 'module'; declare type: NodeType.tProgram; - declare invalidAnnotations?: RollupAnnotation[]; + declare invalidAnnotations?: readonly RollupAnnotation[]; private hasCachedEffect: boolean | null = null; private hasLoggedEffect = false; diff --git a/src/ast/nodes/shared/FunctionBase.ts b/src/ast/nodes/shared/FunctionBase.ts index 30c24011c..55b9f7f3d 100644 --- a/src/ast/nodes/shared/FunctionBase.ts +++ b/src/ast/nodes/shared/FunctionBase.ts @@ -215,19 +215,17 @@ export default abstract class FunctionBase extends NodeBase { parseNode(esTreeNode: GenericEsTreeNode): this { const { body, params } = esTreeNode; - const parameters: typeof this.params = (this.params = []); 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. - for (const parameter of params) { - parameters.push( + const parameters: typeof this.params = (this.params = params.map( + (parameter: GenericEsTreeNode) => new (context.getNodeConstructor(parameter.type))(this, scope).parseNode( parameter ) as unknown as PatternNode - ); - } + )); scope.addParameterVariables( parameters.map( parameter => parameter.declare('parameter', UNKNOWN_EXPRESSION) as ParameterVariable[] diff --git a/src/ast/nodes/shared/Node.ts b/src/ast/nodes/shared/Node.ts index 8f3fdc8e4..d9f7cd030 100644 --- a/src/ast/nodes/shared/Node.ts +++ b/src/ast/nodes/shared/Node.ts @@ -32,7 +32,7 @@ export const INCLUDE_PARAMETERS = 'variables' as const; export type IncludeChildren = boolean | typeof INCLUDE_PARAMETERS; export interface Node extends Entity { - annotations?: RollupAnnotation[]; + annotations?: readonly RollupAnnotation[]; end: number; included: boolean; needsBoundaries?: boolean; @@ -127,7 +127,7 @@ export interface ChainElement extends ExpressionNode { } export class NodeBase extends ExpressionEntity implements ExpressionNode { - declare annotations?: RollupAnnotation[]; + declare annotations?: readonly RollupAnnotation[]; declare end: number; parent: Node | { context: AstContext; type: string }; declare scope: ChildScope; diff --git a/src/utils/astConverterHelpers.ts b/src/utils/astConverterHelpers.ts index 96bea8535..da5ad27f4 100644 --- a/src/utils/astConverterHelpers.ts +++ b/src/utils/astConverterHelpers.ts @@ -1,3 +1,4 @@ +import { EMPTY_ARRAY } from './blank'; import FIXED_STRINGS from './convert-ast-strings'; import type { ReadString } from './getReadStringFunction'; @@ -12,7 +13,11 @@ export interface RollupAnnotation { type: AnnotationType; } -export const convertAnnotations = (position: number, buffer: Uint32Array): RollupAnnotation[] => { +export const convertAnnotations = ( + position: number, + buffer: Uint32Array +): readonly RollupAnnotation[] => { + if (position === 0) return EMPTY_ARRAY; const length = buffer[position++]; const list: any[] = []; for (let index = 0; index < length; index++) { diff --git a/src/utils/bufferToAst.ts b/src/utils/bufferToAst.ts index 88e41268a..d9903568d 100644 --- a/src/utils/bufferToAst.ts +++ b/src/utils/bufferToAst.ts @@ -4,6 +4,7 @@ import type * as estree from 'estree'; import { PanicError, ParseError } from '../ast/nodes/NodeType'; import type { RollupAstNode } from '../rollup/types'; +import { EMPTY_ARRAY } from '../utils/blank'; import type { RollupAnnotation } from './astConverterHelpers'; import { ANNOTATION_KEY, @@ -35,7 +36,7 @@ const nodeConverters: ((position: number, buffer: Uint32Array, readString: ReadS function panicError(position, buffer, readString): PanicErrorNode { const start = buffer[position++]; const end = buffer[position++]; - const message = convertString(position, buffer, readString); + const message = convertString(buffer[position], buffer, readString); return { type: 'PanicError', start, @@ -46,7 +47,7 @@ const nodeConverters: ((position: number, buffer: Uint32Array, readString: ReadS function parseError(position, buffer, readString): ParseErrorNode { const start = buffer[position++]; const end = buffer[position++]; - const message = convertString(position, buffer, readString); + const message = convertString(buffer[position], buffer, readString); return { type: 'ParseError', start, @@ -57,7 +58,7 @@ const nodeConverters: ((position: number, buffer: Uint32Array, readString: ReadS function arrayExpression(position, buffer, readString): ArrayExpressionNode { const start = buffer[position++]; const end = buffer[position++]; - const elements = convertNodeList(position, buffer, readString); + const elements = convertNodeList(buffer[position], buffer, readString); return { type: 'ArrayExpression', start, @@ -68,7 +69,7 @@ const nodeConverters: ((position: number, buffer: Uint32Array, readString: ReadS function arrayPattern(position, buffer, readString): ArrayPatternNode { const start = buffer[position++]; const end = buffer[position++]; - const elements = convertNodeList(position, buffer, readString); + const elements = convertNodeList(buffer[position], buffer, readString); return { type: 'ArrayPattern', start, @@ -83,9 +84,9 @@ const nodeConverters: ((position: number, buffer: Uint32Array, readString: ReadS const async = (flags & 1) === 1; const expression = (flags & 2) === 2; const generator = (flags & 4) === 4; + const annotations = convertAnnotations(buffer[position++], buffer); const parameters = convertNodeList(buffer[position++], buffer, readString); - const body = convertNode(buffer[position++], buffer, readString); - const annotations = convertAnnotations(position, buffer); + const body = convertNode(buffer[position], buffer, readString); return { type: 'ArrowFunctionExpression', start, @@ -103,8 +104,8 @@ const nodeConverters: ((position: number, buffer: Uint32Array, readString: ReadS const start = buffer[position++]; const end = buffer[position++]; const operator = FIXED_STRINGS[buffer[position++]] as estree.AssignmentOperator; - const right = convertNode(buffer[position++], buffer, readString); - const left = convertNode(position, buffer, readString); + const left = convertNode(buffer[position++], buffer, readString); + const right = convertNode(buffer[position], buffer, readString); return { type: 'AssignmentExpression', start, @@ -117,8 +118,8 @@ const nodeConverters: ((position: number, buffer: Uint32Array, readString: ReadS function assignmentPattern(position, buffer, readString): AssignmentPatternNode { const start = buffer[position++]; const end = buffer[position++]; - const right = convertNode(buffer[position++], buffer, readString); - const left = convertNode(position, buffer, readString); + const left = convertNode(buffer[position++], buffer, readString); + const right = convertNode(buffer[position], buffer, readString); return { type: 'AssignmentPattern', start, @@ -130,7 +131,7 @@ const nodeConverters: ((position: number, buffer: Uint32Array, readString: ReadS function awaitExpression(position, buffer, readString): AwaitExpressionNode { const start = buffer[position++]; const end = buffer[position++]; - const argument = convertNode(position, buffer, readString); + const argument = convertNode(buffer[position], buffer, readString); return { type: 'AwaitExpression', start, @@ -142,8 +143,8 @@ const nodeConverters: ((position: number, buffer: Uint32Array, readString: ReadS const start = buffer[position++]; const end = buffer[position++]; const operator = FIXED_STRINGS[buffer[position++]] as estree.BinaryOperator; - const right = convertNode(buffer[position++], buffer, readString); - const left = convertNode(position, buffer, readString); + const left = convertNode(buffer[position++], buffer, readString); + const right = convertNode(buffer[position], buffer, readString); return { type: 'BinaryExpression', start, @@ -156,7 +157,7 @@ const nodeConverters: ((position: number, buffer: Uint32Array, readString: ReadS function blockStatement(position, buffer, readString): BlockStatementNode { const start = buffer[position++]; const end = buffer[position++]; - const body = convertNodeList(position, buffer, readString); + const body = convertNodeList(buffer[position], buffer, readString); return { type: 'BlockStatement', start, @@ -181,9 +182,9 @@ const nodeConverters: ((position: number, buffer: Uint32Array, readString: ReadS const end = buffer[position++]; const flags = buffer[position++]; const optional = (flags & 1) === 1; + const annotations = convertAnnotations(buffer[position++], buffer); const callee = convertNode(buffer[position++], buffer, readString); - const callArguments = convertNodeList(buffer[position++], buffer, readString); - const annotations = convertAnnotations(position, buffer); + const callArguments = convertNodeList(buffer[position], buffer, readString); return { type: 'CallExpression', start, @@ -212,7 +213,7 @@ const nodeConverters: ((position: number, buffer: Uint32Array, readString: ReadS function chainExpression(position, buffer, readString): ChainExpressionNode { const start = buffer[position++]; const end = buffer[position++]; - const expression = convertNode(position, buffer, readString); + const expression = convertNode(buffer[position], buffer, readString); return { type: 'ChainExpression', start, @@ -223,7 +224,7 @@ const nodeConverters: ((position: number, buffer: Uint32Array, readString: ReadS function classBody(position, buffer, readString): ClassBodyNode { const start = buffer[position++]; const end = buffer[position++]; - const body = convertNodeList(position, buffer, readString); + const body = convertNodeList(buffer[position], buffer, readString); return { type: 'ClassBody', start, @@ -270,9 +271,9 @@ const nodeConverters: ((position: number, buffer: Uint32Array, readString: ReadS function conditionalExpression(position, buffer, readString): ConditionalExpressionNode { const start = buffer[position++]; const end = buffer[position++]; + const test = convertNode(buffer[position++], buffer, readString); const consequent = convertNode(buffer[position++], buffer, readString); - const alternate = convertNode(buffer[position++], buffer, readString); - const test = convertNode(position, buffer, readString); + const alternate = convertNode(buffer[position], buffer, readString); return { type: 'ConditionalExpression', start, @@ -306,8 +307,8 @@ const nodeConverters: ((position: number, buffer: Uint32Array, readString: ReadS function directive(position, buffer, readString): DirectiveNode { const start = buffer[position++]; const end = buffer[position++]; - const expression = convertNode(buffer[position++], buffer, readString); - const directive = convertString(position, buffer, readString); + const directive = convertString(buffer[position++], buffer, readString); + const expression = convertNode(buffer[position], buffer, readString); return { type: 'ExpressionStatement', start, @@ -319,8 +320,8 @@ const nodeConverters: ((position: number, buffer: Uint32Array, readString: ReadS function doWhileStatement(position, buffer, readString): DoWhileStatementNode { const start = buffer[position++]; const end = buffer[position++]; - const test = convertNode(buffer[position++], buffer, readString); - const body = convertNode(position, buffer, readString); + const body = convertNode(buffer[position++], buffer, readString); + const test = convertNode(buffer[position], buffer, readString); return { type: 'DoWhileStatement', start, @@ -358,7 +359,7 @@ const nodeConverters: ((position: number, buffer: Uint32Array, readString: ReadS function exportDefaultDeclaration(position, buffer, readString): ExportDefaultDeclarationNode { const start = buffer[position++]; const end = buffer[position++]; - const declaration = convertNode(position, buffer, readString); + const declaration = convertNode(buffer[position], buffer, readString); return { type: 'ExportDefaultDeclaration', start, @@ -369,13 +370,13 @@ const nodeConverters: ((position: number, buffer: Uint32Array, readString: ReadS function exportNamedDeclaration(position, buffer, readString): ExportNamedDeclarationNode { const start = buffer[position++]; const end = buffer[position++]; + const specifiers = convertNodeList(buffer[position++], buffer, readString); const sourcePosition = buffer[position++]; const source = sourcePosition === 0 ? null : convertNode(sourcePosition, buffer, readString); const attributes = convertNodeList(buffer[position++], buffer, readString); - const declarationPosition = buffer[position++]; + const declarationPosition = buffer[position]; const declaration = declarationPosition === 0 ? null : convertNode(declarationPosition, buffer, readString); - const specifiers = convertNodeList(position, buffer, readString); return { type: 'ExportNamedDeclaration', start, @@ -389,8 +390,8 @@ const nodeConverters: ((position: number, buffer: Uint32Array, readString: ReadS function exportSpecifier(position, buffer, readString): ExportSpecifierNode { const start = buffer[position++]; const end = buffer[position++]; - const exportedPosition = buffer[position++]; - const local = convertNode(position, buffer, readString); + const local = convertNode(buffer[position++], buffer, readString); + const exportedPosition = buffer[position]; return { type: 'ExportSpecifier', start, @@ -403,7 +404,7 @@ const nodeConverters: ((position: number, buffer: Uint32Array, readString: ReadS function expressionStatement(position, buffer, readString): ExpressionStatementNode { const start = buffer[position++]; const end = buffer[position++]; - const expression = convertNode(position, buffer, readString); + const expression = convertNode(buffer[position], buffer, readString); return { type: 'ExpressionStatement', start, @@ -414,9 +415,9 @@ const nodeConverters: ((position: number, buffer: Uint32Array, readString: ReadS function forInStatement(position, buffer, readString): ForInStatementNode { const start = buffer[position++]; const end = buffer[position++]; + const left = convertNode(buffer[position++], buffer, readString); const right = convertNode(buffer[position++], buffer, readString); - const body = convertNode(buffer[position++], buffer, readString); - const left = convertNode(position, buffer, readString); + const body = convertNode(buffer[position], buffer, readString); return { type: 'ForInStatement', start, @@ -431,9 +432,9 @@ const nodeConverters: ((position: number, buffer: Uint32Array, readString: ReadS const end = buffer[position++]; const flags = buffer[position++]; const awaited = (flags & 1) === 1; + const left = convertNode(buffer[position++], buffer, readString); const right = convertNode(buffer[position++], buffer, readString); - const body = convertNode(buffer[position++], buffer, readString); - const left = convertNode(position, buffer, readString); + const body = convertNode(buffer[position], buffer, readString); return { type: 'ForOfStatement', start, @@ -470,11 +471,11 @@ const nodeConverters: ((position: number, buffer: Uint32Array, readString: ReadS const flags = buffer[position++]; const async = (flags & 1) === 1; const generator = (flags & 2) === 2; + const annotations = convertAnnotations(buffer[position++], buffer); const idPosition = buffer[position++]; const id = idPosition === 0 ? null : convertNode(idPosition, buffer, readString); const parameters = convertNodeList(buffer[position++], buffer, readString); - const body = convertNode(buffer[position++], buffer, readString); - const annotations = convertAnnotations(position, buffer); + const body = convertNode(buffer[position], buffer, readString); return { type: 'FunctionDeclaration', start, @@ -494,11 +495,11 @@ const nodeConverters: ((position: number, buffer: Uint32Array, readString: ReadS const flags = buffer[position++]; const async = (flags & 1) === 1; const generator = (flags & 2) === 2; + const annotations = convertAnnotations(buffer[position++], buffer); const idPosition = buffer[position++]; const id = idPosition === 0 ? null : convertNode(idPosition, buffer, readString); const parameters = convertNodeList(buffer[position++], buffer, readString); - const body = convertNode(buffer[position++], buffer, readString); - const annotations = convertAnnotations(position, buffer); + const body = convertNode(buffer[position], buffer, readString); return { type: 'FunctionExpression', start, @@ -515,7 +516,7 @@ const nodeConverters: ((position: number, buffer: Uint32Array, readString: ReadS function identifier(position, buffer, readString): IdentifierNode { const start = buffer[position++]; const end = buffer[position++]; - const name = convertString(position, buffer, readString); + const name = convertString(buffer[position], buffer, readString); return { type: 'Identifier', start, @@ -526,11 +527,11 @@ const nodeConverters: ((position: number, buffer: Uint32Array, readString: ReadS function ifStatement(position, buffer, readString): IfStatementNode { const start = buffer[position++]; const end = buffer[position++]; + const test = convertNode(buffer[position++], buffer, readString); const consequent = convertNode(buffer[position++], buffer, readString); - const alternatePosition = buffer[position++]; + const alternatePosition = buffer[position]; const alternate = alternatePosition === 0 ? null : convertNode(alternatePosition, buffer, readString); - const test = convertNode(position, buffer, readString); return { type: 'IfStatement', start, @@ -543,8 +544,8 @@ const nodeConverters: ((position: number, buffer: Uint32Array, readString: ReadS function importAttribute(position, buffer, readString): ImportAttributeNode { const start = buffer[position++]; const end = buffer[position++]; - const value = convertNode(buffer[position++], buffer, readString); - const key = convertNode(position, buffer, readString); + const key = convertNode(buffer[position++], buffer, readString); + const value = convertNode(buffer[position], buffer, readString); return { type: 'ImportAttribute', start, @@ -556,9 +557,9 @@ const nodeConverters: ((position: number, buffer: Uint32Array, readString: ReadS function importDeclaration(position, buffer, readString): ImportDeclarationNode { const start = buffer[position++]; const end = buffer[position++]; + const specifiers = convertNodeList(buffer[position++], buffer, readString); const source = convertNode(buffer[position++], buffer, readString); - const attributes = convertNodeList(buffer[position++], buffer, readString); - const specifiers = convertNodeList(position, buffer, readString); + const attributes = convertNodeList(buffer[position], buffer, readString); return { type: 'ImportDeclaration', start, @@ -571,7 +572,7 @@ const nodeConverters: ((position: number, buffer: Uint32Array, readString: ReadS function importDefaultSpecifier(position, buffer, readString): ImportDefaultSpecifierNode { const start = buffer[position++]; const end = buffer[position++]; - const local = convertNode(position, buffer, readString); + const local = convertNode(buffer[position], buffer, readString); return { type: 'ImportDefaultSpecifier', start, @@ -582,9 +583,9 @@ const nodeConverters: ((position: number, buffer: Uint32Array, readString: ReadS function importExpression(position, buffer, readString): ImportExpressionNode { const start = buffer[position++]; const end = buffer[position++]; - const optionsPosition = buffer[position++]; + const source = convertNode(buffer[position++], buffer, readString); + const optionsPosition = buffer[position]; const options = optionsPosition === 0 ? null : convertNode(optionsPosition, buffer, readString); - const source = convertNode(position, buffer, readString); return { type: 'ImportExpression', start, @@ -596,7 +597,7 @@ const nodeConverters: ((position: number, buffer: Uint32Array, readString: ReadS function importNamespaceSpecifier(position, buffer, readString): ImportNamespaceSpecifierNode { const start = buffer[position++]; const end = buffer[position++]; - const local = convertNode(position, buffer, readString); + const local = convertNode(buffer[position], buffer, readString); return { type: 'ImportNamespaceSpecifier', start, @@ -621,8 +622,8 @@ const nodeConverters: ((position: number, buffer: Uint32Array, readString: ReadS function labeledStatement(position, buffer, readString): LabeledStatementNode { const start = buffer[position++]; const end = buffer[position++]; - const body = convertNode(buffer[position++], buffer, readString); - const label = convertNode(position, buffer, readString); + const label = convertNode(buffer[position++], buffer, readString); + const body = convertNode(buffer[position], buffer, readString); return { type: 'LabeledStatement', start, @@ -634,8 +635,8 @@ const nodeConverters: ((position: number, buffer: Uint32Array, readString: ReadS function literalBigInt(position, buffer, readString): LiteralBigIntNode { const start = buffer[position++]; const end = buffer[position++]; - const raw = convertString(buffer[position++], buffer, readString); - const bigint = convertString(position, buffer, readString); + const bigint = convertString(buffer[position++], buffer, readString); + const raw = convertString(buffer[position], buffer, readString); return { type: 'Literal', start, @@ -686,8 +687,8 @@ const nodeConverters: ((position: number, buffer: Uint32Array, readString: ReadS function literalRegExp(position, buffer, readString): LiteralRegExpNode { const start = buffer[position++]; const end = buffer[position++]; - const pattern = convertString(buffer[position++], buffer, readString); - const flags = convertString(position, buffer, readString); + const flags = convertString(buffer[position++], buffer, readString); + const pattern = convertString(buffer[position], buffer, readString); return { type: 'Literal', start, @@ -700,9 +701,9 @@ const nodeConverters: ((position: number, buffer: Uint32Array, readString: ReadS function literalString(position, buffer, readString): LiteralStringNode { const start = buffer[position++]; const end = buffer[position++]; - const rawPosition = buffer[position++]; + const value = convertString(buffer[position++], buffer, readString); + const rawPosition = buffer[position]; const raw = rawPosition === 0 ? undefined : convertString(rawPosition, buffer, readString); - const value = convertString(position, buffer, readString); return { type: 'Literal', start, @@ -715,8 +716,8 @@ const nodeConverters: ((position: number, buffer: Uint32Array, readString: ReadS const start = buffer[position++]; const end = buffer[position++]; const operator = FIXED_STRINGS[buffer[position++]] as estree.LogicalOperator; - const right = convertNode(buffer[position++], buffer, readString); - const left = convertNode(position, buffer, readString); + const left = convertNode(buffer[position++], buffer, readString); + const right = convertNode(buffer[position], buffer, readString); return { type: 'LogicalExpression', start, @@ -732,8 +733,8 @@ const nodeConverters: ((position: number, buffer: Uint32Array, readString: ReadS const flags = buffer[position++]; const computed = (flags & 1) === 1; const optional = (flags & 2) === 2; - const property = convertNode(buffer[position++], buffer, readString); - const object = convertNode(position, buffer, readString); + const object = convertNode(buffer[position++], buffer, readString); + const property = convertNode(buffer[position], buffer, readString); return { type: 'MemberExpression', start, @@ -747,8 +748,8 @@ const nodeConverters: ((position: number, buffer: Uint32Array, readString: ReadS function metaProperty(position, buffer, readString): MetaPropertyNode { const start = buffer[position++]; const end = buffer[position++]; - const property = convertNode(buffer[position++], buffer, readString); - const meta = convertNode(position, buffer, readString); + const meta = convertNode(buffer[position++], buffer, readString); + const property = convertNode(buffer[position], buffer, readString); return { type: 'MetaProperty', start, @@ -763,9 +764,9 @@ const nodeConverters: ((position: number, buffer: Uint32Array, readString: ReadS const flags = buffer[position++]; const isStatic = (flags & 1) === 1; const computed = (flags & 2) === 2; + const key = convertNode(buffer[position++], buffer, readString); const value = convertNode(buffer[position++], buffer, readString); - const kind = FIXED_STRINGS[buffer[position++]] as estree.MethodDefinition['kind']; - const key = convertNode(position, buffer, readString); + const kind = FIXED_STRINGS[buffer[position]] as estree.MethodDefinition['kind']; return { type: 'MethodDefinition', start, @@ -780,9 +781,9 @@ const nodeConverters: ((position: number, buffer: Uint32Array, readString: ReadS function newExpression(position, buffer, readString): NewExpressionNode { const start = buffer[position++]; const end = buffer[position++]; + const annotations = convertAnnotations(buffer[position++], buffer); const callee = convertNode(buffer[position++], buffer, readString); - const callArguments = convertNodeList(buffer[position++], buffer, readString); - const annotations = convertAnnotations(position, buffer); + const callArguments = convertNodeList(buffer[position], buffer, readString); return { type: 'NewExpression', start, @@ -795,7 +796,7 @@ const nodeConverters: ((position: number, buffer: Uint32Array, readString: ReadS function objectExpression(position, buffer, readString): ObjectExpressionNode { const start = buffer[position++]; const end = buffer[position++]; - const properties = convertNodeList(position, buffer, readString); + const properties = convertNodeList(buffer[position], buffer, readString); return { type: 'ObjectExpression', start, @@ -806,7 +807,7 @@ const nodeConverters: ((position: number, buffer: Uint32Array, readString: ReadS function objectPattern(position, buffer, readString): ObjectPatternNode { const start = buffer[position++]; const end = buffer[position++]; - const properties = convertNodeList(position, buffer, readString); + const properties = convertNodeList(buffer[position], buffer, readString); return { type: 'ObjectPattern', start, @@ -817,7 +818,7 @@ const nodeConverters: ((position: number, buffer: Uint32Array, readString: ReadS function privateIdentifier(position, buffer, readString): PrivateIdentifierNode { const start = buffer[position++]; const end = buffer[position++]; - const name = convertString(position, buffer, readString); + const name = convertString(buffer[position], buffer, readString); return { type: 'PrivateIdentifier', start, @@ -828,8 +829,8 @@ const nodeConverters: ((position: number, buffer: Uint32Array, readString: ReadS function program(position, buffer, readString): ProgramNode { const start = buffer[position++]; const end = buffer[position++]; - const invalidAnnotations = convertAnnotations(buffer[position++], buffer); - const body = convertNodeList(position, buffer, readString); + const body = convertNodeList(buffer[position++], buffer, readString); + const invalidAnnotations = convertAnnotations(buffer[position], buffer); return { type: 'Program', start, @@ -867,9 +868,9 @@ const nodeConverters: ((position: number, buffer: Uint32Array, readString: ReadS const flags = buffer[position++]; const isStatic = (flags & 1) === 1; const computed = (flags & 2) === 2; - const valuePosition = buffer[position++]; + const key = convertNode(buffer[position++], buffer, readString); + const valuePosition = buffer[position]; const value = valuePosition === 0 ? null : convertNode(valuePosition, buffer, readString); - const key = convertNode(position, buffer, readString); return { type: 'PropertyDefinition', start, @@ -883,7 +884,7 @@ const nodeConverters: ((position: number, buffer: Uint32Array, readString: ReadS function restElement(position, buffer, readString): RestElementNode { const start = buffer[position++]; const end = buffer[position++]; - const argument = convertNode(position, buffer, readString); + const argument = convertNode(buffer[position], buffer, readString); return { type: 'RestElement', start, @@ -907,7 +908,7 @@ const nodeConverters: ((position: number, buffer: Uint32Array, readString: ReadS function sequenceExpression(position, buffer, readString): SequenceExpressionNode { const start = buffer[position++]; const end = buffer[position++]; - const expressions = convertNodeList(position, buffer, readString); + const expressions = convertNodeList(buffer[position], buffer, readString); return { type: 'SequenceExpression', start, @@ -918,7 +919,7 @@ const nodeConverters: ((position: number, buffer: Uint32Array, readString: ReadS function spreadElement(position, buffer, readString): SpreadElementNode { const start = buffer[position++]; const end = buffer[position++]; - const argument = convertNode(position, buffer, readString); + const argument = convertNode(buffer[position], buffer, readString); return { type: 'SpreadElement', start, @@ -929,7 +930,7 @@ const nodeConverters: ((position: number, buffer: Uint32Array, readString: ReadS function staticBlock(position, buffer, readString): StaticBlockNode { const start = buffer[position++]; const end = buffer[position++]; - const body = convertNodeList(position, buffer, readString); + const body = convertNodeList(buffer[position], buffer, readString); return { type: 'StaticBlock', start, @@ -963,8 +964,8 @@ const nodeConverters: ((position: number, buffer: Uint32Array, readString: ReadS function switchStatement(position, buffer, readString): SwitchStatementNode { const start = buffer[position++]; const end = buffer[position++]; - const cases = convertNodeList(buffer[position++], buffer, readString); - const discriminant = convertNode(position, buffer, readString); + const discriminant = convertNode(buffer[position++], buffer, readString); + const cases = convertNodeList(buffer[position], buffer, readString); return { type: 'SwitchStatement', start, @@ -976,8 +977,8 @@ const nodeConverters: ((position: number, buffer: Uint32Array, readString: ReadS function taggedTemplateExpression(position, buffer, readString): TaggedTemplateExpressionNode { const start = buffer[position++]; const end = buffer[position++]; - const quasi = convertNode(buffer[position++], buffer, readString); - const tag = convertNode(position, buffer, readString); + const tag = convertNode(buffer[position++], buffer, readString); + const quasi = convertNode(buffer[position], buffer, readString); return { type: 'TaggedTemplateExpression', start, @@ -994,7 +995,7 @@ const nodeConverters: ((position: number, buffer: Uint32Array, readString: ReadS const cookedPosition = buffer[position++]; const cooked = cookedPosition === 0 ? undefined : convertString(cookedPosition, buffer, readString); - const raw = convertString(position, buffer, readString); + const raw = convertString(buffer[position], buffer, readString); return { type: 'TemplateElement', start, @@ -1006,8 +1007,8 @@ const nodeConverters: ((position: number, buffer: Uint32Array, readString: ReadS function templateLiteral(position, buffer, readString): TemplateLiteralNode { const start = buffer[position++]; const end = buffer[position++]; - const expressions = convertNodeList(buffer[position++], buffer, readString); - const quasis = convertNodeList(position, buffer, readString); + const quasis = convertNodeList(buffer[position++], buffer, readString); + const expressions = convertNodeList(buffer[position], buffer, readString); return { type: 'TemplateLiteral', start, @@ -1028,7 +1029,7 @@ const nodeConverters: ((position: number, buffer: Uint32Array, readString: ReadS function throwStatement(position, buffer, readString): ThrowStatementNode { const start = buffer[position++]; const end = buffer[position++]; - const argument = convertNode(position, buffer, readString); + const argument = convertNode(buffer[position], buffer, readString); return { type: 'ThrowStatement', start, @@ -1039,12 +1040,12 @@ const nodeConverters: ((position: number, buffer: Uint32Array, readString: ReadS function tryStatement(position, buffer, readString): TryStatementNode { const start = buffer[position++]; const end = buffer[position++]; + const block = convertNode(buffer[position++], buffer, readString); const handlerPosition = buffer[position++]; const handler = handlerPosition === 0 ? null : convertNode(handlerPosition, buffer, readString); - const finalizerPosition = buffer[position++]; + const finalizerPosition = buffer[position]; const finalizer = finalizerPosition === 0 ? null : convertNode(finalizerPosition, buffer, readString); - const block = convertNode(position, buffer, readString); return { type: 'TryStatement', start, @@ -1058,7 +1059,7 @@ const nodeConverters: ((position: number, buffer: Uint32Array, readString: ReadS const start = buffer[position++]; const end = buffer[position++]; const operator = FIXED_STRINGS[buffer[position++]] as estree.UnaryOperator; - const argument = convertNode(position, buffer, readString); + const argument = convertNode(buffer[position], buffer, readString); return { type: 'UnaryExpression', start, @@ -1074,7 +1075,7 @@ const nodeConverters: ((position: number, buffer: Uint32Array, readString: ReadS const flags = buffer[position++]; const prefix = (flags & 1) === 1; const operator = FIXED_STRINGS[buffer[position++]] as estree.UpdateOperator; - const argument = convertNode(position, buffer, readString); + const argument = convertNode(buffer[position], buffer, readString); return { type: 'UpdateExpression', start, @@ -1088,7 +1089,7 @@ const nodeConverters: ((position: number, buffer: Uint32Array, readString: ReadS const start = buffer[position++]; const end = buffer[position++]; const kind = FIXED_STRINGS[buffer[position++]] as estree.VariableDeclaration['kind']; - const declarations = convertNodeList(position, buffer, readString); + const declarations = convertNodeList(buffer[position], buffer, readString); return { type: 'VariableDeclaration', start, @@ -1100,9 +1101,9 @@ const nodeConverters: ((position: number, buffer: Uint32Array, readString: ReadS function variableDeclarator(position, buffer, readString): VariableDeclaratorNode { const start = buffer[position++]; const end = buffer[position++]; - const initPosition = buffer[position++]; + const id = convertNode(buffer[position++], buffer, readString); + const initPosition = buffer[position]; const init = initPosition === 0 ? null : convertNode(initPosition, buffer, readString); - const id = convertNode(position, buffer, readString); return { type: 'VariableDeclarator', start, @@ -1114,8 +1115,8 @@ const nodeConverters: ((position: number, buffer: Uint32Array, readString: ReadS function whileStatement(position, buffer, readString): WhileStatementNode { const start = buffer[position++]; const end = buffer[position++]; - const body = convertNode(buffer[position++], buffer, readString); - const test = convertNode(position, buffer, readString); + const test = convertNode(buffer[position++], buffer, readString); + const body = convertNode(buffer[position], buffer, readString); return { type: 'WhileStatement', start, @@ -1147,7 +1148,7 @@ export type ParseErrorNode = RollupAstNode<{ type: 'ParseError'; message: string export type ArrayExpressionNode = RollupAstNode; export type ArrayPatternNode = RollupAstNode; export type ArrowFunctionExpressionNode = RollupAstNode & { - [ANNOTATION_KEY]?: RollupAnnotation[]; + [ANNOTATION_KEY]?: readonly RollupAnnotation[]; id: null; }; export type AssignmentExpressionNode = RollupAstNode; @@ -1157,7 +1158,7 @@ export type BinaryExpressionNode = RollupAstNode; export type BlockStatementNode = RollupAstNode; export type BreakStatementNode = RollupAstNode; export type CallExpressionNode = RollupAstNode & { - [ANNOTATION_KEY]?: RollupAnnotation[]; + [ANNOTATION_KEY]?: readonly RollupAnnotation[]; }; export type CatchClauseNode = RollupAstNode; export type ChainExpressionNode = RollupAstNode; @@ -1183,11 +1184,11 @@ export type ForInStatementNode = RollupAstNode; export type ForOfStatementNode = RollupAstNode; export type ForStatementNode = RollupAstNode; export type FunctionDeclarationNode = RollupAstNode & { - [ANNOTATION_KEY]?: RollupAnnotation[]; + [ANNOTATION_KEY]?: readonly RollupAnnotation[]; expression: false; }; export type FunctionExpressionNode = RollupAstNode & { - [ANNOTATION_KEY]?: RollupAnnotation[]; + [ANNOTATION_KEY]?: readonly RollupAnnotation[]; expression: false; }; export type IdentifierNode = RollupAstNode; @@ -1220,13 +1221,13 @@ export type MemberExpressionNode = RollupAstNode; export type MetaPropertyNode = RollupAstNode; export type MethodDefinitionNode = RollupAstNode; export type NewExpressionNode = RollupAstNode & { - [ANNOTATION_KEY]?: RollupAnnotation[]; + [ANNOTATION_KEY]?: readonly RollupAnnotation[]; }; export type ObjectExpressionNode = RollupAstNode; export type ObjectPatternNode = RollupAstNode; export type PrivateIdentifierNode = RollupAstNode; export type ProgramNode = RollupAstNode & { - [INVALID_ANNOTATION_KEY]?: RollupAnnotation[]; + [INVALID_ANNOTATION_KEY]?: readonly RollupAnnotation[]; sourceType: 'module'; }; export type PropertyNode = RollupAstNode; @@ -1264,6 +1265,7 @@ export function convertNode(position: number, buffer: Uint32Array, readString: R } function convertNodeList(position: number, buffer: Uint32Array, readString: ReadString): any[] { + if (position === 0) return EMPTY_ARRAY as never[]; const length = buffer[position++]; const list: any[] = []; for (let index = 0; index < length; index++) { From 555982a37b4c97cfd1e204eb39e06d07a58afdee Mon Sep 17 00:00:00 2001 From: Lukas Taegert-Atkinson Date: Sun, 7 Apr 2024 09:22:17 +0200 Subject: [PATCH 09/45] Improve error message when running on unsupported MUSL Linux (#5454) --- native.js | 59 +++++++++++++++++++++++++++---------------------------- 1 file changed, 29 insertions(+), 30 deletions(-) diff --git a/native.js b/native.js index 492a52b2c..e7cc903dc 100644 --- a/native.js +++ b/native.js @@ -35,36 +35,6 @@ const msvcLinkFilenameByArch = { }; const packageBase = getPackageBase(); - -if (!packageBase) { - throw new Error( - `Your current platform "${platform}" 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.` - ); -} - -function getPackageBase() { - const imported = bindingsByPlatformAndArch[platform]?.[arch]; - if (!imported) { - return null; - } - if ('musl' in imported && isMusl()) { - return imported.musl; - } - return imported.base; -} - const localName = `./rollup.${packageBase}.node`; const requireWithFriendlyError = id => { try { @@ -99,6 +69,35 @@ const { parse, parseAsync, xxhashBase64Url, xxhashBase36, xxhashBase16 } = requi existsSync(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; From 0b665c31833525c923c0fc20f43ebfca748c6670 Mon Sep 17 00:00:00 2001 From: Lukas Taegert-Atkinson Date: Sun, 7 Apr 2024 09:24:23 +0200 Subject: [PATCH 10/45] 4.14.1 --- CHANGELOG.md | 16 ++++++++++++++++ browser/package.json | 2 +- package-lock.json | 4 ++-- package.json | 2 +- 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0967d5b77..f0befdeff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,21 @@ # rollup changelog +## 4.14.1 + +_2024-04-07_ + +### Bug Fixes + +- Show better error when running on musl Linux where the musl build is not supported (#5454) + +### Pull Requests + +- [#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) + ## 4.14.0 _2024-04-03_ diff --git a/browser/package.json b/browser/package.json index 4e9d9071a..bc9ae3660 100644 --- a/browser/package.json +++ b/browser/package.json @@ -1,6 +1,6 @@ { "name": "@rollup/browser", - "version": "4.14.0", + "version": "4.14.1", "description": "Next-generation ES module bundler browser build", "main": "dist/rollup.browser.js", "module": "dist/es/rollup.browser.js", diff --git a/package-lock.json b/package-lock.json index da69d844c..3b007f703 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "rollup", - "version": "4.14.0", + "version": "4.14.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "rollup", - "version": "4.14.0", + "version": "4.14.1", "license": "MIT", "dependencies": { "@types/estree": "1.0.5" diff --git a/package.json b/package.json index 856bbb5e5..db342ca10 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rollup", - "version": "4.14.0", + "version": "4.14.1", "description": "Next-generation ES module bundler", "main": "dist/rollup.js", "module": "dist/es/rollup.js", From b957e1dd9148188876edba4cffcdc007310b899c Mon Sep 17 00:00:00 2001 From: Lukas Taegert-Atkinson Date: Wed, 10 Apr 2024 06:49:42 +0200 Subject: [PATCH 11/45] Fix ppc64le target (#5460) The NodeJS architecture is ppc64 See also https://nodejs.org/api/process.html#processarch --- native.js | 2 +- npm/linux-powerpc64le-gnu/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/native.js b/native.js index e7cc903dc..5233af4e5 100644 --- a/native.js +++ b/native.js @@ -16,7 +16,7 @@ const bindingsByPlatformAndArch = { linux: { arm: { base: 'linux-arm-gnueabihf', musl: null }, arm64: { base: 'linux-arm64-gnu', musl: 'linux-arm64-musl' }, - ppc64le: { base: 'linux-powerpc64le-gnu', musl: null }, + ppc64: { base: 'linux-powerpc64le-gnu', musl: null }, riscv64: { base: 'linux-riscv64-gnu', musl: null }, s390x: { base: 'linux-s390x-gnu', musl: null }, x64: { base: 'linux-x64-gnu', musl: 'linux-x64-musl' } diff --git a/npm/linux-powerpc64le-gnu/package.json b/npm/linux-powerpc64le-gnu/package.json index 4b344cfdb..1c8ed678f 100644 --- a/npm/linux-powerpc64le-gnu/package.json +++ b/npm/linux-powerpc64le-gnu/package.json @@ -5,7 +5,7 @@ "linux" ], "cpu": [ - "ppc64le" + "ppc64" ], "files": [ "rollup.linux-powerpc64le-gnu.node" From 8c31e9b1dfafce59a0dcb0f1d297083c6e22bdf8 Mon Sep 17 00:00:00 2001 From: XiaoPi <530257315@qq.com> Date: Wed, 10 Apr 2024 12:42:07 +0800 Subject: [PATCH 12/45] chore: tweak the comment about files should not be edited (#5463) --- .../src/convert_ast/converter/ast_constants.rs | 2 +- .../src/convert_ast/converter/string_constants.rs | 3 ++- scripts/generate-buffer-parsers.js | 8 ++++---- scripts/generate-buffer-to-ast.js | 8 ++++---- scripts/generate-child-node-keys.js | 8 ++++---- scripts/generate-rust-constants.js | 8 ++++---- scripts/generate-string-constants.js | 11 +++++------ scripts/helpers.js | 10 ++++++++++ src/ast/bufferParsers.ts | 2 +- src/ast/childNodeKeys.ts | 2 +- src/utils/bufferToAst.ts | 2 +- src/utils/convert-ast-strings.ts | 3 ++- 12 files changed, 39 insertions(+), 28 deletions(-) diff --git a/rust/parse_ast/src/convert_ast/converter/ast_constants.rs b/rust/parse_ast/src/convert_ast/converter/ast_constants.rs index 8e28edc72..011154f5a 100644 --- a/rust/parse_ast/src/convert_ast/converter/ast_constants.rs +++ b/rust/parse_ast/src/convert_ast/converter/ast_constants.rs @@ -1,4 +1,4 @@ -// This file is generated by scripts/generate-ast-converters.js. +// 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(); diff --git a/rust/parse_ast/src/convert_ast/converter/string_constants.rs b/rust/parse_ast/src/convert_ast/converter/string_constants.rs index c6f8e0a46..b5955be0e 100644 --- a/rust/parse_ast/src/convert_ast/converter/string_constants.rs +++ b/rust/parse_ast/src/convert_ast/converter/string_constants.rs @@ -1,5 +1,6 @@ -// This file is generated by scripts/generate-string-constant.js. +// 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 diff --git a/scripts/generate-buffer-parsers.js b/scripts/generate-buffer-parsers.js index 4faa9e7c7..1340d334b 100644 --- a/scripts/generate-buffer-parsers.js +++ b/scripts/generate-buffer-parsers.js @@ -1,6 +1,8 @@ import { writeFile } from 'node:fs/promises'; import { astNodeNamesWithFieldOrder } from './ast-types.js'; -import { firstLetterLowercase, lintTsFile } from './helpers.js'; +import { firstLetterLowercase, generateNotEditFilesComment, lintTsFile } from './helpers.js'; + +const notEditFilesComment = generateNotEditFilesComment(import.meta.url); const bufferParsersFile = new URL('../src/ast/bufferParsers.ts', import.meta.url); @@ -168,9 +170,7 @@ function getFieldDefinition([fieldName, fieldType], node, originalNode, offset) } } -const bufferParsers = `// This file is generated by scripts/generate-ast-converters.js. -// Do not edit this file directly. - +const bufferParsers = `${notEditFilesComment} import type * as estree from 'estree'; import type { AstContext } from '../Module'; import { convertAnnotations, convertString } from '../utils/astConverterHelpers'; diff --git a/scripts/generate-buffer-to-ast.js b/scripts/generate-buffer-to-ast.js index 78c3dbf35..132cf0dc9 100644 --- a/scripts/generate-buffer-to-ast.js +++ b/scripts/generate-buffer-to-ast.js @@ -1,6 +1,8 @@ import { writeFile } from 'node:fs/promises'; import { astNodeNamesWithFieldOrder } from './ast-types.js'; -import { firstLetterLowercase, lintTsFile } from './helpers.js'; +import { firstLetterLowercase, generateNotEditFilesComment, lintTsFile } from './helpers.js'; + +const notEditFilesComment = generateNotEditFilesComment(import.meta.url); const bufferToJsAstFile = new URL('../src/utils/bufferToAst.ts', import.meta.url); @@ -156,9 +158,7 @@ const types = astNodeNamesWithFieldOrder.map(({ name, node }) => { return typeDefinition; }); -const bufferToJsAst = `// This file is generated by scripts/generate-ast-converters.js. -// Do not edit this file directly. - +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'; diff --git a/scripts/generate-child-node-keys.js b/scripts/generate-child-node-keys.js index 104b186d1..6bc080bca 100644 --- a/scripts/generate-child-node-keys.js +++ b/scripts/generate-child-node-keys.js @@ -1,6 +1,8 @@ import { writeFile } from 'node:fs/promises'; import { AST_NODES } from './ast-types.js'; -import { lintTsFile } from './helpers.js'; +import { generateNotEditFilesComment, lintTsFile } from './helpers.js'; + +const notEditFilesComment = generateNotEditFilesComment(import.meta.url); const childNodeKeysFile = new URL('../src/ast/childNodeKeys.ts', import.meta.url); @@ -18,9 +20,7 @@ for (const [name, node] of Object.entries(AST_NODES)) { } } -const childNodeKeys = `// This file is generated by scripts/generate-ast-converters.js. -// Do not edit this file directly. - +const childNodeKeys = `${notEditFilesComment} export const childNodeKeys: Record = { ${Object.entries(childNodeKeysByAstType) .sort(([astType1], [astType2]) => astType1.localeCompare(astType2)) diff --git a/scripts/generate-rust-constants.js b/scripts/generate-rust-constants.js index f7c84365e..ae74a631e 100644 --- a/scripts/generate-rust-constants.js +++ b/scripts/generate-rust-constants.js @@ -1,9 +1,11 @@ import { writeFile } from 'node:fs/promises'; import { AST_NODES, astNodeNamesWithFieldOrder } from './ast-types.js'; -import { lintRustFile, toScreamingSnakeCase } from './helpers.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 @@ -67,9 +69,7 @@ const reservedBytesAndOffsets = astNodeNamesWithFieldOrder }) .join('\n'); -const astConstants = `// This file is generated by scripts/generate-ast-converters.js. -// Do not edit this file directly. - +const astConstants = `${notEditFilesComment} ${nodeTypes} ${reservedBytesAndOffsets} diff --git a/scripts/generate-string-constants.js b/scripts/generate-string-constants.js index 11f7dbc01..120c2a6c9 100644 --- a/scripts/generate-string-constants.js +++ b/scripts/generate-string-constants.js @@ -1,5 +1,7 @@ import { writeFile } from 'node:fs/promises'; -import { lintRustFile, lintTsFile } from './helpers.js'; +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', @@ -73,11 +75,8 @@ const stringConstantsTemplate = [ ['STRING_AWAIT_USING', 'await using'] ]; -const tipComment = `// This file is generated by scripts/generate-string-constant.js. -// Do not edit this file directly.\n`; - const rustCode = - tipComment + + notEditFilesComment + stringConstantsTemplate .map( ([variableName, value], index) => @@ -86,7 +85,7 @@ const rustCode = .join('\n'); const tsCode = - tipComment + + notEditFilesComment + `export default ` + JSON.stringify( stringConstantsTemplate.map(([, value]) => value), diff --git a/scripts/helpers.js b/scripts/helpers.js index 67f0534cd..c8e170792 100644 --- a/scripts/helpers.js +++ b/scripts/helpers.js @@ -1,5 +1,6 @@ import { spawn } from 'node:child_process'; import { readFile } from 'node:fs/promises'; +import { relative } from 'node:path'; import { fileURLToPath } from 'node:url'; import { ESLint } from 'eslint'; import { blue, bold, cyan, green, magenta, red, yellow } from './colors.js'; @@ -112,3 +113,12 @@ export function firstLetterLowercase(string) { export function toScreamingSnakeCase(string) { return string.replace(/(? = { diff --git a/src/utils/bufferToAst.ts b/src/utils/bufferToAst.ts index d9903568d..381b1688e 100644 --- a/src/utils/bufferToAst.ts +++ b/src/utils/bufferToAst.ts @@ -1,4 +1,4 @@ -// This file is generated by scripts/generate-ast-converters.js. +// This file is generated by scripts/generate-buffer-to-ast.js. // Do not edit this file directly. import type * as estree from 'estree'; diff --git a/src/utils/convert-ast-strings.ts b/src/utils/convert-ast-strings.ts index 0ce8fdeca..ad2da5d2b 100644 --- a/src/utils/convert-ast-strings.ts +++ b/src/utils/convert-ast-strings.ts @@ -1,5 +1,6 @@ -// This file is generated by scripts/generate-string-constant.js. +// This file is generated by scripts/generate-string-constants.js. // Do not edit this file directly. + export default [ 'var', 'let', From eebf061c34bcbe157890d231742e9c93375121ca Mon Sep 17 00:00:00 2001 From: Lukas Taegert-Atkinson Date: Wed, 10 Apr 2024 09:02:09 +0200 Subject: [PATCH 13/45] Add high-level architecture documentation (#5456) * Start working on architecture docs * Extend documentation * Extend documentation * Extend documentation --- ARCHITECTURE.md | 130 ++++++++++++++++++++++++++++++++++++ CONTRIBUTING.md | 4 ++ README.md | 3 +- src/Chunk.ts | 6 +- src/utils/executionOrder.ts | 7 ++ 5 files changed, 146 insertions(+), 4 deletions(-) create mode 100644 ARCHITECTURE.md diff --git a/ARCHITECTURE.md b/ARCHITECTURE.md new file mode 100644 index 000000000..a17953d7f --- /dev/null +++ b/ARCHITECTURE.md @@ -0,0 +1,130 @@ +# High-level architecture + +## Rollup packages + +- The [`rollup`](https://www.npmjs.com/package/rollup) npm package contains both Rollup's Node.js JavaScript interface and the command-line-interface (CLI). +- There is a separate browser build available as [`@rollup/browser`](https://www.npmjs.com/package/@rollup/browser). It exposes the same JavaScript interface as the Node.js build but does not include the CLI and also requires writing a plugin to encapsulate file reading. Instead of native code dependencies, this build has a bundled WASM artifact included that can be loaded in the browser. This is what the [Rollup REPL](https://rollupjs.org/repl) uses. +- For every supported platform-architecture combination, there is a separate pacakge containing the native code. These are not listed in the committed `package.json` file but are added dynamically during publishing as `optionalDependencies`. The `README.md` and `package.json` files for those dependencies can be found in the [`npm`](npm) folder. The corresponding binaries are built and published from [GitHub Actions](.github/workflows/build-and-tests.yml) whenever a new release version tag is pushed. The actual loading of the native code is handled by [`native.js`](native.js) which is copied into the output folder during build. So to add a new platform-architecture combination, you need to + - add a new package in the `npm` folder + - update the `native.js` file + - add the corresponding triple to the [`package.json`](package.json) file as napi-rs depends on this + - extend the [GitHub Actions workflow](.github/workflows/build-and-tests.yml) to build the new package +- There is also a separate `@rollup/wasm-node` package that is identical to the `rollup` package in that it contains the Node.js JavaScript interface and the CLI but does not contain any native code. Instead, it includes a WebAssembly artifact that runs in Node.js. This package and the corresponding artifact only built on GitHub Actions and published via the [`publish-wasm-node-package.js`](scripts/publish-wasm-node-package.js) script. + +## Building Rollup + +### JavaScript interface and CLI + +- The [`rollup.config.ts`](rollup.config.ts) orchestrates building the ESM and CommonJS versions of the JavaScript interface, the CLI, which is an extension of and shares code with the CommonJS build, and the browser build. + - `npm run build:js` builds all JavaScript artifacts. However, as it includes the browser build, it requires the browser Web Assembly artifact to be built first, otherwise the build will fail. +- The JavaScript interface contains the core logic. + - It is mostly environment agnostic. + - To achieve full environment independence in the browser build, [`replace-browser-modules.ts`](build-plugins/replace-browser-modules.ts) replaces some modules with modified browser versions that reside in the [`browser` folder](browser). + - The most prominent difference is the fact that there is no fallback logic for the `resolveId` and `load` plugin hooks. If there is no plugin implementing those hooks for a file, the browser build will fail. + - The entry point for the Node.js build is [`node-entry.ts`](src/node-entry.ts) while the browser build uses [`browser-entry.ts`](src/browser-entry.ts). Those are mostly identical except that the browser build does not expose the watch mode interface. +- The CLI is a wrapper around the JavaScript interface. + - It resides in the [`cli` folder](cli) with the entry point [cli.ts](cli/cli.ts). + - The logic to read configuration files resides in [locaConfigFile.ts](cli/run/loadConfigFile.ts) and is exposed as a separate export via `import { loadConfigFile } from "rollup/loadConfigFile"`. + - Only the CLI is able to handle arrays of configurations. Those are handled sequentially in [`run/index.ts`](cli/run/index.ts). + - The CLI handles several CLI-only options that are specific to the Node.js environment like setting environment variables or handling std-in, see [Command line flags](docs/command-line-interface/index.md#command-line-flags). + +### Native code and Web Assembly + +The `rollup` package relies on optional dependencies to provide platform-specific native code. These are not listed in the committed `package.json` file but are added dynamically during publishing. This logic is handled by [`napi-rs`](https://napi.rs) via `npm run prepublish:napi` from [`scripts/prepublish.js`](scripts/prepublish.js). + +As native modules do not work for the browser build, we use [`wasmpack`](https://rustwasm.github.io/docs/wasm-pack/) to build a WebAssembly artefact. This is triggered from `npm run build` via `npm run build:wasm`. There is also a separate Node wasm build that is again triggered from GitHub actions via `npm run build:wasm:node`. + +From JavaScript, native code is imported by importing [`native.js`](native.js). This module, or its WebAssembly version [`native.wasm.js`](native.wasm.js), is [copied](build-plugins/emit-native-entry.ts) as `native.js` into the output folder during build (via [`publish-wasm-node-package.js`](scripts/publish-wasm-node-package.js) for WebAssembly). Imports of this module are [declared external](build-plugins/external-native-import.ts). + +The Rust entrypoints are [`bindings_napi/src/lib.rs`](rust/bindings_napi/src/lib.rs) for the native modules and [`bindings_wasm/src/lib.rs`](rust/bindings_wasm/src/lib.rs) for WebAssembly. + +## The build and generate phases + +Building an output has two phases + +- The "build" phase builds a module graph form the input files and decides, which code should be included in the output + - It is triggered by calling the `rollup(inputOptions)` function exported by the JavaScript interface + - It returns a "bundle" object that has `generate` and `write` methods +- The "generate" phase generates the output files from the bundle by calling `.generate(outputOptions)` or `.write(outputOptions)` + - The main difference is that `.write` will write the files to disk while `.generate` just returns the output in-memory. Hence `.write` requires the [`file`](https://rollupjs.org/configuration-options/#output-file) or [`dir`](https://rollupjs.org/configuration-options/#output-dir) options to be set while `.generate` does not. + - It is possible to generate multiple outputs from the same bundle e.g. with different formats + - As code-splitting is also part of the "generate" phase, outputs can also use [`preserveModules`](https://rollupjs.org/configuration-options/#output-preservemodules) to keep the file structure or [`inlineDynamicImports`](https://rollupjs.org/configuration-options/#output-inlinedynamicimports) to inline dynamic imports, albeit at the cost of some semantic changes. + +```mermaid +flowchart LR + classDef default fill: transparent, color: black; + classDef graphobject fill: #ffb3b3, stroke: black; + classDef command fill: #ffd2b3, stroke: black, text-align: left; + build("rollup\ninput: main.js"):::command + --> 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 [`chunkAssigment.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 [finalizer](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/CONTRIBUTING.md b/CONTRIBUTING.md index 310ab6843..f59b6a89b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -115,6 +115,10 @@ will start the website locally in development mode via Vite. This will give you 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 Any code change should be submitted as a pull request. The description should explain what the code does and give steps to execute it. The pull request should also contain tests. diff --git a/README.md b/README.md index 721c96a9e..a1b6b9ea8 100644 --- a/README.md +++ b/README.md @@ -89,6 +89,7 @@ But with ES modules, instead of importing the whole `utils` object, we can just ```js // import the ajax function with an ES import statement import { ajax } from 'node:utils'; + var query = 'Rollup'; // call the ajax function ajax('https://api.example.com?search=' + query).then(handleResponse); @@ -108,7 +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 diff --git a/src/Chunk.ts b/src/Chunk.ts index c4e057b02..ddb158b02 100644 --- a/src/Chunk.ts +++ b/src/Chunk.ts @@ -652,15 +652,15 @@ export default class Chunk { const renderedExports = exportMode === 'none' ? [] : this.getChunkExportDeclarations(format); let hasExports = renderedExports.length > 0; let hasDefaultExport = false; - for (const renderedDependence of renderedDependencies) { - const { reexports } = renderedDependence; + for (const renderedDependency of renderedDependencies) { + const { reexports } = renderedDependency; if (reexports?.length) { hasExports = true; if (!hasDefaultExport && reexports.some(reexport => reexport.reexported === 'default')) { hasDefaultExport = true; } if (format === 'es') { - renderedDependence.reexports = reexports.filter( + renderedDependency.reexports = reexports.filter( // eslint-disable-next-line unicorn/prefer-array-some ({ reexported }) => !renderedExports.find(({ exported }) => exported === reexported) ); diff --git a/src/utils/executionOrder.ts b/src/utils/executionOrder.ts index 0b5df46dd..284939f89 100644 --- a/src/utils/executionOrder.ts +++ b/src/utils/executionOrder.ts @@ -12,6 +12,13 @@ export function sortByExecutionOrder(units: OrderedExecutionUnit[]): void { units.sort(compareExecIndex); } +// 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[]; From e2a05394b0c3827b011388e83694c763b1397602 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 12 Apr 2024 02:49:42 +0000 Subject: [PATCH 14/45] chore(deps): lock file maintenance minor/patch updates (#5469) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- package-lock.json | 584 +++++++++++++++++----------------- package.json | 18 +- rust/Cargo.lock | 64 ++-- rust/bindings_napi/Cargo.toml | 4 +- rust/bindings_wasm/Cargo.toml | 2 +- rust/parse_ast/Cargo.toml | 4 +- 6 files changed, 338 insertions(+), 338 deletions(-) diff --git a/package-lock.json b/package-lock.json index 3b007f703..5a3105a3e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -33,14 +33,14 @@ "@rollup/plugin-terser": "^0.4.4", "@rollup/plugin-typescript": "^11.1.6", "@rollup/pluginutils": "^5.1.0", - "@shikijs/vitepress-twoslash": "^1.2.3", + "@shikijs/vitepress-twoslash": "^1.2.4", "@types/eslint": "^8.56.7", "@types/inquirer": "^9.0.7", "@types/mocha": "^10.0.6", "@types/node": "~18.18.14", "@types/yargs-parser": "^21.0.3", - "@typescript-eslint/eslint-plugin": "^7.5.0", - "@typescript-eslint/parser": "^7.5.0", + "@typescript-eslint/eslint-plugin": "^7.6.0", + "@typescript-eslint/parser": "^7.6.0", "@vue/eslint-config-prettier": "^9.0.0", "@vue/eslint-config-typescript": "^13.0.0", "acorn": "^8.11.3", @@ -59,7 +59,7 @@ "eslint-plugin-import": "^2.29.1", "eslint-plugin-prettier": "^5.1.3", "eslint-plugin-unicorn": "^51.0.1", - "eslint-plugin-vue": "^9.24.0", + "eslint-plugin-vue": "^9.24.1", "fixturify": "^3.0.0", "flru": "^1.0.2", "fs-extra": "^11.2.0", @@ -69,7 +69,7 @@ "is-reference": "^3.0.2", "lint-staged": "^15.2.2", "locate-character": "^3.0.0", - "magic-string": "^0.30.8", + "magic-string": "^0.30.9", "mocha": "^10.4.0", "nyc": "^15.1.0", "pinia": "^2.1.7", @@ -77,7 +77,7 @@ "pretty-bytes": "^6.1.1", "pretty-ms": "^9.0.0", "requirejs": "^2.3.6", - "rollup": "^4.13.2", + "rollup": "^4.14.1", "rollup-plugin-license": "^3.3.1", "rollup-plugin-string": "^3.0.0", "semver": "^7.6.0", @@ -86,10 +86,10 @@ "source-map": "^0.7.4", "source-map-support": "^0.5.21", "systemjs": "^6.14.3", - "terser": "^5.30.1", + "terser": "^5.30.3", "tslib": "^2.6.2", - "typescript": "^5.4.3", - "vite": "^5.2.7", + "typescript": "^5.4.4", + "vite": "^5.2.8", "vitepress": "^1.0.2", "vue": "^3.4.21", "wasm-pack": "^0.12.1", @@ -159,151 +159,151 @@ } }, "node_modules/@algolia/cache-browser-local-storage": { - "version": "4.23.2", - "resolved": "https://registry.npmjs.org/@algolia/cache-browser-local-storage/-/cache-browser-local-storage-4.23.2.tgz", - "integrity": "sha512-PvRQdCmtiU22dw9ZcTJkrVKgNBVAxKgD0/cfiqyxhA5+PHzA2WDt6jOmZ9QASkeM2BpyzClJb/Wr1yt2/t78Kw==", + "version": "4.23.3", + "resolved": "https://registry.npmjs.org/@algolia/cache-browser-local-storage/-/cache-browser-local-storage-4.23.3.tgz", + "integrity": "sha512-vRHXYCpPlTDE7i6UOy2xE03zHF2C8MEFjPN2v7fRbqVpcOvAUQK81x3Kc21xyb5aSIpYCjWCZbYZuz8Glyzyyg==", "dev": true, "dependencies": { - "@algolia/cache-common": "4.23.2" + "@algolia/cache-common": "4.23.3" } }, "node_modules/@algolia/cache-common": { - "version": "4.23.2", - "resolved": "https://registry.npmjs.org/@algolia/cache-common/-/cache-common-4.23.2.tgz", - "integrity": "sha512-OUK/6mqr6CQWxzl/QY0/mwhlGvS6fMtvEPyn/7AHUx96NjqDA4X4+Ju7aXFQKh+m3jW9VPB0B9xvEQgyAnRPNw==", + "version": "4.23.3", + "resolved": "https://registry.npmjs.org/@algolia/cache-common/-/cache-common-4.23.3.tgz", + "integrity": "sha512-h9XcNI6lxYStaw32pHpB1TMm0RuxphF+Ik4o7tcQiodEdpKK+wKufY6QXtba7t3k8eseirEMVB83uFFF3Nu54A==", "dev": true }, "node_modules/@algolia/cache-in-memory": { - "version": "4.23.2", - "resolved": "https://registry.npmjs.org/@algolia/cache-in-memory/-/cache-in-memory-4.23.2.tgz", - "integrity": "sha512-rfbi/SnhEa3MmlqQvgYz/9NNJ156NkU6xFxjbxBtLWnHbpj+qnlMoKd+amoiacHRITpajg6zYbLM9dnaD3Bczw==", + "version": "4.23.3", + "resolved": "https://registry.npmjs.org/@algolia/cache-in-memory/-/cache-in-memory-4.23.3.tgz", + "integrity": "sha512-yvpbuUXg/+0rbcagxNT7un0eo3czx2Uf0y4eiR4z4SD7SiptwYTpbuS0IHxcLHG3lq22ukx1T6Kjtk/rT+mqNg==", "dev": true, "dependencies": { - "@algolia/cache-common": "4.23.2" + "@algolia/cache-common": "4.23.3" } }, "node_modules/@algolia/client-account": { - "version": "4.23.2", - "resolved": "https://registry.npmjs.org/@algolia/client-account/-/client-account-4.23.2.tgz", - "integrity": "sha512-VbrOCLIN/5I7iIdskSoSw3uOUPF516k4SjDD4Qz3BFwa3of7D9A0lzBMAvQEJJEPHWdVraBJlGgdJq/ttmquJQ==", + "version": "4.23.3", + "resolved": "https://registry.npmjs.org/@algolia/client-account/-/client-account-4.23.3.tgz", + "integrity": "sha512-hpa6S5d7iQmretHHF40QGq6hz0anWEHGlULcTIT9tbUssWUriN9AUXIFQ8Ei4w9azD0hc1rUok9/DeQQobhQMA==", "dev": true, "dependencies": { - "@algolia/client-common": "4.23.2", - "@algolia/client-search": "4.23.2", - "@algolia/transporter": "4.23.2" + "@algolia/client-common": "4.23.3", + "@algolia/client-search": "4.23.3", + "@algolia/transporter": "4.23.3" } }, "node_modules/@algolia/client-analytics": { - "version": "4.23.2", - "resolved": "https://registry.npmjs.org/@algolia/client-analytics/-/client-analytics-4.23.2.tgz", - "integrity": "sha512-lLj7irsAztGhMoEx/SwKd1cwLY6Daf1Q5f2AOsZacpppSvuFvuBrmkzT7pap1OD/OePjLKxicJS8wNA0+zKtuw==", + "version": "4.23.3", + "resolved": "https://registry.npmjs.org/@algolia/client-analytics/-/client-analytics-4.23.3.tgz", + "integrity": "sha512-LBsEARGS9cj8VkTAVEZphjxTjMVCci+zIIiRhpFun9jGDUlS1XmhCW7CTrnaWeIuCQS/2iPyRqSy1nXPjcBLRA==", "dev": true, "dependencies": { - "@algolia/client-common": "4.23.2", - "@algolia/client-search": "4.23.2", - "@algolia/requester-common": "4.23.2", - "@algolia/transporter": "4.23.2" + "@algolia/client-common": "4.23.3", + "@algolia/client-search": "4.23.3", + "@algolia/requester-common": "4.23.3", + "@algolia/transporter": "4.23.3" } }, "node_modules/@algolia/client-common": { - "version": "4.23.2", - "resolved": "https://registry.npmjs.org/@algolia/client-common/-/client-common-4.23.2.tgz", - "integrity": "sha512-Q2K1FRJBern8kIfZ0EqPvUr3V29ICxCm/q42zInV+VJRjldAD9oTsMGwqUQ26GFMdFYmqkEfCbY4VGAiQhh22g==", + "version": "4.23.3", + "resolved": "https://registry.npmjs.org/@algolia/client-common/-/client-common-4.23.3.tgz", + "integrity": "sha512-l6EiPxdAlg8CYhroqS5ybfIczsGUIAC47slLPOMDeKSVXYG1n0qGiz4RjAHLw2aD0xzh2EXZ7aRguPfz7UKDKw==", "dev": true, "dependencies": { - "@algolia/requester-common": "4.23.2", - "@algolia/transporter": "4.23.2" + "@algolia/requester-common": "4.23.3", + "@algolia/transporter": "4.23.3" } }, "node_modules/@algolia/client-personalization": { - "version": "4.23.2", - "resolved": "https://registry.npmjs.org/@algolia/client-personalization/-/client-personalization-4.23.2.tgz", - "integrity": "sha512-vwPsgnCGhUcHhhQG5IM27z8q7dWrN9itjdvgA6uKf2e9r7vB+WXt4OocK0CeoYQt3OGEAExryzsB8DWqdMK5wg==", + "version": "4.23.3", + "resolved": "https://registry.npmjs.org/@algolia/client-personalization/-/client-personalization-4.23.3.tgz", + "integrity": "sha512-3E3yF3Ocr1tB/xOZiuC3doHQBQ2zu2MPTYZ0d4lpfWads2WTKG7ZzmGnsHmm63RflvDeLK/UVx7j2b3QuwKQ2g==", "dev": true, "dependencies": { - "@algolia/client-common": "4.23.2", - "@algolia/requester-common": "4.23.2", - "@algolia/transporter": "4.23.2" + "@algolia/client-common": "4.23.3", + "@algolia/requester-common": "4.23.3", + "@algolia/transporter": "4.23.3" } }, "node_modules/@algolia/client-search": { - "version": "4.23.2", - "resolved": "https://registry.npmjs.org/@algolia/client-search/-/client-search-4.23.2.tgz", - "integrity": "sha512-CxSB29OVGSE7l/iyoHvamMonzq7Ev8lnk/OkzleODZ1iBcCs3JC/XgTIKzN/4RSTrJ9QybsnlrN/bYCGufo7qw==", + "version": "4.23.3", + "resolved": "https://registry.npmjs.org/@algolia/client-search/-/client-search-4.23.3.tgz", + "integrity": "sha512-P4VAKFHqU0wx9O+q29Q8YVuaowaZ5EM77rxfmGnkHUJggh28useXQdopokgwMeYw2XUht49WX5RcTQ40rZIabw==", "dev": true, "dependencies": { - "@algolia/client-common": "4.23.2", - "@algolia/requester-common": "4.23.2", - "@algolia/transporter": "4.23.2" + "@algolia/client-common": "4.23.3", + "@algolia/requester-common": "4.23.3", + "@algolia/transporter": "4.23.3" } }, "node_modules/@algolia/logger-common": { - "version": "4.23.2", - "resolved": "https://registry.npmjs.org/@algolia/logger-common/-/logger-common-4.23.2.tgz", - "integrity": "sha512-jGM49Q7626cXZ7qRAWXn0jDlzvoA1FvN4rKTi1g0hxKsTTSReyYk0i1ADWjChDPl3Q+nSDhJuosM2bBUAay7xw==", + "version": "4.23.3", + "resolved": "https://registry.npmjs.org/@algolia/logger-common/-/logger-common-4.23.3.tgz", + "integrity": "sha512-y9kBtmJwiZ9ZZ+1Ek66P0M68mHQzKRxkW5kAAXYN/rdzgDN0d2COsViEFufxJ0pb45K4FRcfC7+33YB4BLrZ+g==", "dev": true }, "node_modules/@algolia/logger-console": { - "version": "4.23.2", - "resolved": "https://registry.npmjs.org/@algolia/logger-console/-/logger-console-4.23.2.tgz", - "integrity": "sha512-oo+lnxxEmlhTBTFZ3fGz1O8PJ+G+8FiAoMY2Qo3Q4w23xocQev6KqDTA1JQAGPDxAewNA2VBwWOsVXeXFjrI/Q==", + "version": "4.23.3", + "resolved": "https://registry.npmjs.org/@algolia/logger-console/-/logger-console-4.23.3.tgz", + "integrity": "sha512-8xoiseoWDKuCVnWP8jHthgaeobDLolh00KJAdMe9XPrWPuf1by732jSpgy2BlsLTaT9m32pHI8CRfrOqQzHv3A==", "dev": true, "dependencies": { - "@algolia/logger-common": "4.23.2" + "@algolia/logger-common": "4.23.3" } }, "node_modules/@algolia/recommend": { - "version": "4.23.2", - "resolved": "https://registry.npmjs.org/@algolia/recommend/-/recommend-4.23.2.tgz", - "integrity": "sha512-Q75CjnzRCDzgIlgWfPnkLtrfF4t82JCirhalXkSSwe/c1GH5pWh4xUyDOR3KTMo+YxxX3zTlrL/FjHmUJEWEcg==", + "version": "4.23.3", + "resolved": "https://registry.npmjs.org/@algolia/recommend/-/recommend-4.23.3.tgz", + "integrity": "sha512-9fK4nXZF0bFkdcLBRDexsnGzVmu4TSYZqxdpgBW2tEyfuSSY54D4qSRkLmNkrrz4YFvdh2GM1gA8vSsnZPR73w==", "dev": true, "dependencies": { - "@algolia/cache-browser-local-storage": "4.23.2", - "@algolia/cache-common": "4.23.2", - "@algolia/cache-in-memory": "4.23.2", - "@algolia/client-common": "4.23.2", - "@algolia/client-search": "4.23.2", - "@algolia/logger-common": "4.23.2", - "@algolia/logger-console": "4.23.2", - "@algolia/requester-browser-xhr": "4.23.2", - "@algolia/requester-common": "4.23.2", - "@algolia/requester-node-http": "4.23.2", - "@algolia/transporter": "4.23.2" + "@algolia/cache-browser-local-storage": "4.23.3", + "@algolia/cache-common": "4.23.3", + "@algolia/cache-in-memory": "4.23.3", + "@algolia/client-common": "4.23.3", + "@algolia/client-search": "4.23.3", + "@algolia/logger-common": "4.23.3", + "@algolia/logger-console": "4.23.3", + "@algolia/requester-browser-xhr": "4.23.3", + "@algolia/requester-common": "4.23.3", + "@algolia/requester-node-http": "4.23.3", + "@algolia/transporter": "4.23.3" } }, "node_modules/@algolia/requester-browser-xhr": { - "version": "4.23.2", - "resolved": "https://registry.npmjs.org/@algolia/requester-browser-xhr/-/requester-browser-xhr-4.23.2.tgz", - "integrity": "sha512-TO9wLlp8+rvW9LnIfyHsu8mNAMYrqNdQ0oLF6eTWFxXfxG3k8F/Bh7nFYGk2rFAYty4Fw4XUtrv/YjeNDtM5og==", + "version": "4.23.3", + "resolved": "https://registry.npmjs.org/@algolia/requester-browser-xhr/-/requester-browser-xhr-4.23.3.tgz", + "integrity": "sha512-jDWGIQ96BhXbmONAQsasIpTYWslyjkiGu0Quydjlowe+ciqySpiDUrJHERIRfELE5+wFc7hc1Q5hqjGoV7yghw==", "dev": true, "dependencies": { - "@algolia/requester-common": "4.23.2" + "@algolia/requester-common": "4.23.3" } }, "node_modules/@algolia/requester-common": { - "version": "4.23.2", - "resolved": "https://registry.npmjs.org/@algolia/requester-common/-/requester-common-4.23.2.tgz", - "integrity": "sha512-3EfpBS0Hri0lGDB5H/BocLt7Vkop0bTTLVUBB844HH6tVycwShmsV6bDR7yXbQvFP1uNpgePRD3cdBCjeHmk6Q==", + "version": "4.23.3", + "resolved": "https://registry.npmjs.org/@algolia/requester-common/-/requester-common-4.23.3.tgz", + "integrity": "sha512-xloIdr/bedtYEGcXCiF2muajyvRhwop4cMZo+K2qzNht0CMzlRkm8YsDdj5IaBhshqfgmBb3rTg4sL4/PpvLYw==", "dev": true }, "node_modules/@algolia/requester-node-http": { - "version": "4.23.2", - "resolved": "https://registry.npmjs.org/@algolia/requester-node-http/-/requester-node-http-4.23.2.tgz", - "integrity": "sha512-SVzgkZM/malo+2SB0NWDXpnT7nO5IZwuDTaaH6SjLeOHcya1o56LSWXk+3F3rNLz2GVH+I/rpYKiqmHhSOjerw==", + "version": "4.23.3", + "resolved": "https://registry.npmjs.org/@algolia/requester-node-http/-/requester-node-http-4.23.3.tgz", + "integrity": "sha512-zgu++8Uj03IWDEJM3fuNl34s746JnZOWn1Uz5taV1dFyJhVM/kTNw9Ik7YJWiUNHJQXcaD8IXD1eCb0nq/aByA==", "dev": true, "dependencies": { - "@algolia/requester-common": "4.23.2" + "@algolia/requester-common": "4.23.3" } }, "node_modules/@algolia/transporter": { - "version": "4.23.2", - "resolved": "https://registry.npmjs.org/@algolia/transporter/-/transporter-4.23.2.tgz", - "integrity": "sha512-GY3aGKBy+8AK4vZh8sfkatDciDVKad5rTY2S10Aefyjh7e7UGBP4zigf42qVXwU8VOPwi7l/L7OACGMOFcjB0Q==", + "version": "4.23.3", + "resolved": "https://registry.npmjs.org/@algolia/transporter/-/transporter-4.23.3.tgz", + "integrity": "sha512-Wjl5gttqnf/gQKJA+dafnD0Y6Yw97yvfY8R9h0dQltX1GXTgNs1zWgvtWW0tHl1EgMdhAyw189uWiZMnL3QebQ==", "dev": true, "dependencies": { - "@algolia/cache-common": "4.23.2", - "@algolia/logger-common": "4.23.2", - "@algolia/requester-common": "4.23.2" + "@algolia/cache-common": "4.23.3", + "@algolia/logger-common": "4.23.3", + "@algolia/requester-common": "4.23.3" } }, "node_modules/@ampproject/remapping": { @@ -791,9 +791,9 @@ "dev": true }, "node_modules/@codemirror/view": { - "version": "6.26.1", - "resolved": "https://registry.npmjs.org/@codemirror/view/-/view-6.26.1.tgz", - "integrity": "sha512-wLw0t3R9AwOSQThdZ5Onw8QQtem5asE7+bPlnzc57eubPqiuJKIzwjMZ+C42vQett+iva+J8VgFV4RYWDBh5FA==", + "version": "6.26.2", + "resolved": "https://registry.npmjs.org/@codemirror/view/-/view-6.26.2.tgz", + "integrity": "sha512-j6V48PlFC/O7ERAR5vRW5QKDdchzmyyfojDdt+zPsB0YXoWgcjlC1IWjmlYfx08aQZ3HN5BtALcgGgtSKGMe7A==", "dev": true, "dependencies": { "@codemirror/state": "^6.4.0", @@ -1605,9 +1605,9 @@ } }, "node_modules/@napi-rs/cli": { - "version": "2.18.0", - "resolved": "https://registry.npmjs.org/@napi-rs/cli/-/cli-2.18.0.tgz", - "integrity": "sha512-lfSRT7cs3iC4L+kv9suGYQEezn5Nii7Kpu+THsYVI0tA1Vh59LH45p4QADaD7hvIkmOz79eEGtoKQ9nAkAPkzA==", + "version": "2.18.1", + "resolved": "https://registry.npmjs.org/@napi-rs/cli/-/cli-2.18.1.tgz", + "integrity": "sha512-N4iTeip2VSk0RftgDGuk7IBrgOST/WPUSA3lYstILXsNifR3tHugcbLzo04+OtSrMc+ZUPsXo3Jd1t3dlswAlw==", "dev": true, "bin": { "napi": "scripts/index.js" @@ -1928,9 +1928,9 @@ } }, "node_modules/@rollup/rollup-android-arm-eabi": { - "version": "4.14.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.14.0.tgz", - "integrity": "sha512-jwXtxYbRt1V+CdQSy6Z+uZti7JF5irRKF8hlKfEnF/xJpcNGuuiZMBvuoYM+x9sr9iWGnzrlM0+9hvQ1kgkf1w==", + "version": "4.14.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.14.1.tgz", + "integrity": "sha512-fH8/o8nSUek8ceQnT7K4EQbSiV7jgkHq81m9lWZFIXjJ7lJzpWXbQFpT/Zh6OZYnpFykvzC3fbEvEAFZu03dPA==", "cpu": [ "arm" ], @@ -1941,9 +1941,9 @@ ] }, "node_modules/@rollup/rollup-android-arm64": { - "version": "4.14.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.14.0.tgz", - "integrity": "sha512-fI9nduZhCccjzlsA/OuAwtFGWocxA4gqXGTLvOyiF8d+8o0fZUeSztixkYjcGq1fGZY3Tkq4yRvHPFxU+jdZ9Q==", + "version": "4.14.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.14.1.tgz", + "integrity": "sha512-Y/9OHLjzkunF+KGEoJr3heiD5X9OLa8sbT1lm0NYeKyaM3oMhhQFvPB0bNZYJwlq93j8Z6wSxh9+cyKQaxS7PQ==", "cpu": [ "arm64" ], @@ -1954,9 +1954,9 @@ ] }, "node_modules/@rollup/rollup-darwin-arm64": { - "version": "4.14.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.14.0.tgz", - "integrity": "sha512-BcnSPRM76/cD2gQC+rQNGBN6GStBs2pl/FpweW8JYuz5J/IEa0Fr4AtrPv766DB/6b2MZ/AfSIOSGw3nEIP8SA==", + "version": "4.14.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.14.1.tgz", + "integrity": "sha512-+kecg3FY84WadgcuSVm6llrABOdQAEbNdnpi5X3UwWiFVhZIZvKgGrF7kmLguvxHNQy+UuRV66cLVl3S+Rkt+Q==", "cpu": [ "arm64" ], @@ -1967,9 +1967,9 @@ ] }, "node_modules/@rollup/rollup-darwin-x64": { - "version": "4.14.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.14.0.tgz", - "integrity": "sha512-LDyFB9GRolGN7XI6955aFeI3wCdCUszFWumWU0deHA8VpR3nWRrjG6GtGjBrQxQKFevnUTHKCfPR4IvrW3kCgQ==", + "version": "4.14.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.14.1.tgz", + "integrity": "sha512-2pYRzEjVqq2TB/UNv47BV/8vQiXkFGVmPFwJb+1E0IFFZbIX8/jo1olxqqMbo6xCXf8kabANhp5bzCij2tFLUA==", "cpu": [ "x64" ], @@ -1980,9 +1980,9 @@ ] }, "node_modules/@rollup/rollup-linux-arm-gnueabihf": { - "version": "4.14.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.14.0.tgz", - "integrity": "sha512-ygrGVhQP47mRh0AAD0zl6QqCbNsf0eTo+vgwkY6LunBcg0f2Jv365GXlDUECIyoXp1kKwL5WW6rsO429DBY/bA==", + "version": "4.14.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.14.1.tgz", + "integrity": "sha512-mS6wQ6Do6/wmrF9aTFVpIJ3/IDXhg1EZcQFYHZLHqw6AzMBjTHWnCG35HxSqUNphh0EHqSM6wRTT8HsL1C0x5g==", "cpu": [ "arm" ], @@ -1993,9 +1993,9 @@ ] }, "node_modules/@rollup/rollup-linux-arm64-gnu": { - "version": "4.14.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.14.0.tgz", - "integrity": "sha512-x+uJ6MAYRlHGe9wi4HQjxpaKHPM3d3JjqqCkeC5gpnnI6OWovLdXTpfa8trjxPLnWKyBsSi5kne+146GAxFt4A==", + "version": "4.14.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.14.1.tgz", + "integrity": "sha512-p9rGKYkHdFMzhckOTFubfxgyIO1vw//7IIjBBRVzyZebWlzRLeNhqxuSaZ7kCEKVkm/kuC9fVRW9HkC/zNRG2w==", "cpu": [ "arm64" ], @@ -2006,9 +2006,9 @@ ] }, "node_modules/@rollup/rollup-linux-arm64-musl": { - "version": "4.14.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.14.0.tgz", - "integrity": "sha512-nrRw8ZTQKg6+Lttwqo6a2VxR9tOroa2m91XbdQ2sUUzHoedXlsyvY1fN4xWdqz8PKmf4orDwejxXHjh7YBGUCA==", + "version": "4.14.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.14.1.tgz", + "integrity": "sha512-nDY6Yz5xS/Y4M2i9JLQd3Rofh5OR8Bn8qe3Mv/qCVpHFlwtZSBYSPaU4mrGazWkXrdQ98GB//H0BirGR/SKFSw==", "cpu": [ "arm64" ], @@ -2019,9 +2019,9 @@ ] }, "node_modules/@rollup/rollup-linux-powerpc64le-gnu": { - "version": "4.14.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-powerpc64le-gnu/-/rollup-linux-powerpc64le-gnu-4.14.0.tgz", - "integrity": "sha512-xV0d5jDb4aFu84XKr+lcUJ9y3qpIWhttO3Qev97z8DKLXR62LC3cXT/bMZXrjLF9X+P5oSmJTzAhqwUbY96PnA==", + "version": "4.14.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-powerpc64le-gnu/-/rollup-linux-powerpc64le-gnu-4.14.1.tgz", + "integrity": "sha512-im7HE4VBL+aDswvcmfx88Mp1soqL9OBsdDBU8NqDEYtkri0qV0THhQsvZtZeNNlLeCUQ16PZyv7cqutjDF35qw==", "cpu": [ "ppc64le" ], @@ -2032,9 +2032,9 @@ ] }, "node_modules/@rollup/rollup-linux-riscv64-gnu": { - "version": "4.14.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.14.0.tgz", - "integrity": "sha512-SDDhBQwZX6LPRoPYjAZWyL27LbcBo7WdBFWJi5PI9RPCzU8ijzkQn7tt8NXiXRiFMJCVpkuMkBf4OxSxVMizAw==", + "version": "4.14.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.14.1.tgz", + "integrity": "sha512-RWdiHuAxWmzPJgaHJdpvUUlDz8sdQz4P2uv367T2JocdDa98iRw2UjIJ4QxSyt077mXZT2X6pKfT2iYtVEvOFw==", "cpu": [ "riscv64" ], @@ -2045,9 +2045,9 @@ ] }, "node_modules/@rollup/rollup-linux-s390x-gnu": { - "version": "4.14.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.14.0.tgz", - "integrity": "sha512-RxB/qez8zIDshNJDufYlTT0ZTVut5eCpAZ3bdXDU9yTxBzui3KhbGjROK2OYTTor7alM7XBhssgoO3CZ0XD3qA==", + "version": "4.14.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.14.1.tgz", + "integrity": "sha512-VMgaGQ5zRX6ZqV/fas65/sUGc9cPmsntq2FiGmayW9KMNfWVG/j0BAqImvU4KTeOOgYSf1F+k6at1UfNONuNjA==", "cpu": [ "s390x" ], @@ -2058,9 +2058,9 @@ ] }, "node_modules/@rollup/rollup-linux-x64-gnu": { - "version": "4.14.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.14.0.tgz", - "integrity": "sha512-C6y6z2eCNCfhZxT9u+jAM2Fup89ZjiG5pIzZIDycs1IwESviLxwkQcFRGLjnDrP+PT+v5i4YFvlcfAs+LnreXg==", + "version": "4.14.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.14.1.tgz", + "integrity": "sha512-9Q7DGjZN+hTdJomaQ3Iub4m6VPu1r94bmK2z3UeWP3dGUecRC54tmVu9vKHTm1bOt3ASoYtEz6JSRLFzrysKlA==", "cpu": [ "x64" ], @@ -2071,9 +2071,9 @@ ] }, "node_modules/@rollup/rollup-linux-x64-musl": { - "version": "4.14.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.14.0.tgz", - "integrity": "sha512-i0QwbHYfnOMYsBEyjxcwGu5SMIi9sImDVjDg087hpzXqhBSosxkE7gyIYFHgfFl4mr7RrXksIBZ4DoLoP4FhJg==", + "version": "4.14.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.14.1.tgz", + "integrity": "sha512-JNEG/Ti55413SsreTguSx0LOVKX902OfXIKVg+TCXO6Gjans/k9O6ww9q3oLGjNDaTLxM+IHFMeXy/0RXL5R/g==", "cpu": [ "x64" ], @@ -2084,9 +2084,9 @@ ] }, "node_modules/@rollup/rollup-win32-arm64-msvc": { - "version": "4.14.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.14.0.tgz", - "integrity": "sha512-Fq52EYb0riNHLBTAcL0cun+rRwyZ10S9vKzhGKKgeD+XbwunszSY0rVMco5KbOsTlwovP2rTOkiII/fQ4ih/zQ==", + "version": "4.14.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.14.1.tgz", + "integrity": "sha512-ryS22I9y0mumlLNwDFYZRDFLwWh3aKaC72CWjFcFvxK0U6v/mOkM5Up1bTbCRAhv3kEIwW2ajROegCIQViUCeA==", "cpu": [ "arm64" ], @@ -2097,9 +2097,9 @@ ] }, "node_modules/@rollup/rollup-win32-ia32-msvc": { - "version": "4.14.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.14.0.tgz", - "integrity": "sha512-e/PBHxPdJ00O9p5Ui43+vixSgVf4NlLsmV6QneGERJ3lnjIua/kim6PRFe3iDueT1rQcgSkYP8ZBBXa/h4iPvw==", + "version": "4.14.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.14.1.tgz", + "integrity": "sha512-TdloItiGk+T0mTxKx7Hp279xy30LspMso+GzQvV2maYePMAWdmrzqSNZhUpPj3CGw12aGj57I026PgLCTu8CGg==", "cpu": [ "ia32" ], @@ -2110,9 +2110,9 @@ ] }, "node_modules/@rollup/rollup-win32-x64-msvc": { - "version": "4.14.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.14.0.tgz", - "integrity": "sha512-aGg7iToJjdklmxlUlJh/PaPNa4PmqHfyRMLunbL3eaMO0gp656+q1zOKkpJ/CVe9CryJv6tAN1HDoR8cNGzkag==", + "version": "4.14.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.14.1.tgz", + "integrity": "sha512-wQGI+LY/Py20zdUPq+XCem7JcPOyzIJBm3dli+56DJsQOHbnXZFEwgmnC6el1TPAfC8lBT3m+z69RmLykNUbew==", "cpu": [ "x64" ], @@ -2123,42 +2123,42 @@ ] }, "node_modules/@shikijs/core": { - "version": "1.2.4", - "resolved": "https://registry.npmjs.org/@shikijs/core/-/core-1.2.4.tgz", - "integrity": "sha512-ClaUWpt8oTzjcF0MM1P81AeWyzc1sNSJlAjMG80CbwqbFqXSNz+NpQVUC0icobt3sZn43Sn27M4pHD/Jmp3zHw==", + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/@shikijs/core/-/core-1.3.0.tgz", + "integrity": "sha512-7fedsBfuILDTBmrYZNFI8B6ATTxhQAasUHllHmjvSZPnoq4bULWoTpHwmuQvZ8Aq03/tAa2IGo6RXqWtHdWaCA==", "dev": true }, "node_modules/@shikijs/transformers": { - "version": "1.2.4", - "resolved": "https://registry.npmjs.org/@shikijs/transformers/-/transformers-1.2.4.tgz", - "integrity": "sha512-ysGkpsHxRxLmz8nGKeFdV+gKj1NXt+88sM/34kfKVWTWIXg5gsFOJxJBbG7k+fUR5JlD6sNh65W9qPXrbVE1wQ==", + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/@shikijs/transformers/-/transformers-1.3.0.tgz", + "integrity": "sha512-3mlpg2I9CjhjE96dEWQOGeCWoPcyTov3s4aAsHmgvnTHa8MBknEnCQy8/xivJPSpD+olqOqIEoHnLfbNJK29AA==", "dev": true, "dependencies": { - "shiki": "1.2.4" + "shiki": "1.3.0" } }, "node_modules/@shikijs/twoslash": { - "version": "1.2.4", - "resolved": "https://registry.npmjs.org/@shikijs/twoslash/-/twoslash-1.2.4.tgz", - "integrity": "sha512-4F2gNlCFN9HY0jV3J/IBfqkI7w2HBwycwUBx9fLYGYxzbfu0gYRJdQYWtvJC/sG2rYTYlJrS5BpWdXYoMHwbXw==", + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/@shikijs/twoslash/-/twoslash-1.3.0.tgz", + "integrity": "sha512-XF8Xmotej+cavT6ibKtnsN+TagUJF6eieOV0botcXLhj5aMTPtO+Jdjm9+0vGgloy9JHtuXsik1/JqYMvPIIVw==", "dev": true, "dependencies": { - "@shikijs/core": "1.2.4", + "@shikijs/core": "1.3.0", "twoslash": "^0.2.5" } }, "node_modules/@shikijs/vitepress-twoslash": { - "version": "1.2.4", - "resolved": "https://registry.npmjs.org/@shikijs/vitepress-twoslash/-/vitepress-twoslash-1.2.4.tgz", - "integrity": "sha512-LI8Q8A08dRQpEEiespjTBGcT2i+0Uf3Z03FE+okBlObd4Wf+Sq/YNiLR6ga/7V2z/vhktRwcb/2O3+UZMRiEKg==", + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/@shikijs/vitepress-twoslash/-/vitepress-twoslash-1.3.0.tgz", + "integrity": "sha512-fzgoLysy9aSBrZzV5KLeEUjBmCYhz2gZr+36FAtUeNB+GTDIITTlMUzCaqfnYyrDycoIemy7hw/fhNXPPhEjbQ==", "dev": true, "dependencies": { - "@shikijs/twoslash": "1.2.4", + "@shikijs/twoslash": "1.3.0", "floating-vue": "^5.2.2", "mdast-util-from-markdown": "^2.0.0", "mdast-util-gfm": "^3.0.0", "mdast-util-to-hast": "^13.1.0", - "shiki": "1.2.4", + "shiki": "1.3.0", "twoslash": "^0.2.5", "twoslash-vue": "^0.2.5", "vue": "^3.4.21" @@ -2192,9 +2192,9 @@ } }, "node_modules/@types/eslint": { - "version": "8.56.7", - "resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-8.56.7.tgz", - "integrity": "sha512-SjDvI/x3zsZnOkYZ3lCt9lOZWZLB2jIlNKz+LBgCtDurK0JZcwucxYHn1w2BJkD34dgX9Tjnak0txtq4WTggEA==", + "version": "8.56.8", + "resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-8.56.8.tgz", + "integrity": "sha512-LdDdQVDzDXf3ijhhMnE27C5vc0QEknD8GiMR/Hi+fVbdZNfAfCy2j69m0LjUd2MAy0+kIgnOtd5ndTmDk/VWCA==", "dev": true, "dependencies": { "@types/estree": "*", @@ -2386,22 +2386,22 @@ } }, "node_modules/@typescript-eslint/eslint-plugin": { - "version": "7.5.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-7.5.0.tgz", - "integrity": "sha512-HpqNTH8Du34nLxbKgVMGljZMG0rJd2O9ecvr2QLYp+7512ty1j42KnsFwspPXg1Vh8an9YImf6CokUBltisZFQ==", + "version": "7.6.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-7.6.0.tgz", + "integrity": "sha512-gKmTNwZnblUdnTIJu3e9kmeRRzV2j1a/LUO27KNNAnIC5zjy1aSvXSRp4rVNlmAoHlQ7HzX42NbKpcSr4jF80A==", "dev": true, "dependencies": { - "@eslint-community/regexpp": "^4.5.1", - "@typescript-eslint/scope-manager": "7.5.0", - "@typescript-eslint/type-utils": "7.5.0", - "@typescript-eslint/utils": "7.5.0", - "@typescript-eslint/visitor-keys": "7.5.0", + "@eslint-community/regexpp": "^4.10.0", + "@typescript-eslint/scope-manager": "7.6.0", + "@typescript-eslint/type-utils": "7.6.0", + "@typescript-eslint/utils": "7.6.0", + "@typescript-eslint/visitor-keys": "7.6.0", "debug": "^4.3.4", "graphemer": "^1.4.0", - "ignore": "^5.2.4", + "ignore": "^5.3.1", "natural-compare": "^1.4.0", - "semver": "^7.5.4", - "ts-api-utils": "^1.0.1" + "semver": "^7.6.0", + "ts-api-utils": "^1.3.0" }, "engines": { "node": "^18.18.0 || >=20.0.0" @@ -2421,15 +2421,15 @@ } }, "node_modules/@typescript-eslint/parser": { - "version": "7.5.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-7.5.0.tgz", - "integrity": "sha512-cj+XGhNujfD2/wzR1tabNsidnYRaFfEkcULdcIyVBYcXjBvBKOes+mpMBP7hMpOyk+gBcfXsrg4NBGAStQyxjQ==", + "version": "7.6.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-7.6.0.tgz", + "integrity": "sha512-usPMPHcwX3ZoPWnBnhhorc14NJw9J4HpSXQX4urF2TPKG0au0XhJoZyX62fmvdHONUkmyUe74Hzm1//XA+BoYg==", "dev": true, "dependencies": { - "@typescript-eslint/scope-manager": "7.5.0", - "@typescript-eslint/types": "7.5.0", - "@typescript-eslint/typescript-estree": "7.5.0", - "@typescript-eslint/visitor-keys": "7.5.0", + "@typescript-eslint/scope-manager": "7.6.0", + "@typescript-eslint/types": "7.6.0", + "@typescript-eslint/typescript-estree": "7.6.0", + "@typescript-eslint/visitor-keys": "7.6.0", "debug": "^4.3.4" }, "engines": { @@ -2449,13 +2449,13 @@ } }, "node_modules/@typescript-eslint/scope-manager": { - "version": "7.5.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-7.5.0.tgz", - "integrity": "sha512-Z1r7uJY0MDeUlql9XJ6kRVgk/sP11sr3HKXn268HZyqL7i4cEfrdFuSSY/0tUqT37l5zT0tJOsuDP16kio85iA==", + "version": "7.6.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-7.6.0.tgz", + "integrity": "sha512-ngttyfExA5PsHSx0rdFgnADMYQi+Zkeiv4/ZxGYUWd0nLs63Ha0ksmp8VMxAIC0wtCFxMos7Lt3PszJssG/E6w==", "dev": true, "dependencies": { - "@typescript-eslint/types": "7.5.0", - "@typescript-eslint/visitor-keys": "7.5.0" + "@typescript-eslint/types": "7.6.0", + "@typescript-eslint/visitor-keys": "7.6.0" }, "engines": { "node": "^18.18.0 || >=20.0.0" @@ -2466,15 +2466,15 @@ } }, "node_modules/@typescript-eslint/type-utils": { - "version": "7.5.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-7.5.0.tgz", - "integrity": "sha512-A021Rj33+G8mx2Dqh0nMO9GyjjIBK3MqgVgZ2qlKf6CJy51wY/lkkFqq3TqqnH34XyAHUkq27IjlUkWlQRpLHw==", + "version": "7.6.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-7.6.0.tgz", + "integrity": "sha512-NxAfqAPNLG6LTmy7uZgpK8KcuiS2NZD/HlThPXQRGwz6u7MDBWRVliEEl1Gj6U7++kVJTpehkhZzCJLMK66Scw==", "dev": true, "dependencies": { - "@typescript-eslint/typescript-estree": "7.5.0", - "@typescript-eslint/utils": "7.5.0", + "@typescript-eslint/typescript-estree": "7.6.0", + "@typescript-eslint/utils": "7.6.0", "debug": "^4.3.4", - "ts-api-utils": "^1.0.1" + "ts-api-utils": "^1.3.0" }, "engines": { "node": "^18.18.0 || >=20.0.0" @@ -2493,9 +2493,9 @@ } }, "node_modules/@typescript-eslint/types": { - "version": "7.5.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-7.5.0.tgz", - "integrity": "sha512-tv5B4IHeAdhR7uS4+bf8Ov3k793VEVHd45viRRkehIUZxm0WF82VPiLgHzA/Xl4TGPg1ZD49vfxBKFPecD5/mg==", + "version": "7.6.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-7.6.0.tgz", + "integrity": "sha512-h02rYQn8J+MureCvHVVzhl69/GAfQGPQZmOMjG1KfCl7o3HtMSlPaPUAPu6lLctXI5ySRGIYk94clD/AUMCUgQ==", "dev": true, "engines": { "node": "^18.18.0 || >=20.0.0" @@ -2506,19 +2506,19 @@ } }, "node_modules/@typescript-eslint/typescript-estree": { - "version": "7.5.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-7.5.0.tgz", - "integrity": "sha512-YklQQfe0Rv2PZEueLTUffiQGKQneiIEKKnfIqPIOxgM9lKSZFCjT5Ad4VqRKj/U4+kQE3fa8YQpskViL7WjdPQ==", + "version": "7.6.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-7.6.0.tgz", + "integrity": "sha512-+7Y/GP9VuYibecrCQWSKgl3GvUM5cILRttpWtnAu8GNL9j11e4tbuGZmZjJ8ejnKYyBRb2ddGQ3rEFCq3QjMJw==", "dev": true, "dependencies": { - "@typescript-eslint/types": "7.5.0", - "@typescript-eslint/visitor-keys": "7.5.0", + "@typescript-eslint/types": "7.6.0", + "@typescript-eslint/visitor-keys": "7.6.0", "debug": "^4.3.4", "globby": "^11.1.0", "is-glob": "^4.0.3", - "minimatch": "9.0.3", - "semver": "^7.5.4", - "ts-api-utils": "^1.0.1" + "minimatch": "^9.0.4", + "semver": "^7.6.0", + "ts-api-utils": "^1.3.0" }, "engines": { "node": "^18.18.0 || >=20.0.0" @@ -2534,18 +2534,18 @@ } }, "node_modules/@typescript-eslint/utils": { - "version": "7.5.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-7.5.0.tgz", - "integrity": "sha512-3vZl9u0R+/FLQcpy2EHyRGNqAS/ofJ3Ji8aebilfJe+fobK8+LbIFmrHciLVDxjDoONmufDcnVSF38KwMEOjzw==", + "version": "7.6.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-7.6.0.tgz", + "integrity": "sha512-x54gaSsRRI+Nwz59TXpCsr6harB98qjXYzsRxGqvA5Ue3kQH+FxS7FYU81g/omn22ML2pZJkisy6Q+ElK8pBCA==", "dev": true, "dependencies": { "@eslint-community/eslint-utils": "^4.4.0", - "@types/json-schema": "^7.0.12", - "@types/semver": "^7.5.0", - "@typescript-eslint/scope-manager": "7.5.0", - "@typescript-eslint/types": "7.5.0", - "@typescript-eslint/typescript-estree": "7.5.0", - "semver": "^7.5.4" + "@types/json-schema": "^7.0.15", + "@types/semver": "^7.5.8", + "@typescript-eslint/scope-manager": "7.6.0", + "@typescript-eslint/types": "7.6.0", + "@typescript-eslint/typescript-estree": "7.6.0", + "semver": "^7.6.0" }, "engines": { "node": "^18.18.0 || >=20.0.0" @@ -2559,13 +2559,13 @@ } }, "node_modules/@typescript-eslint/visitor-keys": { - "version": "7.5.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-7.5.0.tgz", - "integrity": "sha512-mcuHM/QircmA6O7fy6nn2w/3ditQkj+SgtOc8DW3uQ10Yfj42amm2i+6F2K4YAOPNNTmE6iM1ynM6lrSwdendA==", + "version": "7.6.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-7.6.0.tgz", + "integrity": "sha512-4eLB7t+LlNUmXzfOu1VAIAdkjbu5xNSerURS9X/S5TUKWFRpXRQZbmtPqgKmYx8bj3J0irtQXSiWAOY82v+cgw==", "dev": true, "dependencies": { - "@typescript-eslint/types": "7.5.0", - "eslint-visitor-keys": "^3.4.1" + "@typescript-eslint/types": "7.6.0", + "eslint-visitor-keys": "^3.4.3" }, "engines": { "node": "^18.18.0 || >=20.0.0" @@ -2678,12 +2678,12 @@ "dev": true }, "node_modules/@vue/devtools-kit": { - "version": "7.0.25", - "resolved": "https://registry.npmjs.org/@vue/devtools-kit/-/devtools-kit-7.0.25.tgz", - "integrity": "sha512-wbLkSnOTsKHPb1mB9koFHUoSAF8Dp6Ii/ocR2+DeXFY4oKqIjCeJb/4Lihk4rgqEhCy1WwxLfTgNDo83VvDYkQ==", + "version": "7.0.27", + "resolved": "https://registry.npmjs.org/@vue/devtools-kit/-/devtools-kit-7.0.27.tgz", + "integrity": "sha512-/A5xM38pPCFX5Yhl/lRFAzjyK6VNsH670nww2WbjFKWqlu3I+lMxWKzQkCW6A1V8bduITgl2kHORfg2gTw6QaA==", "dev": true, "dependencies": { - "@vue/devtools-shared": "^7.0.25", + "@vue/devtools-shared": "^7.0.27", "hookable": "^5.5.3", "mitt": "^3.0.1", "perfect-debounce": "^1.0.0", @@ -2700,9 +2700,9 @@ "dev": true }, "node_modules/@vue/devtools-shared": { - "version": "7.0.25", - "resolved": "https://registry.npmjs.org/@vue/devtools-shared/-/devtools-shared-7.0.25.tgz", - "integrity": "sha512-5+XYhcHSXuJSguYnNwL6/e6VTmXwCfryWQOkffh9ZU2zMByybqqqBrMWqvBkqTmMFCjPdzulo66xXbVbwLaElQ==", + "version": "7.0.27", + "resolved": "https://registry.npmjs.org/@vue/devtools-shared/-/devtools-shared-7.0.27.tgz", + "integrity": "sha512-4VxtmZ6yjhiSloqZZq2UYU0TBGxOJ8GxWvp5OlAH70zYqi0FIAyWGPkOhvfoZ7DKQyv2UU0mmKzFHjsEkelGyQ==", "dev": true, "dependencies": { "rfdc": "^1.3.1" @@ -3072,26 +3072,26 @@ } }, "node_modules/algoliasearch": { - "version": "4.23.2", - "resolved": "https://registry.npmjs.org/algoliasearch/-/algoliasearch-4.23.2.tgz", - "integrity": "sha512-8aCl055IsokLuPU8BzLjwzXjb7ty9TPcUFFOk0pYOwsE5DMVhE3kwCMFtsCFKcnoPZK7oObm+H5mbnSO/9ioxQ==", - "dev": true, - "dependencies": { - "@algolia/cache-browser-local-storage": "4.23.2", - "@algolia/cache-common": "4.23.2", - "@algolia/cache-in-memory": "4.23.2", - "@algolia/client-account": "4.23.2", - "@algolia/client-analytics": "4.23.2", - "@algolia/client-common": "4.23.2", - "@algolia/client-personalization": "4.23.2", - "@algolia/client-search": "4.23.2", - "@algolia/logger-common": "4.23.2", - "@algolia/logger-console": "4.23.2", - "@algolia/recommend": "4.23.2", - "@algolia/requester-browser-xhr": "4.23.2", - "@algolia/requester-common": "4.23.2", - "@algolia/requester-node-http": "4.23.2", - "@algolia/transporter": "4.23.2" + "version": "4.23.3", + "resolved": "https://registry.npmjs.org/algoliasearch/-/algoliasearch-4.23.3.tgz", + "integrity": "sha512-Le/3YgNvjW9zxIQMRhUHuhiUjAlKY/zsdZpfq4dlLqg6mEm0nL6yk+7f2hDOtLpxsgE4jSzDmvHL7nXdBp5feg==", + "dev": true, + "dependencies": { + "@algolia/cache-browser-local-storage": "4.23.3", + "@algolia/cache-common": "4.23.3", + "@algolia/cache-in-memory": "4.23.3", + "@algolia/client-account": "4.23.3", + "@algolia/client-analytics": "4.23.3", + "@algolia/client-common": "4.23.3", + "@algolia/client-personalization": "4.23.3", + "@algolia/client-search": "4.23.3", + "@algolia/logger-common": "4.23.3", + "@algolia/logger-console": "4.23.3", + "@algolia/recommend": "4.23.3", + "@algolia/requester-browser-xhr": "4.23.3", + "@algolia/requester-common": "4.23.3", + "@algolia/requester-node-http": "4.23.3", + "@algolia/transporter": "4.23.3" } }, "node_modules/ansi-colors": { @@ -3689,9 +3689,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001605", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001605.tgz", - "integrity": "sha512-nXwGlFWo34uliI9z3n6Qc0wZaf7zaZWA1CPZ169La5mV3I/gem7bst0vr5XQH5TJXZIMfDeZyOrZnSlVzKxxHQ==", + "version": "1.0.30001608", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001608.tgz", + "integrity": "sha512-cjUJTQkk9fQlJR2s4HMuPMvTiRggl0rAVMtthQuyOlDWuqHXqN8azLq+pi8B2TjwKJ32diHjUqRIKeFX4z1FoA==", "dev": true, "funding": [ { @@ -4528,9 +4528,9 @@ } }, "node_modules/electron-to-chromium": { - "version": "1.4.728", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.728.tgz", - "integrity": "sha512-Ud1v7hJJYIqehlUJGqR6PF1Ek8l80zWwxA6nGxigBsGJ9f9M2fciHyrIiNMerSHSH3p+0/Ia7jIlnDkt41h5cw==", + "version": "1.4.735", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.735.tgz", + "integrity": "sha512-pkYpvwg8VyOTQAeBqZ7jsmpCjko1Qc6We1ZtZCjRyYbT5v4AIUKDy5cQTRotQlSSZmMr8jqpEt6JtOj5k7lR7A==", "dev": true }, "node_modules/emoji-regex": { @@ -5039,9 +5039,9 @@ } }, "node_modules/eslint-plugin-vue": { - "version": "9.24.0", - "resolved": "https://registry.npmjs.org/eslint-plugin-vue/-/eslint-plugin-vue-9.24.0.tgz", - "integrity": "sha512-9SkJMvF8NGMT9aQCwFc5rj8Wo1XWSMSHk36i7ZwdI614BU7sIOR28ZjuFPKp8YGymZN12BSEbiSwa7qikp+PBw==", + "version": "9.24.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-vue/-/eslint-plugin-vue-9.24.1.tgz", + "integrity": "sha512-wk3SuwmS1pZdcuJlokGYEi/buDOwD6KltvhIZyOnpJ/378dcQ4zchu9PAMbbLAaydCz1iYc5AozszcOOgZIIOg==", "dev": true, "dependencies": { "@eslint-community/eslint-utils": "^4.4.0", @@ -5057,7 +5057,7 @@ "node": "^14.17.0 || >=16.0.0" }, "peerDependencies": { - "eslint": "^6.2.0 || ^7.0.0 || ^8.0.0" + "eslint": "^6.2.0 || ^7.0.0 || ^8.0.0 || ^9.0.0" } }, "node_modules/eslint-scope": { @@ -8228,9 +8228,9 @@ } }, "node_modules/minimatch": { - "version": "9.0.3", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.3.tgz", - "integrity": "sha512-RHiac9mvaRw0x3AYRgDC1CxAP7HTcNrrECeA8YYJeWnpo+2Q5CegtZjaotWTWxDG3UeGA1coE05iH1mPjT/2mg==", + "version": "9.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.4.tgz", + "integrity": "sha512-KqWh+VchfxcMNRAJjj2tnsSJdNbHsVgnkBhTNrW7AjVo6OvLtxw8zfT9oLw1JSohlFzJ8jCoTgaoXvJ+kHt6fw==", "dev": true, "dependencies": { "brace-expansion": "^2.0.1" @@ -9477,9 +9477,9 @@ } }, "node_modules/preact": { - "version": "10.20.1", - "resolved": "https://registry.npmjs.org/preact/-/preact-10.20.1.tgz", - "integrity": "sha512-JIFjgFg9B2qnOoGiYMVBtrcFxHqn+dNXbq76bVmcaHYJFYR4lW67AOcXgAYQQTDYXDOg/kTZrKPNCdRgJ2UJmw==", + "version": "10.20.2", + "resolved": "https://registry.npmjs.org/preact/-/preact-10.20.2.tgz", + "integrity": "sha512-S1d1ernz3KQ+Y2awUxKakpfOg2CEmJmwOP+6igPx6dgr6pgDvenqYviyokWso2rhHvGtTlWWnJDa7RaPbQerTg==", "dev": true, "funding": { "type": "opencollective", @@ -10109,9 +10109,9 @@ } }, "node_modules/rollup": { - "version": "4.14.0", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.14.0.tgz", - "integrity": "sha512-Qe7w62TyawbDzB4yt32R0+AbIo6m1/sqO7UPzFS8Z/ksL5mrfhA0v4CavfdmFav3D+ub4QeAgsGEe84DoWe/nQ==", + "version": "4.14.1", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.14.1.tgz", + "integrity": "sha512-4LnHSdd3QK2pa1J6dFbfm1HN0D7vSK/ZuZTsdyUAlA6Rr1yTouUTL13HaDOGJVgby461AhrNGBS7sCGXXtT+SA==", "dev": true, "dependencies": { "@types/estree": "1.0.5" @@ -10124,21 +10124,21 @@ "npm": ">=8.0.0" }, "optionalDependencies": { - "@rollup/rollup-android-arm-eabi": "4.14.0", - "@rollup/rollup-android-arm64": "4.14.0", - "@rollup/rollup-darwin-arm64": "4.14.0", - "@rollup/rollup-darwin-x64": "4.14.0", - "@rollup/rollup-linux-arm-gnueabihf": "4.14.0", - "@rollup/rollup-linux-arm64-gnu": "4.14.0", - "@rollup/rollup-linux-arm64-musl": "4.14.0", - "@rollup/rollup-linux-powerpc64le-gnu": "4.14.0", - "@rollup/rollup-linux-riscv64-gnu": "4.14.0", - "@rollup/rollup-linux-s390x-gnu": "4.14.0", - "@rollup/rollup-linux-x64-gnu": "4.14.0", - "@rollup/rollup-linux-x64-musl": "4.14.0", - "@rollup/rollup-win32-arm64-msvc": "4.14.0", - "@rollup/rollup-win32-ia32-msvc": "4.14.0", - "@rollup/rollup-win32-x64-msvc": "4.14.0", + "@rollup/rollup-android-arm-eabi": "4.14.1", + "@rollup/rollup-android-arm64": "4.14.1", + "@rollup/rollup-darwin-arm64": "4.14.1", + "@rollup/rollup-darwin-x64": "4.14.1", + "@rollup/rollup-linux-arm-gnueabihf": "4.14.1", + "@rollup/rollup-linux-arm64-gnu": "4.14.1", + "@rollup/rollup-linux-arm64-musl": "4.14.1", + "@rollup/rollup-linux-powerpc64le-gnu": "4.14.1", + "@rollup/rollup-linux-riscv64-gnu": "4.14.1", + "@rollup/rollup-linux-s390x-gnu": "4.14.1", + "@rollup/rollup-linux-x64-gnu": "4.14.1", + "@rollup/rollup-linux-x64-musl": "4.14.1", + "@rollup/rollup-win32-arm64-msvc": "4.14.1", + "@rollup/rollup-win32-ia32-msvc": "4.14.1", + "@rollup/rollup-win32-x64-msvc": "4.14.1", "fsevents": "~2.3.2" } }, @@ -10520,12 +10520,12 @@ } }, "node_modules/shiki": { - "version": "1.2.4", - "resolved": "https://registry.npmjs.org/shiki/-/shiki-1.2.4.tgz", - "integrity": "sha512-Q9n9jKiOjJCRPztA9POn3/uZXNySHDNKAsPNpmtHDcFyi6ZQhx5vQKZW3Nhrwn8TWW3RudSRk66zqY603EZDeg==", + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/shiki/-/shiki-1.3.0.tgz", + "integrity": "sha512-9aNdQy/etMXctnPzsje1h1XIGm9YfRcSksKOGqZWXA/qP9G18/8fpz5Bjpma8bOgz3tqIpjERAd6/lLjFyzoww==", "dev": true, "dependencies": { - "@shikijs/core": "1.2.4" + "@shikijs/core": "1.3.0" } }, "node_modules/shx": { @@ -11401,9 +11401,9 @@ } }, "node_modules/typescript": { - "version": "5.4.4", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.4.4.tgz", - "integrity": "sha512-dGE2Vv8cpVvw28v8HCPqyb08EzbBURxDpuhJvTrusShUfGnhHBafDsLdS1EhhxyL6BJQE+2cT3dDPAv+MQ6oLw==", + "version": "5.4.5", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.4.5.tgz", + "integrity": "sha512-vcI4UpRgg81oIRUFwR0WSIHKt11nJ7SAVlYNIu+QpqeyXP+gpQJy/Z4+F0aGxSE4MqwjyXvW/TzgkLAx2AGHwQ==", "dev": true, "bin": { "tsc": "bin/tsc", @@ -11716,25 +11716,25 @@ } }, "node_modules/vitepress": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/vitepress/-/vitepress-1.0.2.tgz", - "integrity": "sha512-bEj9yTEdWyewJFOhEREZF+mXuAgOq27etuJZT6DZSp+J3XpQstXMJc5piSVwhZBtuj8OfA0iXy+jdP1c71KMYQ==", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/vitepress/-/vitepress-1.1.0.tgz", + "integrity": "sha512-G+NS5I2OETxC0SfGAMDO75JWNkrcir0UCptuhQMNoaZhhlqvYtTDQhph4qGc5dtiTtZkcFa/bCcSx+A2gSS3lA==", "dev": true, "dependencies": { "@docsearch/css": "^3.6.0", "@docsearch/js": "^3.6.0", - "@shikijs/core": "^1.2.0", - "@shikijs/transformers": "^1.2.0", + "@shikijs/core": "^1.2.4", + "@shikijs/transformers": "^1.2.4", "@types/markdown-it": "^13.0.7", "@vitejs/plugin-vue": "^5.0.4", - "@vue/devtools-api": "^7.0.16", + "@vue/devtools-api": "^7.0.25", "@vueuse/core": "^10.9.0", "@vueuse/integrations": "^10.9.0", "focus-trap": "^7.5.4", "mark.js": "8.11.1", "minisearch": "^6.3.0", - "shiki": "^1.2.0", - "vite": "^5.2.2", + "shiki": "^1.2.4", + "vite": "^5.2.8", "vue": "^3.4.21" }, "bin": { @@ -11754,12 +11754,12 @@ } }, "node_modules/vitepress/node_modules/@vue/devtools-api": { - "version": "7.0.25", - "resolved": "https://registry.npmjs.org/@vue/devtools-api/-/devtools-api-7.0.25.tgz", - "integrity": "sha512-fL6DlRp4MSXCLYcqYvKU7QhQZWE3Hfu7X8pC25BS74coJi7uJeSWs4tmrITcwFihNmC9S5GPiffkMdckkeWjzg==", + "version": "7.0.27", + "resolved": "https://registry.npmjs.org/@vue/devtools-api/-/devtools-api-7.0.27.tgz", + "integrity": "sha512-BFCFCusSDcw2UcOFD/QeK7OxD1x2C/m+uAN30Q7jLKECSW53hmz0urzJmX834GuWDZX/hIxkyUKnLLfEIP1c/w==", "dev": true, "dependencies": { - "@vue/devtools-kit": "^7.0.25" + "@vue/devtools-kit": "^7.0.27" } }, "node_modules/vue": { diff --git a/package.json b/package.json index db342ca10..70faa1799 100644 --- a/package.json +++ b/package.json @@ -130,14 +130,14 @@ "@rollup/plugin-terser": "^0.4.4", "@rollup/plugin-typescript": "^11.1.6", "@rollup/pluginutils": "^5.1.0", - "@shikijs/vitepress-twoslash": "^1.2.3", + "@shikijs/vitepress-twoslash": "^1.2.4", "@types/eslint": "^8.56.7", "@types/inquirer": "^9.0.7", "@types/mocha": "^10.0.6", "@types/node": "~18.18.14", "@types/yargs-parser": "^21.0.3", - "@typescript-eslint/eslint-plugin": "^7.5.0", - "@typescript-eslint/parser": "^7.5.0", + "@typescript-eslint/eslint-plugin": "^7.6.0", + "@typescript-eslint/parser": "^7.6.0", "@vue/eslint-config-prettier": "^9.0.0", "@vue/eslint-config-typescript": "^13.0.0", "acorn": "^8.11.3", @@ -156,7 +156,7 @@ "eslint-plugin-import": "^2.29.1", "eslint-plugin-prettier": "^5.1.3", "eslint-plugin-unicorn": "^51.0.1", - "eslint-plugin-vue": "^9.24.0", + "eslint-plugin-vue": "^9.24.1", "fixturify": "^3.0.0", "flru": "^1.0.2", "fs-extra": "^11.2.0", @@ -166,7 +166,7 @@ "is-reference": "^3.0.2", "lint-staged": "^15.2.2", "locate-character": "^3.0.0", - "magic-string": "^0.30.8", + "magic-string": "^0.30.9", "mocha": "^10.4.0", "nyc": "^15.1.0", "pinia": "^2.1.7", @@ -174,7 +174,7 @@ "pretty-bytes": "^6.1.1", "pretty-ms": "^9.0.0", "requirejs": "^2.3.6", - "rollup": "^4.13.2", + "rollup": "^4.14.1", "rollup-plugin-license": "^3.3.1", "rollup-plugin-string": "^3.0.0", "semver": "^7.6.0", @@ -183,10 +183,10 @@ "source-map": "^0.7.4", "source-map-support": "^0.5.21", "systemjs": "^6.14.3", - "terser": "^5.30.1", + "terser": "^5.30.3", "tslib": "^2.6.2", - "typescript": "^5.4.3", - "vite": "^5.2.7", + "typescript": "^5.4.4", + "vite": "^5.2.8", "vitepress": "^1.0.2", "vue": "^3.4.21", "wasm-pack": "^0.12.1", diff --git a/rust/Cargo.lock b/rust/Cargo.lock index e16163536..1ebf99ae6 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -36,9 +36,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.81" +version = "1.0.82" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0952808a6c2afd1aa8947271f3a60f1a6763c7b912d210184c5149b5cf147247" +checksum = "f538837af36e6f6a9be0faa67f9a314f8119e4e4b5867c6ab40ed60360142519" [[package]] name = "arrayvec" @@ -143,15 +143,15 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.15.4" +version = "3.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ff69b9dd49fd426c69a0db9fc04dd934cdb6645ff000864d98f7e2af8830eaa" +checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" [[package]] name = "cc" -version = "1.0.90" +version = "1.0.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8cd6604a82acf3039f1144f54b8eb34e91ffba622051189e71b781822d5ee1f5" +checksum = "2678b2e3449475e95b0aa6f9b506a28e61b3dc8996592b983695e8ebb58a8b41" [[package]] name = "cfg-if" @@ -259,9 +259,9 @@ checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" [[package]] name = "getrandom" -version = "0.2.12" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "190092ea657667030ac6a35e305e62fc4dd69fd98ac98631e5d3a2b1575a12b5" +checksum = "94b22e06ecb0110981051723910cbf0b5f5e09a2062dd7663334ee79a9d1286c" dependencies = [ "cfg-if", "js-sys", @@ -284,9 +284,9 @@ checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" [[package]] name = "hstr" -version = "0.2.8" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0f5356d62012374578cd3a5c013d6586de3efbca3b53379fc1edfbb95c9db14" +checksum = "5a9de2bdef6354361892492bab5e316b2d78a0ee9971db4d36da9b1eb0e11999" dependencies = [ "hashbrown", "new_debug_unreachable", @@ -415,9 +415,9 @@ dependencies = [ [[package]] name = "napi" -version = "2.16.1" +version = "2.16.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4ca998356d8ff9fba7a070dae4508a2298439c98c9f3bc9c07669538b999e8f" +checksum = "70d04890ef4ec001fad791be785b8b920e2a3f5a6b1188e7a81dfa6197c0dee4" dependencies = [ "bitflags 2.5.0", "ctor", @@ -434,9 +434,9 @@ checksum = "2f9130fccc5f763cf2069b34a089a18f0d0883c66aceb81f2fad541a3d823c43" [[package]] name = "napi-derive" -version = "2.16.1" +version = "2.16.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b138cecf1141ae0ff5d62f4aa0e2f269aec339f66070f346ba6fb4279f1fc178" +checksum = "aff4a63f26a7aa9fa25df6ea36675890115972b207ae516e86bd0c47e31eba39" dependencies = [ "cfg-if", "convert_case", @@ -448,9 +448,9 @@ dependencies = [ [[package]] name = "napi-derive-backend" -version = "1.0.63" +version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce5126b64f6ad9e28e30e6d15213dd378626b38f556454afebc42f7f02a90902" +checksum = "e5e76afe642e2424ebe465406e328e4316d82af1f79256231d4b0f184c67550a" dependencies = [ "convert_case", "once_cell", @@ -463,9 +463,9 @@ dependencies = [ [[package]] name = "napi-sys" -version = "2.3.0" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2503fa6af34dc83fb74888df8b22afe933b58d37daf7d80424b1c60c68196b8b" +checksum = "427802e8ec3a734331fec1035594a210ce1ff4dc5bc1950530920ab717964ea3" dependencies = [ "libloading", ] @@ -654,9 +654,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.35" +version = "1.0.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" +checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" dependencies = [ "proc-macro2", ] @@ -1029,9 +1029,9 @@ dependencies = [ [[package]] name = "swc_ecma_codegen" -version = "0.148.14" +version = "0.148.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1e318142ff1297c1d3d8f230b4f3eda8454d1420341fb098a9d9edbc373ef3c" +checksum = "5206067d7c5034e4e19e71ebce270081594eb726c108d0a0a026f7ecbb6f8abd" dependencies = [ "memchr", "num-bigint", @@ -1060,9 +1060,9 @@ dependencies = [ [[package]] name = "swc_ecma_minifier" -version = "0.192.20" +version = "0.192.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2025b1b4fb4bff8502378ecf37fe63726e6dfbd0ee3429abcda341edebcfb06a" +checksum = "c1b038d6effbed5103d38460e6b9f5006fd6ffa91e827efdf78953b0e97d3895" dependencies = [ "arrayvec", "indexmap", @@ -1093,9 +1093,9 @@ dependencies = [ [[package]] name = "swc_ecma_parser" -version = "0.143.12" +version = "0.143.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6fc7ab256f83a9491b37a510dd1cba9d81bb306faf3cff1dacdbc897fa4869f" +checksum = "5354a20ab66c2ec5001982271b6e7c750b7fca3409888ab9703ae3d3c845fed4" dependencies = [ "either", "new_debug_unreachable", @@ -1150,9 +1150,9 @@ dependencies = [ [[package]] name = "swc_ecma_transforms_optimization" -version = "0.198.18" +version = "0.198.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa1a53995a9199fa11343506646d0cdce69e612a5dad47897169cf4fdf8b7fcb" +checksum = "6aa7b9e42c741cd1c324870d707eaa427426697fc2fd7f85d89a18c9092aea2b" dependencies = [ "dashmap", "indexmap", @@ -1191,9 +1191,9 @@ dependencies = [ [[package]] name = "swc_ecma_utils" -version = "0.127.16" +version = "0.127.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b693d3fd413b76be123d2ce899a9788db8f85ca6127a1b1d743ed9cb8a68fdcc" +checksum = "624c19fdbe1807275b16560892cf7a12a9ac3f631fb10ad45aaa3eeac903e6e5" dependencies = [ "indexmap", "num_cpus", @@ -1266,9 +1266,9 @@ dependencies = [ [[package]] name = "swc_visit" -version = "0.5.11" +version = "0.5.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6af31bfc7b5b7405eb0cfb5158a40f12e827af9db74ce93b0cf8b838ee1c100" +checksum = "0263be55289abfe9c877ffef83d877b5bdfac036ffe2de793f48f5e47e41dbae" dependencies = [ "either", "swc_visit_macros", diff --git a/rust/bindings_napi/Cargo.toml b/rust/bindings_napi/Cargo.toml index 91aa15c46..28b0f59c2 100644 --- a/rust/bindings_napi/Cargo.toml +++ b/rust/bindings_napi/Cargo.toml @@ -10,8 +10,8 @@ crate-type = ["cdylib"] [dependencies] # Default enable napi4 feature, see https://nodejs.org/api/n-api.html#node-api-version-matrix -napi = { version = "2.16.1", default-features = false, features = ["napi4"] } -napi-derive = "2.16.1" +napi = { version = "2.16.2", default-features = false, features = ["napi4"] } +napi-derive = "2.16.2" parse_ast = { path = "../parse_ast" } xxhash = { path = "../xxhash" } diff --git a/rust/bindings_wasm/Cargo.toml b/rust/bindings_wasm/Cargo.toml index 757f96a4d..37bdf1c0b 100644 --- a/rust/bindings_wasm/Cargo.toml +++ b/rust/bindings_wasm/Cargo.toml @@ -8,7 +8,7 @@ wasm-bindgen = "0.2.92" parse_ast = { path = "../parse_ast" } xxhash = { path = "../xxhash" } js-sys = "0.3.69" -getrandom = { version = "0.2.12", features = ["js"] } +getrandom = { version = "0.2.14", features = ["js"] } [lib] crate-type = ["cdylib", "rlib"] diff --git a/rust/parse_ast/Cargo.toml b/rust/parse_ast/Cargo.toml index 1312be487..49d100da1 100644 --- a/rust/parse_ast/Cargo.toml +++ b/rust/parse_ast/Cargo.toml @@ -6,10 +6,10 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -anyhow = "1.0.81" +anyhow = "1.0.82" swc_atoms = "0.6.6" swc_compiler_base = "0.7.20" swc_common = { version = "0.33.22", features = ["ahash", "parking_lot"] } swc_ecma_ast = "0.112.7" -swc_ecma_parser = "0.143.12" +swc_ecma_parser = "0.143.13" parking_lot = "0.12.1" From 4e72323a58f6752602838486d3769003c513e7c6 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 12 Apr 2024 03:19:41 +0000 Subject: [PATCH 15/45] chore(deps): lock file maintenance (#5470) chore(deps): lock file maintenance minor/patch updates Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> From 2fdfe1c3b70c66781ea62a48ae1aaa94ee29f9b7 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 12 Apr 2024 07:14:36 +0200 Subject: [PATCH 16/45] chore(deps): update dependency eslint-plugin-unicorn to v52 (#5468) * chore(deps): update dependency eslint-plugin-unicorn to v52 * Fix linting --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Lukas Taegert-Atkinson --- build-plugins/add-cli-entry.ts | 4 +- build-plugins/copy-types.ts | 4 +- build-plugins/generate-license-file.ts | 4 +- build-plugins/replace-browser-modules.ts | 4 +- cli/run/commandPlugins.ts | 6 +- cli/run/getConfigPath.ts | 6 +- cli/run/loadConfigFile.ts | 9 +- docs/plugin-development/index.md | 4 +- docs/repl/examples/.eslintrc.json | 5 + native.js | 4 +- package-lock.json | 8 +- package.json | 2 +- rollup.config.ts | 2 +- scripts/helpers.js | 4 +- scripts/prepublish.js | 4 +- scripts/publish-wasm-node-package.js | 6 +- scripts/update-snapshots.js | 26 +- src/watch/watch.ts | 4 +- test/browser/index.js | 10 +- test/chunking-form/index.js | 119 +++++---- test/cli/index.js | 15 +- test/cli/samples/log-side-effects/_config.js | 4 +- test/cli/samples/logs/_config.js | 4 +- .../samples/plugin/absolute-esm/_config.js | 4 +- test/cli/samples/plugin/absolute/_config.js | 4 +- test/cli/samples/warn-multiple/_config.js | 4 +- test/cli/samples/warn-plugin-loc/_config.js | 4 +- test/cli/samples/warn-plugin/_config.js | 6 +- .../warn-unknown-options/rollup.config.js | 44 ++-- test/form/index.js | 6 +- .../samples/guessed-global-names/_config.js | 4 +- test/form/samples/paths-relative/_config.js | 4 +- .../relative-external-with-global/_config.js | 4 +- .../error/_config.js | 6 +- .../_config.js | 4 +- .../validate-resolved-by-logic/_config.js | 4 +- .../warn-misplaced-annotations/_config.js | 4 +- .../_config.js | 6 +- test/utils.js | 16 +- test/watch/index.js | 246 +++++++++--------- 40 files changed, 326 insertions(+), 302 deletions(-) create mode 100644 docs/repl/examples/.eslintrc.json diff --git a/build-plugins/add-cli-entry.ts b/build-plugins/add-cli-entry.ts index b3b6a207a..907e25b06 100644 --- a/build-plugins/add-cli-entry.ts +++ b/build-plugins/add-cli-entry.ts @@ -1,5 +1,5 @@ import { chmod } from 'node:fs/promises'; -import { resolve } from 'node:path'; +import path from 'node:path'; import type { Plugin } from 'rollup'; const CLI_CHUNK = 'bin/rollup'; @@ -16,7 +16,7 @@ export default function addCliEntry(): Plugin { }, name: 'add-cli-entry', writeBundle({ dir }) { - return chmod(resolve(dir!, CLI_CHUNK), '755'); + return chmod(path.resolve(dir!, CLI_CHUNK), '755'); } }; } diff --git a/build-plugins/copy-types.ts b/build-plugins/copy-types.ts index d68cfa349..b9e5e7be3 100644 --- a/build-plugins/copy-types.ts +++ b/build-plugins/copy-types.ts @@ -1,5 +1,5 @@ import { readFile } from 'node:fs/promises'; -import { resolve } from 'node:path'; +import path from 'node:path'; import type { Plugin } from 'rollup'; function copyRollupType( @@ -10,7 +10,7 @@ function copyRollupType( return { async generateBundle(_options, _bundle, isWrite) { if (isWrite) { - let source = await readFile(resolve(inputFile), 'utf8'); + let source = await readFile(path.resolve(inputFile), 'utf8'); if (rollupImportPath) { source = source.replace(rollupImportPath, './rollup'); } diff --git a/build-plugins/generate-license-file.ts b/build-plugins/generate-license-file.ts index 622671c04..1b94cec4e 100644 --- a/build-plugins/generate-license-file.ts +++ b/build-plugins/generate-license-file.ts @@ -1,5 +1,5 @@ import { readFile, writeFile } from 'node:fs/promises'; -import { join } from 'node:path'; +import path from 'node:path'; import type { PluginImpl } from 'rollup'; import license, { type Dependency, type Person } from 'rollup-plugin-license'; @@ -57,7 +57,7 @@ async function generateLicenseFile( `${[...licenses].join(', ')}\n\n` + `# Bundled dependencies:\n` + dependencyLicenseTexts; - const licenseFile = join(directory, 'LICENSE.md'); + const licenseFile = path.join(directory, 'LICENSE.md'); const existingLicenseText = await readFile(licenseFile, 'utf8'); if (existingLicenseText !== licenseText) { await writeFile(licenseFile, licenseText); diff --git a/build-plugins/replace-browser-modules.ts b/build-plugins/replace-browser-modules.ts index 9e5bfaaf3..f1cecf2d1 100644 --- a/build-plugins/replace-browser-modules.ts +++ b/build-plugins/replace-browser-modules.ts @@ -1,4 +1,4 @@ -import { dirname, join } from 'node:path'; +import path from 'node:path'; import { fileURLToPath } from 'node:url'; import type { Plugin as RollupPlugin } from 'rollup'; import type { Plugin } from 'vite'; @@ -37,7 +37,7 @@ export default function replaceBrowserModules(): Plugin & RollupPlugin { name: 'replace-browser-modules', resolveId(source: string, importer: string | undefined) { if (importer && source[0] === '.') { - return resolutions.get(join(dirname(importer), source)); + return resolutions.get(path.join(path.dirname(importer), source)); } }, transformIndexHtml(html) { diff --git a/cli/run/commandPlugins.ts b/cli/run/commandPlugins.ts index 2076dd590..f2ee1e9c3 100644 --- a/cli/run/commandPlugins.ts +++ b/cli/run/commandPlugins.ts @@ -1,4 +1,4 @@ -import { resolve } from 'node:path'; +import path from 'node:path'; import { pathToFileURL } from 'node:url'; import type { InputOptionsWithPlugins } from '../../src/rollup/types'; import { normalizePluginOption } from '../../src/utils/options/options'; @@ -73,11 +73,11 @@ async function loadAndRegisterPlugin( } if (!plugin) { try { - if (pluginText[0] == '.') pluginText = resolve(pluginText); + if (pluginText[0] == '.') pluginText = path.resolve(pluginText); // 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(resolve(pluginText)).href; + pluginText = pathToFileURL(path.resolve(pluginText)).href; } plugin = await requireOrImport(pluginText); } catch (error: any) { diff --git a/cli/run/getConfigPath.ts b/cli/run/getConfigPath.ts index 0338266e1..be72bffb4 100644 --- a/cli/run/getConfigPath.ts +++ b/cli/run/getConfigPath.ts @@ -1,5 +1,5 @@ import { readdir } from 'node:fs/promises'; -import { resolve } from 'node:path'; +import path from 'node:path'; import { cwd } from 'node:process'; import { logMissingExternalConfig } from '../../src/utils/logs'; import { handleError } from '../logging'; @@ -8,7 +8,7 @@ const DEFAULT_CONFIG_BASE = 'rollup.config'; export async function getConfigPath(commandConfig: string | true): Promise { if (commandConfig === true) { - return resolve(await findConfigFileNameInCwd()); + return path.resolve(await findConfigFileNameInCwd()); } if (commandConfig.slice(0, 5) === 'node:') { const packageName = commandConfig.slice(5); @@ -27,7 +27,7 @@ export async function getConfigPath(commandConfig: string | true): Promise { diff --git a/cli/run/loadConfigFile.ts b/cli/run/loadConfigFile.ts index 4888667dc..d01c1980e 100644 --- a/cli/run/loadConfigFile.ts +++ b/cli/run/loadConfigFile.ts @@ -1,5 +1,5 @@ import { unlink, writeFile } from 'node:fs/promises'; -import { dirname, isAbsolute, join } from 'node:path'; +import path from 'node:path'; import process from 'node:process'; import { pathToFileURL } from 'node:url'; import * as rollup from '../../src/node-entry'; @@ -98,7 +98,7 @@ async function loadTranspiledConfigFile( const warnings = batchWarnings(commandOptions); const inputOptions = { external: (id: string) => - (id[0] !== '.' && !isAbsolute(id)) || id.slice(-5, id.length) === '.json', + (id[0] !== '.' && !path.isAbsolute(id)) || id.slice(-5, id.length) === '.json', input: fileName, onwarn: warnings.add, plugins: [], @@ -130,7 +130,10 @@ async function loadTranspiledConfigFile( warnings.flush(); } return loadConfigFromWrittenFile( - join(dirname(fileName), `rollup.config-${Date.now()}.${bundleConfigAsCjs ? 'cjs' : 'mjs'}`), + path.join( + path.dirname(fileName), + `rollup.config-${Date.now()}.${bundleConfigAsCjs ? 'cjs' : 'mjs'}` + ), code ); } diff --git a/docs/plugin-development/index.md b/docs/plugin-development/index.md index a82d72d97..5831d4d6f 100644 --- a/docs/plugin-development/index.md +++ b/docs/plugin-development/index.md @@ -124,7 +124,7 @@ Instead of a function, hooks can also be objects. In that case, the actual hook This can be useful when you need to run several command line tools in different [`writeBundle`](#writebundle) hooks that depend on each other (note that if possible, it is recommended to add/remove files in the sequential [`generateBundle`](#generatebundle) hook, though, which is faster, works with pure in-memory builds and permits other in-memory build plugins to see the files). You can combine this option with `order` for additional sorting. ```js twoslash - import { resolve } from 'node:path'; + import path from 'node:path'; import { readdir } from 'node:fs/promises'; // ---cut-start--- @@ -137,7 +137,7 @@ Instead of a function, hooks can also be objects. In that case, the actual hook sequential: true, order: 'post', async handler({ dir }) { - const topLevelFiles = await readdir(resolve(dir)); + const topLevelFiles = await readdir(path.resolve(dir)); console.log(topLevelFiles); } } diff --git a/docs/repl/examples/.eslintrc.json b/docs/repl/examples/.eslintrc.json new file mode 100644 index 000000000..600f9a4f1 --- /dev/null +++ b/docs/repl/examples/.eslintrc.json @@ -0,0 +1,5 @@ +{ + "rules": { + "unicorn/no-anonymous-default-export": "off" + } +} diff --git a/native.js b/native.js index 5233af4e5..d927ec36d 100644 --- a/native.js +++ b/native.js @@ -1,5 +1,5 @@ const { existsSync } = require('node:fs'); -const { join } = require('node:path'); +const path = require('node:path'); const { platform, arch, report } = require('node:process'); const isMusl = () => !report.getReport().header.glibcVersionRuntime; @@ -66,7 +66,7 @@ const requireWithFriendlyError = id => { }; const { parse, parseAsync, xxhashBase64Url, xxhashBase36, xxhashBase16 } = requireWithFriendlyError( - existsSync(join(__dirname, localName)) ? localName : `@rollup/rollup-${packageBase}` + existsSync(path.join(__dirname, localName)) ? localName : `@rollup/rollup-${packageBase}` ); function getPackageBase() { diff --git a/package-lock.json b/package-lock.json index 5a3105a3e..c0b36008e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -58,7 +58,7 @@ "eslint-config-prettier": "^9.1.0", "eslint-plugin-import": "^2.29.1", "eslint-plugin-prettier": "^5.1.3", - "eslint-plugin-unicorn": "^51.0.1", + "eslint-plugin-unicorn": "^52.0.0", "eslint-plugin-vue": "^9.24.1", "fixturify": "^3.0.0", "flru": "^1.0.2", @@ -5006,9 +5006,9 @@ } }, "node_modules/eslint-plugin-unicorn": { - "version": "51.0.1", - "resolved": "https://registry.npmjs.org/eslint-plugin-unicorn/-/eslint-plugin-unicorn-51.0.1.tgz", - "integrity": "sha512-MuR/+9VuB0fydoI0nIn2RDA5WISRn4AsJyNSaNKLVwie9/ONvQhxOBbkfSICBPnzKrB77Fh6CZZXjgTt/4Latw==", + "version": "52.0.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-unicorn/-/eslint-plugin-unicorn-52.0.0.tgz", + "integrity": "sha512-1Yzm7/m+0R4djH0tjDjfVei/ju2w3AzUGjG6q8JnuNIL5xIwsflyCooW5sfBvQp2pMYQFSWWCFONsjCax1EHng==", "dev": true, "dependencies": { "@babel/helper-validator-identifier": "^7.22.20", diff --git a/package.json b/package.json index 70faa1799..47492b5a8 100644 --- a/package.json +++ b/package.json @@ -155,7 +155,7 @@ "eslint-config-prettier": "^9.1.0", "eslint-plugin-import": "^2.29.1", "eslint-plugin-prettier": "^5.1.3", - "eslint-plugin-unicorn": "^51.0.1", + "eslint-plugin-unicorn": "^52.0.0", "eslint-plugin-vue": "^9.24.1", "fixturify": "^3.0.0", "flru": "^1.0.2", diff --git a/rollup.config.ts b/rollup.config.ts index 6a89a23a1..609358a99 100644 --- a/rollup.config.ts +++ b/rollup.config.ts @@ -53,7 +53,7 @@ const nodePlugins: readonly Plugin[] = [ externalNativeImport() ]; -export default async function ( +export default async function getConfig( command: Record ): Promise { const { collectLicenses, writeLicense } = getLicenseHandler( diff --git a/scripts/helpers.js b/scripts/helpers.js index c8e170792..aa9143dbf 100644 --- a/scripts/helpers.js +++ b/scripts/helpers.js @@ -1,6 +1,6 @@ import { spawn } from 'node:child_process'; import { readFile } from 'node:fs/promises'; -import { relative } from 'node:path'; +import path from 'node:path'; import { fileURLToPath } from 'node:url'; import { ESLint } from 'eslint'; import { blue, bold, cyan, green, magenta, red, yellow } from './colors.js'; @@ -119,6 +119,6 @@ export function toScreamingSnakeCase(string) { * @returns {string} */ export function generateNotEditFilesComment(filePath) { - return `// This file is generated by ${relative(process.cwd(), fileURLToPath(filePath))}. + return `// This file is generated by ${path.relative(process.cwd(), fileURLToPath(filePath))}. // Do not edit this file directly.\n\n`; } diff --git a/scripts/prepublish.js b/scripts/prepublish.js index d43a85977..ef95f741f 100755 --- a/scripts/prepublish.js +++ b/scripts/prepublish.js @@ -1,7 +1,7 @@ #!/usr/bin/env node import { readFile, writeFile } from 'node:fs/promises'; -import { resolve } from 'node:path'; +import path from 'node:path'; import { chdir } from 'node:process'; import { fileURLToPath } from 'node:url'; import { readJson, runWithEcho } from './helpers.js'; @@ -23,7 +23,7 @@ if (!matched) { const isPreRelease = !!matched[1]; await verifyChangelog(isPreRelease); -await runWithEcho('npm', ['publish'], { cwd: resolve('browser') }); +await runWithEcho('npm', ['publish'], { cwd: path.resolve('browser') }); await publishWasmNodePackage(); const { optionalDependencies } = await readJson(MAIN_PACKAGE); diff --git a/scripts/publish-wasm-node-package.js b/scripts/publish-wasm-node-package.js index 7c0d7c2f1..a2af64331 100644 --- a/scripts/publish-wasm-node-package.js +++ b/scripts/publish-wasm-node-package.js @@ -1,5 +1,5 @@ import { cp, mkdir, readFile, writeFile } from 'node:fs/promises'; -import { resolve } from 'node:path'; +import path from 'node:path'; import { fileURLToPath } from 'node:url'; import { readJson, runWithEcho } from './helpers.js'; import { MAIN_PACKAGE } from './release-constants.js'; @@ -16,7 +16,7 @@ const PACKAGE_DIR = fileURLToPath(new URL('../wasm-node-package', import.meta.ur * @return {string} */ function getOutputPath(...pathSegments) { - return resolve(PACKAGE_DIR, ...pathSegments); + return path.resolve(PACKAGE_DIR, ...pathSegments); } export default async function publishWasmNodePackage() { @@ -51,5 +51,5 @@ export default async function publishWasmNodePackage() { }) ]); - await runWithEcho('npm', ['publish'], { cwd: resolve(PACKAGE_DIR) }); + await runWithEcho('npm', ['publish'], { cwd: path.resolve(PACKAGE_DIR) }); } diff --git a/scripts/update-snapshots.js b/scripts/update-snapshots.js index 542e0de34..13100e1a4 100755 --- a/scripts/update-snapshots.js +++ b/scripts/update-snapshots.js @@ -1,41 +1,41 @@ #!/usr/bin/env node import { readdirSync } from 'node:fs'; -import { dirname, join, resolve } from 'node:path'; +import path from 'node:path'; import { fileURLToPath } from 'node:url'; import fs from 'fs-extra'; -const basePath = resolve(dirname(fileURLToPath(import.meta.url)), '../test'); +const basePath = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../test'); -const formPath = join(basePath, 'form/samples'); +const formPath = path.join(basePath, 'form/samples'); const formDirectoriesToHandle = readdirSync(formPath); for (const directory of formDirectoriesToHandle) { - const testPath = join(formPath, directory); + const testPath = path.join(formPath, directory); const testFiles = readdirSync(testPath); if (!testFiles.includes('_config.js')) { - formDirectoriesToHandle.push(...testFiles.map(filename => join(directory, filename))); + formDirectoriesToHandle.push(...testFiles.map(filename => path.join(directory, filename))); } else if (testFiles.includes('_actual')) { - const expectedPath = join(testPath, '_expected'); + const expectedPath = path.join(testPath, '_expected'); fs.removeSync(expectedPath); - fs.copySync(join(testPath, '_actual'), expectedPath); + fs.copySync(path.join(testPath, '_actual'), expectedPath); } else if (testFiles.includes('_actual.js')) { - fs.copySync(join(testPath, '_actual.js'), 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 chunkingPath = path.join(basePath, 'chunking-form/samples'); const chunkingDirectoriesToHandle = readdirSync(chunkingPath); for (const directory of chunkingDirectoriesToHandle) { - const testPath = join(chunkingPath, directory); + const testPath = path.join(chunkingPath, directory); const testFiles = readdirSync(testPath); if (!testFiles.includes('_config.js')) { - chunkingDirectoriesToHandle.push(...testFiles.map(filename => join(directory, filename))); + chunkingDirectoriesToHandle.push(...testFiles.map(filename => path.join(directory, filename))); } else if (testFiles.includes('_actual')) { - const expectedPath = join(testPath, '_expected'); + const expectedPath = path.join(testPath, '_expected'); fs.removeSync(expectedPath); - fs.copySync(join(testPath, '_actual'), expectedPath); + fs.copySync(path.join(testPath, '_actual'), expectedPath); } else { throw new Error(`Could not find test output in ${testPath}`); } diff --git a/src/watch/watch.ts b/src/watch/watch.ts index 87065853a..65f665f5f 100644 --- a/src/watch/watch.ts +++ b/src/watch/watch.ts @@ -1,4 +1,4 @@ -import { resolve } from 'node:path'; +import path from 'node:path'; import process from 'node:process'; import { createFilter } from '@rollup/pluginutils'; import { rollupInternal } from '../rollup/rollup'; @@ -153,7 +153,7 @@ export class Task { 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 resolve(output.file || output.dir!); + if (output.file || output.dir) return path.resolve(output.file || output.dir!); return undefined as never; }); diff --git a/test/browser/index.js b/test/browser/index.js index dd06cc691..103ab5d24 100644 --- a/test/browser/index.js +++ b/test/browser/index.js @@ -2,7 +2,7 @@ // 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 { basename, resolve } = require('node:path'); +const path = require('node:path'); global.performance = require('node:perf_hooks').performance; @@ -18,13 +18,13 @@ const { assertFilesAreEqual, runTestSuiteWithSamples, compareError } = require(' runTestSuiteWithSamples( 'browser', - resolve(__dirname, 'samples'), + path.resolve(__dirname, 'samples'), /** * @param {import('../types').TestConfigBrowser} config */ (directory, config) => { (config.skip ? it.skip : config.solo ? it.only : it)( - basename(directory) + ': ' + config.description, + path.basename(directory) + ': ' + config.description, async () => { let bundle; try { @@ -91,7 +91,7 @@ function assertOutputMatches(output, directory) { } currentDirectory[fileName] = file.source || file.code; } - fixturify.writeSync(resolve(directory, '_actual'), actual); - const expected = fixturify.readSync(resolve(directory, '_expected')); + fixturify.writeSync(path.resolve(directory, '_actual'), actual); + const expected = fixturify.readSync(path.resolve(directory, '_expected')); assertFilesAreEqual(actual, expected); } diff --git a/test/chunking-form/index.js b/test/chunking-form/index.js index ac0aae5af..332ff7559 100644 --- a/test/chunking-form/index.js +++ b/test/chunking-form/index.js @@ -1,4 +1,4 @@ -const { basename, resolve } = require('node:path'); +const path = require('node:path'); /** * @type {import('../../src/rollup/types')} Rollup */ @@ -9,67 +9,72 @@ const { runTestSuiteWithSamples, assertDirectoriesAreEqual } = require('../utils const FORMATS = ['es', 'cjs', 'amd', 'system']; -runTestSuiteWithSamples('chunking form', resolve(__dirname, 'samples'), (directory, config) => { - (config.skip ? describe.skip : config.solo ? describe.only : describe)( - basename(directory) + ': ' + 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; - if (config.before) { - before(config.before); - } - if (config.after) { - after(config.after); - } - const logs = []; - after(() => config.logs && compareLogs(logs, config.logs)); + if (config.before) { + before(config.before); + } + if (config.after) { + after(config.after); + } + const logs = []; + after(() => config.logs && compareLogs(logs, config.logs)); - for (const format of FORMATS) { - it('generates ' + format, async () => { - process.chdir(directory); - const warnings = []; - 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); - } + for (const format of FORMATS) { + it('generates ' + format, async () => { + process.chdir(directory); + const warnings = []; + 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); + } + }, + strictDeprecations: true, + ...config.options + })); + await generateAndTestBundle( + bundle, + { + dir: `${directory}/_actual/${format}`, + exports: 'auto', + format, + chunkFileNames: 'generated-[name].js', + validate: true, + ...(config.options || {}).output }, - strictDeprecations: true, - ...config.options - })); - await generateAndTestBundle( - bundle, - { - dir: `${directory}/_actual/${format}`, - exports: 'auto', - format, - chunkFileNames: 'generated-[name].js', - validate: true, - ...(config.options || {}).output - }, - `${directory}/_expected/${format}`, - config - ); - if (warnings.length > 0) { - const codes = new Set(); - for (const { code } of warnings) { - codes.add(code); - } - 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' + `${directory}/_expected/${format}`, + config ); - } - }); + if (warnings.length > 0) { + const codes = new Set(); + for (const { code } of warnings) { + codes.add(code); + } + 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' + ); + } + }); + } } - } - ); -}); + ); + } +); async function generateAndTestBundle(bundle, outputOptions, expectedDirectory, config) { await bundle.write({ diff --git a/test/cli/index.js b/test/cli/index.js index c7e6abf23..06c982667 100644 --- a/test/cli/index.js +++ b/test/cli/index.js @@ -1,7 +1,7 @@ const assert = require('node:assert'); const { exec } = require('node:child_process'); const { existsSync, readFileSync } = require('node:fs'); -const { basename, resolve, sep } = require('node:path'); +const path = require('node:path'); const process = require('node:process'); const { copySync, removeSync, statSync } = require('fs-extra'); const { @@ -12,23 +12,26 @@ const { const cwd = process.cwd(); -removeSync(resolve(__dirname, 'node_modules')); -copySync(resolve(__dirname, 'node_modules_rename_me'), resolve(__dirname, 'node_modules')); +removeSync(path.resolve(__dirname, 'node_modules')); +copySync( + path.resolve(__dirname, 'node_modules_rename_me'), + path.resolve(__dirname, 'node_modules') +); runTestSuiteWithSamples( 'cli', - resolve(__dirname, 'samples'), + path.resolve(__dirname, 'samples'), /** * @param {import('../types').TestConfigCli} config */ (directory, config) => { (config.skip ? it.skip : config.solo ? it.only : it)( - basename(directory) + ': ' + config.description, + path.basename(directory) + ': ' + config.description, async () => { process.chdir(config.cwd || directory); const command = config.command.replace( /(^| )rollup($| )/g, - `node ${resolve(__dirname, '../../dist/bin')}${sep}rollup ` + `node ${path.resolve(__dirname, '../../dist/bin')}${path.sep}rollup ` ); try { await runTest(config, command); diff --git a/test/cli/samples/log-side-effects/_config.js b/test/cli/samples/log-side-effects/_config.js index 767341522..f0e55c0b2 100644 --- a/test/cli/samples/log-side-effects/_config.js +++ b/test/cli/samples/log-side-effects/_config.js @@ -1,4 +1,4 @@ -const { sep } = require('node:path'); +const path = require('node:path'); const { assertIncludes } = require('../../../utils.js'); module.exports = defineTest({ @@ -7,7 +7,7 @@ module.exports = defineTest({ env: { FORCE_COLOR: undefined, NO_COLOR: true }, stderr: stderr => assertIncludes( - stderr.replaceAll(__dirname + sep, 'CWD/'), + 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'); diff --git a/test/cli/samples/logs/_config.js b/test/cli/samples/logs/_config.js index 5d445eac4..65f1b136a 100644 --- a/test/cli/samples/logs/_config.js +++ b/test/cli/samples/logs/_config.js @@ -1,5 +1,5 @@ const assert = require('node:assert'); -const { sep } = require('node:path'); +const path = require('node:path'); const BOLD = '\u001B[1m'; const BLUE = '\u001B[34m'; @@ -15,7 +15,7 @@ module.exports = defineTest({ env: { FORCE_COLOR: '1', TERM: 'xterm' }, stderr(stderr) { assert.strictEqual( - stderr.replaceAll(__dirname + sep, 'CWD/'), + stderr.replaceAll(__dirname + path.sep, 'CWD/'), `${CYAN} ${BOLD}main.js${REGULAR} → ${BOLD}stdout${REGULAR}...${NOCOLOR} ${BOLD}${CYAN}[plugin test] simple-info${NOCOLOR}${REGULAR} diff --git a/test/cli/samples/plugin/absolute-esm/_config.js b/test/cli/samples/plugin/absolute-esm/_config.js index 4d26c4ec1..14aefbe9f 100644 --- a/test/cli/samples/plugin/absolute-esm/_config.js +++ b/test/cli/samples/plugin/absolute-esm/_config.js @@ -1,6 +1,6 @@ -const { sep } = require('node:path'); +const path = require('node:path'); module.exports = defineTest({ description: 'ESM CLI --plugin /absolute/path', - command: `rollup main.js -p "${__dirname}${sep}my-esm-plugin.mjs={comment: 'Absolute ESM'}"` + command: `rollup main.js -p "${__dirname}${path.sep}my-esm-plugin.mjs={comment: 'Absolute ESM'}"` }); diff --git a/test/cli/samples/plugin/absolute/_config.js b/test/cli/samples/plugin/absolute/_config.js index 63e893182..792357f03 100644 --- a/test/cli/samples/plugin/absolute/_config.js +++ b/test/cli/samples/plugin/absolute/_config.js @@ -1,6 +1,6 @@ -const { sep } = require('node:path'); +const path = require('node:path'); module.exports = defineTest({ description: 'CLI --plugin /absolute/path', - command: `rollup main.js -p "${__dirname}${sep}my-plugin.js={VALUE: 'absolute', ZZZ: 1}"` + command: `rollup main.js -p "${__dirname}${path.sep}my-plugin.js={VALUE: 'absolute', ZZZ: 1}"` }); diff --git a/test/cli/samples/warn-multiple/_config.js b/test/cli/samples/warn-multiple/_config.js index a8f69e70d..6dbe61804 100644 --- a/test/cli/samples/warn-multiple/_config.js +++ b/test/cli/samples/warn-multiple/_config.js @@ -1,4 +1,4 @@ -const { sep } = require('node:path'); +const path = require('node:path'); const { assertIncludes } = require('../../../utils.js'); module.exports = defineTest({ @@ -32,7 +32,7 @@ module.exports = defineTest({ '8: export {url, assert, path};' ); assertIncludes( - stderr.replaceAll(__dirname + sep, 'CWD/'), + 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" + diff --git a/test/cli/samples/warn-plugin-loc/_config.js b/test/cli/samples/warn-plugin-loc/_config.js index 4b4320612..67effad8b 100644 --- a/test/cli/samples/warn-plugin-loc/_config.js +++ b/test/cli/samples/warn-plugin-loc/_config.js @@ -1,4 +1,4 @@ -const { sep } = require('node:path'); +const path = require('node:path'); const { assertIncludes } = require('../../../utils.js'); module.exports = defineTest({ @@ -6,7 +6,7 @@ module.exports = defineTest({ command: 'rollup -c', stderr: stderr => { assertIncludes( - stderr.replaceAll(__dirname + sep, 'CWD/'), + 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' + diff --git a/test/cli/samples/warn-plugin/_config.js b/test/cli/samples/warn-plugin/_config.js index 2d581d3f8..14bd2068e 100644 --- a/test/cli/samples/warn-plugin/_config.js +++ b/test/cli/samples/warn-plugin/_config.js @@ -1,4 +1,4 @@ -const { sep } = require('node:path'); +const path = require('node:path'); const { assertIncludes } = require('../../../utils.js'); module.exports = defineTest({ @@ -7,11 +7,11 @@ module.exports = defineTest({ env: { FORCE_COLOR: undefined, NO_COLOR: true }, stderr: stderr => { assertIncludes( - stderr.replaceAll(__dirname + sep, 'CWD/'), + stderr.replaceAll(__dirname + path.sep, 'CWD/'), '[plugin second-plugin] other.js: Fifth\n' + 'CWD/other.js\n' ); assertIncludes( - stderr.replaceAll(__dirname + sep, 'CWD/'), + stderr.replaceAll(__dirname + path.sep, 'CWD/'), '(!) [plugin test-plugin] First\n' + '(!) [plugin test-plugin] Second\n' + 'https://information\n' + diff --git a/test/cli/samples/warn-unknown-options/rollup.config.js b/test/cli/samples/warn-unknown-options/rollup.config.js index 87fe5f3d7..4a166b640 100644 --- a/test/cli/samples/warn-unknown-options/rollup.config.js +++ b/test/cli/samples/warn-unknown-options/rollup.config.js @@ -3,24 +3,26 @@ const replace = require('@rollup/plugin-replace'); let warnings = 0; -module.exports = commands => ({ - 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 - }` - ); - } -}); +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/form/index.js b/test/form/index.js index 88bf40ba9..84d634961 100644 --- a/test/form/index.js +++ b/test/form/index.js @@ -1,6 +1,6 @@ const assert = require('node:assert'); const { existsSync, readFileSync } = require('node:fs'); -const { basename, resolve } = require('node:path'); +const path = require('node:path'); /** * @type {import('../../src/rollup/types')} Rollup */ @@ -17,7 +17,7 @@ const FORMATS = ['amd', 'cjs', 'system', 'es', 'iife', 'umd']; runTestSuiteWithSamples( 'form', - resolve(__dirname, 'samples'), + path.resolve(__dirname, 'samples'), /** * @param {import('../types').TestConfigForm} config */ @@ -25,7 +25,7 @@ runTestSuiteWithSamples( const isSingleFormatTest = existsSync(directory + '/_expected.js'); const itOrDescribe = isSingleFormatTest ? it : describe; (config.skip ? itOrDescribe.skip : config.solo ? itOrDescribe.only : itOrDescribe)( - basename(directory) + ': ' + config.description, + path.basename(directory) + ': ' + config.description, () => { let bundle; const logs = []; diff --git a/test/form/samples/guessed-global-names/_config.js b/test/form/samples/guessed-global-names/_config.js index 5f26cbab9..4f063098d 100644 --- a/test/form/samples/guessed-global-names/_config.js +++ b/test/form/samples/guessed-global-names/_config.js @@ -1,4 +1,4 @@ -const { resolve } = require('node:path'); +const path = require('node:path'); module.exports = defineTest({ description: 'guesses global names if necessary', @@ -9,7 +9,7 @@ module.exports = defineTest({ 'changed', 'special-character', 'with/slash', - resolve(__dirname, 'relative.js') + path.resolve(__dirname, 'relative.js') ] } }); diff --git a/test/form/samples/paths-relative/_config.js b/test/form/samples/paths-relative/_config.js index 95a73fc1e..72205b1d5 100644 --- a/test/form/samples/paths-relative/_config.js +++ b/test/form/samples/paths-relative/_config.js @@ -1,6 +1,6 @@ -const { resolve } = require('node:path'); +const path = require('node:path'); -const resolved = resolve(__dirname, 'foo.js'); +const resolved = path.resolve(__dirname, 'foo.js'); module.exports = defineTest({ description: 'external paths (#754)', diff --git a/test/form/samples/relative-external-with-global/_config.js b/test/form/samples/relative-external-with-global/_config.js index eb7f44208..2f669821a 100644 --- a/test/form/samples/relative-external-with-global/_config.js +++ b/test/form/samples/relative-external-with-global/_config.js @@ -1,6 +1,6 @@ -const { resolve } = require('node:path'); +const path = require('node:path'); -const throttle = resolve(__dirname, 'lib/throttle.js'); +const throttle = path.resolve(__dirname, 'lib/throttle.js'); module.exports = defineTest({ description: 'applies globals to externalised relative imports', diff --git a/test/function/samples/max-parallel-file-operations/error/_config.js b/test/function/samples/max-parallel-file-operations/error/_config.js index 0283412b7..00549c255 100644 --- a/test/function/samples/max-parallel-file-operations/error/_config.js +++ b/test/function/samples/max-parallel-file-operations/error/_config.js @@ -1,5 +1,5 @@ const { promises: fs } = require('node:fs'); -const { join } = require('node:path'); +const path = require('node:path'); const { loader } = require('../../../../utils.js'); const fsReadFile = fs.readFile; @@ -25,7 +25,7 @@ module.exports = defineTest({ fs.readFile = fsReadFile; }, error: { - message: `Could not load ${join(__dirname, 'dep.js')} (imported by main): broken`, - watchFiles: [join(__dirname, 'dep.js')] + 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/relative-external-include-once-two-external/_config.js b/test/function/samples/relative-external-include-once-two-external/_config.js index 357ee534c..e73c40325 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,10 +1,10 @@ const assert = require('node:assert'); -const { join } = require('node:path'); +const path = require('node:path'); module.exports = defineTest({ description: 'includes a relative external module only once (two external deps)', options: { - external: [join(__dirname, './foo.js'), join(__dirname, './first/foo.js')] + external: [path.join(__dirname, './foo.js'), path.join(__dirname, './first/foo.js')] }, context: { require(required) { diff --git a/test/function/samples/validate-resolved-by-logic/_config.js b/test/function/samples/validate-resolved-by-logic/_config.js index aadce4f4b..515fcef41 100644 --- a/test/function/samples/validate-resolved-by-logic/_config.js +++ b/test/function/samples/validate-resolved-by-logic/_config.js @@ -1,10 +1,10 @@ const assert = require('node:assert'); -const { resolve } = require('node:path'); +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 = resolve(__dirname, 'main.js'); +const MAIN_PATH = path.resolve(__dirname, 'main.js'); module.exports = defineTest({ description: 'validate resolvedBy logic', diff --git a/test/function/samples/warn-misplaced-annotations/_config.js b/test/function/samples/warn-misplaced-annotations/_config.js index 5b03c2940..284ff1223 100644 --- a/test/function/samples/warn-misplaced-annotations/_config.js +++ b/test/function/samples/warn-misplaced-annotations/_config.js @@ -1,5 +1,5 @@ -const { join } = require('node:path'); -const ID_MAIN = join(__dirname, 'main.js'); +const path = require('node:path'); +const ID_MAIN = path.join(__dirname, 'main.js'); module.exports = defineTest({ description: 'warns for misplaced annotations', diff --git a/test/function/samples/warning-incorrect-sourcemap-location/_config.js b/test/function/samples/warning-incorrect-sourcemap-location/_config.js index 092bfeb0a..426e283a8 100644 --- a/test/function/samples/warning-incorrect-sourcemap-location/_config.js +++ b/test/function/samples/warning-incorrect-sourcemap-location/_config.js @@ -1,6 +1,6 @@ -const { join } = require('node:path'); -const ID_MAIN = join(__dirname, 'main.js'); -const ID_CONSTANTS = join(__dirname, 'constants.js'); +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', diff --git a/test/utils.js b/test/utils.js index 564da6417..7c8511599 100644 --- a/test/utils.js +++ b/test/utils.js @@ -19,7 +19,7 @@ const { writeSync, existsSync } = require('node:fs'); -const { basename, join } = require('node:path'); +const path = require('node:path'); const { platform, version } = require('node:process'); const { Parser } = require('acorn'); const { importAssertions } = require('acorn-import-assertions'); @@ -227,7 +227,7 @@ function runSamples(samplesDirectory, runTest, onTeardown) { for (const fileName of readdirSync(samplesDirectory) .filter(name => name[0] !== '.') .sort()) { - runTestsInDirectory(join(samplesDirectory, fileName), runTest); + runTestsInDirectory(path.join(samplesDirectory, fileName), runTest); } } @@ -247,9 +247,9 @@ function runTestsInDirectory(directory, runTest) { recursive: true }); } else { - describe(basename(directory), () => { + describe(path.basename(directory), () => { for (const fileName of fileNames.filter(name => name[0] !== '.').sort()) { - runTestsInDirectory(join(directory, fileName), runTest); + runTestsInDirectory(path.join(directory, fileName), runTest); } }); } @@ -262,14 +262,14 @@ function getFileNamesAndRemoveOutput(directory) { try { return readdirSync(directory).filter(fileName => { if (fileName === '_actual') { - rmSync(join(directory, '_actual'), { + rmSync(path.join(directory, '_actual'), { force: true, recursive: true }); return false; } if (fileName === '_actual.js') { - unlinkSync(join(directory, '_actual.js')); + unlinkSync(path.join(directory, '_actual.js')); return false; } return true; @@ -292,7 +292,7 @@ exports.getFileNamesAndRemoveOutput = getFileNamesAndRemoveOutput; * @param {(directory: string, config: C) => void} runTest */ function loadConfigAndRunTest(directory, runTest) { - const configFile = join(directory, '_config.js'); + const configFile = path.join(directory, '_config.js'); const config = require(configFile); if (!config || !config.description) { throw new Error(`Found invalid config without description: ${configFile}`); @@ -449,7 +449,7 @@ exports.replaceDirectoryInStringifiedObject = function replaceDirectoryInStringi }; /** @type {boolean} */ -exports.hasEsBuild = existsSync(join(__dirname, '../dist/es')); +exports.hasEsBuild = existsSync(path.join(__dirname, '../dist/es')); const acornParser = Parser.extend(importAssertions); diff --git a/test/watch/index.js b/test/watch/index.js index 9b2669d60..d725d2ae7 100644 --- a/test/watch/index.js +++ b/test/watch/index.js @@ -1,7 +1,7 @@ const assert = require('node:assert'); const { existsSync, readdirSync, readFileSync, rmSync, unlinkSync } = require('node:fs'); const { rm, unlink, writeFile, mkdir } = require('node:fs/promises'); -const { join, resolve } = require('node:path'); +const path = require('node:path'); const { hrtime } = require('node:process'); const { copy } = require('fs-extra'); /** @@ -10,12 +10,12 @@ const { copy } = require('fs-extra'); const rollup = require('../../dist/rollup'); const { atomicWriteFileSync, wait, withTimeout } = require('../utils'); -const SAMPLES_DIR = join(__dirname, 'samples'); -const TEMP_DIR = join(__dirname, '../_tmp'); -const INPUT_DIR = join(TEMP_DIR, 'input'); -const ENTRY_FILE = join(INPUT_DIR, 'main.js'); -const OUTPUT_DIR = join(TEMP_DIR, 'output'); -const BUNDLE_FILE = join(OUTPUT_DIR, 'bundle.js'); +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'); describe('rollup.watch', function () { this.timeout(40_000); @@ -41,7 +41,7 @@ describe('rollup.watch', function () { it('watches a file and triggers reruns if necessary', async () => { let triggerRestart = false; - await copy(join(SAMPLES_DIR, 'basic'), INPUT_DIR); + await copy(path.join(SAMPLES_DIR, 'basic'), INPUT_DIR); watcher = rollup.watch({ input: ENTRY_FILE, plugins: { @@ -94,7 +94,7 @@ describe('rollup.watch', function () { let run = 0; const events = new Set(); - await copy(join(SAMPLES_DIR, 'basic'), INPUT_DIR); + await copy(path.join(SAMPLES_DIR, 'basic'), INPUT_DIR); watcher = rollup.watch({ input: ENTRY_FILE, plugins: { @@ -144,7 +144,7 @@ describe('rollup.watch', function () { }); it('does not fail for virtual files', async () => { - await copy(join(SAMPLES_DIR, 'basic'), INPUT_DIR); + await copy(path.join(SAMPLES_DIR, 'basic'), INPUT_DIR); watcher = rollup.watch({ input: ENTRY_FILE, plugins: { @@ -189,7 +189,7 @@ describe('rollup.watch', function () { it('passes file events to the watchChange plugin hook once for each change', async () => { let watchChangeCnt = 0; - await copy(join(SAMPLES_DIR, 'basic'), INPUT_DIR); + await copy(path.join(SAMPLES_DIR, 'basic'), INPUT_DIR); await wait(100); watcher = rollup.watch({ input: ENTRY_FILE, @@ -246,11 +246,11 @@ describe('rollup.watch', function () { }); it('passes change parameter to the watchChange plugin hook', async () => { - const WATCHED_ID = join(INPUT_DIR, 'watched'); + const WATCHED_ID = path.join(INPUT_DIR, 'watched'); const events = []; let ids; const expectedIds = [WATCHED_ID, ENTRY_FILE]; - await copy(join(SAMPLES_DIR, 'watch-files'), INPUT_DIR); + await copy(path.join(SAMPLES_DIR, 'watch-files'), INPUT_DIR); await unlink(WATCHED_ID); await wait(100); watcher = rollup.watch({ @@ -321,10 +321,10 @@ describe('rollup.watch', function () { }); it('correctly rewrites change event during build delay', async () => { - const WATCHED_ID = join(INPUT_DIR, 'watched'); + const WATCHED_ID = path.join(INPUT_DIR, 'watched'); const MAIN_ID = ENTRY_FILE; let lastEvent = null; - await copy(join(SAMPLES_DIR, 'watch-files'), INPUT_DIR); + await copy(path.join(SAMPLES_DIR, 'watch-files'), INPUT_DIR); await wait(100); watcher = rollup.watch({ input: ENTRY_FILE, @@ -400,7 +400,7 @@ describe('rollup.watch', function () { let calls = 0; let context1; let context2; - await copy(join(SAMPLES_DIR, 'basic'), INPUT_DIR); + await copy(path.join(SAMPLES_DIR, 'basic'), INPUT_DIR); watcher = rollup.watch({ input: ENTRY_FILE, output: { @@ -449,9 +449,9 @@ describe('rollup.watch', function () { }); it('watches a file in code-splitting mode', async () => { - await copy(join(SAMPLES_DIR, 'code-splitting'), INPUT_DIR); + await copy(path.join(SAMPLES_DIR, 'code-splitting'), INPUT_DIR); watcher = rollup.watch({ - input: [join(INPUT_DIR, 'main1.js'), join(INPUT_DIR, 'main2.js')], + input: [path.join(INPUT_DIR, 'main1.js'), path.join(INPUT_DIR, 'main2.js')], output: { dir: OUTPUT_DIR, format: 'cjs', @@ -464,27 +464,27 @@ describe('rollup.watch', function () { 'BUNDLE_END', 'END', () => { - assert.strictEqual(run(join(OUTPUT_DIR, 'main1.js')), 21); - assert.strictEqual(run(join(OUTPUT_DIR, 'main2.js')), 42); - atomicWriteFileSync(join(INPUT_DIR, 'shared.js'), 'export const value = 22;'); + 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(join(OUTPUT_DIR, 'main1.js')), 22); - assert.strictEqual(run(join(OUTPUT_DIR, 'main2.js')), 44); + assert.strictEqual(run(path.join(OUTPUT_DIR, 'main1.js')), 22); + assert.strictEqual(run(path.join(OUTPUT_DIR, 'main2.js')), 44); } ]); }); it('watches a file in code-splitting mode with an input object', async () => { - await copy(join(SAMPLES_DIR, 'code-splitting'), INPUT_DIR); + await copy(path.join(SAMPLES_DIR, 'code-splitting'), INPUT_DIR); watcher = rollup.watch({ input: { - _main_1: join(INPUT_DIR, 'main1.js'), - 'subfolder/_main_2': join(INPUT_DIR, 'main2.js') + _main_1: path.join(INPUT_DIR, 'main1.js'), + 'subfolder/_main_2': path.join(INPUT_DIR, 'main2.js') }, output: { dir: OUTPUT_DIR, @@ -498,23 +498,23 @@ describe('rollup.watch', function () { 'BUNDLE_END', 'END', () => { - assert.strictEqual(run(join(OUTPUT_DIR, '_main_1.js')), 21); - assert.strictEqual(run(join(OUTPUT_DIR, 'subfolder/_main_2.js')), 42); - atomicWriteFileSync(join(INPUT_DIR, 'shared.js'), 'export const value = 22;'); + 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(join(OUTPUT_DIR, '_main_1.js')), 22); - assert.strictEqual(run(join(OUTPUT_DIR, 'subfolder/_main_2.js')), 44); + 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', async () => { - await copy(join(SAMPLES_DIR, 'basic'), INPUT_DIR); + await copy(path.join(SAMPLES_DIR, 'basic'), INPUT_DIR); watcher = rollup.watch({ input: ENTRY_FILE, output: { @@ -550,7 +550,7 @@ describe('rollup.watch', function () { }); it('recovers from an error on initial build', async () => { - await copy(join(SAMPLES_DIR, 'error'), INPUT_DIR); + await copy(path.join(SAMPLES_DIR, 'error'), INPUT_DIR); watcher = rollup.watch({ input: ENTRY_FILE, output: { @@ -580,7 +580,7 @@ describe('rollup.watch', function () { it('recovers from a plugin error on initial build', async () => { let error = true; - await copy(join(SAMPLES_DIR, 'basic'), INPUT_DIR); + await copy(path.join(SAMPLES_DIR, 'basic'), INPUT_DIR); watcher = rollup.watch({ input: ENTRY_FILE, plugins: { @@ -618,7 +618,7 @@ describe('rollup.watch', function () { it('awaits and recovers from a plugin error in the watchChange hook', async () => { let fail = true; - await copy(join(SAMPLES_DIR, 'basic'), INPUT_DIR); + await copy(path.join(SAMPLES_DIR, 'basic'), INPUT_DIR); watcher = rollup.watch({ input: ENTRY_FILE, plugins: { @@ -661,7 +661,7 @@ describe('rollup.watch', function () { }); it('recovers from an error even when erroring entry was "renamed" (#38)', async () => { - await copy(join(SAMPLES_DIR, 'basic'), INPUT_DIR); + await copy(path.join(SAMPLES_DIR, 'basic'), INPUT_DIR); watcher = rollup.watch({ input: ENTRY_FILE, output: { @@ -699,7 +699,7 @@ describe('rollup.watch', function () { }); it('recovers from an error even when erroring dependency was "renamed" (#38)', async () => { - await copy(join(SAMPLES_DIR, 'dependency'), INPUT_DIR); + await copy(path.join(SAMPLES_DIR, 'dependency'), INPUT_DIR); watcher = rollup.watch({ input: ENTRY_FILE, output: { @@ -715,16 +715,16 @@ describe('rollup.watch', function () { 'END', () => { assert.strictEqual(run(BUNDLE_FILE), 43); - unlinkSync(join(INPUT_DIR, 'dep.js')); - atomicWriteFileSync(join(INPUT_DIR, 'dep.js'), 'export nope;'); + 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 'nope'", 'END', () => { - unlinkSync(join(INPUT_DIR, 'dep.js')); - atomicWriteFileSync(join(INPUT_DIR, 'dep.js'), 'export const value = 43;'); + unlinkSync(path.join(INPUT_DIR, 'dep.js')); + atomicWriteFileSync(path.join(INPUT_DIR, 'dep.js'), 'export const value = 43;'); }, 'START', 'BUNDLE_START', @@ -737,7 +737,7 @@ describe('rollup.watch', function () { }); it('handles closing the watcher during a build', async () => { - await copy(join(SAMPLES_DIR, 'basic'), INPUT_DIR); + await copy(path.join(SAMPLES_DIR, 'basic'), INPUT_DIR); watcher = rollup.watch({ input: ENTRY_FILE, plugins: { @@ -765,7 +765,7 @@ describe('rollup.watch', function () { }); it('handles closing the watcher during a build even if an error occurred', async () => { - await copy(join(SAMPLES_DIR, 'error'), INPUT_DIR); + await copy(path.join(SAMPLES_DIR, 'error'), INPUT_DIR); watcher = rollup.watch({ input: ENTRY_FILE, plugins: { @@ -793,7 +793,7 @@ describe('rollup.watch', function () { }); it('stops watching files that are no longer part of the graph', async () => { - await copy(join(SAMPLES_DIR, 'dependency'), INPUT_DIR); + await copy(path.join(SAMPLES_DIR, 'dependency'), INPUT_DIR); watcher = rollup.watch({ input: ENTRY_FILE, output: { @@ -821,7 +821,7 @@ describe('rollup.watch', function () { watcher.once('event', event => { unexpectedEvent = event; }); - atomicWriteFileSync(join(INPUT_DIR, 'dep.js'), '= invalid'); + atomicWriteFileSync(path.join(INPUT_DIR, 'dep.js'), '= invalid'); await wait(400); assert.strictEqual(unexpectedEvent, false); } @@ -829,7 +829,7 @@ describe('rollup.watch', function () { }); it('refuses to watch the output file (#15)', async () => { - await copy(join(SAMPLES_DIR, 'basic'), INPUT_DIR); + await copy(path.join(SAMPLES_DIR, 'basic'), INPUT_DIR); watcher = rollup.watch({ input: ENTRY_FILE, output: { @@ -865,7 +865,7 @@ describe('rollup.watch', function () { }); it('ignores files that are not specified in options.watch.include, if given', async () => { - await copy(join(SAMPLES_DIR, 'ignored'), INPUT_DIR); + await copy(path.join(SAMPLES_DIR, 'ignored'), INPUT_DIR); watcher = rollup.watch({ input: ENTRY_FILE, output: { @@ -874,7 +874,7 @@ describe('rollup.watch', function () { exports: 'auto' }, watch: { - include: [join(INPUT_DIR, '+(main|foo).js')] + include: [path.join(INPUT_DIR, '+(main|foo).js')] } }); return sequence(watcher, [ @@ -887,7 +887,7 @@ describe('rollup.watch', function () { foo: 'foo-1', bar: 'bar-1' }); - atomicWriteFileSync(join(INPUT_DIR, 'foo.js'), `export default 'foo-2';`); + atomicWriteFileSync(path.join(INPUT_DIR, 'foo.js'), `export default 'foo-2';`); }, 'START', 'BUNDLE_START', @@ -902,7 +902,7 @@ describe('rollup.watch', function () { watcher.once('event', event => { unexpectedEvent = event; }); - atomicWriteFileSync(join(INPUT_DIR, 'bar.js'), "export default 'bar-2';"); + atomicWriteFileSync(path.join(INPUT_DIR, 'bar.js'), "export default 'bar-2';"); await wait(400); assert.deepStrictEqual(run(BUNDLE_FILE), { foo: 'foo-2', @@ -914,7 +914,7 @@ describe('rollup.watch', function () { }); it('ignores files that are specified in options.watch.exclude, if given', async () => { - await copy(join(SAMPLES_DIR, 'ignored'), INPUT_DIR); + await copy(path.join(SAMPLES_DIR, 'ignored'), INPUT_DIR); watcher = rollup.watch({ input: ENTRY_FILE, output: { @@ -923,7 +923,7 @@ describe('rollup.watch', function () { exports: 'auto' }, watch: { - exclude: [join(INPUT_DIR, 'bar.js')] + exclude: [path.join(INPUT_DIR, 'bar.js')] } }); return sequence(watcher, [ @@ -936,7 +936,7 @@ describe('rollup.watch', function () { foo: 'foo-1', bar: 'bar-1' }); - atomicWriteFileSync(join(INPUT_DIR, 'foo.js'), `export default 'foo-2';`); + atomicWriteFileSync(path.join(INPUT_DIR, 'foo.js'), `export default 'foo-2';`); }, 'START', 'BUNDLE_START', @@ -951,7 +951,7 @@ describe('rollup.watch', function () { watcher.once('event', event => { unexpectedEvent = event; }); - atomicWriteFileSync(join(INPUT_DIR, 'bar.js'), "export default 'bar-2';"); + atomicWriteFileSync(path.join(INPUT_DIR, 'bar.js'), "export default 'bar-2';"); await wait(400); assert.deepStrictEqual(run(BUNDLE_FILE), { foo: 'foo-2', @@ -963,21 +963,21 @@ describe('rollup.watch', function () { }); it('only rebuilds the appropriate configs', async () => { - await copy(join(SAMPLES_DIR, 'multiple'), INPUT_DIR); + await copy(path.join(SAMPLES_DIR, 'multiple'), INPUT_DIR); await wait(100); watcher = rollup.watch([ { - input: join(INPUT_DIR, 'main1.js'), + input: path.join(INPUT_DIR, 'main1.js'), output: { - file: join(OUTPUT_DIR, 'bundle1.js'), + file: path.join(OUTPUT_DIR, 'bundle1.js'), format: 'cjs', exports: 'auto' } }, { - input: join(INPUT_DIR, 'main2.js'), + input: path.join(INPUT_DIR, 'main2.js'), output: { - file: join(OUTPUT_DIR, 'bundle2.js'), + file: path.join(OUTPUT_DIR, 'bundle2.js'), format: 'cjs', exports: 'auto' } @@ -991,38 +991,38 @@ describe('rollup.watch', function () { 'BUNDLE_END', 'END', () => { - assert.deepStrictEqual(run(join(OUTPUT_DIR, 'bundle1.js')), 42); - assert.deepStrictEqual(run(join(OUTPUT_DIR, 'bundle2.js')), 43); - atomicWriteFileSync(join(INPUT_DIR, 'main2.js'), 'export default 44'); + 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(join(OUTPUT_DIR, 'bundle1.js')), 42); - assert.deepStrictEqual(run(join(OUTPUT_DIR, 'bundle2.js')), 44); + 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', async () => { - await copy(join(SAMPLES_DIR, 'multiple'), INPUT_DIR); + await copy(path.join(SAMPLES_DIR, 'multiple'), INPUT_DIR); await wait(100); watcher = rollup.watch([ { - input: join(INPUT_DIR, 'main1.js'), + input: path.join(INPUT_DIR, 'main1.js'), watch: false, output: { - file: join(OUTPUT_DIR, 'bundle1.js'), + file: path.join(OUTPUT_DIR, 'bundle1.js'), format: 'cjs', exports: 'auto' } }, { - input: join(INPUT_DIR, 'main2.js'), + input: path.join(INPUT_DIR, 'main2.js'), output: { - file: join(OUTPUT_DIR, 'bundle2.js'), + file: path.join(OUTPUT_DIR, 'bundle2.js'), format: 'cjs', exports: 'auto' } @@ -1034,15 +1034,21 @@ describe('rollup.watch', function () { 'BUNDLE_END', 'END', () => { - assert.strictEqual(existsSync(resolve(__dirname, join(OUTPUT_DIR, 'bundle1.js'))), false); - assert.strictEqual(existsSync(resolve(__dirname, join(OUTPUT_DIR, 'bundle2.js'))), true); - assert.deepStrictEqual(run(join(OUTPUT_DIR, 'bundle2.js')), 43); + 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', async () => { - await copy(join(SAMPLES_DIR, 'globals'), INPUT_DIR); + await copy(path.join(SAMPLES_DIR, 'globals'), INPUT_DIR); watcher = rollup.watch({ input: ENTRY_FILE, output: { @@ -1069,7 +1075,7 @@ describe('rollup.watch', function () { }); it('treats filenames literally, not as globs', async () => { - await copy(join(SAMPLES_DIR, 'non-glob'), INPUT_DIR); + await copy(path.join(SAMPLES_DIR, 'non-glob'), INPUT_DIR); watcher = rollup.watch({ input: ENTRY_FILE, output: { @@ -1085,7 +1091,7 @@ describe('rollup.watch', function () { 'END', () => { assert.strictEqual(run(BUNDLE_FILE), 42); - atomicWriteFileSync(join(INPUT_DIR, '[foo]/bar.js'), `export const bar = 43;`); + atomicWriteFileSync(path.join(INPUT_DIR, '[foo]/bar.js'), `export const bar = 43;`); }, 'START', 'BUNDLE_START', @@ -1101,9 +1107,9 @@ describe('rollup.watch', function () { let dynamicName; let staticName; let chunkName; - await copy(join(SAMPLES_DIR, 'hashing'), INPUT_DIR); + await copy(path.join(SAMPLES_DIR, 'hashing'), INPUT_DIR); watcher = rollup.watch({ - input: [join(INPUT_DIR, 'main-static.js'), join(INPUT_DIR, 'main-dynamic.js')], + input: [path.join(INPUT_DIR, 'main-static.js'), path.join(INPUT_DIR, 'main-dynamic.js')], output: { dir: OUTPUT_DIR, format: 'cjs', @@ -1126,7 +1132,7 @@ describe('rollup.watch', function () { // this should only update the hash of that particular entry point atomicWriteFileSync( - join(INPUT_DIR, 'main-static.js'), + path.join(INPUT_DIR, 'main-static.js'), "import {value} from './shared';\nexport default 2 * value;" ); }, @@ -1146,7 +1152,7 @@ describe('rollup.watch', function () { staticName = newStaticName; // this should update all hashes - atomicWriteFileSync(join(INPUT_DIR, 'shared.js'), 'export const value = 42;'); + atomicWriteFileSync(path.join(INPUT_DIR, 'shared.js'), 'export const value = 42;'); }, 'START', 'BUNDLE_START', @@ -1163,7 +1169,7 @@ describe('rollup.watch', function () { it('runs transforms again on previously erroring files that were changed back', async () => { const brokenFiles = new Set(); - await copy(join(SAMPLES_DIR, 'basic'), INPUT_DIR); + await copy(path.join(SAMPLES_DIR, 'basic'), INPUT_DIR); const INITIAL_CONTENT = 'export default 42;'; atomicWriteFileSync(ENTRY_FILE, INITIAL_CONTENT); watcher = rollup.watch({ @@ -1215,7 +1221,7 @@ describe('rollup.watch', function () { it('skips filesystem writes when configured', async () => { let watchChangeCnt = 0; - await copy(join(SAMPLES_DIR, 'skip-writes'), INPUT_DIR); + await copy(path.join(SAMPLES_DIR, 'skip-writes'), INPUT_DIR); watcher = rollup.watch({ input: ENTRY_FILE, output: { @@ -1269,13 +1275,13 @@ describe('rollup.watch', function () { assert.strictEqual(existsSync(BUNDLE_FILE), false); assert.strictEqual(watchChangeCnt, 3); // still aware of its output destination - assert.strictEqual(event.output[0], resolve(BUNDLE_FILE)); + assert.strictEqual(event.output[0], path.resolve(BUNDLE_FILE)); } ]); }); it('rebuilds immediately by default', async () => { - await copy(join(SAMPLES_DIR, 'basic'), INPUT_DIR); + await copy(path.join(SAMPLES_DIR, 'basic'), INPUT_DIR); await wait(300); watcher = rollup.watch({ input: ENTRY_FILE, @@ -1314,7 +1320,7 @@ describe('rollup.watch', function () { }).retries(1); it('observes configured build delays', async () => { - await copy(join(SAMPLES_DIR, 'basic'), INPUT_DIR); + await copy(path.join(SAMPLES_DIR, 'basic'), INPUT_DIR); watcher = rollup.watch( [ { @@ -1394,16 +1400,16 @@ describe('rollup.watch', function () { describe('addWatchFile', () => { it('supports adding additional watch files in plugin hooks', async () => { const watchChangeIds = new Set(); - const buildEndFile = resolve(join(INPUT_DIR, 'buildEnd')); - const buildStartFile = resolve(join(INPUT_DIR, 'buildStart')); - const generateBundleFile = resolve(join(INPUT_DIR, 'generateBUndle')); - const loadFile = resolve(join(INPUT_DIR, 'load')); - const moduleParsedFile = resolve(join(INPUT_DIR, 'moduleParsed')); - const renderChunkFile = resolve(join(INPUT_DIR, 'renderChunk')); - const renderStartFile = resolve(join(INPUT_DIR, 'renderStart')); - const resolveIdFile = resolve(join(INPUT_DIR, 'resolveId')); - const transformFile = resolve(join(INPUT_DIR, 'transform')); - const writeBundleFile = resolve(join(INPUT_DIR, 'writeBundle')); + 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, @@ -1416,7 +1422,7 @@ describe('rollup.watch', function () { transformFile, writeBundleFile ]; - await copy(join(SAMPLES_DIR, 'basic'), INPUT_DIR); + await copy(path.join(SAMPLES_DIR, 'basic'), INPUT_DIR); await Promise.all(watchFiles.map(file => writeFile(file, 'initial'))); watcher = rollup.watch({ @@ -1486,8 +1492,8 @@ describe('rollup.watch', function () { }); it('respects changed watched files in the load hook', async () => { - const WATCHED_ID = join(INPUT_DIR, 'watched'); - await copy(join(SAMPLES_DIR, 'watch-files'), INPUT_DIR); + 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: { @@ -1522,9 +1528,9 @@ describe('rollup.watch', function () { }); it('respects changed watched files in the transform hook and removes them if they are no longer watched', async () => { - const WATCHED_ID = join(INPUT_DIR, 'watched'); + const WATCHED_ID = path.join(INPUT_DIR, 'watched'); let addWatchFile = true; - await copy(join(SAMPLES_DIR, 'watch-files'), INPUT_DIR); + await copy(path.join(SAMPLES_DIR, 'watch-files'), INPUT_DIR); watcher = rollup.watch({ input: ENTRY_FILE, output: { @@ -1582,7 +1588,7 @@ describe('rollup.watch', function () { }); it('respects changed watched modules that are already part of the graph in the transform hook', async () => { - await copy(join(SAMPLES_DIR, 'dependencies'), INPUT_DIR); + await copy(path.join(SAMPLES_DIR, 'dependencies'), INPUT_DIR); watcher = rollup.watch({ input: ENTRY_FILE, output: { @@ -1593,8 +1599,8 @@ describe('rollup.watch', function () { plugins: { transform(code, id) { if (id.endsWith('dep1.js')) { - this.addWatchFile(resolve(join(INPUT_DIR, 'dep2.js'))); - const text = readFileSync(join(INPUT_DIR, 'dep2.js')).toString().trim(); + 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)}`; } } @@ -1607,7 +1613,7 @@ describe('rollup.watch', function () { 'END', () => { assert.strictEqual(run(BUNDLE_FILE), `dep1: "export default 'dep2';", dep2: "dep2"`); - atomicWriteFileSync(join(INPUT_DIR, 'dep2.js'), 'export default "next";'); + atomicWriteFileSync(path.join(INPUT_DIR, 'dep2.js'), 'export default "next";'); }, 'START', 'BUNDLE_START', @@ -1620,8 +1626,8 @@ describe('rollup.watch', function () { }); it('respects changed watched directories in the transform hook', async () => { - const WATCHED_ID = join(INPUT_DIR, 'watched'); - await copy(join(SAMPLES_DIR, 'watch-files'), INPUT_DIR); + 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: { @@ -1657,7 +1663,7 @@ describe('rollup.watch', function () { }); it('respects initially missing added watched files', async () => { - await copy(join(SAMPLES_DIR, 'basic'), INPUT_DIR); + await copy(path.join(SAMPLES_DIR, 'basic'), INPUT_DIR); watcher = rollup.watch({ input: ENTRY_FILE, output: { @@ -1667,8 +1673,8 @@ describe('rollup.watch', function () { }, plugins: { transform() { - this.addWatchFile(join(INPUT_DIR, 'dep')); - return `export default ${existsSync(join(INPUT_DIR, 'dep'))}`; + this.addWatchFile(path.join(INPUT_DIR, 'dep')); + return `export default ${existsSync(path.join(INPUT_DIR, 'dep'))}`; } } }); @@ -1679,7 +1685,7 @@ describe('rollup.watch', function () { 'END', () => { assert.strictEqual(run(BUNDLE_FILE), false); - atomicWriteFileSync(join(INPUT_DIR, 'dep'), ''); + atomicWriteFileSync(path.join(INPUT_DIR, 'dep'), ''); }, 'START', 'BUNDLE_START', @@ -1692,8 +1698,8 @@ describe('rollup.watch', function () { }); it('respects unlinked and re-added watched files', async () => { - await copy(join(SAMPLES_DIR, 'basic'), INPUT_DIR); - await writeFile(join(INPUT_DIR, 'dep'), ''); + await copy(path.join(SAMPLES_DIR, 'basic'), INPUT_DIR); + await writeFile(path.join(INPUT_DIR, 'dep'), ''); watcher = rollup.watch({ input: ENTRY_FILE, output: { @@ -1703,8 +1709,8 @@ describe('rollup.watch', function () { }, plugins: { transform() { - this.addWatchFile(join(INPUT_DIR, 'dep')); - return `export default ${existsSync(join(INPUT_DIR, 'dep'))}`; + this.addWatchFile(path.join(INPUT_DIR, 'dep')); + return `export default ${existsSync(path.join(INPUT_DIR, 'dep'))}`; } } }); @@ -1715,7 +1721,7 @@ describe('rollup.watch', function () { 'END', () => { assert.strictEqual(run(BUNDLE_FILE), true); - unlinkSync(join(INPUT_DIR, 'dep')); + unlinkSync(path.join(INPUT_DIR, 'dep')); }, 'START', 'BUNDLE_START', @@ -1723,7 +1729,7 @@ describe('rollup.watch', function () { 'END', () => { assert.strictEqual(run(BUNDLE_FILE), false); - atomicWriteFileSync(join(INPUT_DIR, 'dep'), ''); + atomicWriteFileSync(path.join(INPUT_DIR, 'dep'), ''); }, 'START', 'BUNDLE_START', @@ -1736,11 +1742,11 @@ describe('rollup.watch', function () { }); it('does not rerun the transform hook if a non-watched change triggered the re-run', async () => { - const WATCHED_ID = join(INPUT_DIR, 'watched'); + const WATCHED_ID = path.join(INPUT_DIR, 'watched'); let transformRuns = 0; - await copy(join(SAMPLES_DIR, 'watch-files'), INPUT_DIR); + await copy(path.join(SAMPLES_DIR, 'watch-files'), INPUT_DIR); await wait(100); - await writeFile(join(INPUT_DIR, 'alsoWatched'), 'initial'); + await writeFile(path.join(INPUT_DIR, 'alsoWatched'), 'initial'); watcher = rollup.watch({ input: ENTRY_FILE, output: { @@ -1750,7 +1756,7 @@ describe('rollup.watch', function () { }, plugins: { buildStart() { - this.addWatchFile(join(INPUT_DIR, 'alsoWatched')); + this.addWatchFile(path.join(INPUT_DIR, 'alsoWatched')); }, transform() { transformRuns++; @@ -1766,7 +1772,7 @@ describe('rollup.watch', function () { 'END', () => { assert.strictEqual(transformRuns, 1); - atomicWriteFileSync(join(INPUT_DIR, 'alsoWatched'), 'next'); + atomicWriteFileSync(path.join(INPUT_DIR, 'alsoWatched'), 'next'); }, 'START', 'BUNDLE_START', From cfbaaaa09e48df21423bea2c709e19f7038d17a0 Mon Sep 17 00:00:00 2001 From: Lukas Taegert-Atkinson Date: Fri, 12 Apr 2024 08:10:21 +0200 Subject: [PATCH 17/45] Ensure reexported namespaces do not prevent creation of default export helpers (#5466) * Add test * Use better variable name * Ensure reexported namespaces do not prevent creation of default export helpers --- src/Chunk.ts | 41 +++++++++++-------- .../_config.js | 27 ++++++++++++ .../main.js | 2 + .../_config.js | 33 +++++++++++++++ .../main.js | 3 ++ .../_config.js | 34 +++++++++++++++ .../main.js | 5 +++ 7 files changed, 129 insertions(+), 16 deletions(-) create mode 100644 test/function/samples/external-namespace-and-default-reexport-compat/_config.js create mode 100644 test/function/samples/external-namespace-and-default-reexport-compat/main.js create mode 100644 test/function/samples/external-namespace-and-default-reexport-compat2/_config.js create mode 100644 test/function/samples/external-namespace-and-default-reexport-compat2/main.js create mode 100644 test/function/samples/external-namespace-and-default-reexport-compat3/_config.js create mode 100644 test/function/samples/external-namespace-and-default-reexport-compat3/main.js diff --git a/src/Chunk.ts b/src/Chunk.ts index ddb158b02..bfb7fc1dc 100644 --- a/src/Chunk.ts +++ b/src/Chunk.ts @@ -908,9 +908,14 @@ export default class Chunk { deconflictedDefault.add(chunk); } } else if ( - variable.name === '*' && - namespaceInteropHelpersByInteropType[interop(module.id)] + variable.isNamespace && + namespaceInteropHelpersByInteropType[interop(module.id)] && + (this.imports.has(variable) || + !this.exportNamesByVariable.get(variable)?.every(name => name.startsWith('*'))) ) { + // 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); } } @@ -1139,30 +1144,34 @@ export default class Chunk { const reexportSpecifiers = this.getReexportSpecifiers(); const renderedDependencies = new Map(); const fileName = this.getFileName(); - for (const dep of this.dependencies) { - const imports = importSpecifiers.get(dep) || null; - const reexports = reexportSpecifiers.get(dep) || null; - const namedExportsMode = dep instanceof ExternalChunk || dep.exportMode !== 'default'; - const importPath = dep.getImportPath(fileName); - - renderedDependencies.set(dep, { - attributes: dep instanceof ExternalChunk ? dep.getImportAttributes(this.snippets) : null, - defaultVariableName: dep.defaultVariableName, + 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: - dep instanceof ExternalChunk && + dependency instanceof ExternalChunk && (this.outputOptions.format === 'umd' || this.outputOptions.format === 'iife') && getGlobalName( - dep, + dependency, this.outputOptions.globals, (imports || reexports) !== null, this.inputOptions.onLog ), importPath, imports, - isChunk: dep instanceof Chunk, - name: dep.variableName, + isChunk: dependency instanceof Chunk, + name: dependency.variableName, namedExportsMode, - namespaceVariableName: dep.namespaceVariableName, + namespaceVariableName: dependency.namespaceVariableName, reexports }); } 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 000000000..60e4d4f23 --- /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 000000000..aa701236c --- /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 000000000..a22b8c49e --- /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 000000000..af1dccc74 --- /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 000000000..99012e486 --- /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 000000000..af3044e19 --- /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'; From 7275328b41b29605142bfdf55d68cb54e895a20c Mon Sep 17 00:00:00 2001 From: Lukas Taegert-Atkinson Date: Fri, 12 Apr 2024 08:12:32 +0200 Subject: [PATCH 18/45] 4.14.2 --- CHANGELOG.md | 19 +++++++++++++++++++ browser/package.json | 2 +- package-lock.json | 4 ++-- package.json | 2 +- 4 files changed, 23 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f0befdeff..3f9dc91f9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,24 @@ # rollup changelog +## 4.14.2 + +_2024-04-12_ + +### Bug Fixes + +- 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) + +### Pull Requests + +- [#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]) + ## 4.14.1 _2024-04-07_ diff --git a/browser/package.json b/browser/package.json index bc9ae3660..a967d6031 100644 --- a/browser/package.json +++ b/browser/package.json @@ -1,6 +1,6 @@ { "name": "@rollup/browser", - "version": "4.14.1", + "version": "4.14.2", "description": "Next-generation ES module bundler browser build", "main": "dist/rollup.browser.js", "module": "dist/es/rollup.browser.js", diff --git a/package-lock.json b/package-lock.json index c0b36008e..9c26a32ca 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "rollup", - "version": "4.14.1", + "version": "4.14.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "rollup", - "version": "4.14.1", + "version": "4.14.2", "license": "MIT", "dependencies": { "@types/estree": "1.0.5" diff --git a/package.json b/package.json index 47492b5a8..d2f531da1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rollup", - "version": "4.14.1", + "version": "4.14.2", "description": "Next-generation ES module bundler", "main": "dist/rollup.js", "module": "dist/es/rollup.js", From 49ed6d949ea4bf78cf3f78e27fa9cac5c3026408 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BF=A0=20/=20green?= Date: Mon, 15 Apr 2024 13:28:04 +0900 Subject: [PATCH 19/45] Add linux arm musl build (#5471) * Add linux arm musl build * Use strip = true in Cargo.toml instead --- .github/workflows/build-and-tests.yml | 41 ++++++++++++--------------- native.js | 2 +- npm/linux-arm-musleabihf/README.md | 3 ++ npm/linux-arm-musleabihf/package.json | 19 +++++++++++++ package-lock.json | 2 +- package.json | 3 +- rust/Cargo.toml | 1 + 7 files changed, 45 insertions(+), 26 deletions(-) create mode 100644 npm/linux-arm-musleabihf/README.md create mode 100644 npm/linux-arm-musleabihf/package.json diff --git a/.github/workflows/build-and-tests.yml b/.github/workflows/build-and-tests.yml index 1ae05d776..6885df6ad 100644 --- a/.github/workflows/build-and-tests.yml +++ b/.github/workflows/build-and-tests.yml @@ -106,15 +106,13 @@ jobs: target: x86_64-apple-darwin build: >- set -e && - npm run build:napi -- --release && - strip -x *.node + npm run build:napi -- --release - host: macos-latest target: aarch64-apple-darwin build: >- set -e && rustup target add aarch64-apple-darwin && - npm run build:napi -- --release --target aarch64-apple-darwin && - strip -x *.node + npm run build:napi -- --release --target aarch64-apple-darwin # Linux - host: ubuntu-latest @@ -123,14 +121,13 @@ jobs: build: >- set -e && rustup target add x86_64-unknown-linux-gnu && - npm run build:napi -- --release --target x86_64-unknown-linux-gnu && - strip *.node + npm run build:napi -- --release --target x86_64-unknown-linux-gnu - host: ubuntu-latest target: x86_64-unknown-linux-musl docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine build: >- set -e && - npm run build:napi -- --release && strip *.node + npm run build:napi -- --release - host: ubuntu-latest target: armv7-unknown-linux-gnueabihf zig: true @@ -139,8 +136,13 @@ jobs: sudo apt-get install gcc-arm-linux-gnueabihf -y build: >- set -e && - npm run build:napi -- --release --target armv7-unknown-linux-gnueabihf && - arm-linux-gnueabihf-strip *.node + npm run build:napi -- --release --target armv7-unknown-linux-gnueabihf + - host: ubuntu-latest + target: armv7-unknown-linux-musleabihf + zig: true + build: >- + set -e && + npm run build:napi -- --release --target armv7-unknown-linux-musleabihf - host: ubuntu-latest target: aarch64-unknown-linux-gnu docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian-aarch64 @@ -149,8 +151,7 @@ jobs: export JEMALLOC_SYS_WITH_LG_PAGE=16 && rustup default nightly-2023-10-05 && rustup target add aarch64-unknown-linux-gnu && - npm run build:napi -- --release --target aarch64-unknown-linux-gnu && - aarch64-unknown-linux-gnu-strip *.node + npm run build:napi -- --release --target aarch64-unknown-linux-gnu - host: ubuntu-latest target: aarch64-unknown-linux-musl docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine @@ -159,20 +160,17 @@ jobs: export JEMALLOC_SYS_WITH_LG_PAGE=16 && rustup default nightly-2023-10-05 && rustup target add aarch64-unknown-linux-musl && - RUSTFLAGS='-C target-feature=-crt-static -C linker=aarch64-linux-musl-gcc' npm run build:napi -- --release --target aarch64-unknown-linux-musl && - /aarch64-linux-musl-cross/bin/aarch64-linux-musl-strip *.node + RUSTFLAGS='-C target-feature=-crt-static -C linker=aarch64-linux-musl-gcc' npm run build:napi -- --release --target aarch64-unknown-linux-musl - host: ubuntu-latest target: armv7-linux-androideabi build: >- set -e && - npm run build:napi -- --release --target armv7-linux-androideabi && - ${ANDROID_NDK_LATEST_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip *.node + npm run build:napi -- --release --target armv7-linux-androideabi - host: ubuntu-latest target: aarch64-linux-android build: >- set -e && - npm run build:napi -- --release --target aarch64-linux-android && - ${ANDROID_NDK_LATEST_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip *.node + npm run build:napi -- --release --target aarch64-linux-android - host: ubuntu-latest target: riscv64gc-unknown-linux-gnu setup: | @@ -181,8 +179,7 @@ jobs: build: >- set -e && rustup target add riscv64gc-unknown-linux-gnu && - npm run build:napi -- --release --target riscv64gc-unknown-linux-gnu && - riscv64-linux-gnu-strip *.node + npm run build:napi -- --release --target riscv64gc-unknown-linux-gnu - host: ubuntu-latest target: powerpc64le-unknown-linux-gnu setup: | @@ -191,8 +188,7 @@ jobs: build: >- set -e && export CARGO_TARGET_POWERPC64LE_UNKNOWN_LINUX_GNU_LINKER=powerpc64le-linux-gnu-gcc && rustup target add powerpc64le-unknown-linux-gnu && - npm run build:napi -- --release --target powerpc64le-unknown-linux-gnu && - powerpc64le-linux-gnu-strip *.node + npm run build:napi -- --release --target powerpc64le-unknown-linux-gnu - host: ubuntu-latest target: s390x-unknown-linux-gnu setup: | @@ -202,8 +198,7 @@ jobs: set -e && export CARGO_TARGET_S390X_UNKNOWN_LINUX_GNU_LINKER=s390x-linux-gnu-gcc && rustup target add s390x-unknown-linux-gnu && - npm run build:napi -- --release --target s390x-unknown-linux-gnu && - s390x-linux-gnu-strip *.node + npm run build:napi -- --release --target s390x-unknown-linux-gnu name: Build ${{ matrix.settings.name || matrix.settings.target }} runs-on: ${{ matrix.settings.host }} timeout-minutes: 30 diff --git a/native.js b/native.js index d927ec36d..e0d54b8cf 100644 --- a/native.js +++ b/native.js @@ -14,7 +14,7 @@ const bindingsByPlatformAndArch = { x64: { base: 'darwin-x64' } }, linux: { - arm: { base: 'linux-arm-gnueabihf', musl: null }, + arm: { base: 'linux-arm-gnueabihf', musl: 'linux-arm-musleabihf' }, arm64: { base: 'linux-arm64-gnu', musl: 'linux-arm64-musl' }, ppc64: { base: 'linux-powerpc64le-gnu', musl: null }, riscv64: { base: 'linux-riscv64-gnu', musl: null }, diff --git a/npm/linux-arm-musleabihf/README.md b/npm/linux-arm-musleabihf/README.md new file mode 100644 index 000000000..09798f728 --- /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 000000000..2a07544f2 --- /dev/null +++ b/npm/linux-arm-musleabihf/package.json @@ -0,0 +1,19 @@ +{ + "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": "rollup/rollup", + "main": "./rollup.linux-arm-musleabihf.node" +} diff --git a/package-lock.json b/package-lock.json index 9c26a32ca..4f57a060d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -23,7 +23,7 @@ "@codemirror/view": "^6.26.1", "@jridgewell/sourcemap-codec": "^1.4.15", "@mermaid-js/mermaid-cli": "^10.8.0", - "@napi-rs/cli": "^2.18.0", + "@napi-rs/cli": "^2.18.1", "@rollup/plugin-alias": "^5.1.0", "@rollup/plugin-buble": "^1.0.3", "@rollup/plugin-commonjs": "^25.0.7", diff --git a/package.json b/package.json index d2f531da1..ae840597c 100644 --- a/package.json +++ b/package.json @@ -23,6 +23,7 @@ "aarch64-unknown-linux-musl", "armv7-linux-androideabi", "armv7-unknown-linux-gnueabihf", + "armv7-unknown-linux-musleabihf", "i686-pc-windows-msvc", "riscv64gc-unknown-linux-gnu", "powerpc64le-unknown-linux-gnu", @@ -120,7 +121,7 @@ "@codemirror/view": "^6.26.1", "@jridgewell/sourcemap-codec": "^1.4.15", "@mermaid-js/mermaid-cli": "^10.8.0", - "@napi-rs/cli": "^2.18.0", + "@napi-rs/cli": "^2.18.1", "@rollup/plugin-alias": "^5.1.0", "@rollup/plugin-buble": "^1.0.3", "@rollup/plugin-commonjs": "^25.0.7", diff --git a/rust/Cargo.toml b/rust/Cargo.toml index d3a9a7145..7f14caaef 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -1,5 +1,6 @@ [profile.release] lto = true +strip = true [workspace] resolver = "2" From e64f3d8d0cdc561f00d3efe503e3081f81889679 Mon Sep 17 00:00:00 2001 From: Lukas Taegert-Atkinson Date: Mon, 15 Apr 2024 09:01:42 +0200 Subject: [PATCH 20/45] 4.14.3 --- CHANGELOG.md | 12 ++++++++++++ browser/package.json | 2 +- package-lock.json | 4 ++-- package.json | 2 +- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3f9dc91f9..d0b318fec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,17 @@ # rollup changelog +## 4.14.3 + +_2024-04-15_ + +### Bug Fixes + +- Support Alpine Linux and other MUSL builds on ARM (#5471) + +### Pull Requests + +- [#5471](https://github.com/rollup/rollup/pull/5471): Add linux arm musl build (@sapphi-red) + ## 4.14.2 _2024-04-12_ diff --git a/browser/package.json b/browser/package.json index a967d6031..be731a027 100644 --- a/browser/package.json +++ b/browser/package.json @@ -1,6 +1,6 @@ { "name": "@rollup/browser", - "version": "4.14.2", + "version": "4.14.3", "description": "Next-generation ES module bundler browser build", "main": "dist/rollup.browser.js", "module": "dist/es/rollup.browser.js", diff --git a/package-lock.json b/package-lock.json index 4f57a060d..0cdaae345 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "rollup", - "version": "4.14.2", + "version": "4.14.3", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "rollup", - "version": "4.14.2", + "version": "4.14.3", "license": "MIT", "dependencies": { "@types/estree": "1.0.5" diff --git a/package.json b/package.json index ae840597c..36ea22307 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rollup", - "version": "4.14.2", + "version": "4.14.3", "description": "Next-generation ES module bundler", "main": "dist/rollup.js", "module": "dist/es/rollup.js", From 4ca4ea973e317a64b274a16d5a69d321da841d7c Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 19 Apr 2024 10:08:50 +0200 Subject: [PATCH 21/45] chore(deps): lock file maintenance minor/patch updates (#5475) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- package-lock.json | 508 +++++++++++++++++----------------- package.json | 24 +- rust/Cargo.lock | 167 +++++------ rust/bindings_napi/Cargo.toml | 6 +- rust/parse_ast/Cargo.toml | 8 +- 5 files changed, 358 insertions(+), 355 deletions(-) diff --git a/package-lock.json b/package-lock.json index 0cdaae345..95e302af9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -20,7 +20,7 @@ "@codemirror/language": "^6.10.1", "@codemirror/search": "^6.5.6", "@codemirror/state": "^6.4.1", - "@codemirror/view": "^6.26.1", + "@codemirror/view": "^6.26.3", "@jridgewell/sourcemap-codec": "^1.4.15", "@mermaid-js/mermaid-cli": "^10.8.0", "@napi-rs/cli": "^2.18.1", @@ -33,14 +33,14 @@ "@rollup/plugin-terser": "^0.4.4", "@rollup/plugin-typescript": "^11.1.6", "@rollup/pluginutils": "^5.1.0", - "@shikijs/vitepress-twoslash": "^1.2.4", - "@types/eslint": "^8.56.7", + "@shikijs/vitepress-twoslash": "^1.3.0", + "@types/eslint": "^8.56.9", "@types/inquirer": "^9.0.7", "@types/mocha": "^10.0.6", "@types/node": "~18.18.14", "@types/yargs-parser": "^21.0.3", - "@typescript-eslint/eslint-plugin": "^7.6.0", - "@typescript-eslint/parser": "^7.6.0", + "@typescript-eslint/eslint-plugin": "^7.7.0", + "@typescript-eslint/parser": "^7.7.0", "@vue/eslint-config-prettier": "^9.0.0", "@vue/eslint-config-typescript": "^13.0.0", "acorn": "^8.11.3", @@ -59,13 +59,13 @@ "eslint-plugin-import": "^2.29.1", "eslint-plugin-prettier": "^5.1.3", "eslint-plugin-unicorn": "^52.0.0", - "eslint-plugin-vue": "^9.24.1", + "eslint-plugin-vue": "^9.25.0", "fixturify": "^3.0.0", "flru": "^1.0.2", "fs-extra": "^11.2.0", "github-api": "^3.4.0", "husky": "^9.0.11", - "inquirer": "^9.2.17", + "inquirer": "^9.2.18", "is-reference": "^3.0.2", "lint-staged": "^15.2.2", "locate-character": "^3.0.0", @@ -77,7 +77,7 @@ "pretty-bytes": "^6.1.1", "pretty-ms": "^9.0.0", "requirejs": "^2.3.6", - "rollup": "^4.14.1", + "rollup": "^4.14.3", "rollup-plugin-license": "^3.3.1", "rollup-plugin-string": "^3.0.0", "semver": "^7.6.0", @@ -88,10 +88,10 @@ "systemjs": "^6.14.3", "terser": "^5.30.3", "tslib": "^2.6.2", - "typescript": "^5.4.4", - "vite": "^5.2.8", - "vitepress": "^1.0.2", - "vue": "^3.4.21", + "typescript": "^5.4.5", + "vite": "^5.2.9", + "vitepress": "^1.1.0", + "vue": "^3.4.22", "wasm-pack": "^0.12.1", "weak-napi": "^2.0.2", "yargs-parser": "^21.1.1" @@ -704,9 +704,9 @@ } }, "node_modules/@codemirror/autocomplete": { - "version": "6.15.0", - "resolved": "https://registry.npmjs.org/@codemirror/autocomplete/-/autocomplete-6.15.0.tgz", - "integrity": "sha512-G2Zm0mXznxz97JhaaOdoEG2cVupn4JjPaS4AcNvZzhOsnnG9YVN68VzfoUw6dYTsIxT6a/cmoFEN47KAWhXaOg==", + "version": "6.16.0", + "resolved": "https://registry.npmjs.org/@codemirror/autocomplete/-/autocomplete-6.16.0.tgz", + "integrity": "sha512-P/LeCTtZHRTCU4xQsa89vSKWecYv1ZqwzOd5topheGRf+qtacFgBeIMQi3eL8Kt/BUNvxUWkx+5qP2jlGoARrg==", "dev": true, "dependencies": { "@codemirror/language": "^6.0.0", @@ -722,9 +722,9 @@ } }, "node_modules/@codemirror/commands": { - "version": "6.3.3", - "resolved": "https://registry.npmjs.org/@codemirror/commands/-/commands-6.3.3.tgz", - "integrity": "sha512-dO4hcF0fGT9tu1Pj1D2PvGvxjeGkbC6RGcZw6Qs74TH+Ed1gw98jmUgd2axWvIZEqTeTuFrg1lEB1KV6cK9h1A==", + "version": "6.4.0", + "resolved": "https://registry.npmjs.org/@codemirror/commands/-/commands-6.4.0.tgz", + "integrity": "sha512-HB3utD5GxCvEhSyj5EuG9KpuQQhFpxalh3lwrspyL/GeSNDe4c6JDxVzL12SJ+7gUknHjZzmq7OPCb9QPgiRmQ==", "dev": true, "dependencies": { "@codemirror/language": "^6.0.0", @@ -791,9 +791,9 @@ "dev": true }, "node_modules/@codemirror/view": { - "version": "6.26.2", - "resolved": "https://registry.npmjs.org/@codemirror/view/-/view-6.26.2.tgz", - "integrity": "sha512-j6V48PlFC/O7ERAR5vRW5QKDdchzmyyfojDdt+zPsB0YXoWgcjlC1IWjmlYfx08aQZ3HN5BtALcgGgtSKGMe7A==", + "version": "6.26.3", + "resolved": "https://registry.npmjs.org/@codemirror/view/-/view-6.26.3.tgz", + "integrity": "sha512-gmqxkPALZjkgSxIeeweY/wGQXBfwTUaLs8h7OKtSwfbj9Ct3L11lD+u1sS7XHppxFQoMDiMDp07P9f3I2jWOHw==", "dev": true, "dependencies": { "@codemirror/state": "^6.4.0", @@ -1374,6 +1374,15 @@ "integrity": "sha512-93zYdMES/c1D69yZiKDBj0V24vqNzB/koF26KPaagAfd3P/4gUlh3Dys5ogAK+Exi9QyzlD8x/08Zt7wIKcDcA==", "dev": true }, + "node_modules/@inquirer/figures": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@inquirer/figures/-/figures-1.0.1.tgz", + "integrity": "sha512-mtup3wVKia3ZwULPHcbs4Mor8Voi+iIXEWD7wCNbIO6lYR62oPCTQyrddi5OMYVXHzeCSoneZwJuS8sBvlEwDw==", + "dev": true, + "engines": { + "node": ">=18" + } + }, "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", @@ -1605,9 +1614,9 @@ } }, "node_modules/@napi-rs/cli": { - "version": "2.18.1", - "resolved": "https://registry.npmjs.org/@napi-rs/cli/-/cli-2.18.1.tgz", - "integrity": "sha512-N4iTeip2VSk0RftgDGuk7IBrgOST/WPUSA3lYstILXsNifR3tHugcbLzo04+OtSrMc+ZUPsXo3Jd1t3dlswAlw==", + "version": "2.18.2", + "resolved": "https://registry.npmjs.org/@napi-rs/cli/-/cli-2.18.2.tgz", + "integrity": "sha512-IXQji3IF5eStxTHe/PxDSRjPrFymYAQ5FbIvqurxzxyWR8nJql9mtvmCP8y2g8tSoW5xhaToLQW0+mO3lUZq4w==", "dev": true, "bin": { "napi": "scripts/index.js" @@ -1928,9 +1937,9 @@ } }, "node_modules/@rollup/rollup-android-arm-eabi": { - "version": "4.14.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.14.1.tgz", - "integrity": "sha512-fH8/o8nSUek8ceQnT7K4EQbSiV7jgkHq81m9lWZFIXjJ7lJzpWXbQFpT/Zh6OZYnpFykvzC3fbEvEAFZu03dPA==", + "version": "4.14.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.14.3.tgz", + "integrity": "sha512-X9alQ3XM6I9IlSlmC8ddAvMSyG1WuHk5oUnXGw+yUBs3BFoTizmG1La/Gr8fVJvDWAq+zlYTZ9DBgrlKRVY06g==", "cpu": [ "arm" ], @@ -1941,9 +1950,9 @@ ] }, "node_modules/@rollup/rollup-android-arm64": { - "version": "4.14.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.14.1.tgz", - "integrity": "sha512-Y/9OHLjzkunF+KGEoJr3heiD5X9OLa8sbT1lm0NYeKyaM3oMhhQFvPB0bNZYJwlq93j8Z6wSxh9+cyKQaxS7PQ==", + "version": "4.14.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.14.3.tgz", + "integrity": "sha512-eQK5JIi+POhFpzk+LnjKIy4Ks+pwJ+NXmPxOCSvOKSNRPONzKuUvWE+P9JxGZVxrtzm6BAYMaL50FFuPe0oWMQ==", "cpu": [ "arm64" ], @@ -1954,9 +1963,9 @@ ] }, "node_modules/@rollup/rollup-darwin-arm64": { - "version": "4.14.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.14.1.tgz", - "integrity": "sha512-+kecg3FY84WadgcuSVm6llrABOdQAEbNdnpi5X3UwWiFVhZIZvKgGrF7kmLguvxHNQy+UuRV66cLVl3S+Rkt+Q==", + "version": "4.14.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.14.3.tgz", + "integrity": "sha512-Od4vE6f6CTT53yM1jgcLqNfItTsLt5zE46fdPaEmeFHvPs5SjZYlLpHrSiHEKR1+HdRfxuzXHjDOIxQyC3ptBA==", "cpu": [ "arm64" ], @@ -1967,9 +1976,9 @@ ] }, "node_modules/@rollup/rollup-darwin-x64": { - "version": "4.14.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.14.1.tgz", - "integrity": "sha512-2pYRzEjVqq2TB/UNv47BV/8vQiXkFGVmPFwJb+1E0IFFZbIX8/jo1olxqqMbo6xCXf8kabANhp5bzCij2tFLUA==", + "version": "4.14.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.14.3.tgz", + "integrity": "sha512-0IMAO21axJeNIrvS9lSe/PGthc8ZUS+zC53O0VhF5gMxfmcKAP4ESkKOCwEi6u2asUrt4mQv2rjY8QseIEb1aw==", "cpu": [ "x64" ], @@ -1980,9 +1989,22 @@ ] }, "node_modules/@rollup/rollup-linux-arm-gnueabihf": { - "version": "4.14.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.14.1.tgz", - "integrity": "sha512-mS6wQ6Do6/wmrF9aTFVpIJ3/IDXhg1EZcQFYHZLHqw6AzMBjTHWnCG35HxSqUNphh0EHqSM6wRTT8HsL1C0x5g==", + "version": "4.14.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.14.3.tgz", + "integrity": "sha512-ge2DC7tHRHa3caVEoSbPRJpq7azhG+xYsd6u2MEnJ6XzPSzQsTKyXvh6iWjXRf7Rt9ykIUWHtl0Uz3T6yXPpKw==", + "cpu": [ + "arm" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm-musleabihf": { + "version": "4.14.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.14.3.tgz", + "integrity": "sha512-ljcuiDI4V3ySuc7eSk4lQ9wU8J8r8KrOUvB2U+TtK0TiW6OFDmJ+DdIjjwZHIw9CNxzbmXY39wwpzYuFDwNXuw==", "cpu": [ "arm" ], @@ -1993,9 +2015,9 @@ ] }, "node_modules/@rollup/rollup-linux-arm64-gnu": { - "version": "4.14.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.14.1.tgz", - "integrity": "sha512-p9rGKYkHdFMzhckOTFubfxgyIO1vw//7IIjBBRVzyZebWlzRLeNhqxuSaZ7kCEKVkm/kuC9fVRW9HkC/zNRG2w==", + "version": "4.14.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.14.3.tgz", + "integrity": "sha512-Eci2us9VTHm1eSyn5/eEpaC7eP/mp5n46gTRB3Aar3BgSvDQGJZuicyq6TsH4HngNBgVqC5sDYxOzTExSU+NjA==", "cpu": [ "arm64" ], @@ -2006,9 +2028,9 @@ ] }, "node_modules/@rollup/rollup-linux-arm64-musl": { - "version": "4.14.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.14.1.tgz", - "integrity": "sha512-nDY6Yz5xS/Y4M2i9JLQd3Rofh5OR8Bn8qe3Mv/qCVpHFlwtZSBYSPaU4mrGazWkXrdQ98GB//H0BirGR/SKFSw==", + "version": "4.14.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.14.3.tgz", + "integrity": "sha512-UrBoMLCq4E92/LCqlh+blpqMz5h1tJttPIniwUgOFJyjWI1qrtrDhhpHPuFxULlUmjFHfloWdixtDhSxJt5iKw==", "cpu": [ "arm64" ], @@ -2019,11 +2041,11 @@ ] }, "node_modules/@rollup/rollup-linux-powerpc64le-gnu": { - "version": "4.14.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-powerpc64le-gnu/-/rollup-linux-powerpc64le-gnu-4.14.1.tgz", - "integrity": "sha512-im7HE4VBL+aDswvcmfx88Mp1soqL9OBsdDBU8NqDEYtkri0qV0THhQsvZtZeNNlLeCUQ16PZyv7cqutjDF35qw==", + "version": "4.14.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-powerpc64le-gnu/-/rollup-linux-powerpc64le-gnu-4.14.3.tgz", + "integrity": "sha512-5aRjvsS8q1nWN8AoRfrq5+9IflC3P1leMoy4r2WjXyFqf3qcqsxRCfxtZIV58tCxd+Yv7WELPcO9mY9aeQyAmw==", "cpu": [ - "ppc64le" + "ppc64" ], "dev": true, "optional": true, @@ -2032,9 +2054,9 @@ ] }, "node_modules/@rollup/rollup-linux-riscv64-gnu": { - "version": "4.14.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.14.1.tgz", - "integrity": "sha512-RWdiHuAxWmzPJgaHJdpvUUlDz8sdQz4P2uv367T2JocdDa98iRw2UjIJ4QxSyt077mXZT2X6pKfT2iYtVEvOFw==", + "version": "4.14.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.14.3.tgz", + "integrity": "sha512-sk/Qh1j2/RJSX7FhEpJn8n0ndxy/uf0kI/9Zc4b1ELhqULVdTfN6HL31CDaTChiBAOgLcsJ1sgVZjWv8XNEsAQ==", "cpu": [ "riscv64" ], @@ -2045,9 +2067,9 @@ ] }, "node_modules/@rollup/rollup-linux-s390x-gnu": { - "version": "4.14.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.14.1.tgz", - "integrity": "sha512-VMgaGQ5zRX6ZqV/fas65/sUGc9cPmsntq2FiGmayW9KMNfWVG/j0BAqImvU4KTeOOgYSf1F+k6at1UfNONuNjA==", + "version": "4.14.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.14.3.tgz", + "integrity": "sha512-jOO/PEaDitOmY9TgkxF/TQIjXySQe5KVYB57H/8LRP/ux0ZoO8cSHCX17asMSv3ruwslXW/TLBcxyaUzGRHcqg==", "cpu": [ "s390x" ], @@ -2058,9 +2080,9 @@ ] }, "node_modules/@rollup/rollup-linux-x64-gnu": { - "version": "4.14.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.14.1.tgz", - "integrity": "sha512-9Q7DGjZN+hTdJomaQ3Iub4m6VPu1r94bmK2z3UeWP3dGUecRC54tmVu9vKHTm1bOt3ASoYtEz6JSRLFzrysKlA==", + "version": "4.14.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.14.3.tgz", + "integrity": "sha512-8ybV4Xjy59xLMyWo3GCfEGqtKV5M5gCSrZlxkPGvEPCGDLNla7v48S662HSGwRd6/2cSneMQWiv+QzcttLrrOA==", "cpu": [ "x64" ], @@ -2071,9 +2093,9 @@ ] }, "node_modules/@rollup/rollup-linux-x64-musl": { - "version": "4.14.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.14.1.tgz", - "integrity": "sha512-JNEG/Ti55413SsreTguSx0LOVKX902OfXIKVg+TCXO6Gjans/k9O6ww9q3oLGjNDaTLxM+IHFMeXy/0RXL5R/g==", + "version": "4.14.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.14.3.tgz", + "integrity": "sha512-s+xf1I46trOY10OqAtZ5Rm6lzHre/UiLA1J2uOhCFXWkbZrJRkYBPO6FhvGfHmdtQ3Bx793MNa7LvoWFAm93bg==", "cpu": [ "x64" ], @@ -2084,9 +2106,9 @@ ] }, "node_modules/@rollup/rollup-win32-arm64-msvc": { - "version": "4.14.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.14.1.tgz", - "integrity": "sha512-ryS22I9y0mumlLNwDFYZRDFLwWh3aKaC72CWjFcFvxK0U6v/mOkM5Up1bTbCRAhv3kEIwW2ajROegCIQViUCeA==", + "version": "4.14.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.14.3.tgz", + "integrity": "sha512-+4h2WrGOYsOumDQ5S2sYNyhVfrue+9tc9XcLWLh+Kw3UOxAvrfOrSMFon60KspcDdytkNDh7K2Vs6eMaYImAZg==", "cpu": [ "arm64" ], @@ -2097,9 +2119,9 @@ ] }, "node_modules/@rollup/rollup-win32-ia32-msvc": { - "version": "4.14.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.14.1.tgz", - "integrity": "sha512-TdloItiGk+T0mTxKx7Hp279xy30LspMso+GzQvV2maYePMAWdmrzqSNZhUpPj3CGw12aGj57I026PgLCTu8CGg==", + "version": "4.14.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.14.3.tgz", + "integrity": "sha512-T1l7y/bCeL/kUwh9OD4PQT4aM7Bq43vX05htPJJ46RTI4r5KNt6qJRzAfNfM+OYMNEVBWQzR2Gyk+FXLZfogGw==", "cpu": [ "ia32" ], @@ -2110,9 +2132,9 @@ ] }, "node_modules/@rollup/rollup-win32-x64-msvc": { - "version": "4.14.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.14.1.tgz", - "integrity": "sha512-wQGI+LY/Py20zdUPq+XCem7JcPOyzIJBm3dli+56DJsQOHbnXZFEwgmnC6el1TPAfC8lBT3m+z69RmLykNUbew==", + "version": "4.14.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.14.3.tgz", + "integrity": "sha512-/BypzV0H1y1HzgYpxqRaXGBRqfodgoBBCcsrujT6QRcakDQdfU+Lq9PENPh5jB4I44YWq+0C2eHsHya+nZY1sA==", "cpu": [ "x64" ], @@ -2192,9 +2214,9 @@ } }, "node_modules/@types/eslint": { - "version": "8.56.8", - "resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-8.56.8.tgz", - "integrity": "sha512-LdDdQVDzDXf3ijhhMnE27C5vc0QEknD8GiMR/Hi+fVbdZNfAfCy2j69m0LjUd2MAy0+kIgnOtd5ndTmDk/VWCA==", + "version": "8.56.10", + "resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-8.56.10.tgz", + "integrity": "sha512-Shavhk87gCtY2fhXDctcfS3e6FdxWkCx1iUZ9eEUbh7rTqlZT0/IzOkCOVt0fCjcFuZ9FPYfuezTBImfHCDBGQ==", "dev": true, "dependencies": { "@types/estree": "*", @@ -2269,9 +2291,9 @@ "dev": true }, "node_modules/@types/markdown-it": { - "version": "13.0.7", - "resolved": "https://registry.npmjs.org/@types/markdown-it/-/markdown-it-13.0.7.tgz", - "integrity": "sha512-U/CBi2YUUcTHBt5tjO2r5QV/x0Po6nsYwQU4Y04fBS6vfoImaiZ6f8bi3CjTCxBPQSO1LMyUqkByzi8AidyxfA==", + "version": "14.0.1", + "resolved": "https://registry.npmjs.org/@types/markdown-it/-/markdown-it-14.0.1.tgz", + "integrity": "sha512-6WfOG3jXR78DW8L5cTYCVVGAsIFZskRHCDo5tbqa+qtKVt4oDRVH7hyIWu1SpDQJlmIoEivNQZ5h+AGAOrgOtQ==", "dev": true, "dependencies": { "@types/linkify-it": "*", @@ -2386,16 +2408,16 @@ } }, "node_modules/@typescript-eslint/eslint-plugin": { - "version": "7.6.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-7.6.0.tgz", - "integrity": "sha512-gKmTNwZnblUdnTIJu3e9kmeRRzV2j1a/LUO27KNNAnIC5zjy1aSvXSRp4rVNlmAoHlQ7HzX42NbKpcSr4jF80A==", + "version": "7.7.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-7.7.0.tgz", + "integrity": "sha512-GJWR0YnfrKnsRoluVO3PRb9r5aMZriiMMM/RHj5nnTrBy1/wIgk76XCtCKcnXGjpZQJQRFtGV9/0JJ6n30uwpQ==", "dev": true, "dependencies": { "@eslint-community/regexpp": "^4.10.0", - "@typescript-eslint/scope-manager": "7.6.0", - "@typescript-eslint/type-utils": "7.6.0", - "@typescript-eslint/utils": "7.6.0", - "@typescript-eslint/visitor-keys": "7.6.0", + "@typescript-eslint/scope-manager": "7.7.0", + "@typescript-eslint/type-utils": "7.7.0", + "@typescript-eslint/utils": "7.7.0", + "@typescript-eslint/visitor-keys": "7.7.0", "debug": "^4.3.4", "graphemer": "^1.4.0", "ignore": "^5.3.1", @@ -2421,15 +2443,15 @@ } }, "node_modules/@typescript-eslint/parser": { - "version": "7.6.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-7.6.0.tgz", - "integrity": "sha512-usPMPHcwX3ZoPWnBnhhorc14NJw9J4HpSXQX4urF2TPKG0au0XhJoZyX62fmvdHONUkmyUe74Hzm1//XA+BoYg==", + "version": "7.7.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-7.7.0.tgz", + "integrity": "sha512-fNcDm3wSwVM8QYL4HKVBggdIPAy9Q41vcvC/GtDobw3c4ndVT3K6cqudUmjHPw8EAp4ufax0o58/xvWaP2FmTg==", "dev": true, "dependencies": { - "@typescript-eslint/scope-manager": "7.6.0", - "@typescript-eslint/types": "7.6.0", - "@typescript-eslint/typescript-estree": "7.6.0", - "@typescript-eslint/visitor-keys": "7.6.0", + "@typescript-eslint/scope-manager": "7.7.0", + "@typescript-eslint/types": "7.7.0", + "@typescript-eslint/typescript-estree": "7.7.0", + "@typescript-eslint/visitor-keys": "7.7.0", "debug": "^4.3.4" }, "engines": { @@ -2449,13 +2471,13 @@ } }, "node_modules/@typescript-eslint/scope-manager": { - "version": "7.6.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-7.6.0.tgz", - "integrity": "sha512-ngttyfExA5PsHSx0rdFgnADMYQi+Zkeiv4/ZxGYUWd0nLs63Ha0ksmp8VMxAIC0wtCFxMos7Lt3PszJssG/E6w==", + "version": "7.7.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-7.7.0.tgz", + "integrity": "sha512-/8INDn0YLInbe9Wt7dK4cXLDYp0fNHP5xKLHvZl3mOT5X17rK/YShXaiNmorl+/U4VKCVIjJnx4Ri5b0y+HClw==", "dev": true, "dependencies": { - "@typescript-eslint/types": "7.6.0", - "@typescript-eslint/visitor-keys": "7.6.0" + "@typescript-eslint/types": "7.7.0", + "@typescript-eslint/visitor-keys": "7.7.0" }, "engines": { "node": "^18.18.0 || >=20.0.0" @@ -2466,13 +2488,13 @@ } }, "node_modules/@typescript-eslint/type-utils": { - "version": "7.6.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-7.6.0.tgz", - "integrity": "sha512-NxAfqAPNLG6LTmy7uZgpK8KcuiS2NZD/HlThPXQRGwz6u7MDBWRVliEEl1Gj6U7++kVJTpehkhZzCJLMK66Scw==", + "version": "7.7.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-7.7.0.tgz", + "integrity": "sha512-bOp3ejoRYrhAlnT/bozNQi3nio9tIgv3U5C0mVDdZC7cpcQEDZXvq8inrHYghLVwuNABRqrMW5tzAv88Vy77Sg==", "dev": true, "dependencies": { - "@typescript-eslint/typescript-estree": "7.6.0", - "@typescript-eslint/utils": "7.6.0", + "@typescript-eslint/typescript-estree": "7.7.0", + "@typescript-eslint/utils": "7.7.0", "debug": "^4.3.4", "ts-api-utils": "^1.3.0" }, @@ -2493,9 +2515,9 @@ } }, "node_modules/@typescript-eslint/types": { - "version": "7.6.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-7.6.0.tgz", - "integrity": "sha512-h02rYQn8J+MureCvHVVzhl69/GAfQGPQZmOMjG1KfCl7o3HtMSlPaPUAPu6lLctXI5ySRGIYk94clD/AUMCUgQ==", + "version": "7.7.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-7.7.0.tgz", + "integrity": "sha512-G01YPZ1Bd2hn+KPpIbrAhEWOn5lQBrjxkzHkWvP6NucMXFtfXoevK82hzQdpfuQYuhkvFDeQYbzXCjR1z9Z03w==", "dev": true, "engines": { "node": "^18.18.0 || >=20.0.0" @@ -2506,13 +2528,13 @@ } }, "node_modules/@typescript-eslint/typescript-estree": { - "version": "7.6.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-7.6.0.tgz", - "integrity": "sha512-+7Y/GP9VuYibecrCQWSKgl3GvUM5cILRttpWtnAu8GNL9j11e4tbuGZmZjJ8ejnKYyBRb2ddGQ3rEFCq3QjMJw==", + "version": "7.7.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-7.7.0.tgz", + "integrity": "sha512-8p71HQPE6CbxIBy2kWHqM1KGrC07pk6RJn40n0DSc6bMOBBREZxSDJ+BmRzc8B5OdaMh1ty3mkuWRg4sCFiDQQ==", "dev": true, "dependencies": { - "@typescript-eslint/types": "7.6.0", - "@typescript-eslint/visitor-keys": "7.6.0", + "@typescript-eslint/types": "7.7.0", + "@typescript-eslint/visitor-keys": "7.7.0", "debug": "^4.3.4", "globby": "^11.1.0", "is-glob": "^4.0.3", @@ -2534,17 +2556,17 @@ } }, "node_modules/@typescript-eslint/utils": { - "version": "7.6.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-7.6.0.tgz", - "integrity": "sha512-x54gaSsRRI+Nwz59TXpCsr6harB98qjXYzsRxGqvA5Ue3kQH+FxS7FYU81g/omn22ML2pZJkisy6Q+ElK8pBCA==", + "version": "7.7.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-7.7.0.tgz", + "integrity": "sha512-LKGAXMPQs8U/zMRFXDZOzmMKgFv3COlxUQ+2NMPhbqgVm6R1w+nU1i4836Pmxu9jZAuIeyySNrN/6Rc657ggig==", "dev": true, "dependencies": { "@eslint-community/eslint-utils": "^4.4.0", "@types/json-schema": "^7.0.15", "@types/semver": "^7.5.8", - "@typescript-eslint/scope-manager": "7.6.0", - "@typescript-eslint/types": "7.6.0", - "@typescript-eslint/typescript-estree": "7.6.0", + "@typescript-eslint/scope-manager": "7.7.0", + "@typescript-eslint/types": "7.7.0", + "@typescript-eslint/typescript-estree": "7.7.0", "semver": "^7.6.0" }, "engines": { @@ -2559,12 +2581,12 @@ } }, "node_modules/@typescript-eslint/visitor-keys": { - "version": "7.6.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-7.6.0.tgz", - "integrity": "sha512-4eLB7t+LlNUmXzfOu1VAIAdkjbu5xNSerURS9X/S5TUKWFRpXRQZbmtPqgKmYx8bj3J0irtQXSiWAOY82v+cgw==", + "version": "7.7.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-7.7.0.tgz", + "integrity": "sha512-h0WHOj8MhdhY8YWkzIF30R379y0NqyOHExI9N9KCzvmu05EgG4FumeYa3ccfKUSphyWkWQE1ybVrgz/Pbam6YA==", "dev": true, "dependencies": { - "@typescript-eslint/types": "7.6.0", + "@typescript-eslint/types": "7.7.0", "eslint-visitor-keys": "^3.4.3" }, "engines": { @@ -2622,53 +2644,53 @@ } }, "node_modules/@vue/compiler-core": { - "version": "3.4.21", - "resolved": "https://registry.npmjs.org/@vue/compiler-core/-/compiler-core-3.4.21.tgz", - "integrity": "sha512-MjXawxZf2SbZszLPYxaFCjxfibYrzr3eYbKxwpLR9EQN+oaziSu3qKVbwBERj1IFIB8OLUewxB5m/BFzi613og==", + "version": "3.4.23", + "resolved": "https://registry.npmjs.org/@vue/compiler-core/-/compiler-core-3.4.23.tgz", + "integrity": "sha512-HAFmuVEwNqNdmk+w4VCQ2pkLk1Vw4XYiiyxEp3z/xvl14aLTUBw2OfVH3vBcx+FtGsynQLkkhK410Nah1N2yyQ==", "dev": true, "dependencies": { - "@babel/parser": "^7.23.9", - "@vue/shared": "3.4.21", + "@babel/parser": "^7.24.1", + "@vue/shared": "3.4.23", "entities": "^4.5.0", "estree-walker": "^2.0.2", - "source-map-js": "^1.0.2" + "source-map-js": "^1.2.0" } }, "node_modules/@vue/compiler-dom": { - "version": "3.4.21", - "resolved": "https://registry.npmjs.org/@vue/compiler-dom/-/compiler-dom-3.4.21.tgz", - "integrity": "sha512-IZC6FKowtT1sl0CR5DpXSiEB5ayw75oT2bma1BEhV7RRR1+cfwLrxc2Z8Zq/RGFzJ8w5r9QtCOvTjQgdn0IKmA==", + "version": "3.4.23", + "resolved": "https://registry.npmjs.org/@vue/compiler-dom/-/compiler-dom-3.4.23.tgz", + "integrity": "sha512-t0b9WSTnCRrzsBGrDd1LNR5HGzYTr7LX3z6nNBG+KGvZLqrT0mY6NsMzOqlVMBKKXKVuusbbB5aOOFgTY+senw==", "dev": true, "dependencies": { - "@vue/compiler-core": "3.4.21", - "@vue/shared": "3.4.21" + "@vue/compiler-core": "3.4.23", + "@vue/shared": "3.4.23" } }, "node_modules/@vue/compiler-sfc": { - "version": "3.4.21", - "resolved": "https://registry.npmjs.org/@vue/compiler-sfc/-/compiler-sfc-3.4.21.tgz", - "integrity": "sha512-me7epoTxYlY+2CUM7hy9PCDdpMPfIwrOvAXud2Upk10g4YLv9UBW7kL798TvMeDhPthkZ0CONNrK2GoeI1ODiQ==", + "version": "3.4.23", + "resolved": "https://registry.npmjs.org/@vue/compiler-sfc/-/compiler-sfc-3.4.23.tgz", + "integrity": "sha512-fSDTKTfzaRX1kNAUiaj8JB4AokikzStWgHooMhaxyjZerw624L+IAP/fvI4ZwMpwIh8f08PVzEnu4rg8/Npssw==", "dev": true, "dependencies": { - "@babel/parser": "^7.23.9", - "@vue/compiler-core": "3.4.21", - "@vue/compiler-dom": "3.4.21", - "@vue/compiler-ssr": "3.4.21", - "@vue/shared": "3.4.21", + "@babel/parser": "^7.24.1", + "@vue/compiler-core": "3.4.23", + "@vue/compiler-dom": "3.4.23", + "@vue/compiler-ssr": "3.4.23", + "@vue/shared": "3.4.23", "estree-walker": "^2.0.2", - "magic-string": "^0.30.7", - "postcss": "^8.4.35", - "source-map-js": "^1.0.2" + "magic-string": "^0.30.8", + "postcss": "^8.4.38", + "source-map-js": "^1.2.0" } }, "node_modules/@vue/compiler-ssr": { - "version": "3.4.21", - "resolved": "https://registry.npmjs.org/@vue/compiler-ssr/-/compiler-ssr-3.4.21.tgz", - "integrity": "sha512-M5+9nI2lPpAsgXOGQobnIueVqc9sisBFexh5yMIMRAPYLa7+5wEJs8iqOZc1WAa9WQbx9GR2twgznU8LTIiZ4Q==", + "version": "3.4.23", + "resolved": "https://registry.npmjs.org/@vue/compiler-ssr/-/compiler-ssr-3.4.23.tgz", + "integrity": "sha512-hb6Uj2cYs+tfqz71Wj6h3E5t6OKvb4MVcM2Nl5i/z1nv1gjEhw+zYaNOV+Xwn+SSN/VZM0DgANw5TuJfxfezPg==", "dev": true, "dependencies": { - "@vue/compiler-dom": "3.4.21", - "@vue/shared": "3.4.21" + "@vue/compiler-dom": "3.4.23", + "@vue/shared": "3.4.23" } }, "node_modules/@vue/devtools-api": { @@ -2772,52 +2794,52 @@ } }, "node_modules/@vue/reactivity": { - "version": "3.4.21", - "resolved": "https://registry.npmjs.org/@vue/reactivity/-/reactivity-3.4.21.tgz", - "integrity": "sha512-UhenImdc0L0/4ahGCyEzc/pZNwVgcglGy9HVzJ1Bq2Mm9qXOpP8RyNTjookw/gOCUlXSEtuZ2fUg5nrHcoqJcw==", + "version": "3.4.23", + "resolved": "https://registry.npmjs.org/@vue/reactivity/-/reactivity-3.4.23.tgz", + "integrity": "sha512-GlXR9PL+23fQ3IqnbSQ8OQKLodjqCyoCrmdLKZk3BP7jN6prWheAfU7a3mrltewTkoBm+N7qMEb372VHIkQRMQ==", "dev": true, "dependencies": { - "@vue/shared": "3.4.21" + "@vue/shared": "3.4.23" } }, "node_modules/@vue/runtime-core": { - "version": "3.4.21", - "resolved": "https://registry.npmjs.org/@vue/runtime-core/-/runtime-core-3.4.21.tgz", - "integrity": "sha512-pQthsuYzE1XcGZznTKn73G0s14eCJcjaLvp3/DKeYWoFacD9glJoqlNBxt3W2c5S40t6CCcpPf+jG01N3ULyrA==", + "version": "3.4.23", + "resolved": "https://registry.npmjs.org/@vue/runtime-core/-/runtime-core-3.4.23.tgz", + "integrity": "sha512-FeQ9MZEXoFzFkFiw9MQQ/FWs3srvrP+SjDKSeRIiQHIhtkzoj0X4rWQlRNHbGuSwLra6pMyjAttwixNMjc/xLw==", "dev": true, "dependencies": { - "@vue/reactivity": "3.4.21", - "@vue/shared": "3.4.21" + "@vue/reactivity": "3.4.23", + "@vue/shared": "3.4.23" } }, "node_modules/@vue/runtime-dom": { - "version": "3.4.21", - "resolved": "https://registry.npmjs.org/@vue/runtime-dom/-/runtime-dom-3.4.21.tgz", - "integrity": "sha512-gvf+C9cFpevsQxbkRBS1NpU8CqxKw0ebqMvLwcGQrNpx6gqRDodqKqA+A2VZZpQ9RpK2f9yfg8VbW/EpdFUOJw==", + "version": "3.4.23", + "resolved": "https://registry.npmjs.org/@vue/runtime-dom/-/runtime-dom-3.4.23.tgz", + "integrity": "sha512-RXJFwwykZWBkMiTPSLEWU3kgVLNAfActBfWFlZd0y79FTUxexogd0PLG4HH2LfOktjRxV47Nulygh0JFXe5f9A==", "dev": true, "dependencies": { - "@vue/runtime-core": "3.4.21", - "@vue/shared": "3.4.21", + "@vue/runtime-core": "3.4.23", + "@vue/shared": "3.4.23", "csstype": "^3.1.3" } }, "node_modules/@vue/server-renderer": { - "version": "3.4.21", - "resolved": "https://registry.npmjs.org/@vue/server-renderer/-/server-renderer-3.4.21.tgz", - "integrity": "sha512-aV1gXyKSN6Rz+6kZ6kr5+Ll14YzmIbeuWe7ryJl5muJ4uwSwY/aStXTixx76TwkZFJLm1aAlA/HSWEJ4EyiMkg==", + "version": "3.4.23", + "resolved": "https://registry.npmjs.org/@vue/server-renderer/-/server-renderer-3.4.23.tgz", + "integrity": "sha512-LDwGHtnIzvKFNS8dPJ1SSU5Gvm36p2ck8wCZc52fc3k/IfjKcwCyrWEf0Yag/2wTFUBXrqizfhK9c/mC367dXQ==", "dev": true, "dependencies": { - "@vue/compiler-ssr": "3.4.21", - "@vue/shared": "3.4.21" + "@vue/compiler-ssr": "3.4.23", + "@vue/shared": "3.4.23" }, "peerDependencies": { - "vue": "3.4.21" + "vue": "3.4.23" } }, "node_modules/@vue/shared": { - "version": "3.4.21", - "resolved": "https://registry.npmjs.org/@vue/shared/-/shared-3.4.21.tgz", - "integrity": "sha512-PuJe7vDIi6VYSinuEbUIQgMIRZGgM8e4R+G+/dQTk0X1NEdvgvvgv7m+rfmDH1gZzyA1OjjoWskvHlfRNfQf3g==", + "version": "3.4.23", + "resolved": "https://registry.npmjs.org/@vue/shared/-/shared-3.4.23.tgz", + "integrity": "sha512-wBQ0gvf+SMwsCQOyusNw/GoXPV47WGd1xB5A1Pgzy0sQ3Bi5r5xm3n+92y3gCnB3MWqnRDdvfkRGxhKtbBRNgg==", "dev": true }, "node_modules/@vueuse/core": { @@ -3689,9 +3711,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001608", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001608.tgz", - "integrity": "sha512-cjUJTQkk9fQlJR2s4HMuPMvTiRggl0rAVMtthQuyOlDWuqHXqN8azLq+pi8B2TjwKJ32diHjUqRIKeFX4z1FoA==", + "version": "1.0.30001611", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001611.tgz", + "integrity": "sha512-19NuN1/3PjA3QI8Eki55N8my4LzfkMCRLgCVfrl/slbSAchQfV0+GwjPrK3rq37As4UCLlM/DHajbKkAqbv92Q==", "dev": true, "funding": [ { @@ -4177,9 +4199,9 @@ } }, "node_modules/core-js-compat": { - "version": "3.36.1", - "resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.36.1.tgz", - "integrity": "sha512-Dk997v9ZCt3X/npqzyGdTlq6t7lDBhZwGvV94PKzDArjp7BTRm7WlDAXYd/OWdeFHO8OChQYRJNJvUCqCbrtKA==", + "version": "3.37.0", + "resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.37.0.tgz", + "integrity": "sha512-vYq4L+T8aS5UuFg4UwDhc7YNRWVeVZwltad9C/jV3R2LgVOpS9BDr7l/WL6BN0dbV3k1XejPTHqqEzJgsa0frA==", "dev": true, "dependencies": { "browserslist": "^4.23.0" @@ -4528,9 +4550,9 @@ } }, "node_modules/electron-to-chromium": { - "version": "1.4.735", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.735.tgz", - "integrity": "sha512-pkYpvwg8VyOTQAeBqZ7jsmpCjko1Qc6We1ZtZCjRyYbT5v4AIUKDy5cQTRotQlSSZmMr8jqpEt6JtOj5k7lR7A==", + "version": "1.4.744", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.744.tgz", + "integrity": "sha512-nAGcF0yeKKfrP13LMFr5U1eghfFSvFLg302VUFzWlcjPOnUYd52yU5x6PBYrujhNbc4jYmZFrGZFK+xasaEzVA==", "dev": true }, "node_modules/emoji-regex": { @@ -5039,9 +5061,9 @@ } }, "node_modules/eslint-plugin-vue": { - "version": "9.24.1", - "resolved": "https://registry.npmjs.org/eslint-plugin-vue/-/eslint-plugin-vue-9.24.1.tgz", - "integrity": "sha512-wk3SuwmS1pZdcuJlokGYEi/buDOwD6KltvhIZyOnpJ/378dcQ4zchu9PAMbbLAaydCz1iYc5AozszcOOgZIIOg==", + "version": "9.25.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-vue/-/eslint-plugin-vue-9.25.0.tgz", + "integrity": "sha512-tDWlx14bVe6Bs+Nnh3IGrD+hb11kf2nukfm6jLsmJIhmiRQ1SUaksvwY9U5MvPB0pcrg0QK0xapQkfITs3RKOA==", "dev": true, "dependencies": { "@eslint-community/eslint-utils": "^4.4.0", @@ -5397,30 +5419,6 @@ "pend": "~1.2.0" } }, - "node_modules/figures": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/figures/-/figures-3.2.0.tgz", - "integrity": "sha512-yaduQFRKLXYOGgEn6AZau90j3ggSOyiqXU0F9JZfeXYhNa+Jk4X+s45A2zg5jns87GAFa34BBm2kXw4XpNcbdg==", - "dev": true, - "dependencies": { - "escape-string-regexp": "^1.0.5" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/figures/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, - "engines": { - "node": ">=0.8.0" - } - }, "node_modules/file-entry-cache": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-6.0.1.tgz", @@ -6291,18 +6289,18 @@ "dev": true }, "node_modules/inquirer": { - "version": "9.2.17", - "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-9.2.17.tgz", - "integrity": "sha512-Vr3Ia2ud5sGnioURkE69endl4SkeJcMzTF6SosKcX5GALJfId7C+JvO5ZZb6y1LOXnEofCPbwzoQ1q0e8Gaduw==", + "version": "9.2.19", + "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-9.2.19.tgz", + "integrity": "sha512-WpxOT71HGsFya6/mj5PUue0sWwbpbiPfAR+332zLj/siB0QA1PZM8v3GepegFV1Op189UxHUCF6y8AySdtOMVA==", "dev": true, "dependencies": { + "@inquirer/figures": "^1.0.1", "@ljharb/through": "^2.3.13", "ansi-escapes": "^4.3.2", "chalk": "^5.3.0", "cli-cursor": "^3.1.0", "cli-width": "^4.1.0", "external-editor": "^3.1.0", - "figures": "^3.2.0", "lodash": "^4.17.21", "mute-stream": "1.0.0", "ora": "^5.4.1", @@ -7417,15 +7415,12 @@ } }, "node_modules/magic-string": { - "version": "0.30.9", - "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.9.tgz", - "integrity": "sha512-S1+hd+dIrC8EZqKyT9DstTH/0Z+f76kmmvZnkfQVmOpDEF9iVgdYif3Q/pIWHmCoo59bQVGW0kVL3e2nl+9+Sw==", + "version": "0.30.10", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.10.tgz", + "integrity": "sha512-iIRwTIf0QKV3UAnYK4PU8uiEc4SRh5jX0mwpIwETPpHdhVM4f53RSwS/vXvN1JhGX+Cs7B8qIq3d6AH49O5fAQ==", "dev": true, "dependencies": { "@jridgewell/sourcemap-codec": "^1.4.15" - }, - "engines": { - "node": ">=12" } }, "node_modules/make-dir": { @@ -8119,9 +8114,9 @@ } }, "node_modules/micromark-util-subtokenize": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/micromark-util-subtokenize/-/micromark-util-subtokenize-2.0.0.tgz", - "integrity": "sha512-vc93L1t+gpR3p8jxeVdaYlbV2jTYteDje19rNSS/H5dlhxUYll5Fy6vJ2cDwP8RnsXi818yGty1ayP55y3W6fg==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-util-subtokenize/-/micromark-util-subtokenize-2.0.1.tgz", + "integrity": "sha512-jZNtiFl/1aY73yS3UGQkutD0UbhTt68qnRpw2Pifmz5wV9h8gOVsN70v+Lq/f1rKaU/W8pxRe8y8Q9FX1AOe1Q==", "dev": true, "funding": [ { @@ -10109,9 +10104,9 @@ } }, "node_modules/rollup": { - "version": "4.14.1", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.14.1.tgz", - "integrity": "sha512-4LnHSdd3QK2pa1J6dFbfm1HN0D7vSK/ZuZTsdyUAlA6Rr1yTouUTL13HaDOGJVgby461AhrNGBS7sCGXXtT+SA==", + "version": "4.14.3", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.14.3.tgz", + "integrity": "sha512-ag5tTQKYsj1bhrFC9+OEWqb5O6VYgtQDO9hPDBMmIbePwhfSr+ExlcU741t8Dhw5DkPCQf6noz0jb36D6W9/hw==", "dev": true, "dependencies": { "@types/estree": "1.0.5" @@ -10124,21 +10119,22 @@ "npm": ">=8.0.0" }, "optionalDependencies": { - "@rollup/rollup-android-arm-eabi": "4.14.1", - "@rollup/rollup-android-arm64": "4.14.1", - "@rollup/rollup-darwin-arm64": "4.14.1", - "@rollup/rollup-darwin-x64": "4.14.1", - "@rollup/rollup-linux-arm-gnueabihf": "4.14.1", - "@rollup/rollup-linux-arm64-gnu": "4.14.1", - "@rollup/rollup-linux-arm64-musl": "4.14.1", - "@rollup/rollup-linux-powerpc64le-gnu": "4.14.1", - "@rollup/rollup-linux-riscv64-gnu": "4.14.1", - "@rollup/rollup-linux-s390x-gnu": "4.14.1", - "@rollup/rollup-linux-x64-gnu": "4.14.1", - "@rollup/rollup-linux-x64-musl": "4.14.1", - "@rollup/rollup-win32-arm64-msvc": "4.14.1", - "@rollup/rollup-win32-ia32-msvc": "4.14.1", - "@rollup/rollup-win32-x64-msvc": "4.14.1", + "@rollup/rollup-android-arm-eabi": "4.14.3", + "@rollup/rollup-android-arm64": "4.14.3", + "@rollup/rollup-darwin-arm64": "4.14.3", + "@rollup/rollup-darwin-x64": "4.14.3", + "@rollup/rollup-linux-arm-gnueabihf": "4.14.3", + "@rollup/rollup-linux-arm-musleabihf": "4.14.3", + "@rollup/rollup-linux-arm64-gnu": "4.14.3", + "@rollup/rollup-linux-arm64-musl": "4.14.3", + "@rollup/rollup-linux-powerpc64le-gnu": "4.14.3", + "@rollup/rollup-linux-riscv64-gnu": "4.14.3", + "@rollup/rollup-linux-s390x-gnu": "4.14.3", + "@rollup/rollup-linux-x64-gnu": "4.14.3", + "@rollup/rollup-linux-x64-musl": "4.14.3", + "@rollup/rollup-win32-arm64-msvc": "4.14.3", + "@rollup/rollup-win32-ia32-msvc": "4.14.3", + "@rollup/rollup-win32-x64-msvc": "4.14.3", "fsevents": "~2.3.2" } }, @@ -11661,9 +11657,9 @@ } }, "node_modules/vite": { - "version": "5.2.8", - "resolved": "https://registry.npmjs.org/vite/-/vite-5.2.8.tgz", - "integrity": "sha512-OyZR+c1CE8yeHw5V5t59aXsUPPVTHMDjEZz8MgguLL/Q7NblxhZUlTu9xSPqlsUO/y+X7dlU05jdhvyycD55DA==", + "version": "5.2.9", + "resolved": "https://registry.npmjs.org/vite/-/vite-5.2.9.tgz", + "integrity": "sha512-uOQWfuZBlc6Y3W/DTuQ1Sr+oIXWvqljLvS881SVmAj00d5RdgShLcuXWxseWPd4HXwiYBFW/vXHfKFeqj9uQnw==", "dev": true, "dependencies": { "esbuild": "^0.20.1", @@ -11716,26 +11712,26 @@ } }, "node_modules/vitepress": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/vitepress/-/vitepress-1.1.0.tgz", - "integrity": "sha512-G+NS5I2OETxC0SfGAMDO75JWNkrcir0UCptuhQMNoaZhhlqvYtTDQhph4qGc5dtiTtZkcFa/bCcSx+A2gSS3lA==", + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/vitepress/-/vitepress-1.1.3.tgz", + "integrity": "sha512-hGrIYN0w9IHWs0NQSnlMjKV/v/HLfD+Ywv5QdvCSkiT32mpNOOwUrZjnqZv/JL/WBPpUc94eghTUvmipxw0xrA==", "dev": true, "dependencies": { "@docsearch/css": "^3.6.0", "@docsearch/js": "^3.6.0", - "@shikijs/core": "^1.2.4", - "@shikijs/transformers": "^1.2.4", - "@types/markdown-it": "^13.0.7", + "@shikijs/core": "^1.3.0", + "@shikijs/transformers": "^1.3.0", + "@types/markdown-it": "^14.0.1", "@vitejs/plugin-vue": "^5.0.4", - "@vue/devtools-api": "^7.0.25", + "@vue/devtools-api": "^7.0.27", "@vueuse/core": "^10.9.0", "@vueuse/integrations": "^10.9.0", "focus-trap": "^7.5.4", "mark.js": "8.11.1", "minisearch": "^6.3.0", - "shiki": "^1.2.4", - "vite": "^5.2.8", - "vue": "^3.4.21" + "shiki": "^1.3.0", + "vite": "^5.2.9", + "vue": "^3.4.23" }, "bin": { "vitepress": "bin/vitepress.js" @@ -11763,16 +11759,16 @@ } }, "node_modules/vue": { - "version": "3.4.21", - "resolved": "https://registry.npmjs.org/vue/-/vue-3.4.21.tgz", - "integrity": "sha512-5hjyV/jLEIKD/jYl4cavMcnzKwjMKohureP8ejn3hhEjwhWIhWeuzL2kJAjzl/WyVsgPY56Sy4Z40C3lVshxXA==", + "version": "3.4.23", + "resolved": "https://registry.npmjs.org/vue/-/vue-3.4.23.tgz", + "integrity": "sha512-X1y6yyGJ28LMUBJ0k/qIeKHstGd+BlWQEOT40x3auJFTmpIhpbKLgN7EFsqalnJXq1Km5ybDEsp6BhuWKciUDg==", "dev": true, "dependencies": { - "@vue/compiler-dom": "3.4.21", - "@vue/compiler-sfc": "3.4.21", - "@vue/runtime-dom": "3.4.21", - "@vue/server-renderer": "3.4.21", - "@vue/shared": "3.4.21" + "@vue/compiler-dom": "3.4.23", + "@vue/compiler-sfc": "3.4.23", + "@vue/runtime-dom": "3.4.23", + "@vue/server-renderer": "3.4.23", + "@vue/shared": "3.4.23" }, "peerDependencies": { "typescript": "*" diff --git a/package.json b/package.json index 36ea22307..8fbd81aec 100644 --- a/package.json +++ b/package.json @@ -118,7 +118,7 @@ "@codemirror/language": "^6.10.1", "@codemirror/search": "^6.5.6", "@codemirror/state": "^6.4.1", - "@codemirror/view": "^6.26.1", + "@codemirror/view": "^6.26.3", "@jridgewell/sourcemap-codec": "^1.4.15", "@mermaid-js/mermaid-cli": "^10.8.0", "@napi-rs/cli": "^2.18.1", @@ -131,14 +131,14 @@ "@rollup/plugin-terser": "^0.4.4", "@rollup/plugin-typescript": "^11.1.6", "@rollup/pluginutils": "^5.1.0", - "@shikijs/vitepress-twoslash": "^1.2.4", - "@types/eslint": "^8.56.7", + "@shikijs/vitepress-twoslash": "^1.3.0", + "@types/eslint": "^8.56.9", "@types/inquirer": "^9.0.7", "@types/mocha": "^10.0.6", "@types/node": "~18.18.14", "@types/yargs-parser": "^21.0.3", - "@typescript-eslint/eslint-plugin": "^7.6.0", - "@typescript-eslint/parser": "^7.6.0", + "@typescript-eslint/eslint-plugin": "^7.7.0", + "@typescript-eslint/parser": "^7.7.0", "@vue/eslint-config-prettier": "^9.0.0", "@vue/eslint-config-typescript": "^13.0.0", "acorn": "^8.11.3", @@ -157,13 +157,13 @@ "eslint-plugin-import": "^2.29.1", "eslint-plugin-prettier": "^5.1.3", "eslint-plugin-unicorn": "^52.0.0", - "eslint-plugin-vue": "^9.24.1", + "eslint-plugin-vue": "^9.25.0", "fixturify": "^3.0.0", "flru": "^1.0.2", "fs-extra": "^11.2.0", "github-api": "^3.4.0", "husky": "^9.0.11", - "inquirer": "^9.2.17", + "inquirer": "^9.2.18", "is-reference": "^3.0.2", "lint-staged": "^15.2.2", "locate-character": "^3.0.0", @@ -175,7 +175,7 @@ "pretty-bytes": "^6.1.1", "pretty-ms": "^9.0.0", "requirejs": "^2.3.6", - "rollup": "^4.14.1", + "rollup": "^4.14.3", "rollup-plugin-license": "^3.3.1", "rollup-plugin-string": "^3.0.0", "semver": "^7.6.0", @@ -186,10 +186,10 @@ "systemjs": "^6.14.3", "terser": "^5.30.3", "tslib": "^2.6.2", - "typescript": "^5.4.4", - "vite": "^5.2.8", - "vitepress": "^1.0.2", - "vue": "^3.4.21", + "typescript": "^5.4.5", + "vite": "^5.2.9", + "vitepress": "^1.1.0", + "vue": "^3.4.22", "wasm-pack": "^0.12.1", "weak-napi": "^2.0.2", "yargs-parser": "^21.1.1" diff --git a/rust/Cargo.lock b/rust/Cargo.lock index 1ebf99ae6..bcb749f12 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -48,9 +48,9 @@ checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" [[package]] name = "ast_node" -version = "0.9.6" +version = "0.9.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3e3e06ec6ac7d893a0db7127d91063ad7d9da8988f8a1a256f03729e6eec026" +checksum = "2e521452c6bce47ee5a5461c5e5d707212907826de14124962c58fcaf463115e" dependencies = [ "proc-macro2", "quote", @@ -149,9 +149,9 @@ checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" [[package]] name = "cc" -version = "1.0.92" +version = "1.0.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2678b2e3449475e95b0aa6f9b506a28e61b3dc8996592b983695e8ebb58a8b41" +checksum = "17f6e324229dc011159fcc089755d1e2e216a90d43a7dea6853ca740b84f35e7" [[package]] name = "cfg-if" @@ -170,9 +170,9 @@ dependencies = [ [[package]] name = "ctor" -version = "0.2.7" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad291aa74992b9b7a7e88c38acbbf6ad7e107f1d90ee8775b7bc1fc3394f485c" +checksum = "edb49164822f3ee45b17acd4a208cfc1251410cf0cad9a833234c9890774dd9f" dependencies = [ "quote", "syn", @@ -215,9 +215,9 @@ dependencies = [ [[package]] name = "either" -version = "1.10.0" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11157ac094ffbdde99aa67b23417ebdd801842852b500e395a45a9c0aac03e4a" +checksum = "a47c1c47d2f5964e29c61246e81db715514cd532db6b5116a25ea3c03d6780a2" [[package]] name = "equivalent" @@ -284,9 +284,9 @@ checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" [[package]] name = "hstr" -version = "0.2.9" +version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a9de2bdef6354361892492bab5e316b2d78a0ee9971db4d36da9b1eb0e11999" +checksum = "96274be293b8877e61974a607105d09c84caebe9620b47774aa8a6b942042dd4" dependencies = [ "hashbrown", "new_debug_unreachable", @@ -368,7 +368,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c2a198fb6b0eada2a8df47933734e6d35d350665a33a3593d7164fa52c75c19" dependencies = [ "cfg-if", - "windows-targets 0.52.4", + "windows-targets 0.52.5", ] [[package]] @@ -415,9 +415,9 @@ dependencies = [ [[package]] name = "napi" -version = "2.16.2" +version = "2.16.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70d04890ef4ec001fad791be785b8b920e2a3f5a6b1188e7a81dfa6197c0dee4" +checksum = "da1edd9510299935e4f52a24d1e69ebd224157e3e962c6c847edec5c2e4f786f" dependencies = [ "bitflags 2.5.0", "ctor", @@ -428,15 +428,15 @@ dependencies = [ [[package]] name = "napi-build" -version = "2.1.2" +version = "2.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f9130fccc5f763cf2069b34a089a18f0d0883c66aceb81f2fad541a3d823c43" +checksum = "e1c0f5d67ee408a4685b61f5ab7e58605c8ae3f2b4189f0127d804ff13d5560a" [[package]] name = "napi-derive" -version = "2.16.2" +version = "2.16.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aff4a63f26a7aa9fa25df6ea36675890115972b207ae516e86bd0c47e31eba39" +checksum = "e5a6de411b6217dbb47cd7a8c48684b162309ff48a77df9228c082400dd5b030" dependencies = [ "cfg-if", "convert_case", @@ -448,9 +448,9 @@ dependencies = [ [[package]] name = "napi-derive-backend" -version = "1.0.64" +version = "1.0.65" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5e76afe642e2424ebe465406e328e4316d82af1f79256231d4b0f184c67550a" +checksum = "c3e35868d43b178b0eb9c17bd018960b1b5dd1732a7d47c23debe8f5c4caf498" dependencies = [ "convert_case", "once_cell", @@ -636,9 +636,9 @@ checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" [[package]] name = "proc-macro2" -version = "1.0.79" +version = "1.0.81" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e835ff2298f5721608eb1a980ecaee1aef2c132bf95ecc026a11b7bf3c01c02e" +checksum = "3d1597b0c024618f09a9c3b8655b7e430397a36d23fdafec26d6965e9eec3eba" dependencies = [ "unicode-ident", ] @@ -788,18 +788,18 @@ checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" [[package]] name = "serde" -version = "1.0.197" +version = "1.0.198" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2" +checksum = "9846a40c979031340571da2545a4e5b7c4163bdae79b301d5f86d03979451fcc" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.197" +version = "1.0.198" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" +checksum = "e88edab869b01783ba905e7d0153f9fc1a6505a96e4ad3018011eedb838566d9" dependencies = [ "proc-macro2", "quote", @@ -808,9 +808,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.115" +version = "1.0.116" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12dc5c46daa8e9fdf4f5e71b6cf9a53f2487da0e86e55808e2d35539666497dd" +checksum = "3e17db7126d17feb94eb3fad46bf1a96b034e8aacbc2e775fe81505f8b0b2813" dependencies = [ "itoa", "ryu", @@ -895,9 +895,9 @@ checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" [[package]] name = "string_enum" -version = "0.4.2" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b650ea2087d32854a0f20b837fc56ec987a1cb4f758c9757e1171ee9812da63" +checksum = "6960defec35d15d58331ffb8a315d551634f757fe139c7b3d6063cae88ec90f6" dependencies = [ "proc-macro2", "quote", @@ -907,9 +907,9 @@ dependencies = [ [[package]] name = "swc_atoms" -version = "0.6.6" +version = "0.6.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04d9d1941a7d24fc503efa29c53f88dd61e6a15cc371947a75cca3b48d564b5b" +checksum = "bb6567e4e67485b3e7662b486f1565bdae54bd5b9d6b16b2ba1a9babb1e42125" dependencies = [ "hstr", "once_cell", @@ -933,9 +933,9 @@ dependencies = [ [[package]] name = "swc_common" -version = "0.33.22" +version = "0.33.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8f91d53367db183e55ecaa090c9a2b6e62ddbd1258aa2ac6c6925772eec9e2b" +checksum = "a529796c240cd87da18d26d63f9de4c7ad3680cf0a04b95f0c37f4c4f0a0da63" dependencies = [ "ahash", "ast_node", @@ -1011,9 +1011,9 @@ dependencies = [ [[package]] name = "swc_ecma_ast" -version = "0.112.7" +version = "0.112.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bcd97ee367b48444f90416ea56e71d761600f816bcae9df4f99293d1fa36bd5" +checksum = "d1d5c33c22ad50e8e34b3080a6fb133316d2eaa7d00400fc5018151f5ca44c5a" dependencies = [ "bitflags 2.5.0", "is-macro", @@ -1029,9 +1029,9 @@ dependencies = [ [[package]] name = "swc_ecma_codegen" -version = "0.148.15" +version = "0.148.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5206067d7c5034e4e19e71ebce270081594eb726c108d0a0a026f7ecbb6f8abd" +checksum = "7188b2848402ce983f6c618a829b4ceb18d21eed7986782a7b7028cc234ede6b" dependencies = [ "memchr", "num-bigint", @@ -1048,9 +1048,9 @@ dependencies = [ [[package]] name = "swc_ecma_codegen_macros" -version = "0.7.4" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "394b8239424b339a12012ceb18726ed0244fce6bf6345053cb9320b2791dcaa5" +checksum = "17ab87ba81ae05efd394ab4a8cbdba595ac3554a5e393c76699449d47c43582e" dependencies = [ "proc-macro2", "quote", @@ -1060,9 +1060,9 @@ dependencies = [ [[package]] name = "swc_ecma_minifier" -version = "0.192.22" +version = "0.192.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1b038d6effbed5103d38460e6b9f5006fd6ffa91e827efdf78953b0e97d3895" +checksum = "1feab97d24c9931c5e88dca7730e6a6d4c7689ced9ba05814d9092651b3534db" dependencies = [ "arrayvec", "indexmap", @@ -1093,9 +1093,9 @@ dependencies = [ [[package]] name = "swc_ecma_parser" -version = "0.143.13" +version = "0.143.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5354a20ab66c2ec5001982271b6e7c750b7fca3409888ab9703ae3d3c845fed4" +checksum = "40b7faa481ac015b330f1c4bc8df2c9947242020e23ccdb10bc7a8ef84342509" dependencies = [ "either", "new_debug_unreachable", @@ -1115,9 +1115,9 @@ dependencies = [ [[package]] name = "swc_ecma_transforms_base" -version = "0.137.17" +version = "0.137.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66b5818db80d8d9fcbc1d3453f1d246a7f56ea708ba136717a84a8caf0977afd" +checksum = "660badfe2eed8b6213ec9dcd71aa0786f8fb46ffa012e0313bcba1fe4a9a5c73" dependencies = [ "better_scoped_tls", "bitflags 2.5.0", @@ -1150,9 +1150,9 @@ dependencies = [ [[package]] name = "swc_ecma_transforms_optimization" -version = "0.198.19" +version = "0.198.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6aa7b9e42c741cd1c324870d707eaa427426697fc2fd7f85d89a18c9092aea2b" +checksum = "73e8de92a02fbd61965c723669f9d425dc1544831507abd78d9fca24c3974324" dependencies = [ "dashmap", "indexmap", @@ -1174,9 +1174,9 @@ dependencies = [ [[package]] name = "swc_ecma_usage_analyzer" -version = "0.23.13" +version = "0.23.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21ccc0ff427471b70e48f265854a2e0843ef8429c729009898bea993f300fa77" +checksum = "b82af8ae5c6e5c1c1bdef70d5fb3ef16917985031f8688a7342c10a2123cfa6b" dependencies = [ "indexmap", "rustc-hash", @@ -1191,9 +1191,9 @@ dependencies = [ [[package]] name = "swc_ecma_utils" -version = "0.127.17" +version = "0.127.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "624c19fdbe1807275b16560892cf7a12a9ac3f631fb10ad45aaa3eeac903e6e5" +checksum = "15d40abfc4f3a7bfdf54d11ac705cc9dd0836c48bf085b359143b4d40b50cb31" dependencies = [ "indexmap", "num_cpus", @@ -1234,9 +1234,9 @@ dependencies = [ [[package]] name = "swc_fast_graph" -version = "0.21.20" +version = "0.21.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa43c68166a88e233f241976dc3291c30471385fd1019d1fa5660ac503520110" +checksum = "54db83cdbd924cc8b5082ab54ff2a1b4f53ecde8f53c87b9f9c877c9daef4569" dependencies = [ "indexmap", "petgraph", @@ -1246,9 +1246,9 @@ dependencies = [ [[package]] name = "swc_macros_common" -version = "0.3.9" +version = "0.3.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50176cfc1cbc8bb22f41c6fe9d1ec53fbe057001219b5954961b8ad0f336fce9" +checksum = "5a5be7766a95a2840ded618baeaab63809b71230ef19094b34f76c8af4d85aa2" dependencies = [ "proc-macro2", "quote", @@ -1289,9 +1289,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.58" +version = "2.0.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44cfb93f38070beee36b3fef7d4f5a16f27751d94b187b666a5cc5e9b0d30687" +checksum = "909518bc7b1c9b779f1bbf07f2929d35af9f0f37e47c6e9ef7f9dddc1e1821f3" dependencies = [ "proc-macro2", "quote", @@ -1533,17 +1533,18 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7dd37b7e5ab9018759f893a1952c9420d060016fc19a472b4bb20d1bdd694d1b" +checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" dependencies = [ - "windows_aarch64_gnullvm 0.52.4", - "windows_aarch64_msvc 0.52.4", - "windows_i686_gnu 0.52.4", - "windows_i686_msvc 0.52.4", - "windows_x86_64_gnu 0.52.4", - "windows_x86_64_gnullvm 0.52.4", - "windows_x86_64_msvc 0.52.4", + "windows_aarch64_gnullvm 0.52.5", + "windows_aarch64_msvc 0.52.5", + "windows_i686_gnu 0.52.5", + "windows_i686_gnullvm", + "windows_i686_msvc 0.52.5", + "windows_x86_64_gnu 0.52.5", + "windows_x86_64_gnullvm 0.52.5", + "windows_x86_64_msvc 0.52.5", ] [[package]] @@ -1554,9 +1555,9 @@ checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" [[package]] name = "windows_aarch64_gnullvm" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bcf46cf4c365c6f2d1cc93ce535f2c8b244591df96ceee75d8e83deb70a9cac9" +checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" [[package]] name = "windows_aarch64_msvc" @@ -1566,9 +1567,9 @@ checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" [[package]] name = "windows_aarch64_msvc" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da9f259dd3bcf6990b55bffd094c4f7235817ba4ceebde8e6d11cd0c5633b675" +checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" [[package]] name = "windows_i686_gnu" @@ -1578,9 +1579,15 @@ checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" [[package]] name = "windows_i686_gnu" -version = "0.52.4" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b474d8268f99e0995f25b9f095bc7434632601028cf86590aea5c8a5cb7801d3" +checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" [[package]] name = "windows_i686_msvc" @@ -1590,9 +1597,9 @@ checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" [[package]] name = "windows_i686_msvc" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1515e9a29e5bed743cb4415a9ecf5dfca648ce85ee42e15873c3cd8610ff8e02" +checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" [[package]] name = "windows_x86_64_gnu" @@ -1602,9 +1609,9 @@ checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" [[package]] name = "windows_x86_64_gnu" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5eee091590e89cc02ad514ffe3ead9eb6b660aedca2183455434b93546371a03" +checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" [[package]] name = "windows_x86_64_gnullvm" @@ -1614,9 +1621,9 @@ checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" [[package]] name = "windows_x86_64_gnullvm" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77ca79f2451b49fa9e2af39f0747fe999fcda4f5e241b2898624dca97a1f2177" +checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" [[package]] name = "windows_x86_64_msvc" @@ -1626,9 +1633,9 @@ checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "windows_x86_64_msvc" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32b752e52a2da0ddfbdbcc6fceadfeede4c939ed16d13e648833a61dfb611ed8" +checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" [[package]] name = "wyz" diff --git a/rust/bindings_napi/Cargo.toml b/rust/bindings_napi/Cargo.toml index 28b0f59c2..520fe6ab5 100644 --- a/rust/bindings_napi/Cargo.toml +++ b/rust/bindings_napi/Cargo.toml @@ -10,8 +10,8 @@ crate-type = ["cdylib"] [dependencies] # Default enable napi4 feature, see https://nodejs.org/api/n-api.html#node-api-version-matrix -napi = { version = "2.16.2", default-features = false, features = ["napi4"] } -napi-derive = "2.16.2" +napi = { version = "2.16.4", default-features = false, features = ["napi4"] } +napi-derive = "2.16.3" parse_ast = { path = "../parse_ast" } xxhash = { path = "../xxhash" } @@ -22,4 +22,4 @@ mimalloc-rust = { version = "0.2" } mimalloc-rust = { version = "0.2", features = ["local-dynamic-tls"] } [build-dependencies] -napi-build = "2.1.2" +napi-build = "2.1.3" diff --git a/rust/parse_ast/Cargo.toml b/rust/parse_ast/Cargo.toml index 49d100da1..0dcf71b55 100644 --- a/rust/parse_ast/Cargo.toml +++ b/rust/parse_ast/Cargo.toml @@ -7,9 +7,9 @@ edition = "2021" [dependencies] anyhow = "1.0.82" -swc_atoms = "0.6.6" +swc_atoms = "0.6.7" swc_compiler_base = "0.7.20" -swc_common = { version = "0.33.22", features = ["ahash", "parking_lot"] } -swc_ecma_ast = "0.112.7" -swc_ecma_parser = "0.143.13" +swc_common = { version = "0.33.25", features = ["ahash", "parking_lot"] } +swc_ecma_ast = "0.112.8" +swc_ecma_parser = "0.143.16" parking_lot = "0.12.1" From 0bf4675b7a94bd696d00c0ccfee3705fb785d162 Mon Sep 17 00:00:00 2001 From: Lukas Taegert-Atkinson Date: Sat, 20 Apr 2024 06:51:09 +0200 Subject: [PATCH 22/45] Try to run emulated smoke tests for Linux environments (#5477) * Try adding initial config for ppc64le * Comment out any parts of the pipeline we are not working on * Try to install NodeJS and attempt a bootstrap build * Move smoke test to separate step with longer timeout * Add additional targets to smoke tests Also install latest node version * Try wget over curl * Separate build for Alpine * Add logging * Fix Rollup installation * Use correct path for native artifact * Install plugin * Correctly hand over js artifact * Make binary executable * Enable caching * Add missing types * Also install rollup * Display versions after nvm * Add more logging * Install all dependencies after all * Fix bashrc path * Run nvm during run script * Also add git * Try apt-get again * Re-introduce optional nvm * Fix nvm install * Go back to previous way of installing nvm * Unskip most things and add test that hopefully fails * Add safe directory to silence warning * Install dependencies in smoke tests and build JS locally --- .github/workflows/build-and-tests.yml | 97 ++++++++++++++++++++++++++- 1 file changed, 96 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-and-tests.yml b/.github/workflows/build-and-tests.yml index 6885df6ad..d683dd039 100644 --- a/.github/workflows/build-and-tests.yml +++ b/.github/workflows/build-and-tests.yml @@ -270,6 +270,100 @@ jobs: if-no-files-found: error if: ${{ !matrix.settings.is-wasm-build }} + # smoke test for some architectures that do not receive the full test suite + smoke-test: + permissions: + packages: write # for caching container images + name: Smoke Test ${{ matrix.settings.target }} + needs: + - build + strategy: + fail-fast: false + matrix: + settings: + - arch: aarch64 + distro: ubuntu_latest + target: aarch64-unknown-linux-gnu + - arch: aarch64 + distro: alpine_latest + target: aarch64-unknown-linux-musl + - arch: armv7 + distro: ubuntu_latest + target: armv7-unknown-linux-gnueabihf +# There is a bug that hangs the build when running npm +# - arch: armv7 +# distro: alpine_latest +# target: armv7-unknown-linux-musleabihf + - arch: ppc64le + distro: ubuntu_latest + target: powerpc64le-unknown-linux-gnu + use-nvm: true + - arch: s390x + distro: ubuntu_latest + target: s390x-unknown-linux-gnu + use-nvm: true +# I could not find a way to install Node without compiling from source +# - arch: riscv64 +# distro: ubuntu_latest +# target: riscv64gc-unknown-linux-gnu + runs-on: ubuntu-latest + timeout-minutes: 120 + steps: + - name: Checkout Commit + uses: actions/checkout@v4 + - name: Cache Node Modules + id: cache-node-modules + uses: actions/cache@v4 + with: + path: node_modules + key: node-modules-${{ runner.os }}-${{ hashFiles('package-lock.json') }} + - name: Install dependencies + if: steps.cache-node-modules.outputs.cache-hit != 'true' + run: npm ci --ignore-scripts + - name: Build JS + run: npm run build:cjs + - name: Download napi artifacts + uses: actions/download-artifact@v4 + with: + name: bindings-${{ matrix.settings.target }} + path: dist/ + - name: Run Smoke Test + uses: uraimo/run-on-arch-action@v2 + with: + arch: ${{ matrix.settings.arch }} + distro: ${{ matrix.settings.distro }} + githubToken: ${{ github.token }} + install: | + case "${{ matrix.settings.distro }}" in + ubuntu*) + apt-get update -y + apt-get install -y curl git + if [[ -z "${{ matrix.settings.use-nvm }}" ]]; then + curl -fsSL https://deb.nodesource.com/setup_lts.x | bash - + apt-get install -y nodejs + fi + ;; + alpine*) + apk add nodejs npm git + ;; + esac + run: | + set -e + if [[ -n "${{ matrix.settings.use-nvm }}" ]]; then + curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash + source ~/.nvm/nvm.sh + nvm install --lts + fi + echo "Node: $(node -v)" + echo "npm: $(npm -v)" + git config --global --add safe.directory /home/runner/work/rollup/rollup + chmod +x dist/bin/rollup + dist/bin/rollup --version | grep -E 'rollup v[0-9]+\.[0-9]+\.[0-9]+' + mv dist dist-build + node dist-build/bin/rollup --config rollup.config.ts --configPlugin typescript --configTest --forceExit + cp dist-build/rollup.*.node dist/ + dist/bin/rollup --version | grep -E 'rollup v[0-9]+\.[0-9]+\.[0-9]+' + test: name: Test${{ matrix.additionalName || '' }} Node ${{ matrix.node }} (${{ matrix.settings.target }}) needs: @@ -349,8 +443,9 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 15 needs: - - test - lint + - test + - smoke-test # This needs to be adapted for Rollup 5 if: startsWith(github.ref_name, 'v4') steps: From f24679ef51bcc5ff2e5d0b625ec18951f1d29b73 Mon Sep 17 00:00:00 2001 From: Andre Escudero Date: Sat, 20 Apr 2024 00:26:07 -0500 Subject: [PATCH 23/45] Add ImportAttributesKey to choose keyword ("with" | "assert") (#5474) * Add ImportAttributesKey to choose keyword ("with" | "assert") * Revert settings.json change * Added documentation for importAttributesKey * Revert wasm bindings * Fix lint issue * Remove space * Revert bindings_wasm_bg.wasm.d.ts * Revert test/form/index.js --------- Co-authored-by: Lukas Taegert-Atkinson --- cli/help.md | 1 + docs/command-line-interface/index.md | 2 + docs/configuration-options/index.md | 10 +++++ docs/javascript-api/index.md | 1 + docs/repl/stores/options.ts | 6 +++ src/finalisers/es.ts | 14 +++++-- src/rollup/types.d.ts | 3 ++ src/utils/options/mergeOptions.ts | 1 + src/utils/options/normalizeOutputOptions.ts | 1 + .../_config.js | 14 +++++++ .../_expected/amd.js | 35 +++++++++++++++++ .../_expected/cjs.js | 39 +++++++++++++++++++ .../_expected/es.js | 7 ++++ .../_expected/iife.js | 38 ++++++++++++++++++ .../_expected/system.js | 29 ++++++++++++++ .../_expected/umd.js | 39 +++++++++++++++++++ .../main.js | 9 +++++ .../_config.js | 13 +++++++ .../_expected/amd.js | 35 +++++++++++++++++ .../_expected/cjs.js | 39 +++++++++++++++++++ .../_expected/es.js | 7 ++++ .../_expected/iife.js | 38 ++++++++++++++++++ .../_expected/system.js | 29 ++++++++++++++ .../_expected/umd.js | 39 +++++++++++++++++++ .../main.js | 9 +++++ .../_config.js | 14 +++++++ .../_expected/amd.js | 35 +++++++++++++++++ .../_expected/cjs.js | 39 +++++++++++++++++++ .../_expected/es.js | 7 ++++ .../_expected/iife.js | 38 ++++++++++++++++++ .../_expected/system.js | 29 ++++++++++++++ .../_expected/umd.js | 39 +++++++++++++++++++ .../keeps-static-attributes-key-with/main.js | 9 +++++ .../samples/output-options-hook/_config.js | 1 + test/misc/optionList.js | 4 +- 35 files changed, 667 insertions(+), 6 deletions(-) create mode 100644 test/form/samples/import-attributes/keeps-static-attributes-key-assert/_config.js create mode 100644 test/form/samples/import-attributes/keeps-static-attributes-key-assert/_expected/amd.js create mode 100644 test/form/samples/import-attributes/keeps-static-attributes-key-assert/_expected/cjs.js create mode 100644 test/form/samples/import-attributes/keeps-static-attributes-key-assert/_expected/es.js create mode 100644 test/form/samples/import-attributes/keeps-static-attributes-key-assert/_expected/iife.js create mode 100644 test/form/samples/import-attributes/keeps-static-attributes-key-assert/_expected/system.js create mode 100644 test/form/samples/import-attributes/keeps-static-attributes-key-assert/_expected/umd.js create mode 100644 test/form/samples/import-attributes/keeps-static-attributes-key-assert/main.js create mode 100644 test/form/samples/import-attributes/keeps-static-attributes-key-default/_config.js create mode 100644 test/form/samples/import-attributes/keeps-static-attributes-key-default/_expected/amd.js create mode 100644 test/form/samples/import-attributes/keeps-static-attributes-key-default/_expected/cjs.js create mode 100644 test/form/samples/import-attributes/keeps-static-attributes-key-default/_expected/es.js create mode 100644 test/form/samples/import-attributes/keeps-static-attributes-key-default/_expected/iife.js create mode 100644 test/form/samples/import-attributes/keeps-static-attributes-key-default/_expected/system.js create mode 100644 test/form/samples/import-attributes/keeps-static-attributes-key-default/_expected/umd.js create mode 100644 test/form/samples/import-attributes/keeps-static-attributes-key-default/main.js create mode 100644 test/form/samples/import-attributes/keeps-static-attributes-key-with/_config.js create mode 100644 test/form/samples/import-attributes/keeps-static-attributes-key-with/_expected/amd.js create mode 100644 test/form/samples/import-attributes/keeps-static-attributes-key-with/_expected/cjs.js create mode 100644 test/form/samples/import-attributes/keeps-static-attributes-key-with/_expected/es.js create mode 100644 test/form/samples/import-attributes/keeps-static-attributes-key-with/_expected/iife.js create mode 100644 test/form/samples/import-attributes/keeps-static-attributes-key-with/_expected/system.js create mode 100644 test/form/samples/import-attributes/keeps-static-attributes-key-with/_expected/umd.js create mode 100644 test/form/samples/import-attributes/keeps-static-attributes-key-with/main.js diff --git a/cli/help.md b/cli/help.md index 8cc71ada1..c0048b559 100644 --- a/cli/help.md +++ b/cli/help.md @@ -50,6 +50,7 @@ Basic options: --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 diff --git a/docs/command-line-interface/index.md b/docs/command-line-interface/index.md index c0bb9608a..dd38fe6aa 100755 --- a/docs/command-line-interface/index.md +++ b/docs/command-line-interface/index.md @@ -97,6 +97,7 @@ export default { generatedCode, hashCharacters, hoistTransitiveImports, + importAttributesKey, inlineDynamicImports, interop, intro, @@ -417,6 +418,7 @@ Many options have command line equivalents. In those cases, any arguments passed --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 diff --git a/docs/configuration-options/index.md b/docs/configuration-options/index.md index f6248db14..f106d8811 100755 --- a/docs/configuration-options/index.md +++ b/docs/configuration-options/index.md @@ -930,6 +930,16 @@ This determines the character set that Rollup is allowed to use in file hashes. By default, when creating multiple chunks, transitive imports of entry chunks will be added as empty imports to the entry chunks. See ["Why do additional imports turn up in my entry chunks when code-splitting?"](../faqs/index.md#why-do-additional-imports-turn-up-in-my-entry-chunks-when-code-splitting) for details and background. Setting this option to `false` will disable this behaviour. This option is ignored when using the [`output.preserveModules`](#output-preservemodules) option as here, imports will never be hoisted. +### output.importAttributesKey + +| | | +| -------: | :----------------------------- | +| Type: | `"with" \| "assert"` | +| CLI: | `--importAttributesKey ` | +| Default: | `"assert"` | + +This determines the keyword set that Rollup will use for import attributes. + ### output.inlineDynamicImports | | | diff --git a/docs/javascript-api/index.md b/docs/javascript-api/index.md index 3ac58d4b2..7567b25c9 100755 --- a/docs/javascript-api/index.md +++ b/docs/javascript-api/index.md @@ -196,6 +196,7 @@ const outputOptions = { generatedCode, hashCharacters, hoistTransitiveImports, + importAttributesKey, inlineDynamicImports, interop, intro, diff --git a/docs/repl/stores/options.ts b/docs/repl/stores/options.ts index e092696d9..8a394d1fc 100644 --- a/docs/repl/stores/options.ts +++ b/docs/repl/stores/options.ts @@ -252,6 +252,11 @@ export const useOptions = defineStore('options2', () => { 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, @@ -445,6 +450,7 @@ export const useOptions = defineStore('options2', () => { optionOutputGlobals, optionOutputHashCharacters, optionOutputHoistTransitiveImports, + optionOutputImportAttributesKey, optionOutputIndent, optionOutputInlineDynamicImports, optionOutputInterop, diff --git a/src/finalisers/es.ts b/src/finalisers/es.ts index 16e121359..d0587405d 100644 --- a/src/finalisers/es.ts +++ b/src/finalisers/es.ts @@ -1,6 +1,6 @@ import type { Bundle as MagicStringBundle } from 'magic-string'; import type { ChunkDependency, ChunkExports, ImportSpecifier, ReexportSpecifier } from '../Chunk'; -import type { NormalizedOutputOptions } from '../rollup/types'; +import type { ImportAttributesKey, NormalizedOutputOptions } from '../rollup/types'; import type { GenerateCodeSnippets } from '../utils/generateCodeSnippets'; import { stringifyIdentifierIfNeeded } from '../utils/identifierHelpers'; import { getHelpersBlock } from '../utils/interopHelpers'; @@ -9,11 +9,16 @@ import type { FinaliserOptions } from './index'; export default function es( magicString: MagicStringBundle, { accessedGlobals, indent: t, intro, outro, dependencies, exports, snippets }: FinaliserOptions, - { externalLiveBindings, freeze, generatedCode: { symbols } }: NormalizedOutputOptions + { + externalLiveBindings, + freeze, + generatedCode: { symbols }, + importAttributesKey + }: NormalizedOutputOptions ): void { const { n } = snippets; - const importBlock = getImportBlock(dependencies, snippets); + const importBlock = getImportBlock(dependencies, importAttributesKey, snippets); if (importBlock.length > 0) intro += importBlock.join(n) + n + n; intro += getHelpersBlock( null, @@ -35,11 +40,12 @@ export default function es( function getImportBlock( dependencies: readonly ChunkDependency[], + importAttributesKey: ImportAttributesKey, { _ }: GenerateCodeSnippets ): string[] { const importBlock: string[] = []; for (const { importPath, reexports, imports, name, attributes } of dependencies) { - const assertion = attributes ? `${_}assert${_}${attributes}` : ''; + const assertion = attributes ? `${_}${importAttributesKey}${_}${attributes}` : ''; const pathWithAssertion = `'${importPath}'${assertion};`; if (!reexports && !imports) { importBlock.push(`import${_}${pathWithAssertion}`); diff --git a/src/rollup/types.d.ts b/src/rollup/types.d.ts index 710131e81..0b44882a8 100644 --- a/src/rollup/types.d.ts +++ b/src/rollup/types.d.ts @@ -623,6 +623,7 @@ 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'; @@ -712,6 +713,7 @@ export interface OutputOptions { globals?: GlobalsOption; hashCharacters?: HashCharacters; hoistTransitiveImports?: boolean; + importAttributesKey?: ImportAttributesKey; indent?: string | boolean; inlineDynamicImports?: boolean; interop?: InteropType | GetInterop; @@ -764,6 +766,7 @@ export interface NormalizedOutputOptions { globals: GlobalsOption; hashCharacters: HashCharacters; hoistTransitiveImports: boolean; + importAttributesKey: ImportAttributesKey; indent: true | string; inlineDynamicImports: boolean; interop: GetInterop; diff --git a/src/utils/options/mergeOptions.ts b/src/utils/options/mergeOptions.ts index 0621d8189..60130dcc9 100644 --- a/src/utils/options/mergeOptions.ts +++ b/src/utils/options/mergeOptions.ts @@ -254,6 +254,7 @@ async function mergeOutputOptions( globals: getOption('globals'), hashCharacters: getOption('hashCharacters'), hoistTransitiveImports: getOption('hoistTransitiveImports'), + importAttributesKey: getOption('importAttributesKey'), indent: getOption('indent'), inlineDynamicImports: getOption('inlineDynamicImports'), interop: getOption('interop'), diff --git a/src/utils/options/normalizeOutputOptions.ts b/src/utils/options/normalizeOutputOptions.ts index 629651742..0ee418cde 100644 --- a/src/utils/options/normalizeOutputOptions.ts +++ b/src/utils/options/normalizeOutputOptions.ts @@ -71,6 +71,7 @@ export async function normalizeOutputOptions( globals: config.globals || {}, hashCharacters: config.hashCharacters ?? 'base64', hoistTransitiveImports: config.hoistTransitiveImports ?? true, + importAttributesKey: config.importAttributesKey ?? 'assert', indent: getIndent(config, compact), inlineDynamicImports, interop: getInterop(config), 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 000000000..4e5338b75 --- /dev/null +++ b/test/form/samples/import-attributes/keeps-static-attributes-key-assert/_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: { + name: 'bundle', + importAttributesKey: 'assert' + } + } +}); 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 000000000..57334be0e --- /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 000000000..c8fe9e7fa --- /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 000000000..ba6c7ba45 --- /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 000000000..a6954cada --- /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$1); 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 000000000..d823b361f --- /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 000000000..b485744c3 --- /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$1)); +})(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 000000000..645381650 --- /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 000000000..ab2d9002a --- /dev/null +++ b/test/form/samples/import-attributes/keeps-static-attributes-key-default/_config.js @@ -0,0 +1,13 @@ +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: { + 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 000000000..57334be0e --- /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 000000000..c8fe9e7fa --- /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 000000000..ba6c7ba45 --- /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 000000000..a6954cada --- /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$1); 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 000000000..d823b361f --- /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 000000000..b485744c3 --- /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$1)); +})(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 000000000..645381650 --- /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 000000000..c2ce1c369 --- /dev/null +++ b/test/form/samples/import-attributes/keeps-static-attributes-key-with/_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: { + name: 'bundle', + importAttributesKey: 'with' + } + } +}); 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 000000000..57334be0e --- /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 000000000..c8fe9e7fa --- /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 000000000..e51512351 --- /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 000000000..a6954cada --- /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$1); 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 000000000..d823b361f --- /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 000000000..b485744c3 --- /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$1)); +})(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 000000000..645381650 --- /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/function/samples/output-options-hook/_config.js b/test/function/samples/output-options-hook/_config.js index 4be31d598..69333391c 100644 --- a/test/function/samples/output-options-hook/_config.js +++ b/test/function/samples/output-options-hook/_config.js @@ -46,6 +46,7 @@ module.exports = defineTest({ globals: {}, hashCharacters: 'base64', hoistTransitiveImports: true, + importAttributesKey: 'assert', indent: true, inlineDynamicImports: false, manualChunks: {}, diff --git a/test/misc/optionList.js b/test/misc/optionList.js index b669bdabc..b598310f2 100644 --- a/test/misc/optionList.js +++ b/test/misc/optionList.js @@ -1,6 +1,6 @@ exports.input = 'cache, context, experimentalCacheExpiry, experimentalLogSideEffects, external, input, logLevel, makeAbsoluteExternalsRelative, maxParallelFileOps, moduleContext, onLog, onwarn, perf, plugins, preserveEntrySignatures, preserveSymlinks, shimMissingExports, strictDeprecations, treeshake, watch'; exports.flags = - 'amd, assetFileNames, banner, bundleConfigAsCjs, c, cache, chunkFileNames, compact, config, 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, indent, inlineDynamicImports, input, interop, intro, logLevel, m, makeAbsoluteExternalsRelative, manualChunks, maxParallelFileOps, minifyInternalExports, moduleContext, n, name, noConflict, o, onLog, onwarn, outro, p, paths, perf, plugin, plugins, preserveEntrySignatures, preserveModules, preserveModulesRoot, preserveSymlinks, reexportProtoFromExternal, sanitizeFileName, shimMissingExports, silent, sourcemap, sourcemapBaseUrl, sourcemapExcludeSources, sourcemapFile, sourcemapFileNames, stdin, strict, strictDeprecations, systemNullSetters, treeshake, v, validate, w, waitForBundleInput, watch'; + 'amd, assetFileNames, banner, bundleConfigAsCjs, c, cache, chunkFileNames, compact, config, 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, logLevel, m, makeAbsoluteExternalsRelative, manualChunks, maxParallelFileOps, minifyInternalExports, moduleContext, n, name, noConflict, o, onLog, onwarn, outro, p, paths, perf, plugin, plugins, preserveEntrySignatures, preserveModules, preserveModulesRoot, preserveSymlinks, reexportProtoFromExternal, sanitizeFileName, shimMissingExports, silent, sourcemap, sourcemapBaseUrl, sourcemapExcludeSources, sourcemapFile, sourcemapFileNames, stdin, strict, strictDeprecations, systemNullSetters, treeshake, v, validate, w, waitForBundleInput, watch'; exports.output = - 'amd, assetFileNames, banner, chunkFileNames, compact, dir, dynamicImportInCjs, entryFileNames, esModule, experimentalMinChunkSize, exports, extend, externalImportAssertions, externalImportAttributes, externalLiveBindings, file, footer, format, freeze, generatedCode, globals, hashCharacters, hoistTransitiveImports, indent, inlineDynamicImports, interop, intro, manualChunks, minifyInternalExports, name, noConflict, outro, paths, plugins, preserveModules, preserveModulesRoot, reexportProtoFromExternal, sanitizeFileName, sourcemap, sourcemapBaseUrl, sourcemapExcludeSources, sourcemapFile, sourcemapFileNames, sourcemapIgnoreList, 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, outro, paths, plugins, preserveModules, preserveModulesRoot, reexportProtoFromExternal, sanitizeFileName, sourcemap, sourcemapBaseUrl, sourcemapExcludeSources, sourcemapFile, sourcemapFileNames, sourcemapIgnoreList, sourcemapPathTransform, strict, systemNullSetters, validate'; From e6e05cde31fc144228bb825c9d4ebba2f377075c Mon Sep 17 00:00:00 2001 From: Lukas Taegert-Atkinson Date: Sat, 20 Apr 2024 07:27:33 +0200 Subject: [PATCH 24/45] 4.15.0 --- CHANGELOG.md | 14 ++++++++++++++ browser/package.json | 2 +- package-lock.json | 4 ++-- package.json | 2 +- 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d0b318fec..a08c8115b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,19 @@ # rollup changelog +## 4.15.0 + +_2024-04-20_ + +### Features + +- Add output.importAttributesKey option to select whether to use "with" or "assert" for import attributes (#5474) + +### Pull Requests + +- [#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) + ## 4.14.3 _2024-04-15_ diff --git a/browser/package.json b/browser/package.json index be731a027..7808cf22d 100644 --- a/browser/package.json +++ b/browser/package.json @@ -1,6 +1,6 @@ { "name": "@rollup/browser", - "version": "4.14.3", + "version": "4.15.0", "description": "Next-generation ES module bundler browser build", "main": "dist/rollup.browser.js", "module": "dist/es/rollup.browser.js", diff --git a/package-lock.json b/package-lock.json index 95e302af9..7b16a8e83 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "rollup", - "version": "4.14.3", + "version": "4.15.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "rollup", - "version": "4.14.3", + "version": "4.15.0", "license": "MIT", "dependencies": { "@types/estree": "1.0.5" diff --git a/package.json b/package.json index 8fbd81aec..532cebf61 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rollup", - "version": "4.14.3", + "version": "4.15.0", "description": "Next-generation ES module bundler", "main": "dist/rollup.js", "module": "dist/es/rollup.js", From 5491ab470869cdf2b3bd8526054c424d44fba674 Mon Sep 17 00:00:00 2001 From: liuly Date: Sun, 21 Apr 2024 12:27:13 +0800 Subject: [PATCH 25/45] feat: improve tree-shaking by propagate const parameter (#5443) * feat: improve tree-shaking by propagate const parameter * fix: update old tests (for tree-shaking const param) * test: add test for tree-shaking by propagate const parameter * feat&perf: support object param * style: update coverage * test: update tree-shake-literal-parameter * test: update tree-shake top export * refactor: tree-shaking-literal * fix: test indent * perf: remove same object SPJ getObjectEntity is private, so we can't judge if two object are the same * refactor: support iife * test: tree-shake literal iife * fix: args but not callee should not be optimized * refactor: some logic to function base with comment * feat&perf: support implicitly undefined * test: tree-shake literal conditional * feat: integrate with optimizeCache * test: fix * feat: function argument side effect * style: revert export default change since deoptimizePath will detect * feat: support foo(bar);foo(bar); * test: add more side-effect and top-level test * 4.13.2 * test: add export default test * refactor FunctionParameterState and remove initalization * refactor IIFE * feat: support export default anonymous * fix: nested namespace tracking * feat: support define then export default * performance * refactor: UNKNOWN_EXPRESSION * refactor: reduce complexity * fix: export default function foo and foo called from same mod * style: NodeType * style: remove counter * perf: cache onlyfunctioncall result * style&perf: remove args slice * perf: export default variable * perf: export default variable * style: small updates: naming, private... * perf: LogicalExpression deoptimize cache * style: remove a condition which is always true * style: add protected * style: remove a condition which is always true * style: remove a condition * refactor: lazy bind variable * fix: refresh cache if isReassigned change for ParameterVariable * fix: make sure deoptimize give a final state * style: make coverage more happy --------- Co-authored-by: Lukas Taegert-Atkinson Co-authored-by: Lukas Taegert-Atkinson --- src/ast/nodes/ConditionalExpression.ts | 15 +- src/ast/nodes/FunctionDeclaration.ts | 5 + src/ast/nodes/Identifier.ts | 5 + src/ast/nodes/IfStatement.ts | 4 +- src/ast/nodes/LogicalExpression.ts | 17 +- src/ast/nodes/MemberExpression.ts | 7 +- src/ast/nodes/UpdateExpression.ts | 2 +- src/ast/nodes/shared/FunctionBase.ts | 149 +++++++++++++++++- src/ast/variables/ExportDefaultVariable.ts | 10 ++ src/ast/variables/GlobalVariable.ts | 9 +- src/ast/variables/LocalVariable.ts | 4 +- src/ast/variables/ParameterVariable.ts | 75 ++++++++- src/ast/variables/Variable.ts | 32 +++- .../_expected/amd/dep1.js | 5 +- .../_expected/cjs/dep1.js | 5 +- .../_expected/es/dep1.js | 5 +- .../_expected/system/dep1.js | 5 +- .../dep1.js | 3 +- .../amd/_virtual/_commonjsHelpers.js | 2 +- .../cjs/_virtual/_commonjsHelpers.js | 2 +- .../_expected/es/_virtual/_commonjsHelpers.js | 2 +- .../system/_virtual/_commonjsHelpers.js | 2 +- .../deopt-string-concatenation/_expected.js | 1 + .../deopt-string-concatenation/main.js | 1 + .../samples/side-effect-h/_expected/amd.js | 1 + .../samples/side-effect-h/_expected/cjs.js | 1 + .../samples/side-effect-h/_expected/es.js | 1 + .../samples/side-effect-h/_expected/iife.js | 1 + .../samples/side-effect-h/_expected/system.js | 1 + .../samples/side-effect-h/_expected/umd.js | 1 + test/form/samples/side-effect-h/main.js | 1 + .../_expected/amd.js | 1 + .../_expected/cjs.js | 1 + .../_expected/es.js | 1 + .../_expected/iife.js | 1 + .../_expected/system.js | 1 + .../_expected/umd.js | 1 + .../side-effects-return-statements/main.js | 1 + .../samples/supports-es5-shim/_expected.js | 2 - .../samples/supports-es6-shim/_expected.js | 2 +- .../argument-assignment/_config.js | 3 + .../argument-assignment/_expected.js | 15 ++ .../argument-assignment/main.js | 15 ++ .../do-not-optimize/_config.js | 3 + .../do-not-optimize/_expected.js | 18 +++ .../do-not-optimize/main.js | 16 ++ .../expression-cache/_config.js | 3 + .../expression-cache/_expected.js | 14 ++ .../expression-cache/main.js | 16 ++ .../iife/_config.js | 3 + .../iife/_expected.js | 14 ++ .../tree-shake-literal-parameter/iife/main.js | 18 +++ .../import-function/_config.js | 3 + .../import-function/_expected.js | 70 ++++++++ .../import-function/arrow_lib.js | 30 ++++ .../import-function/lib.js | 37 +++++ .../import-function/main.js | 17 ++ .../indirect-import-function/_config.js | 3 + .../indirect-import-function/_expected.js | 14 ++ .../define_and_export_default.js | 7 + .../import_then_export.js | 3 + .../import_then_export_sub.js | 5 + .../indirect-import-function/main.js | 5 + .../recursion-literal-object/_config.js | 3 + .../recursion-literal-object/_expected.js | 22 +++ .../recursion-literal-object/main.js | 40 +++++ .../recursion-literal/_config.js | 3 + .../recursion-literal/_expected.js | 13 ++ .../recursion-literal/main.js | 13 ++ .../reexport-function/_config.js | 3 + .../reexport-function/_expected.js | 7 + .../reexport-function/main.js | 3 + .../reexport-function/module1.js | 1 + .../reexport-function/module2.js | 5 + .../side-effect/_config.js | 3 + .../side-effect/_expected.js | 63 ++++++++ .../side-effect/main.js | 71 +++++++++ .../top-level/_config.js | 3 + .../top-level/_expected.js | 23 +++ .../top-level/main.js | 23 +++ .../deactivate-via-option/_expected.js | 4 +- .../samples/reassigned-parameter/_config.js | 3 + .../samples/reassigned-parameter/main.js | 7 + 83 files changed, 981 insertions(+), 49 deletions(-) create mode 100644 test/form/samples/tree-shake-literal-parameter/argument-assignment/_config.js create mode 100644 test/form/samples/tree-shake-literal-parameter/argument-assignment/_expected.js create mode 100644 test/form/samples/tree-shake-literal-parameter/argument-assignment/main.js create mode 100644 test/form/samples/tree-shake-literal-parameter/do-not-optimize/_config.js create mode 100644 test/form/samples/tree-shake-literal-parameter/do-not-optimize/_expected.js create mode 100644 test/form/samples/tree-shake-literal-parameter/do-not-optimize/main.js create mode 100644 test/form/samples/tree-shake-literal-parameter/expression-cache/_config.js create mode 100644 test/form/samples/tree-shake-literal-parameter/expression-cache/_expected.js create mode 100644 test/form/samples/tree-shake-literal-parameter/expression-cache/main.js create mode 100644 test/form/samples/tree-shake-literal-parameter/iife/_config.js create mode 100644 test/form/samples/tree-shake-literal-parameter/iife/_expected.js create mode 100644 test/form/samples/tree-shake-literal-parameter/iife/main.js create mode 100644 test/form/samples/tree-shake-literal-parameter/import-function/_config.js create mode 100644 test/form/samples/tree-shake-literal-parameter/import-function/_expected.js create mode 100644 test/form/samples/tree-shake-literal-parameter/import-function/arrow_lib.js create mode 100644 test/form/samples/tree-shake-literal-parameter/import-function/lib.js create mode 100644 test/form/samples/tree-shake-literal-parameter/import-function/main.js create mode 100644 test/form/samples/tree-shake-literal-parameter/indirect-import-function/_config.js create mode 100644 test/form/samples/tree-shake-literal-parameter/indirect-import-function/_expected.js create mode 100644 test/form/samples/tree-shake-literal-parameter/indirect-import-function/define_and_export_default.js create mode 100644 test/form/samples/tree-shake-literal-parameter/indirect-import-function/import_then_export.js create mode 100644 test/form/samples/tree-shake-literal-parameter/indirect-import-function/import_then_export_sub.js create mode 100644 test/form/samples/tree-shake-literal-parameter/indirect-import-function/main.js create mode 100644 test/form/samples/tree-shake-literal-parameter/recursion-literal-object/_config.js create mode 100644 test/form/samples/tree-shake-literal-parameter/recursion-literal-object/_expected.js create mode 100644 test/form/samples/tree-shake-literal-parameter/recursion-literal-object/main.js create mode 100644 test/form/samples/tree-shake-literal-parameter/recursion-literal/_config.js create mode 100644 test/form/samples/tree-shake-literal-parameter/recursion-literal/_expected.js create mode 100644 test/form/samples/tree-shake-literal-parameter/recursion-literal/main.js create mode 100644 test/form/samples/tree-shake-literal-parameter/reexport-function/_config.js create mode 100644 test/form/samples/tree-shake-literal-parameter/reexport-function/_expected.js create mode 100644 test/form/samples/tree-shake-literal-parameter/reexport-function/main.js create mode 100644 test/form/samples/tree-shake-literal-parameter/reexport-function/module1.js create mode 100644 test/form/samples/tree-shake-literal-parameter/reexport-function/module2.js create mode 100644 test/form/samples/tree-shake-literal-parameter/side-effect/_config.js create mode 100644 test/form/samples/tree-shake-literal-parameter/side-effect/_expected.js create mode 100644 test/form/samples/tree-shake-literal-parameter/side-effect/main.js create mode 100644 test/form/samples/tree-shake-literal-parameter/top-level/_config.js create mode 100644 test/form/samples/tree-shake-literal-parameter/top-level/_expected.js create mode 100644 test/form/samples/tree-shake-literal-parameter/top-level/main.js create mode 100644 test/function/samples/reassigned-parameter/_config.js create mode 100644 test/function/samples/reassigned-parameter/main.js diff --git a/src/ast/nodes/ConditionalExpression.ts b/src/ast/nodes/ConditionalExpression.ts index 5645a23f9..88794a1ec 100644 --- a/src/ast/nodes/ConditionalExpression.ts +++ b/src/ast/nodes/ConditionalExpression.ts @@ -1,5 +1,5 @@ import type MagicString from 'magic-string'; -import { BLANK, EMPTY_ARRAY } from '../../utils/blank'; +import { BLANK } from '../../utils/blank'; import type { NodeRenderOptions, RenderOptions } from '../../utils/renderHelpers'; import { findFirstOccurrenceOutsideComment, @@ -46,15 +46,16 @@ export default class ConditionalExpression extends NodeBase implements Deoptimiz } deoptimizeCache(): void { + this.isBranchResolutionAnalysed = false; + const { expressionsToBeDeoptimized } = this; + this.expressionsToBeDeoptimized = []; + for (const expression of expressionsToBeDeoptimized) { + expression.deoptimizeCache(); + } if (this.usedBranch !== null) { const unusedBranch = this.usedBranch === this.consequent ? this.alternate : this.consequent; this.usedBranch = null; unusedBranch.deoptimizePath(UNKNOWN_PATH); - const { expressionsToBeDeoptimized } = this; - this.expressionsToBeDeoptimized = EMPTY_ARRAY as unknown as DeoptimizableEntity[]; - for (const expression of expressionsToBeDeoptimized) { - expression.deoptimizeCache(); - } } } @@ -73,9 +74,9 @@ export default class ConditionalExpression extends NodeBase implements Deoptimiz recursionTracker: PathTracker, origin: DeoptimizableEntity ): LiteralValueOrUnknown { + this.expressionsToBeDeoptimized.push(origin); const usedBranch = this.getUsedBranch(); if (!usedBranch) return UnknownValue; - this.expressionsToBeDeoptimized.push(origin); return usedBranch.getLiteralValueAtPath(path, recursionTracker, origin); } diff --git a/src/ast/nodes/FunctionDeclaration.ts b/src/ast/nodes/FunctionDeclaration.ts index 4f75fce15..9cfa8b21b 100644 --- a/src/ast/nodes/FunctionDeclaration.ts +++ b/src/ast/nodes/FunctionDeclaration.ts @@ -14,6 +14,11 @@ export default class FunctionDeclaration extends FunctionNode { } } + 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 Identifier(this, this.scope.parent as ChildScope).parseNode( diff --git a/src/ast/nodes/Identifier.ts b/src/ast/nodes/Identifier.ts index 11147f3fb..8b13ea5b6 100644 --- a/src/ast/nodes/Identifier.ts +++ b/src/ast/nodes/Identifier.ts @@ -60,10 +60,12 @@ export default class Identifier extends NodeBase implements PatternNode { } } + private isReferenceVariable = false; bind(): void { if (!this.variable && isReference(this, this.parent as NodeWithFieldDefinition)) { this.variable = this.scope.findVariable(this.name); this.variable.addReference(this); + this.isReferenceVariable = true; } } @@ -295,6 +297,9 @@ export default class Identifier extends NodeBase implements PatternNode { this.variable.consolidateInitializers(); this.scope.context.requestTreeshakingPass(); } + if (this.isReferenceVariable) { + this.variable!.addUsedPlace(this); + } } private getVariableRespectingTDZ(): ExpressionEntity | null { diff --git a/src/ast/nodes/IfStatement.ts b/src/ast/nodes/IfStatement.ts index 07651843b..375c4eeaf 100644 --- a/src/ast/nodes/IfStatement.ts +++ b/src/ast/nodes/IfStatement.ts @@ -7,7 +7,7 @@ import { EMPTY_PATH, SHARED_RECURSION_TRACKER } from '../utils/PathTracker'; import BlockStatement from './BlockStatement'; import type Identifier from './Identifier'; import * as NodeType from './NodeType'; -import { type LiteralValueOrUnknown, UnknownValue } from './shared/Expression'; +import { type LiteralValueOrUnknown } from './shared/Expression'; import { type ExpressionNode, type GenericEsTreeNode, @@ -29,7 +29,7 @@ export default class IfStatement extends StatementBase implements DeoptimizableE private testValue: LiteralValueOrUnknown | typeof unset = unset; deoptimizeCache(): void { - this.testValue = UnknownValue; + this.testValue = unset; } hasEffects(context: HasEffectsContext): boolean { diff --git a/src/ast/nodes/LogicalExpression.ts b/src/ast/nodes/LogicalExpression.ts index 55de14861..1b9342951 100644 --- a/src/ast/nodes/LogicalExpression.ts +++ b/src/ast/nodes/LogicalExpression.ts @@ -1,5 +1,5 @@ import type MagicString from 'magic-string'; -import { BLANK, EMPTY_ARRAY } from '../../utils/blank'; +import { BLANK } from '../../utils/blank'; import { findFirstOccurrenceOutsideComment, findNonWhiteSpace, @@ -57,15 +57,13 @@ export default class LogicalExpression extends NodeBase implements Deoptimizable } deoptimizeCache(): void { - if (this.usedBranch) { - const unusedBranch = this.usedBranch === this.left ? this.right : this.left; - this.usedBranch = null; - unusedBranch.deoptimizePath(UNKNOWN_PATH); + this.isBranchResolutionAnalysed = false; + if (this.expressionsToBeDeoptimized.length > 0) { const { scope: { context }, expressionsToBeDeoptimized } = this; - this.expressionsToBeDeoptimized = EMPTY_ARRAY as unknown as DeoptimizableEntity[]; + this.expressionsToBeDeoptimized = []; for (const expression of expressionsToBeDeoptimized) { expression.deoptimizeCache(); } @@ -73,6 +71,11 @@ export default class LogicalExpression extends NodeBase implements Deoptimizable // it is rendered context.requestTreeshakingPass(); } + if (this.usedBranch) { + const unusedBranch = this.usedBranch === this.left ? this.right : this.left; + this.usedBranch = null; + unusedBranch.deoptimizePath(UNKNOWN_PATH); + } } deoptimizePath(path: ObjectPath): void { @@ -90,9 +93,9 @@ export default class LogicalExpression extends NodeBase implements Deoptimizable recursionTracker: PathTracker, origin: DeoptimizableEntity ): LiteralValueOrUnknown { + this.expressionsToBeDeoptimized.push(origin); const usedBranch = this.getUsedBranch(); if (!usedBranch) return UnknownValue; - this.expressionsToBeDeoptimized.push(origin); return usedBranch.getLiteralValueAtPath(path, recursionTracker, origin); } diff --git a/src/ast/nodes/MemberExpression.ts b/src/ast/nodes/MemberExpression.ts index 5c32a896b..cb2bf1d3b 100644 --- a/src/ast/nodes/MemberExpression.ts +++ b/src/ast/nodes/MemberExpression.ts @@ -1,7 +1,7 @@ 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 { BLANK } from '../../utils/blank'; import { LOGLEVEL_WARN } from '../../utils/logging'; import { logIllegalImportReassignment, logMissingExport } from '../../utils/logs'; import type { NodeRenderOptions, RenderOptions } from '../../utils/renderHelpers'; @@ -185,7 +185,7 @@ export default class MemberExpression deoptimizeCache(): void { const { expressionsToBeDeoptimized, object } = this; - this.expressionsToBeDeoptimized = EMPTY_ARRAY as unknown as DeoptimizableEntity[]; + this.expressionsToBeDeoptimized = []; this.propertyKey = UnknownKey; object.deoptimizePath(UNKNOWN_PATH); for (const expression of expressionsToBeDeoptimized) { @@ -396,6 +396,9 @@ export default class MemberExpression ); this.scope.context.requestTreeshakingPass(); } + if (this.variable) { + this.variable.addUsedPlace(this); + } } private applyAssignmentDeoptimization(): void { diff --git a/src/ast/nodes/UpdateExpression.ts b/src/ast/nodes/UpdateExpression.ts index 2d7b0613f..860bdd927 100644 --- a/src/ast/nodes/UpdateExpression.ts +++ b/src/ast/nodes/UpdateExpression.ts @@ -87,7 +87,7 @@ export default class UpdateExpression extends NodeBase { this.argument.deoptimizePath(EMPTY_PATH); if (this.argument instanceof Identifier) { const variable = this.scope.findVariable(this.argument.name); - variable.isReassigned = true; + variable.markReassigned(); } this.scope.context.requestTreeshakingPass(); } diff --git a/src/ast/nodes/shared/FunctionBase.ts b/src/ast/nodes/shared/FunctionBase.ts index 55b9f7f3d..8bea01354 100644 --- a/src/ast/nodes/shared/FunctionBase.ts +++ b/src/ast/nodes/shared/FunctionBase.ts @@ -9,12 +9,23 @@ import { } from '../../NodeInteractions'; import type ReturnValueScope from '../../scopes/ReturnValueScope'; import type { ObjectPath, PathTracker } from '../../utils/PathTracker'; -import { UNKNOWN_PATH, UnknownKey } from '../../utils/PathTracker'; +import { + EMPTY_PATH, + SHARED_RECURSION_TRACKER, + 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 CallExpression from '../CallExpression'; +import type ExportDefaultDeclaration from '../ExportDefaultDeclaration'; import Identifier from '../Identifier'; +import * as NodeType from '../NodeType'; import RestElement from '../RestElement'; import type SpreadElement from '../SpreadElement'; +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'; @@ -27,6 +38,13 @@ import { import type { ObjectEntity } from './ObjectEntity'; import type { PatternNode } from './Pattern'; +type InteractionCalledArguments = NodeInteractionCalled['args']; + +// This handler does nothing. +// Since we always re-evaluate argument values in a new tree-shaking pass, +// we don't need to get notified if it is deoptimized. +const EMPTY_DEOPTIMIZABLE_HANDLER = { deoptimizeCache() {} }; + export default abstract class FunctionBase extends NodeBase { declare body: BlockStatement | ExpressionNode; declare params: PatternNode[]; @@ -57,6 +75,107 @@ export default abstract class FunctionBase extends NodeBase { this.flags = setFlag(this.flags, Flag.generator, value); } + private knownParameterValues: (ExpressionEntity | undefined)[] = []; + private allArguments: InteractionCalledArguments[] = []; + /** + * update knownParameterValues when a call is made to this function + * @param newArguments arguments of the call + */ + private updateKnownParameterValues(newArguments: InteractionCalledArguments): void { + for (let position = 0; position < this.params.length; position++) { + // only the "this" argument newArguments[0] can be null + // it's possible that some arguments are empty, so the value is undefined + const argument = newArguments[position + 1] ?? UNDEFINED_EXPRESSION; + const parameter = this.params[position]; + // RestElement can be, and can only be, the last parameter + if (parameter instanceof RestElement) { + return; + } + + const knownParameterValue = this.knownParameterValues[position]; + if (knownParameterValue === undefined) { + this.knownParameterValues[position] = argument; + continue; + } + if ( + knownParameterValue === UNKNOWN_EXPRESSION || + knownParameterValue === argument || + (knownParameterValue instanceof Identifier && + argument instanceof Identifier && + knownParameterValue.variable === argument.variable) + ) { + continue; + } + + const oldValue = knownParameterValue.getLiteralValueAtPath( + EMPTY_PATH, + SHARED_RECURSION_TRACKER, + EMPTY_DEOPTIMIZABLE_HANDLER + ); + const newValue = argument.getLiteralValueAtPath( + EMPTY_PATH, + SHARED_RECURSION_TRACKER, + EMPTY_DEOPTIMIZABLE_HANDLER + ); + if (oldValue !== newValue || typeof oldValue === 'symbol') { + this.knownParameterValues[position] = UNKNOWN_EXPRESSION; + } // else both are the same literal, no need to update + } + } + + private forwardArgumentsForFunctionCalledOnce(newArguments: InteractionCalledArguments): void { + for (let position = 0; position < this.params.length; position++) { + const parameter = this.params[position]; + if (parameter instanceof Identifier) { + const ParameterVariable = parameter.variable as ParameterVariable | null; + const argument = newArguments[position + 1] ?? UNDEFINED_EXPRESSION; + ParameterVariable?.setKnownValue(argument); + } + } + } + + /** + * each time tree-shake starts, this method should be called to reoptimize the parameters + * a parameter's state will change at most twice: + * `undefined` (no call is made) -> an expression -> `UnknownArgument` + * we are sure it will converge, and can use state from last iteration + */ + private applyFunctionParameterOptimization() { + if (this.allArguments.length === 0) { + return; + } + + if (this.allArguments.length === 1) { + // we are sure what knownParameterValues will be, so skip it and do setKnownValue + this.forwardArgumentsForFunctionCalledOnce(this.allArguments[0]); + return; + } + + // reoptimize all arguments, that's why we save them + for (const argumentsList of this.allArguments) { + this.updateKnownParameterValues(argumentsList); + } + for (let position = 0; position < this.params.length; position++) { + const parameter = this.params[position]; + // Parameters without default values + if (parameter instanceof Identifier) { + const parameterVariable = parameter.variable as ParameterVariable | null; + // Only the RestElement may be undefined + const knownParameterValue = this.knownParameterValues[position]!; + parameterVariable?.setKnownValue(knownParameterValue); + } + } + } + + private deoptimizeFunctionParameters() { + for (const parameter of this.params) { + if (parameter instanceof Identifier) { + const parameterVariable = parameter.variable as ParameterVariable | null; + parameterVariable?.markReassigned(); + } + } + } + protected objectEntity: ObjectEntity | null = null; deoptimizeArgumentsOnInteractionAtPath( @@ -84,6 +203,7 @@ export default abstract class FunctionBase extends NodeBase { this.addArgumentToBeDeoptimized(argument); } } + this.allArguments.push(args); } else { this.getObjectEntity().deoptimizeArgumentsOnInteractionAtPath( interaction, @@ -102,6 +222,7 @@ export default abstract class FunctionBase extends NodeBase { for (const parameterList of this.scope.parameters) { for (const parameter of parameterList) { parameter.deoptimizePath(UNKNOWN_PATH); + parameter.markReassigned(); } } } @@ -180,7 +301,33 @@ export default abstract class FunctionBase extends NodeBase { 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 functionParametersOptimized = false; include(context: InclusionContext, includeChildrenRecursively: IncludeChildren): void { + const isIIFE = + this.parent.type === NodeType.CallExpression && + (this.parent as CallExpression).callee === this; + const shoulOptimizeFunctionParameters = isIIFE || this.onlyFunctionCallUsed(); + if (shoulOptimizeFunctionParameters) { + this.applyFunctionParameterOptimization(); + } else if (this.functionParametersOptimized) { + this.deoptimizeFunctionParameters(); + } + this.functionParametersOptimized = shoulOptimizeFunctionParameters; + if (!this.deoptimized) this.applyDeoptimizations(); this.included = true; const { brokenFlow } = context; diff --git a/src/ast/variables/ExportDefaultVariable.ts b/src/ast/variables/ExportDefaultVariable.ts index 979405b57..70810936e 100644 --- a/src/ast/variables/ExportDefaultVariable.ts +++ b/src/ast/variables/ExportDefaultVariable.ts @@ -3,6 +3,7 @@ import ClassDeclaration from '../nodes/ClassDeclaration'; import type ExportDefaultDeclaration from '../nodes/ExportDefaultDeclaration'; import FunctionDeclaration from '../nodes/FunctionDeclaration'; import Identifier, { type IdentifierWithVariable } from '../nodes/Identifier'; +import type { NodeBase } from '../nodes/shared/Node'; import LocalVariable from './LocalVariable'; import UndefinedVariable from './UndefinedVariable'; import type Variable from './Variable'; @@ -37,6 +38,15 @@ export default class ExportDefaultVariable extends LocalVariable { } } + addUsedPlace(usedPlace: NodeBase): void { + const original = this.getOriginalVariable(); + if (original === this) { + super.addUsedPlace(usedPlace); + } else { + original.addUsedPlace(usedPlace); + } + } + forbidName(name: string) { const original = this.getOriginalVariable(); if (original === this) { diff --git a/src/ast/variables/GlobalVariable.ts b/src/ast/variables/GlobalVariable.ts index d55ed63ae..4f168ac8f 100644 --- a/src/ast/variables/GlobalVariable.ts +++ b/src/ast/variables/GlobalVariable.ts @@ -13,9 +13,12 @@ import type { ObjectPath, PathTracker } from '../utils/PathTracker'; import Variable from './Variable'; export default class GlobalVariable extends Variable { - // Ensure we use live-bindings for globals as we do not know if they have - // been reassigned - 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, diff --git a/src/ast/variables/LocalVariable.ts b/src/ast/variables/LocalVariable.ts index fe5bd4884..83b32a81e 100644 --- a/src/ast/variables/LocalVariable.ts +++ b/src/ast/variables/LocalVariable.ts @@ -91,7 +91,7 @@ export default class LocalVariable extends Variable { return; } if (path.length === 0) { - this.isReassigned = true; + this.markReassigned(); const expressionsToBeDeoptimized = this.expressionsToBeDeoptimized; this.expressionsToBeDeoptimized = EMPTY_ARRAY as unknown as DeoptimizableEntity[]; for (const expression of expressionsToBeDeoptimized) { @@ -222,7 +222,7 @@ export default class LocalVariable extends Variable { if (this.additionalInitializers === null) { this.additionalInitializers = [this.init]; this.init = UNKNOWN_EXPRESSION; - this.isReassigned = true; + this.markReassigned(); } return this.additionalInitializers; } diff --git a/src/ast/variables/ParameterVariable.ts b/src/ast/variables/ParameterVariable.ts index 94f3feb90..a411885a8 100644 --- a/src/ast/variables/ParameterVariable.ts +++ b/src/ast/variables/ParameterVariable.ts @@ -1,14 +1,17 @@ import type { AstContext } from '../../Module'; import { EMPTY_ARRAY } from '../../utils/blank'; +import type { DeoptimizableEntity } from '../DeoptimizableEntity'; +import type { HasEffectsContext } from '../ExecutionContext'; import type { NodeInteraction } from '../NodeInteractions'; -import { INTERACTION_CALLED } from '../NodeInteractions'; +import { INTERACTION_ASSIGNED, INTERACTION_CALLED } from '../NodeInteractions'; import type ExportDefaultDeclaration from '../nodes/ExportDefaultDeclaration'; import type Identifier from '../nodes/Identifier'; -import type { ExpressionEntity } from '../nodes/shared/Expression'; +import type { ExpressionEntity, LiteralValueOrUnknown } from '../nodes/shared/Expression'; import { deoptimizeInteraction, UNKNOWN_EXPRESSION, - UNKNOWN_RETURN_EXPRESSION + UNKNOWN_RETURN_EXPRESSION, + UnknownValue } from '../nodes/shared/Expression'; import type { ObjectPath, ObjectPathKey } from '../utils/PathTracker'; import { @@ -35,6 +38,7 @@ export default class ParameterVariable extends LocalVariable { private deoptimizations = new PathTracker(); private deoptimizedFields = new Set(); private entitiesToBeDeoptimized = new Set(); + private knownExpressionsToBeDeoptimized: DeoptimizableEntity[] = []; constructor( name: string, @@ -71,6 +75,65 @@ export default class ParameterVariable extends LocalVariable { } } + markReassigned(): void { + if (this.isReassigned) { + return; + } + super.markReassigned(); + for (const expression of this.knownExpressionsToBeDeoptimized) { + expression.deoptimizeCache(); + } + this.knownExpressionsToBeDeoptimized = []; + } + + private knownValue: ExpressionEntity = UNKNOWN_EXPRESSION; + /** + * If we are sure about the value of this parameter, we can set it here. + * It can be a literal or the only possible value of the parameter. + * an undefined value means that the parameter is not known. + * @param value The known value of the parameter to be set. + */ + setKnownValue(value: ExpressionEntity): void { + if (this.isReassigned) { + return; + } + if (this.knownValue !== value) { + for (const expression of this.knownExpressionsToBeDeoptimized) { + expression.deoptimizeCache(); + } + this.knownExpressionsToBeDeoptimized = []; + } + this.knownValue = value; + } + + getLiteralValueAtPath( + path: ObjectPath, + recursionTracker: PathTracker, + origin: DeoptimizableEntity + ): LiteralValueOrUnknown { + if (this.isReassigned) { + return UnknownValue; + } + this.knownExpressionsToBeDeoptimized.push(origin); + return recursionTracker.withTrackedEntityAtPath( + path, + this.knownValue, + () => this.knownValue!.getLiteralValueAtPath(path, recursionTracker, origin), + UnknownValue + ); + } + + hasEffectsOnInteractionAtPath( + path: ObjectPath, + interaction: NodeInteraction, + context: HasEffectsContext + ): boolean { + // assigned is a bit different, since the value has a new name (the parameter) + return interaction.type === INTERACTION_ASSIGNED + ? super.hasEffectsOnInteractionAtPath(path, interaction, context) + : this.knownValue.hasEffectsOnInteractionAtPath(path, interaction, context); + } + deoptimizeArgumentsOnInteractionAtPath(interaction: NodeInteraction, path: ObjectPath): void { // For performance reasons, we fully deoptimize all deeper interactions if ( @@ -98,7 +161,11 @@ export default class ParameterVariable extends LocalVariable { } deoptimizePath(path: ObjectPath): void { - if (path.length === 0 || this.deoptimizedFields.has(UnknownKey)) { + if (this.deoptimizedFields.has(UnknownKey)) { + return; + } + if (path.length === 0) { + this.markReassigned(); return; } const key = path[0]; diff --git a/src/ast/variables/Variable.ts b/src/ast/variables/Variable.ts index 521ff1f9b..e22fe48b0 100644 --- a/src/ast/variables/Variable.ts +++ b/src/ast/variables/Variable.ts @@ -4,8 +4,11 @@ import type { RenderOptions } from '../../utils/renderHelpers'; import type { HasEffectsContext } from '../ExecutionContext'; import type { NodeInteraction } from '../NodeInteractions'; import { INTERACTION_ACCESSED } from '../NodeInteractions'; +import type CallExpression from '../nodes/CallExpression'; import type Identifier from '../nodes/Identifier'; +import * as NodeType from '../nodes/NodeType'; import { ExpressionEntity } from '../nodes/shared/Expression'; +import type { NodeBase } from '../nodes/shared/Node'; import type { VariableKind } from '../nodes/shared/VariableKinds'; import type { ObjectPath } from '../utils/PathTracker'; @@ -16,7 +19,6 @@ export default class Variable extends ExpressionEntity { isId = false; // both NamespaceVariable and ExternalVariable can be namespaces declare isNamespace?: boolean; - isReassigned = false; kind: VariableKind | null = null; declare module?: Module | ExternalModule; renderBaseName: string | null = null; @@ -24,6 +26,11 @@ export default class Variable extends ExpressionEntity { private renderedLikeHoisted?: Variable; + readonly isReassigned = false; + markReassigned() { + (this as { isReassigned: boolean }).isReassigned = true; + } + constructor(public name: string) { super(); } @@ -34,6 +41,29 @@ export default class Variable extends ExpressionEntity { */ addReference(_identifier: Identifier): void {} + private onlyFunctionCallUsed = true; + /** + * Check if the identifier variable is only used as function call + * Forward the check to the export default variable if it is only used once + * @returns true if the variable is only used as function call + */ + getOnlyFunctionCallUsed(): boolean { + return this.onlyFunctionCallUsed; + } + + /** + * 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; + } + } + /** * Prevent this variable from being renamed to this name to avoid name * collisions 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 1ebb9552c..c0bb33a62 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 @@ -5,12 +5,13 @@ define(['exports'], (function (exports) { 'use strict'; 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/dep1.js b/test/chunking-form/samples/missing-export-reused-deconflicting/_expected/cjs/dep1.js index a024bcd6f..31b08b56a 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 @@ -5,11 +5,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); exports.missing1 = _missingExportShim; 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 99f4196bf..d9c8b65f0 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 fb77b0059..24aa7ab54 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 @@ -8,12 +8,13 @@ System.register([], (function (exports) { 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/dep1.js b/test/chunking-form/samples/missing-export-reused-deconflicting/dep1.js index 84e22e0fe..f0751ef4c 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/preserve-modules-commonjs/_expected/amd/_virtual/_commonjsHelpers.js b/test/chunking-form/samples/preserve-modules-commonjs/_expected/amd/_virtual/_commonjsHelpers.js index f35ac4ef0..25ed6cf37 100644 --- 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 @@ -1,7 +1,7 @@ define(['exports'], (function (exports) { 'use strict'; function getDefaultExportFromCjs (x) { - return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; + return 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/_commonjsHelpers.js b/test/chunking-form/samples/preserve-modules-commonjs/_expected/cjs/_virtual/_commonjsHelpers.js index ceeaa4d07..fc314aed4 100644 --- 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 @@ -1,7 +1,7 @@ 'use strict'; function getDefaultExportFromCjs (x) { - return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; + return 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/es/_virtual/_commonjsHelpers.js b/test/chunking-form/samples/preserve-modules-commonjs/_expected/es/_virtual/_commonjsHelpers.js index 7b7c5f4f5..5fea8b909 100644 --- 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 @@ -1,5 +1,5 @@ function getDefaultExportFromCjs (x) { - return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; + return x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; } export { getDefaultExportFromCjs }; 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 index dd2c5886a..15f3676f9 100644 --- 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 @@ -6,7 +6,7 @@ System.register([], (function (exports) { exports("getDefaultExportFromCjs", getDefaultExportFromCjs); function getDefaultExportFromCjs (x) { - return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; + return x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; } }) diff --git a/test/form/samples/deopt-string-concatenation/_expected.js b/test/form/samples/deopt-string-concatenation/_expected.js index 68a30dc4f..42785de73 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 68a30dc4f..42785de73 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/side-effect-h/_expected/amd.js b/test/form/samples/side-effect-h/_expected/amd.js index d3a055b34..e46b7cd7c 100644 --- a/test/form/samples/side-effect-h/_expected/amd.js +++ b/test/form/samples/side-effect-h/_expected/amd.js @@ -7,6 +7,7 @@ define((function () { 'use strict'; } foo(); + foo(true); var main = 42; diff --git a/test/form/samples/side-effect-h/_expected/cjs.js b/test/form/samples/side-effect-h/_expected/cjs.js index 1d437295c..4862e7aa0 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 1d5410d07..39c215e33 100644 --- a/test/form/samples/side-effect-h/_expected/es.js +++ b/test/form/samples/side-effect-h/_expected/es.js @@ -5,6 +5,7 @@ function foo ( ok ) { } foo(); +foo(true); var main = 42; diff --git a/test/form/samples/side-effect-h/_expected/iife.js b/test/form/samples/side-effect-h/_expected/iife.js index 083d37914..b6fc61fb4 100644 --- a/test/form/samples/side-effect-h/_expected/iife.js +++ b/test/form/samples/side-effect-h/_expected/iife.js @@ -8,6 +8,7 @@ var myBundle = (function () { } foo(); + foo(true); var main = 42; diff --git a/test/form/samples/side-effect-h/_expected/system.js b/test/form/samples/side-effect-h/_expected/system.js index dcb761aa7..6ace3fb0f 100644 --- a/test/form/samples/side-effect-h/_expected/system.js +++ b/test/form/samples/side-effect-h/_expected/system.js @@ -10,6 +10,7 @@ System.register('myBundle', [], (function (exports) { } foo(); + foo(true); 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 770859846..f72ccce31 100644 --- a/test/form/samples/side-effect-h/_expected/umd.js +++ b/test/form/samples/side-effect-h/_expected/umd.js @@ -11,6 +11,7 @@ } foo(); + foo(true); var main = 42; diff --git a/test/form/samples/side-effect-h/main.js b/test/form/samples/side-effect-h/main.js index 16d734691..b736c13f9 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-effects-return-statements/_expected/amd.js b/test/form/samples/side-effects-return-statements/_expected/amd.js index dcdb995d3..1633b0ab0 100644 --- a/test/form/samples/side-effects-return-statements/_expected/amd.js +++ b/test/form/samples/side-effects-return-statements/_expected/amd.js @@ -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 7dd6e8130..93d4ccf36 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 38f357c97..9898b0d0f 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 c9da6fbbc..81b64ec81 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 968b34163..096bcc73f 100644 --- a/test/form/samples/side-effects-return-statements/_expected/system.js +++ b/test/form/samples/side-effects-return-statements/_expected/system.js @@ -11,6 +11,7 @@ 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 97a5be316..fc3ff304a 100644 --- a/test/form/samples/side-effects-return-statements/_expected/umd.js +++ b/test/form/samples/side-effects-return-statements/_expected/umd.js @@ -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 8e6b3b54f..a1e68e5d6 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/supports-es5-shim/_expected.js b/test/form/samples/supports-es5-shim/_expected.js index bc68debf9..645169277 100644 --- a/test/form/samples/supports-es5-shim/_expected.js +++ b/test/form/samples/supports-es5-shim/_expected.js @@ -2202,7 +2202,6 @@ var es5Shim = {exports: {}}; // eslint-disable-next-line no-global-assign, no-implicit-globals parseInt = (function (origParseInt) { return function parseInt(str, radix) { - if (this instanceof parseInt) { new origParseInt(); } // eslint-disable-line new-cap, no-new, max-statements-per-line var string = trim(String(str)); var defaultedRadix = $Number(radix) || (hexRegex.test(string) ? 16 : 10); return origParseInt(string, defaultedRadix); @@ -2233,7 +2232,6 @@ var es5Shim = {exports: {}}; // eslint-disable-next-line no-global-assign, no-implicit-globals parseInt = (function (origParseInt) { return function parseInt(str, radix) { - if (this instanceof parseInt) { new origParseInt(); } // eslint-disable-line new-cap, no-new, max-statements-per-line var isSym = typeof str === 'symbol'; if (!isSym && str && typeof str === 'object') { try { diff --git a/test/form/samples/supports-es6-shim/_expected.js b/test/form/samples/supports-es6-shim/_expected.js index ae2951820..84fb3b7f0 100644 --- a/test/form/samples/supports-es6-shim/_expected.js +++ b/test/form/samples/supports-es6-shim/_expected.js @@ -2057,7 +2057,7 @@ var es6Shim = {exports: {}}; }; var withinULPDistance = function withinULPDistance(result, expected, distance) { - return _abs(1 - (result / expected)) / Number.EPSILON < (distance || 8); + return _abs(1 - (result / expected)) / Number.EPSILON < (8); }; defineProperties(Math, MathShims); 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 000000000..1a210baea --- /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 000000000..f7cb2c16d --- /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 000000000..d9b364653 --- /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 000000000..d16519b09 --- /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 000000000..8e1230c75 --- /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 000000000..079d60a1b --- /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 000000000..697aea54b --- /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 000000000..8cee56182 --- /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 000000000..4c1f739a1 --- /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 000000000..789458177 --- /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 000000000..49705fc59 --- /dev/null +++ b/test/form/samples/tree-shake-literal-parameter/iife/_expected.js @@ -0,0 +1,14 @@ +const result1 = ((enable) => { + { + return 'enabled'; + } +})(); + +const result2 = (function (enable) { + { + return 'enabled'; + } +})(); + +console.log(result1); +console.log(result2); 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 000000000..468487402 --- /dev/null +++ b/test/form/samples/tree-shake-literal-parameter/iife/main.js @@ -0,0 +1,18 @@ +const result1 = ((enable) => { + if (enable) { + return 'enabled'; + } else { + return 'disabled'; + } +})(true); + +const result2 = (function (enable) { + if (enable) { + return 'enabled'; + } else { + return 'disabled'; + } +})(true); + +console.log(result1); +console.log(result2); \ No newline at end of file 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 000000000..e4a54b5f9 --- /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 000000000..f9d8a0fd9 --- /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 000000000..8b85efc44 --- /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 000000000..be4b8a63c --- /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 000000000..fcd0b9dcb --- /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 000000000..43454f74b --- /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 000000000..39872a4cf --- /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 000000000..b52e1846d --- /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 000000000..30e7e2b91 --- /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 000000000..2afc49468 --- /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 000000000..ad0e9fb26 --- /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 000000000..251df7a6a --- /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 000000000..f909ce360 --- /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 000000000..4f845cc4e --- /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 000000000..251df7a6a --- /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 000000000..2fcab0594 --- /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()); \ No newline at end of file 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 000000000..1187cc47f --- /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 000000000..74efd8ee3 --- /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 000000000..fd105290a --- /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()); \ No newline at end of file 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 000000000..c83b279bb --- /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 000000000..01e152738 --- /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 000000000..c4f4cacaf --- /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 000000000..e06ff5cdc --- /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 000000000..772756634 --- /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 000000000..d7f3ba001 --- /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 000000000..027f90cf3 --- /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 000000000..70d050ab7 --- /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 000000000..9f706606d --- /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/try-statement-deoptimization/deactivate-via-option/_expected.js b/test/form/samples/try-statement-deoptimization/deactivate-via-option/_expected.js index a8d430c8f..7a1891aac 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/function/samples/reassigned-parameter/_config.js b/test/function/samples/reassigned-parameter/_config.js new file mode 100644 index 000000000..5923f0afe --- /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 000000000..6210a58ea --- /dev/null +++ b/test/function/samples/reassigned-parameter/main.js @@ -0,0 +1,7 @@ +function f(a) { + assert.equal(a ? 'OK' : 'FAIL', 'OK'); + a = false; + assert.equal(a ? 'FAIL' : 'OK', 'OK'); +} + +f(true) From 38fe70780cb7e374b47da99e3a3dca6b2a2170d2 Mon Sep 17 00:00:00 2001 From: Lukas Taegert-Atkinson Date: Sun, 21 Apr 2024 06:31:12 +0200 Subject: [PATCH 26/45] 4.16.0 --- CHANGELOG.md | 12 ++++++++++++ browser/package.json | 2 +- package-lock.json | 4 ++-- package.json | 2 +- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a08c8115b..3ca1f14e5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,17 @@ # rollup changelog +## 4.16.0 + +_2024-04-21_ + +### Features + +- Track function call arguments to optimize functions only called once or with the same literal values (#5443) + +### Pull Requests + +- [#5443](https://github.com/rollup/rollup/pull/5443): feat: improve tree-shaking by propagate const parameter (@liuly0322, @lukastaegert) + ## 4.15.0 _2024-04-20_ diff --git a/browser/package.json b/browser/package.json index 7808cf22d..7d62bf71a 100644 --- a/browser/package.json +++ b/browser/package.json @@ -1,6 +1,6 @@ { "name": "@rollup/browser", - "version": "4.15.0", + "version": "4.16.0", "description": "Next-generation ES module bundler browser build", "main": "dist/rollup.browser.js", "module": "dist/es/rollup.browser.js", diff --git a/package-lock.json b/package-lock.json index 7b16a8e83..eb6abce95 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "rollup", - "version": "4.15.0", + "version": "4.16.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "rollup", - "version": "4.15.0", + "version": "4.16.0", "license": "MIT", "dependencies": { "@types/estree": "1.0.5" diff --git a/package.json b/package.json index 532cebf61..b34b76fed 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rollup", - "version": "4.15.0", + "version": "4.16.0", "description": "Next-generation ES module bundler", "main": "dist/rollup.js", "module": "dist/es/rollup.js", From 190893a1bf0fac162d4de366a6584ef30ec84d39 Mon Sep 17 00:00:00 2001 From: liuly Date: Mon, 22 Apr 2024 02:15:56 +0800 Subject: [PATCH 27/45] fix: conditional/logical expression should request a new tree-shaking (#5481) * fix: conditional/logical expression should request a new tree-shaking * perf: rarely expressionsToBeDeoptimized.length > 0, so move it outside --- src/ast/nodes/ConditionalExpression.ts | 18 +++++++++++++---- src/ast/nodes/LogicalExpression.ts | 20 ++++++++++--------- .../_config.js | 3 +++ .../_expected.js | 16 +++++++++++++++ .../main.js | 16 +++++++++++++++ 5 files changed, 60 insertions(+), 13 deletions(-) create mode 100644 test/form/samples/request-tree-shaking-before-render/_config.js create mode 100644 test/form/samples/request-tree-shaking-before-render/_expected.js create mode 100644 test/form/samples/request-tree-shaking-before-render/main.js diff --git a/src/ast/nodes/ConditionalExpression.ts b/src/ast/nodes/ConditionalExpression.ts index 88794a1ec..68ba5be14 100644 --- a/src/ast/nodes/ConditionalExpression.ts +++ b/src/ast/nodes/ConditionalExpression.ts @@ -46,12 +46,22 @@ export default class ConditionalExpression extends NodeBase implements Deoptimiz } deoptimizeCache(): void { - this.isBranchResolutionAnalysed = false; + if ( + this.usedBranch || + this.isBranchResolutionAnalysed || + this.expressionsToBeDeoptimized.length > 0 + ) { + // Request another pass because we need to ensure "include" runs again if it is rendered + this.scope.context.requestTreeshakingPass(); + } const { expressionsToBeDeoptimized } = this; - this.expressionsToBeDeoptimized = []; - for (const expression of expressionsToBeDeoptimized) { - expression.deoptimizeCache(); + if (expressionsToBeDeoptimized.length > 0) { + this.expressionsToBeDeoptimized = []; + for (const expression of expressionsToBeDeoptimized) { + expression.deoptimizeCache(); + } } + this.isBranchResolutionAnalysed = false; if (this.usedBranch !== null) { const unusedBranch = this.usedBranch === this.consequent ? this.alternate : this.consequent; this.usedBranch = null; diff --git a/src/ast/nodes/LogicalExpression.ts b/src/ast/nodes/LogicalExpression.ts index 1b9342951..ee8873151 100644 --- a/src/ast/nodes/LogicalExpression.ts +++ b/src/ast/nodes/LogicalExpression.ts @@ -57,20 +57,22 @@ export default class LogicalExpression extends NodeBase implements Deoptimizable } deoptimizeCache(): void { - this.isBranchResolutionAnalysed = false; - if (this.expressionsToBeDeoptimized.length > 0) { - const { - scope: { context }, - expressionsToBeDeoptimized - } = this; + if ( + this.usedBranch || + this.isBranchResolutionAnalysed || + this.expressionsToBeDeoptimized.length > 0 + ) { + // Request another pass because we need to ensure "include" runs again if it is rendered + this.scope.context.requestTreeshakingPass(); + } + const { expressionsToBeDeoptimized } = this; + if (expressionsToBeDeoptimized.length > 0) { this.expressionsToBeDeoptimized = []; for (const expression of expressionsToBeDeoptimized) { expression.deoptimizeCache(); } - // Request another pass because we need to ensure "include" runs again if - // it is rendered - context.requestTreeshakingPass(); } + this.isBranchResolutionAnalysed = false; if (this.usedBranch) { const unusedBranch = this.usedBranch === this.left ? this.right : this.left; this.usedBranch = null; 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 000000000..00d3b4e06 --- /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 000000000..f02682756 --- /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 000000000..85b8d4935 --- /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) +}) From 5d8019b901e98cc8895751a23e5edfc9135b1a35 Mon Sep 17 00:00:00 2001 From: Lukas Taegert-Atkinson Date: Sun, 21 Apr 2024 20:17:54 +0200 Subject: [PATCH 28/45] 4.16.1 --- CHANGELOG.md | 12 ++++++++++++ browser/package.json | 2 +- package-lock.json | 4 ++-- package.json | 2 +- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3ca1f14e5..18ecbc024 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,17 @@ # rollup changelog +## 4.16.1 + +_2024-04-21_ + +### Bug Fixes + +- Fix crash when rendering logical or conditional expressions (#5481) + +### Pull Requests + +- [#5481](https://github.com/rollup/rollup/pull/5481): fix: conditional/logical expression should request a new tree-shaking (@liuly0322) + ## 4.16.0 _2024-04-21_ diff --git a/browser/package.json b/browser/package.json index 7d62bf71a..87ff48d86 100644 --- a/browser/package.json +++ b/browser/package.json @@ -1,6 +1,6 @@ { "name": "@rollup/browser", - "version": "4.16.0", + "version": "4.16.1", "description": "Next-generation ES module bundler browser build", "main": "dist/rollup.browser.js", "module": "dist/es/rollup.browser.js", diff --git a/package-lock.json b/package-lock.json index eb6abce95..a63a33e0b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "rollup", - "version": "4.16.0", + "version": "4.16.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "rollup", - "version": "4.16.0", + "version": "4.16.1", "license": "MIT", "dependencies": { "@types/estree": "1.0.5" diff --git a/package.json b/package.json index b34b76fed..46ee5c831 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rollup", - "version": "4.16.0", + "version": "4.16.1", "description": "Next-generation ES module bundler", "main": "dist/rollup.js", "module": "dist/es/rollup.js", From a80117f528fafa3194cdab58dddfabbf7d9ceb4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BF=A0=20/=20green?= Date: Mon, 22 Apr 2024 13:54:48 +0900 Subject: [PATCH 29/45] Add libc field to armv7 packages (#5479) --- npm/linux-arm-gnueabihf/package.json | 3 +++ npm/linux-arm-musleabihf/package.json | 3 +++ 2 files changed, 6 insertions(+) diff --git a/npm/linux-arm-gnueabihf/package.json b/npm/linux-arm-gnueabihf/package.json index ff1c7a151..0a58518b1 100644 --- a/npm/linux-arm-gnueabihf/package.json +++ b/npm/linux-arm-gnueabihf/package.json @@ -15,5 +15,8 @@ "homepage": "https://rollupjs.org/", "license": "MIT", "repository": "rollup/rollup", + "libc": [ + "glibc" + ], "main": "./rollup.linux-arm-gnueabihf.node" } diff --git a/npm/linux-arm-musleabihf/package.json b/npm/linux-arm-musleabihf/package.json index 2a07544f2..a71691020 100644 --- a/npm/linux-arm-musleabihf/package.json +++ b/npm/linux-arm-musleabihf/package.json @@ -15,5 +15,8 @@ "homepage": "https://rollupjs.org/", "license": "MIT", "repository": "rollup/rollup", + "libc": [ + "musl" + ], "main": "./rollup.linux-arm-musleabihf.node" } From 4bbe1a3d349d631760a1a8f82c352be8c14dc355 Mon Sep 17 00:00:00 2001 From: liuly Date: Mon, 22 Apr 2024 23:07:03 +0800 Subject: [PATCH 30/45] fix: function parameter reassigned update (#5482) fix: reassigned --- src/ast/variables/ParameterVariable.ts | 6 ++--- .../samples/reassigned-parameter/main.js | 22 +++++++++++++++---- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/src/ast/variables/ParameterVariable.ts b/src/ast/variables/ParameterVariable.ts index a411885a8..fa62eb400 100644 --- a/src/ast/variables/ParameterVariable.ts +++ b/src/ast/variables/ParameterVariable.ts @@ -161,13 +161,13 @@ export default class ParameterVariable extends LocalVariable { } deoptimizePath(path: ObjectPath): void { - if (this.deoptimizedFields.has(UnknownKey)) { - return; - } if (path.length === 0) { this.markReassigned(); return; } + if (this.deoptimizedFields.has(UnknownKey)) { + return; + } const key = path[0]; if (this.deoptimizedFields.has(key)) { return; diff --git a/test/function/samples/reassigned-parameter/main.js b/test/function/samples/reassigned-parameter/main.js index 6210a58ea..f2c6fe7d3 100644 --- a/test/function/samples/reassigned-parameter/main.js +++ b/test/function/samples/reassigned-parameter/main.js @@ -1,7 +1,21 @@ function f(a) { - assert.equal(a ? 'OK' : 'FAIL', 'OK'); - a = false; - assert.equal(a ? 'FAIL' : 'OK', 'OK'); + assert.equal(a ? 'OK' : 'FAIL', 'OK'); + a = false; + assert.equal(a ? 'FAIL' : 'OK', 'OK'); } -f(true) +f(true); + +function g(array) { + if (array === null) { + array = []; + } + + if (array) { + return 'OK'; + } + return array; +} + +assert.equal(g(null), 'OK'); + From 18839eb234f79adc44a591e355fd7b3243a4cd21 Mon Sep 17 00:00:00 2001 From: Lukas Taegert-Atkinson Date: Mon, 22 Apr 2024 17:09:23 +0200 Subject: [PATCH 31/45] 4.16.2 --- CHANGELOG.md | 14 ++++++++++++++ browser/package.json | 2 +- package-lock.json | 4 ++-- package.json | 2 +- 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 18ecbc024..4b91aa9fb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,19 @@ # rollup changelog +## 4.16.2 + +_2024-04-22_ + +### Bug Fixes + +- 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) + +### Pull Requests + +- [#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) + ## 4.16.1 _2024-04-21_ diff --git a/browser/package.json b/browser/package.json index 87ff48d86..159d7e34c 100644 --- a/browser/package.json +++ b/browser/package.json @@ -1,6 +1,6 @@ { "name": "@rollup/browser", - "version": "4.16.1", + "version": "4.16.2", "description": "Next-generation ES module bundler browser build", "main": "dist/rollup.browser.js", "module": "dist/es/rollup.browser.js", diff --git a/package-lock.json b/package-lock.json index a63a33e0b..d0025451d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "rollup", - "version": "4.16.1", + "version": "4.16.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "rollup", - "version": "4.16.1", + "version": "4.16.2", "license": "MIT", "dependencies": { "@types/estree": "1.0.5" diff --git a/package.json b/package.json index 46ee5c831..2ead425cc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rollup", - "version": "4.16.1", + "version": "4.16.2", "description": "Next-generation ES module bundler", "main": "dist/rollup.js", "module": "dist/es/rollup.js", From bcf44996a6fcb5ad6500185b5547babac4c31302 Mon Sep 17 00:00:00 2001 From: liuly Date: Tue, 23 Apr 2024 12:44:54 +0800 Subject: [PATCH 32/45] fix: only optimize annoymous iife (#5486) * fix: only optimize annoymous iife * fix typo Co-authored-by: Adam Freidin * fix typo * support functions having a name but not used --------- Co-authored-by: Adam Freidin --- src/ast/nodes/ArrowFunctionExpression.ts | 10 ++++++- src/ast/nodes/FunctionExpression.ts | 9 +++++++ src/ast/nodes/shared/FunctionBase.ts | 10 +++---- .../iife/_expected.js | 18 +++++++++++++ .../tree-shake-literal-parameter/iife/main.js | 22 +++++++++++++++- test/function/samples/acorn-walk/_config.js | 3 +++ test/function/samples/acorn-walk/main.js | 26 +++++++++++++++++++ 7 files changed, 89 insertions(+), 9 deletions(-) create mode 100644 test/function/samples/acorn-walk/_config.js create mode 100644 test/function/samples/acorn-walk/main.js diff --git a/src/ast/nodes/ArrowFunctionExpression.ts b/src/ast/nodes/ArrowFunctionExpression.ts index 8bf2df385..c99578c87 100644 --- a/src/ast/nodes/ArrowFunctionExpression.ts +++ b/src/ast/nodes/ArrowFunctionExpression.ts @@ -5,8 +5,9 @@ import type ChildScope from '../scopes/ChildScope'; import ReturnValueScope from '../scopes/ReturnValueScope'; import { type ObjectPath } from '../utils/PathTracker'; import type BlockStatement from './BlockStatement'; +import type CallExpression from './CallExpression'; import Identifier from './Identifier'; -import type * as NodeType from './NodeType'; +import * as NodeType from './NodeType'; import { Flag, isFlagSet, setFlag } from './shared/BitFlags'; import FunctionBase from './shared/FunctionBase'; import type { ExpressionNode, IncludeChildren } from './shared/Node'; @@ -67,6 +68,13 @@ export default class ArrowFunctionExpression extends FunctionBase { return false; } + protected onlyFunctionCallUsed(): boolean { + const isIIFE = + this.parent.type === NodeType.CallExpression && + (this.parent as CallExpression).callee === this; + return isIIFE || super.onlyFunctionCallUsed(); + } + include(context: InclusionContext, includeChildrenRecursively: IncludeChildren): void { super.include(context, includeChildrenRecursively); for (const parameter of this.params) { diff --git a/src/ast/nodes/FunctionExpression.ts b/src/ast/nodes/FunctionExpression.ts index be7c5e431..85b2b5cb4 100644 --- a/src/ast/nodes/FunctionExpression.ts +++ b/src/ast/nodes/FunctionExpression.ts @@ -2,6 +2,7 @@ import type MagicString from 'magic-string'; import { BLANK } from '../../utils/blank'; 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'; @@ -25,6 +26,14 @@ export default class FunctionExpression extends FunctionNode { 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, diff --git a/src/ast/nodes/shared/FunctionBase.ts b/src/ast/nodes/shared/FunctionBase.ts index 8bea01354..50fa44110 100644 --- a/src/ast/nodes/shared/FunctionBase.ts +++ b/src/ast/nodes/shared/FunctionBase.ts @@ -19,7 +19,6 @@ import { UNDEFINED_EXPRESSION } from '../../values'; import type ParameterVariable from '../../variables/ParameterVariable'; import type Variable from '../../variables/Variable'; import BlockStatement from '../BlockStatement'; -import type CallExpression from '../CallExpression'; import type ExportDefaultDeclaration from '../ExportDefaultDeclaration'; import Identifier from '../Identifier'; import * as NodeType from '../NodeType'; @@ -317,16 +316,13 @@ export default abstract class FunctionBase extends NodeBase { private functionParametersOptimized = false; include(context: InclusionContext, includeChildrenRecursively: IncludeChildren): void { - const isIIFE = - this.parent.type === NodeType.CallExpression && - (this.parent as CallExpression).callee === this; - const shoulOptimizeFunctionParameters = isIIFE || this.onlyFunctionCallUsed(); - if (shoulOptimizeFunctionParameters) { + const shouldOptimizeFunctionParameters = this.onlyFunctionCallUsed(); + if (shouldOptimizeFunctionParameters) { this.applyFunctionParameterOptimization(); } else if (this.functionParametersOptimized) { this.deoptimizeFunctionParameters(); } - this.functionParametersOptimized = shoulOptimizeFunctionParameters; + this.functionParametersOptimized = shouldOptimizeFunctionParameters; if (!this.deoptimized) this.applyDeoptimizations(); this.included = true; diff --git a/test/form/samples/tree-shake-literal-parameter/iife/_expected.js b/test/form/samples/tree-shake-literal-parameter/iife/_expected.js index 49705fc59..3e6eaeced 100644 --- a/test/form/samples/tree-shake-literal-parameter/iife/_expected.js +++ b/test/form/samples/tree-shake-literal-parameter/iife/_expected.js @@ -10,5 +10,23 @@ const result2 = (function (enable) { } })(); +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 index 468487402..844a193c3 100644 --- a/test/form/samples/tree-shake-literal-parameter/iife/main.js +++ b/test/form/samples/tree-shake-literal-parameter/iife/main.js @@ -14,5 +14,25 @@ const result2 = (function (enable) { } })(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); \ No newline at end of file +console.log(result2); +console.log(result3); +console.log(result4); diff --git a/test/function/samples/acorn-walk/_config.js b/test/function/samples/acorn-walk/_config.js new file mode 100644 index 000000000..02a5c20f5 --- /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 000000000..32da49051 --- /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); From b9a62fd4cf28538d7c3b268eb25e709b45d44cce Mon Sep 17 00:00:00 2001 From: Lukas Taegert-Atkinson Date: Tue, 23 Apr 2024 06:59:12 +0200 Subject: [PATCH 33/45] 4.16.3 --- CHANGELOG.md | 12 ++++++++++++ browser/package.json | 2 +- package-lock.json | 4 ++-- package.json | 2 +- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4b91aa9fb..02b118925 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,17 @@ # rollup changelog +## 4.16.3 + +_2024-04-23_ + +### Bug Fixes + +- Do not optimize IIFEs that have a name and are again referenced inside their definition (#5486) + +### Pull Requests + +- [#5486](https://github.com/rollup/rollup/pull/5486): fix: only optimize annoymous iife (@liuly0322) + ## 4.16.2 _2024-04-22_ diff --git a/browser/package.json b/browser/package.json index 159d7e34c..91f0a5274 100644 --- a/browser/package.json +++ b/browser/package.json @@ -1,6 +1,6 @@ { "name": "@rollup/browser", - "version": "4.16.2", + "version": "4.16.3", "description": "Next-generation ES module bundler browser build", "main": "dist/rollup.browser.js", "module": "dist/es/rollup.browser.js", diff --git a/package-lock.json b/package-lock.json index d0025451d..c12f8eaba 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "rollup", - "version": "4.16.2", + "version": "4.16.3", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "rollup", - "version": "4.16.2", + "version": "4.16.3", "license": "MIT", "dependencies": { "@types/estree": "1.0.5" diff --git a/package.json b/package.json index 2ead425cc..a1a34975a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rollup", - "version": "4.16.2", + "version": "4.16.3", "description": "Next-generation ES module bundler", "main": "dist/rollup.js", "module": "dist/es/rollup.js", From 74da135569868881001635dc6762013f23ce5613 Mon Sep 17 00:00:00 2001 From: Lukas Taegert-Atkinson Date: Tue, 23 Apr 2024 15:02:31 +0200 Subject: [PATCH 34/45] Revert function parameter tracking logic for now (#5487) --- src/ast/nodes/ArrowFunctionExpression.ts | 10 +- src/ast/nodes/ConditionalExpression.ts | 25 +-- src/ast/nodes/FunctionDeclaration.ts | 5 - src/ast/nodes/FunctionExpression.ts | 9 -- src/ast/nodes/Identifier.ts | 5 - src/ast/nodes/IfStatement.ts | 4 +- src/ast/nodes/LogicalExpression.ts | 31 ++-- src/ast/nodes/MemberExpression.ts | 7 +- src/ast/nodes/UpdateExpression.ts | 2 +- src/ast/nodes/shared/FunctionBase.ts | 145 +----------------- src/ast/variables/ExportDefaultVariable.ts | 10 -- src/ast/variables/GlobalVariable.ts | 9 +- src/ast/variables/LocalVariable.ts | 4 +- src/ast/variables/ParameterVariable.ts | 75 +-------- src/ast/variables/Variable.ts | 32 +--- .../_expected/amd/dep1.js | 5 +- .../_expected/cjs/dep1.js | 5 +- .../_expected/es/dep1.js | 5 +- .../_expected/system/dep1.js | 5 +- .../dep1.js | 3 +- .../amd/_virtual/_commonjsHelpers.js | 2 +- .../cjs/_virtual/_commonjsHelpers.js | 2 +- .../_expected/es/_virtual/_commonjsHelpers.js | 2 +- .../system/_virtual/_commonjsHelpers.js | 2 +- .../deopt-string-concatenation/_expected.js | 1 - .../deopt-string-concatenation/main.js | 1 - .../_config.js | 3 - .../_expected.js | 16 -- .../main.js | 16 -- .../samples/side-effect-h/_expected/amd.js | 1 - .../samples/side-effect-h/_expected/cjs.js | 1 - .../samples/side-effect-h/_expected/es.js | 1 - .../samples/side-effect-h/_expected/iife.js | 1 - .../samples/side-effect-h/_expected/system.js | 1 - .../samples/side-effect-h/_expected/umd.js | 1 - test/form/samples/side-effect-h/main.js | 1 - .../_expected/amd.js | 1 - .../_expected/cjs.js | 1 - .../_expected/es.js | 1 - .../_expected/iife.js | 1 - .../_expected/system.js | 1 - .../_expected/umd.js | 1 - .../side-effects-return-statements/main.js | 1 - .../samples/supports-es5-shim/_expected.js | 2 + .../samples/supports-es6-shim/_expected.js | 2 +- .../argument-assignment/_config.js | 3 - .../argument-assignment/_expected.js | 15 -- .../argument-assignment/main.js | 15 -- .../do-not-optimize/_config.js | 3 - .../do-not-optimize/_expected.js | 18 --- .../do-not-optimize/main.js | 16 -- .../expression-cache/_config.js | 3 - .../expression-cache/_expected.js | 14 -- .../expression-cache/main.js | 16 -- .../iife/_config.js | 3 - .../iife/_expected.js | 32 ---- .../tree-shake-literal-parameter/iife/main.js | 38 ----- .../import-function/_config.js | 3 - .../import-function/_expected.js | 70 --------- .../import-function/arrow_lib.js | 30 ---- .../import-function/lib.js | 37 ----- .../import-function/main.js | 17 -- .../indirect-import-function/_config.js | 3 - .../indirect-import-function/_expected.js | 14 -- .../define_and_export_default.js | 7 - .../import_then_export.js | 3 - .../import_then_export_sub.js | 5 - .../indirect-import-function/main.js | 5 - .../recursion-literal-object/_config.js | 3 - .../recursion-literal-object/_expected.js | 22 --- .../recursion-literal-object/main.js | 40 ----- .../recursion-literal/_config.js | 3 - .../recursion-literal/_expected.js | 13 -- .../recursion-literal/main.js | 13 -- .../reexport-function/_config.js | 3 - .../reexport-function/_expected.js | 7 - .../reexport-function/main.js | 3 - .../reexport-function/module1.js | 1 - .../reexport-function/module2.js | 5 - .../side-effect/_config.js | 3 - .../side-effect/_expected.js | 63 -------- .../side-effect/main.js | 71 --------- .../top-level/_config.js | 3 - .../top-level/_expected.js | 23 --- .../top-level/main.js | 23 --- .../deactivate-via-option/_expected.js | 4 +- test/function/samples/acorn-walk/_config.js | 3 - test/function/samples/acorn-walk/main.js | 26 ---- .../samples/reassigned-parameter/_config.js | 3 - .../samples/reassigned-parameter/main.js | 21 --- 90 files changed, 56 insertions(+), 1129 deletions(-) delete mode 100644 test/form/samples/request-tree-shaking-before-render/_config.js delete mode 100644 test/form/samples/request-tree-shaking-before-render/_expected.js delete mode 100644 test/form/samples/request-tree-shaking-before-render/main.js delete mode 100644 test/form/samples/tree-shake-literal-parameter/argument-assignment/_config.js delete mode 100644 test/form/samples/tree-shake-literal-parameter/argument-assignment/_expected.js delete mode 100644 test/form/samples/tree-shake-literal-parameter/argument-assignment/main.js delete mode 100644 test/form/samples/tree-shake-literal-parameter/do-not-optimize/_config.js delete mode 100644 test/form/samples/tree-shake-literal-parameter/do-not-optimize/_expected.js delete mode 100644 test/form/samples/tree-shake-literal-parameter/do-not-optimize/main.js delete mode 100644 test/form/samples/tree-shake-literal-parameter/expression-cache/_config.js delete mode 100644 test/form/samples/tree-shake-literal-parameter/expression-cache/_expected.js delete mode 100644 test/form/samples/tree-shake-literal-parameter/expression-cache/main.js delete mode 100644 test/form/samples/tree-shake-literal-parameter/iife/_config.js delete mode 100644 test/form/samples/tree-shake-literal-parameter/iife/_expected.js delete mode 100644 test/form/samples/tree-shake-literal-parameter/iife/main.js delete mode 100644 test/form/samples/tree-shake-literal-parameter/import-function/_config.js delete mode 100644 test/form/samples/tree-shake-literal-parameter/import-function/_expected.js delete mode 100644 test/form/samples/tree-shake-literal-parameter/import-function/arrow_lib.js delete mode 100644 test/form/samples/tree-shake-literal-parameter/import-function/lib.js delete mode 100644 test/form/samples/tree-shake-literal-parameter/import-function/main.js delete mode 100644 test/form/samples/tree-shake-literal-parameter/indirect-import-function/_config.js delete mode 100644 test/form/samples/tree-shake-literal-parameter/indirect-import-function/_expected.js delete mode 100644 test/form/samples/tree-shake-literal-parameter/indirect-import-function/define_and_export_default.js delete mode 100644 test/form/samples/tree-shake-literal-parameter/indirect-import-function/import_then_export.js delete mode 100644 test/form/samples/tree-shake-literal-parameter/indirect-import-function/import_then_export_sub.js delete mode 100644 test/form/samples/tree-shake-literal-parameter/indirect-import-function/main.js delete mode 100644 test/form/samples/tree-shake-literal-parameter/recursion-literal-object/_config.js delete mode 100644 test/form/samples/tree-shake-literal-parameter/recursion-literal-object/_expected.js delete mode 100644 test/form/samples/tree-shake-literal-parameter/recursion-literal-object/main.js delete mode 100644 test/form/samples/tree-shake-literal-parameter/recursion-literal/_config.js delete mode 100644 test/form/samples/tree-shake-literal-parameter/recursion-literal/_expected.js delete mode 100644 test/form/samples/tree-shake-literal-parameter/recursion-literal/main.js delete mode 100644 test/form/samples/tree-shake-literal-parameter/reexport-function/_config.js delete mode 100644 test/form/samples/tree-shake-literal-parameter/reexport-function/_expected.js delete mode 100644 test/form/samples/tree-shake-literal-parameter/reexport-function/main.js delete mode 100644 test/form/samples/tree-shake-literal-parameter/reexport-function/module1.js delete mode 100644 test/form/samples/tree-shake-literal-parameter/reexport-function/module2.js delete mode 100644 test/form/samples/tree-shake-literal-parameter/side-effect/_config.js delete mode 100644 test/form/samples/tree-shake-literal-parameter/side-effect/_expected.js delete mode 100644 test/form/samples/tree-shake-literal-parameter/side-effect/main.js delete mode 100644 test/form/samples/tree-shake-literal-parameter/top-level/_config.js delete mode 100644 test/form/samples/tree-shake-literal-parameter/top-level/_expected.js delete mode 100644 test/form/samples/tree-shake-literal-parameter/top-level/main.js delete mode 100644 test/function/samples/acorn-walk/_config.js delete mode 100644 test/function/samples/acorn-walk/main.js delete mode 100644 test/function/samples/reassigned-parameter/_config.js delete mode 100644 test/function/samples/reassigned-parameter/main.js diff --git a/src/ast/nodes/ArrowFunctionExpression.ts b/src/ast/nodes/ArrowFunctionExpression.ts index c99578c87..8bf2df385 100644 --- a/src/ast/nodes/ArrowFunctionExpression.ts +++ b/src/ast/nodes/ArrowFunctionExpression.ts @@ -5,9 +5,8 @@ import type ChildScope from '../scopes/ChildScope'; import ReturnValueScope from '../scopes/ReturnValueScope'; import { type ObjectPath } from '../utils/PathTracker'; import type BlockStatement from './BlockStatement'; -import type CallExpression from './CallExpression'; import Identifier from './Identifier'; -import * as NodeType from './NodeType'; +import type * as NodeType from './NodeType'; import { Flag, isFlagSet, setFlag } from './shared/BitFlags'; import FunctionBase from './shared/FunctionBase'; import type { ExpressionNode, IncludeChildren } from './shared/Node'; @@ -68,13 +67,6 @@ export default class ArrowFunctionExpression extends FunctionBase { return false; } - protected onlyFunctionCallUsed(): boolean { - const isIIFE = - this.parent.type === NodeType.CallExpression && - (this.parent as CallExpression).callee === this; - return isIIFE || super.onlyFunctionCallUsed(); - } - include(context: InclusionContext, includeChildrenRecursively: IncludeChildren): void { super.include(context, includeChildrenRecursively); for (const parameter of this.params) { diff --git a/src/ast/nodes/ConditionalExpression.ts b/src/ast/nodes/ConditionalExpression.ts index 68ba5be14..5645a23f9 100644 --- a/src/ast/nodes/ConditionalExpression.ts +++ b/src/ast/nodes/ConditionalExpression.ts @@ -1,5 +1,5 @@ import type MagicString from 'magic-string'; -import { BLANK } from '../../utils/blank'; +import { BLANK, EMPTY_ARRAY } from '../../utils/blank'; import type { NodeRenderOptions, RenderOptions } from '../../utils/renderHelpers'; import { findFirstOccurrenceOutsideComment, @@ -46,26 +46,15 @@ export default class ConditionalExpression extends NodeBase implements Deoptimiz } deoptimizeCache(): void { - if ( - this.usedBranch || - this.isBranchResolutionAnalysed || - this.expressionsToBeDeoptimized.length > 0 - ) { - // Request another pass because we need to ensure "include" runs again if it is rendered - this.scope.context.requestTreeshakingPass(); - } - const { expressionsToBeDeoptimized } = this; - if (expressionsToBeDeoptimized.length > 0) { - this.expressionsToBeDeoptimized = []; - for (const expression of expressionsToBeDeoptimized) { - expression.deoptimizeCache(); - } - } - this.isBranchResolutionAnalysed = false; if (this.usedBranch !== null) { const unusedBranch = this.usedBranch === this.consequent ? this.alternate : this.consequent; this.usedBranch = null; unusedBranch.deoptimizePath(UNKNOWN_PATH); + const { expressionsToBeDeoptimized } = this; + this.expressionsToBeDeoptimized = EMPTY_ARRAY as unknown as DeoptimizableEntity[]; + for (const expression of expressionsToBeDeoptimized) { + expression.deoptimizeCache(); + } } } @@ -84,9 +73,9 @@ export default class ConditionalExpression extends NodeBase implements Deoptimiz recursionTracker: PathTracker, origin: DeoptimizableEntity ): LiteralValueOrUnknown { - this.expressionsToBeDeoptimized.push(origin); const usedBranch = this.getUsedBranch(); if (!usedBranch) return UnknownValue; + this.expressionsToBeDeoptimized.push(origin); return usedBranch.getLiteralValueAtPath(path, recursionTracker, origin); } diff --git a/src/ast/nodes/FunctionDeclaration.ts b/src/ast/nodes/FunctionDeclaration.ts index 9cfa8b21b..4f75fce15 100644 --- a/src/ast/nodes/FunctionDeclaration.ts +++ b/src/ast/nodes/FunctionDeclaration.ts @@ -14,11 +14,6 @@ export default class FunctionDeclaration extends FunctionNode { } } - 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 Identifier(this, this.scope.parent as ChildScope).parseNode( diff --git a/src/ast/nodes/FunctionExpression.ts b/src/ast/nodes/FunctionExpression.ts index 85b2b5cb4..be7c5e431 100644 --- a/src/ast/nodes/FunctionExpression.ts +++ b/src/ast/nodes/FunctionExpression.ts @@ -2,7 +2,6 @@ import type MagicString from 'magic-string'; import { BLANK } from '../../utils/blank'; 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'; @@ -26,14 +25,6 @@ export default class FunctionExpression extends FunctionNode { 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, diff --git a/src/ast/nodes/Identifier.ts b/src/ast/nodes/Identifier.ts index 8b13ea5b6..11147f3fb 100644 --- a/src/ast/nodes/Identifier.ts +++ b/src/ast/nodes/Identifier.ts @@ -60,12 +60,10 @@ export default class Identifier extends NodeBase implements PatternNode { } } - private isReferenceVariable = false; bind(): void { if (!this.variable && isReference(this, this.parent as NodeWithFieldDefinition)) { this.variable = this.scope.findVariable(this.name); this.variable.addReference(this); - this.isReferenceVariable = true; } } @@ -297,9 +295,6 @@ export default class Identifier extends NodeBase implements PatternNode { this.variable.consolidateInitializers(); this.scope.context.requestTreeshakingPass(); } - if (this.isReferenceVariable) { - this.variable!.addUsedPlace(this); - } } private getVariableRespectingTDZ(): ExpressionEntity | null { diff --git a/src/ast/nodes/IfStatement.ts b/src/ast/nodes/IfStatement.ts index 375c4eeaf..07651843b 100644 --- a/src/ast/nodes/IfStatement.ts +++ b/src/ast/nodes/IfStatement.ts @@ -7,7 +7,7 @@ import { EMPTY_PATH, SHARED_RECURSION_TRACKER } from '../utils/PathTracker'; import BlockStatement from './BlockStatement'; import type Identifier from './Identifier'; import * as NodeType from './NodeType'; -import { type LiteralValueOrUnknown } from './shared/Expression'; +import { type LiteralValueOrUnknown, UnknownValue } from './shared/Expression'; import { type ExpressionNode, type GenericEsTreeNode, @@ -29,7 +29,7 @@ export default class IfStatement extends StatementBase implements DeoptimizableE private testValue: LiteralValueOrUnknown | typeof unset = unset; deoptimizeCache(): void { - this.testValue = unset; + this.testValue = UnknownValue; } hasEffects(context: HasEffectsContext): boolean { diff --git a/src/ast/nodes/LogicalExpression.ts b/src/ast/nodes/LogicalExpression.ts index ee8873151..55de14861 100644 --- a/src/ast/nodes/LogicalExpression.ts +++ b/src/ast/nodes/LogicalExpression.ts @@ -1,5 +1,5 @@ import type MagicString from 'magic-string'; -import { BLANK } from '../../utils/blank'; +import { BLANK, EMPTY_ARRAY } from '../../utils/blank'; import { findFirstOccurrenceOutsideComment, findNonWhiteSpace, @@ -57,26 +57,21 @@ export default class LogicalExpression extends NodeBase implements Deoptimizable } deoptimizeCache(): void { - if ( - this.usedBranch || - this.isBranchResolutionAnalysed || - this.expressionsToBeDeoptimized.length > 0 - ) { - // Request another pass because we need to ensure "include" runs again if it is rendered - this.scope.context.requestTreeshakingPass(); - } - const { expressionsToBeDeoptimized } = this; - if (expressionsToBeDeoptimized.length > 0) { - this.expressionsToBeDeoptimized = []; - for (const expression of expressionsToBeDeoptimized) { - expression.deoptimizeCache(); - } - } - this.isBranchResolutionAnalysed = false; if (this.usedBranch) { const unusedBranch = this.usedBranch === this.left ? this.right : this.left; this.usedBranch = null; unusedBranch.deoptimizePath(UNKNOWN_PATH); + 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(); } } @@ -95,9 +90,9 @@ export default class LogicalExpression extends NodeBase implements Deoptimizable recursionTracker: PathTracker, origin: DeoptimizableEntity ): LiteralValueOrUnknown { - this.expressionsToBeDeoptimized.push(origin); const usedBranch = this.getUsedBranch(); if (!usedBranch) return UnknownValue; + this.expressionsToBeDeoptimized.push(origin); return usedBranch.getLiteralValueAtPath(path, recursionTracker, origin); } diff --git a/src/ast/nodes/MemberExpression.ts b/src/ast/nodes/MemberExpression.ts index cb2bf1d3b..5c32a896b 100644 --- a/src/ast/nodes/MemberExpression.ts +++ b/src/ast/nodes/MemberExpression.ts @@ -1,7 +1,7 @@ import type MagicString from 'magic-string'; import type { AstContext } from '../../Module'; import type { NormalizedTreeshakingOptions } from '../../rollup/types'; -import { BLANK } from '../../utils/blank'; +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'; @@ -185,7 +185,7 @@ export default class MemberExpression deoptimizeCache(): void { const { expressionsToBeDeoptimized, object } = this; - this.expressionsToBeDeoptimized = []; + this.expressionsToBeDeoptimized = EMPTY_ARRAY as unknown as DeoptimizableEntity[]; this.propertyKey = UnknownKey; object.deoptimizePath(UNKNOWN_PATH); for (const expression of expressionsToBeDeoptimized) { @@ -396,9 +396,6 @@ export default class MemberExpression ); this.scope.context.requestTreeshakingPass(); } - if (this.variable) { - this.variable.addUsedPlace(this); - } } private applyAssignmentDeoptimization(): void { diff --git a/src/ast/nodes/UpdateExpression.ts b/src/ast/nodes/UpdateExpression.ts index 860bdd927..2d7b0613f 100644 --- a/src/ast/nodes/UpdateExpression.ts +++ b/src/ast/nodes/UpdateExpression.ts @@ -87,7 +87,7 @@ export default class UpdateExpression extends NodeBase { this.argument.deoptimizePath(EMPTY_PATH); if (this.argument instanceof Identifier) { const variable = this.scope.findVariable(this.argument.name); - variable.markReassigned(); + variable.isReassigned = true; } this.scope.context.requestTreeshakingPass(); } diff --git a/src/ast/nodes/shared/FunctionBase.ts b/src/ast/nodes/shared/FunctionBase.ts index 50fa44110..55b9f7f3d 100644 --- a/src/ast/nodes/shared/FunctionBase.ts +++ b/src/ast/nodes/shared/FunctionBase.ts @@ -9,22 +9,12 @@ import { } from '../../NodeInteractions'; import type ReturnValueScope from '../../scopes/ReturnValueScope'; import type { ObjectPath, PathTracker } from '../../utils/PathTracker'; -import { - EMPTY_PATH, - SHARED_RECURSION_TRACKER, - UNKNOWN_PATH, - UnknownKey -} from '../../utils/PathTracker'; -import { UNDEFINED_EXPRESSION } from '../../values'; +import { UNKNOWN_PATH, UnknownKey } from '../../utils/PathTracker'; import type ParameterVariable from '../../variables/ParameterVariable'; -import type Variable from '../../variables/Variable'; import BlockStatement from '../BlockStatement'; -import type ExportDefaultDeclaration from '../ExportDefaultDeclaration'; import Identifier from '../Identifier'; -import * as NodeType from '../NodeType'; import RestElement from '../RestElement'; import type SpreadElement from '../SpreadElement'; -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'; @@ -37,13 +27,6 @@ import { import type { ObjectEntity } from './ObjectEntity'; import type { PatternNode } from './Pattern'; -type InteractionCalledArguments = NodeInteractionCalled['args']; - -// This handler does nothing. -// Since we always re-evaluate argument values in a new tree-shaking pass, -// we don't need to get notified if it is deoptimized. -const EMPTY_DEOPTIMIZABLE_HANDLER = { deoptimizeCache() {} }; - export default abstract class FunctionBase extends NodeBase { declare body: BlockStatement | ExpressionNode; declare params: PatternNode[]; @@ -74,107 +57,6 @@ export default abstract class FunctionBase extends NodeBase { this.flags = setFlag(this.flags, Flag.generator, value); } - private knownParameterValues: (ExpressionEntity | undefined)[] = []; - private allArguments: InteractionCalledArguments[] = []; - /** - * update knownParameterValues when a call is made to this function - * @param newArguments arguments of the call - */ - private updateKnownParameterValues(newArguments: InteractionCalledArguments): void { - for (let position = 0; position < this.params.length; position++) { - // only the "this" argument newArguments[0] can be null - // it's possible that some arguments are empty, so the value is undefined - const argument = newArguments[position + 1] ?? UNDEFINED_EXPRESSION; - const parameter = this.params[position]; - // RestElement can be, and can only be, the last parameter - if (parameter instanceof RestElement) { - return; - } - - const knownParameterValue = this.knownParameterValues[position]; - if (knownParameterValue === undefined) { - this.knownParameterValues[position] = argument; - continue; - } - if ( - knownParameterValue === UNKNOWN_EXPRESSION || - knownParameterValue === argument || - (knownParameterValue instanceof Identifier && - argument instanceof Identifier && - knownParameterValue.variable === argument.variable) - ) { - continue; - } - - const oldValue = knownParameterValue.getLiteralValueAtPath( - EMPTY_PATH, - SHARED_RECURSION_TRACKER, - EMPTY_DEOPTIMIZABLE_HANDLER - ); - const newValue = argument.getLiteralValueAtPath( - EMPTY_PATH, - SHARED_RECURSION_TRACKER, - EMPTY_DEOPTIMIZABLE_HANDLER - ); - if (oldValue !== newValue || typeof oldValue === 'symbol') { - this.knownParameterValues[position] = UNKNOWN_EXPRESSION; - } // else both are the same literal, no need to update - } - } - - private forwardArgumentsForFunctionCalledOnce(newArguments: InteractionCalledArguments): void { - for (let position = 0; position < this.params.length; position++) { - const parameter = this.params[position]; - if (parameter instanceof Identifier) { - const ParameterVariable = parameter.variable as ParameterVariable | null; - const argument = newArguments[position + 1] ?? UNDEFINED_EXPRESSION; - ParameterVariable?.setKnownValue(argument); - } - } - } - - /** - * each time tree-shake starts, this method should be called to reoptimize the parameters - * a parameter's state will change at most twice: - * `undefined` (no call is made) -> an expression -> `UnknownArgument` - * we are sure it will converge, and can use state from last iteration - */ - private applyFunctionParameterOptimization() { - if (this.allArguments.length === 0) { - return; - } - - if (this.allArguments.length === 1) { - // we are sure what knownParameterValues will be, so skip it and do setKnownValue - this.forwardArgumentsForFunctionCalledOnce(this.allArguments[0]); - return; - } - - // reoptimize all arguments, that's why we save them - for (const argumentsList of this.allArguments) { - this.updateKnownParameterValues(argumentsList); - } - for (let position = 0; position < this.params.length; position++) { - const parameter = this.params[position]; - // Parameters without default values - if (parameter instanceof Identifier) { - const parameterVariable = parameter.variable as ParameterVariable | null; - // Only the RestElement may be undefined - const knownParameterValue = this.knownParameterValues[position]!; - parameterVariable?.setKnownValue(knownParameterValue); - } - } - } - - private deoptimizeFunctionParameters() { - for (const parameter of this.params) { - if (parameter instanceof Identifier) { - const parameterVariable = parameter.variable as ParameterVariable | null; - parameterVariable?.markReassigned(); - } - } - } - protected objectEntity: ObjectEntity | null = null; deoptimizeArgumentsOnInteractionAtPath( @@ -202,7 +84,6 @@ export default abstract class FunctionBase extends NodeBase { this.addArgumentToBeDeoptimized(argument); } } - this.allArguments.push(args); } else { this.getObjectEntity().deoptimizeArgumentsOnInteractionAtPath( interaction, @@ -221,7 +102,6 @@ export default abstract class FunctionBase extends NodeBase { for (const parameterList of this.scope.parameters) { for (const parameter of parameterList) { parameter.deoptimizePath(UNKNOWN_PATH); - parameter.markReassigned(); } } } @@ -300,30 +180,7 @@ export default abstract class FunctionBase extends NodeBase { 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 functionParametersOptimized = false; include(context: InclusionContext, includeChildrenRecursively: IncludeChildren): void { - const shouldOptimizeFunctionParameters = this.onlyFunctionCallUsed(); - if (shouldOptimizeFunctionParameters) { - this.applyFunctionParameterOptimization(); - } else if (this.functionParametersOptimized) { - this.deoptimizeFunctionParameters(); - } - this.functionParametersOptimized = shouldOptimizeFunctionParameters; - if (!this.deoptimized) this.applyDeoptimizations(); this.included = true; const { brokenFlow } = context; diff --git a/src/ast/variables/ExportDefaultVariable.ts b/src/ast/variables/ExportDefaultVariable.ts index 70810936e..979405b57 100644 --- a/src/ast/variables/ExportDefaultVariable.ts +++ b/src/ast/variables/ExportDefaultVariable.ts @@ -3,7 +3,6 @@ import ClassDeclaration from '../nodes/ClassDeclaration'; import type ExportDefaultDeclaration from '../nodes/ExportDefaultDeclaration'; import FunctionDeclaration from '../nodes/FunctionDeclaration'; import Identifier, { type IdentifierWithVariable } from '../nodes/Identifier'; -import type { NodeBase } from '../nodes/shared/Node'; import LocalVariable from './LocalVariable'; import UndefinedVariable from './UndefinedVariable'; import type Variable from './Variable'; @@ -38,15 +37,6 @@ export default class ExportDefaultVariable extends LocalVariable { } } - addUsedPlace(usedPlace: NodeBase): void { - const original = this.getOriginalVariable(); - if (original === this) { - super.addUsedPlace(usedPlace); - } else { - original.addUsedPlace(usedPlace); - } - } - forbidName(name: string) { const original = this.getOriginalVariable(); if (original === this) { diff --git a/src/ast/variables/GlobalVariable.ts b/src/ast/variables/GlobalVariable.ts index 4f168ac8f..d55ed63ae 100644 --- a/src/ast/variables/GlobalVariable.ts +++ b/src/ast/variables/GlobalVariable.ts @@ -13,12 +13,9 @@ import type { ObjectPath, PathTracker } from '../utils/PathTracker'; import Variable from './Variable'; export default class GlobalVariable extends Variable { - constructor(name: string) { - super(name); - // Ensure we use live-bindings for globals as we do not know if they have - // been reassigned - this.markReassigned(); - } + // Ensure we use live-bindings for globals as we do not know if they have + // been reassigned + isReassigned = true; deoptimizeArgumentsOnInteractionAtPath( interaction: NodeInteraction, diff --git a/src/ast/variables/LocalVariable.ts b/src/ast/variables/LocalVariable.ts index 83b32a81e..fe5bd4884 100644 --- a/src/ast/variables/LocalVariable.ts +++ b/src/ast/variables/LocalVariable.ts @@ -91,7 +91,7 @@ export default class LocalVariable extends Variable { return; } if (path.length === 0) { - this.markReassigned(); + this.isReassigned = true; const expressionsToBeDeoptimized = this.expressionsToBeDeoptimized; this.expressionsToBeDeoptimized = EMPTY_ARRAY as unknown as DeoptimizableEntity[]; for (const expression of expressionsToBeDeoptimized) { @@ -222,7 +222,7 @@ export default class LocalVariable extends Variable { if (this.additionalInitializers === null) { this.additionalInitializers = [this.init]; this.init = UNKNOWN_EXPRESSION; - this.markReassigned(); + this.isReassigned = true; } return this.additionalInitializers; } diff --git a/src/ast/variables/ParameterVariable.ts b/src/ast/variables/ParameterVariable.ts index fa62eb400..94f3feb90 100644 --- a/src/ast/variables/ParameterVariable.ts +++ b/src/ast/variables/ParameterVariable.ts @@ -1,17 +1,14 @@ import type { AstContext } from '../../Module'; import { EMPTY_ARRAY } from '../../utils/blank'; -import type { DeoptimizableEntity } from '../DeoptimizableEntity'; -import type { HasEffectsContext } from '../ExecutionContext'; import type { NodeInteraction } from '../NodeInteractions'; -import { INTERACTION_ASSIGNED, INTERACTION_CALLED } from '../NodeInteractions'; +import { INTERACTION_CALLED } from '../NodeInteractions'; import type ExportDefaultDeclaration from '../nodes/ExportDefaultDeclaration'; import type Identifier from '../nodes/Identifier'; -import type { ExpressionEntity, LiteralValueOrUnknown } from '../nodes/shared/Expression'; +import type { ExpressionEntity } from '../nodes/shared/Expression'; import { deoptimizeInteraction, UNKNOWN_EXPRESSION, - UNKNOWN_RETURN_EXPRESSION, - UnknownValue + UNKNOWN_RETURN_EXPRESSION } from '../nodes/shared/Expression'; import type { ObjectPath, ObjectPathKey } from '../utils/PathTracker'; import { @@ -38,7 +35,6 @@ export default class ParameterVariable extends LocalVariable { private deoptimizations = new PathTracker(); private deoptimizedFields = new Set(); private entitiesToBeDeoptimized = new Set(); - private knownExpressionsToBeDeoptimized: DeoptimizableEntity[] = []; constructor( name: string, @@ -75,65 +71,6 @@ export default class ParameterVariable extends LocalVariable { } } - markReassigned(): void { - if (this.isReassigned) { - return; - } - super.markReassigned(); - for (const expression of this.knownExpressionsToBeDeoptimized) { - expression.deoptimizeCache(); - } - this.knownExpressionsToBeDeoptimized = []; - } - - private knownValue: ExpressionEntity = UNKNOWN_EXPRESSION; - /** - * If we are sure about the value of this parameter, we can set it here. - * It can be a literal or the only possible value of the parameter. - * an undefined value means that the parameter is not known. - * @param value The known value of the parameter to be set. - */ - setKnownValue(value: ExpressionEntity): void { - if (this.isReassigned) { - return; - } - if (this.knownValue !== value) { - for (const expression of this.knownExpressionsToBeDeoptimized) { - expression.deoptimizeCache(); - } - this.knownExpressionsToBeDeoptimized = []; - } - this.knownValue = value; - } - - getLiteralValueAtPath( - path: ObjectPath, - recursionTracker: PathTracker, - origin: DeoptimizableEntity - ): LiteralValueOrUnknown { - if (this.isReassigned) { - return UnknownValue; - } - this.knownExpressionsToBeDeoptimized.push(origin); - return recursionTracker.withTrackedEntityAtPath( - path, - this.knownValue, - () => this.knownValue!.getLiteralValueAtPath(path, recursionTracker, origin), - UnknownValue - ); - } - - hasEffectsOnInteractionAtPath( - path: ObjectPath, - interaction: NodeInteraction, - context: HasEffectsContext - ): boolean { - // assigned is a bit different, since the value has a new name (the parameter) - return interaction.type === INTERACTION_ASSIGNED - ? super.hasEffectsOnInteractionAtPath(path, interaction, context) - : this.knownValue.hasEffectsOnInteractionAtPath(path, interaction, context); - } - deoptimizeArgumentsOnInteractionAtPath(interaction: NodeInteraction, path: ObjectPath): void { // For performance reasons, we fully deoptimize all deeper interactions if ( @@ -161,11 +98,7 @@ export default class ParameterVariable extends LocalVariable { } deoptimizePath(path: ObjectPath): void { - if (path.length === 0) { - this.markReassigned(); - return; - } - if (this.deoptimizedFields.has(UnknownKey)) { + if (path.length === 0 || this.deoptimizedFields.has(UnknownKey)) { return; } const key = path[0]; diff --git a/src/ast/variables/Variable.ts b/src/ast/variables/Variable.ts index e22fe48b0..521ff1f9b 100644 --- a/src/ast/variables/Variable.ts +++ b/src/ast/variables/Variable.ts @@ -4,11 +4,8 @@ import type { RenderOptions } from '../../utils/renderHelpers'; import type { HasEffectsContext } from '../ExecutionContext'; import type { NodeInteraction } from '../NodeInteractions'; import { INTERACTION_ACCESSED } from '../NodeInteractions'; -import type CallExpression from '../nodes/CallExpression'; import type Identifier from '../nodes/Identifier'; -import * as NodeType from '../nodes/NodeType'; import { ExpressionEntity } from '../nodes/shared/Expression'; -import type { NodeBase } from '../nodes/shared/Node'; import type { VariableKind } from '../nodes/shared/VariableKinds'; import type { ObjectPath } from '../utils/PathTracker'; @@ -19,6 +16,7 @@ export default class Variable extends ExpressionEntity { isId = false; // both NamespaceVariable and ExternalVariable can be namespaces declare isNamespace?: boolean; + isReassigned = false; kind: VariableKind | null = null; declare module?: Module | ExternalModule; renderBaseName: string | null = null; @@ -26,11 +24,6 @@ export default class Variable extends ExpressionEntity { private renderedLikeHoisted?: Variable; - readonly isReassigned = false; - markReassigned() { - (this as { isReassigned: boolean }).isReassigned = true; - } - constructor(public name: string) { super(); } @@ -41,29 +34,6 @@ export default class Variable extends ExpressionEntity { */ addReference(_identifier: Identifier): void {} - private onlyFunctionCallUsed = true; - /** - * Check if the identifier variable is only used as function call - * Forward the check to the export default variable if it is only used once - * @returns true if the variable is only used as function call - */ - getOnlyFunctionCallUsed(): boolean { - return this.onlyFunctionCallUsed; - } - - /** - * 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; - } - } - /** * Prevent this variable from being renamed to this name to avoid name * collisions 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 c0bb33a62..1ebb9552c 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 @@ -5,13 +5,12 @@ define(['exports'], (function (exports) { 'use strict'; console.log('This is the output when a missing export is used internally but not reexported'); function almostUseUnused(useIt) { - { - console.log(useIt); + if (useIt) { console.log(_missingExportShim); } } - almostUseUnused(true); + almostUseUnused(false); exports.missing1 = _missingExportShim; 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 31b08b56a..a024bcd6f 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 @@ -5,12 +5,11 @@ var _missingExportShim = void 0; console.log('This is the output when a missing export is used internally but not reexported'); function almostUseUnused(useIt) { - { - console.log(useIt); + if (useIt) { console.log(_missingExportShim); } } -almostUseUnused(true); +almostUseUnused(false); exports.missing1 = _missingExportShim; 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 d9c8b65f0..99f4196bf 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,12 +3,11 @@ var _missingExportShim = void 0; console.log('This is the output when a missing export is used internally but not reexported'); function almostUseUnused(useIt) { - { - console.log(useIt); + if (useIt) { console.log(_missingExportShim); } } -almostUseUnused(true); +almostUseUnused(false); 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 24aa7ab54..fb77b0059 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 @@ -8,13 +8,12 @@ System.register([], (function (exports) { console.log('This is the output when a missing export is used internally but not reexported'); function almostUseUnused(useIt) { - { - console.log(useIt); + if (useIt) { console.log(_missingExportShim); } } - almostUseUnused(true); + almostUseUnused(false); exports("missing1", _missingExportShim); 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 f0751ef4c..84e22e0fe 100644 --- a/test/chunking-form/samples/missing-export-reused-deconflicting/dep1.js +++ b/test/chunking-form/samples/missing-export-reused-deconflicting/dep1.js @@ -2,9 +2,8 @@ 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(true); +almostUseUnused(false); 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 index 25ed6cf37..f35ac4ef0 100644 --- 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 @@ -1,7 +1,7 @@ define(['exports'], (function (exports) { 'use strict'; function getDefaultExportFromCjs (x) { - return x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : 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/_commonjsHelpers.js b/test/chunking-form/samples/preserve-modules-commonjs/_expected/cjs/_virtual/_commonjsHelpers.js index fc314aed4..ceeaa4d07 100644 --- 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 @@ -1,7 +1,7 @@ 'use strict'; function getDefaultExportFromCjs (x) { - return x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : 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/es/_virtual/_commonjsHelpers.js b/test/chunking-form/samples/preserve-modules-commonjs/_expected/es/_virtual/_commonjsHelpers.js index 5fea8b909..7b7c5f4f5 100644 --- 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 @@ -1,5 +1,5 @@ function getDefaultExportFromCjs (x) { - return x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : 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/system/_virtual/_commonjsHelpers.js b/test/chunking-form/samples/preserve-modules-commonjs/_expected/system/_virtual/_commonjsHelpers.js index 15f3676f9..dd2c5886a 100644 --- 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 @@ -6,7 +6,7 @@ System.register([], (function (exports) { exports("getDefaultExportFromCjs", getDefaultExportFromCjs); function getDefaultExportFromCjs (x) { - return x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; } }) diff --git a/test/form/samples/deopt-string-concatenation/_expected.js b/test/form/samples/deopt-string-concatenation/_expected.js index 42785de73..68a30dc4f 100644 --- a/test/form/samples/deopt-string-concatenation/_expected.js +++ b/test/form/samples/deopt-string-concatenation/_expected.js @@ -9,4 +9,3 @@ 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 42785de73..68a30dc4f 100644 --- a/test/form/samples/deopt-string-concatenation/main.js +++ b/test/form/samples/deopt-string-concatenation/main.js @@ -9,4 +9,3 @@ function parseInt(str, radix) { } console.log(parseInt('1')); -console.log(parseInt(Symbol('1'))); diff --git a/test/form/samples/request-tree-shaking-before-render/_config.js b/test/form/samples/request-tree-shaking-before-render/_config.js deleted file mode 100644 index 00d3b4e06..000000000 --- a/test/form/samples/request-tree-shaking-before-render/_config.js +++ /dev/null @@ -1,3 +0,0 @@ -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 deleted file mode 100644 index f02682756..000000000 --- a/test/form/samples/request-tree-shaking-before-render/_expected.js +++ /dev/null @@ -1,16 +0,0 @@ -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 deleted file mode 100644 index 85b8d4935..000000000 --- a/test/form/samples/request-tree-shaking-before-render/main.js +++ /dev/null @@ -1,16 +0,0 @@ -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/side-effect-h/_expected/amd.js b/test/form/samples/side-effect-h/_expected/amd.js index e46b7cd7c..d3a055b34 100644 --- a/test/form/samples/side-effect-h/_expected/amd.js +++ b/test/form/samples/side-effect-h/_expected/amd.js @@ -7,7 +7,6 @@ define((function () { 'use strict'; } foo(); - foo(true); var main = 42; diff --git a/test/form/samples/side-effect-h/_expected/cjs.js b/test/form/samples/side-effect-h/_expected/cjs.js index 4862e7aa0..1d437295c 100644 --- a/test/form/samples/side-effect-h/_expected/cjs.js +++ b/test/form/samples/side-effect-h/_expected/cjs.js @@ -7,7 +7,6 @@ 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 39c215e33..1d5410d07 100644 --- a/test/form/samples/side-effect-h/_expected/es.js +++ b/test/form/samples/side-effect-h/_expected/es.js @@ -5,7 +5,6 @@ function foo ( ok ) { } foo(); -foo(true); var main = 42; diff --git a/test/form/samples/side-effect-h/_expected/iife.js b/test/form/samples/side-effect-h/_expected/iife.js index b6fc61fb4..083d37914 100644 --- a/test/form/samples/side-effect-h/_expected/iife.js +++ b/test/form/samples/side-effect-h/_expected/iife.js @@ -8,7 +8,6 @@ var myBundle = (function () { } foo(); - foo(true); var main = 42; diff --git a/test/form/samples/side-effect-h/_expected/system.js b/test/form/samples/side-effect-h/_expected/system.js index 6ace3fb0f..dcb761aa7 100644 --- a/test/form/samples/side-effect-h/_expected/system.js +++ b/test/form/samples/side-effect-h/_expected/system.js @@ -10,7 +10,6 @@ System.register('myBundle', [], (function (exports) { } foo(); - foo(true); 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 f72ccce31..770859846 100644 --- a/test/form/samples/side-effect-h/_expected/umd.js +++ b/test/form/samples/side-effect-h/_expected/umd.js @@ -11,7 +11,6 @@ } foo(); - foo(true); var main = 42; diff --git a/test/form/samples/side-effect-h/main.js b/test/form/samples/side-effect-h/main.js index b736c13f9..16d734691 100644 --- a/test/form/samples/side-effect-h/main.js +++ b/test/form/samples/side-effect-h/main.js @@ -5,6 +5,5 @@ function foo ( ok ) { } foo(); -foo(true); export default 42; 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 1633b0ab0..dcdb995d3 100644 --- a/test/form/samples/side-effects-return-statements/_expected/amd.js +++ b/test/form/samples/side-effects-return-statements/_expected/amd.js @@ -8,6 +8,5 @@ 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 93d4ccf36..7dd6e8130 100644 --- a/test/form/samples/side-effects-return-statements/_expected/cjs.js +++ b/test/form/samples/side-effects-return-statements/_expected/cjs.js @@ -8,4 +8,3 @@ 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 9898b0d0f..38f357c97 100644 --- a/test/form/samples/side-effects-return-statements/_expected/es.js +++ b/test/form/samples/side-effects-return-statements/_expected/es.js @@ -6,4 +6,3 @@ 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 81b64ec81..c9da6fbbc 100644 --- a/test/form/samples/side-effects-return-statements/_expected/iife.js +++ b/test/form/samples/side-effects-return-statements/_expected/iife.js @@ -9,6 +9,5 @@ } 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 096bcc73f..968b34163 100644 --- a/test/form/samples/side-effects-return-statements/_expected/system.js +++ b/test/form/samples/side-effects-return-statements/_expected/system.js @@ -11,7 +11,6 @@ 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 fc3ff304a..97a5be316 100644 --- a/test/form/samples/side-effects-return-statements/_expected/umd.js +++ b/test/form/samples/side-effects-return-statements/_expected/umd.js @@ -11,6 +11,5 @@ } 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 a1e68e5d6..8e6b3b54f 100644 --- a/test/form/samples/side-effects-return-statements/main.js +++ b/test/form/samples/side-effects-return-statements/main.js @@ -15,4 +15,3 @@ function isUsed ( x ) { } assert.equal( isUsed( true ), 2 ); -assert.equal( isUsed( false ), 1 ); diff --git a/test/form/samples/supports-es5-shim/_expected.js b/test/form/samples/supports-es5-shim/_expected.js index 645169277..bc68debf9 100644 --- a/test/form/samples/supports-es5-shim/_expected.js +++ b/test/form/samples/supports-es5-shim/_expected.js @@ -2202,6 +2202,7 @@ var es5Shim = {exports: {}}; // eslint-disable-next-line no-global-assign, no-implicit-globals parseInt = (function (origParseInt) { return function parseInt(str, radix) { + if (this instanceof parseInt) { new origParseInt(); } // eslint-disable-line new-cap, no-new, max-statements-per-line var string = trim(String(str)); var defaultedRadix = $Number(radix) || (hexRegex.test(string) ? 16 : 10); return origParseInt(string, defaultedRadix); @@ -2232,6 +2233,7 @@ var es5Shim = {exports: {}}; // eslint-disable-next-line no-global-assign, no-implicit-globals parseInt = (function (origParseInt) { return function parseInt(str, radix) { + if (this instanceof parseInt) { new origParseInt(); } // eslint-disable-line new-cap, no-new, max-statements-per-line var isSym = typeof str === 'symbol'; if (!isSym && str && typeof str === 'object') { try { diff --git a/test/form/samples/supports-es6-shim/_expected.js b/test/form/samples/supports-es6-shim/_expected.js index 84fb3b7f0..ae2951820 100644 --- a/test/form/samples/supports-es6-shim/_expected.js +++ b/test/form/samples/supports-es6-shim/_expected.js @@ -2057,7 +2057,7 @@ var es6Shim = {exports: {}}; }; var withinULPDistance = function withinULPDistance(result, expected, distance) { - return _abs(1 - (result / expected)) / Number.EPSILON < (8); + return _abs(1 - (result / expected)) / Number.EPSILON < (distance || 8); }; defineProperties(Math, MathShims); 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 deleted file mode 100644 index 1a210baea..000000000 --- a/test/form/samples/tree-shake-literal-parameter/argument-assignment/_config.js +++ /dev/null @@ -1,3 +0,0 @@ -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 deleted file mode 100644 index f7cb2c16d..000000000 --- a/test/form/samples/tree-shake-literal-parameter/argument-assignment/_expected.js +++ /dev/null @@ -1,15 +0,0 @@ -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 deleted file mode 100644 index d9b364653..000000000 --- a/test/form/samples/tree-shake-literal-parameter/argument-assignment/main.js +++ /dev/null @@ -1,15 +0,0 @@ -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 deleted file mode 100644 index d16519b09..000000000 --- a/test/form/samples/tree-shake-literal-parameter/do-not-optimize/_config.js +++ /dev/null @@ -1,3 +0,0 @@ -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 deleted file mode 100644 index 8e1230c75..000000000 --- a/test/form/samples/tree-shake-literal-parameter/do-not-optimize/_expected.js +++ /dev/null @@ -1,18 +0,0 @@ -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 deleted file mode 100644 index 079d60a1b..000000000 --- a/test/form/samples/tree-shake-literal-parameter/do-not-optimize/main.js +++ /dev/null @@ -1,16 +0,0 @@ -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 deleted file mode 100644 index 697aea54b..000000000 --- a/test/form/samples/tree-shake-literal-parameter/expression-cache/_config.js +++ /dev/null @@ -1,3 +0,0 @@ -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 deleted file mode 100644 index 8cee56182..000000000 --- a/test/form/samples/tree-shake-literal-parameter/expression-cache/_expected.js +++ /dev/null @@ -1,14 +0,0 @@ -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 deleted file mode 100644 index 4c1f739a1..000000000 --- a/test/form/samples/tree-shake-literal-parameter/expression-cache/main.js +++ /dev/null @@ -1,16 +0,0 @@ -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 deleted file mode 100644 index 789458177..000000000 --- a/test/form/samples/tree-shake-literal-parameter/iife/_config.js +++ /dev/null @@ -1,3 +0,0 @@ -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 deleted file mode 100644 index 3e6eaeced..000000000 --- a/test/form/samples/tree-shake-literal-parameter/iife/_expected.js +++ /dev/null @@ -1,32 +0,0 @@ -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 deleted file mode 100644 index 844a193c3..000000000 --- a/test/form/samples/tree-shake-literal-parameter/iife/main.js +++ /dev/null @@ -1,38 +0,0 @@ -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 deleted file mode 100644 index e4a54b5f9..000000000 --- a/test/form/samples/tree-shake-literal-parameter/import-function/_config.js +++ /dev/null @@ -1,3 +0,0 @@ -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 deleted file mode 100644 index f9d8a0fd9..000000000 --- a/test/form/samples/tree-shake-literal-parameter/import-function/_expected.js +++ /dev/null @@ -1,70 +0,0 @@ -// 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 deleted file mode 100644 index 8b85efc44..000000000 --- a/test/form/samples/tree-shake-literal-parameter/import-function/arrow_lib.js +++ /dev/null @@ -1,30 +0,0 @@ -// 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 deleted file mode 100644 index be4b8a63c..000000000 --- a/test/form/samples/tree-shake-literal-parameter/import-function/lib.js +++ /dev/null @@ -1,37 +0,0 @@ -// 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 deleted file mode 100644 index fcd0b9dcb..000000000 --- a/test/form/samples/tree-shake-literal-parameter/import-function/main.js +++ /dev/null @@ -1,17 +0,0 @@ -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 deleted file mode 100644 index 43454f74b..000000000 --- a/test/form/samples/tree-shake-literal-parameter/indirect-import-function/_config.js +++ /dev/null @@ -1,3 +0,0 @@ -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 deleted file mode 100644 index 39872a4cf..000000000 --- a/test/form/samples/tree-shake-literal-parameter/indirect-import-function/_expected.js +++ /dev/null @@ -1,14 +0,0 @@ -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 deleted file mode 100644 index b52e1846d..000000000 --- a/test/form/samples/tree-shake-literal-parameter/indirect-import-function/define_and_export_default.js +++ /dev/null @@ -1,7 +0,0 @@ -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 deleted file mode 100644 index 30e7e2b91..000000000 --- a/test/form/samples/tree-shake-literal-parameter/indirect-import-function/import_then_export.js +++ /dev/null @@ -1,3 +0,0 @@ -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 deleted file mode 100644 index 2afc49468..000000000 --- a/test/form/samples/tree-shake-literal-parameter/indirect-import-function/import_then_export_sub.js +++ /dev/null @@ -1,5 +0,0 @@ -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 deleted file mode 100644 index ad0e9fb26..000000000 --- a/test/form/samples/tree-shake-literal-parameter/indirect-import-function/main.js +++ /dev/null @@ -1,5 +0,0 @@ -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 deleted file mode 100644 index 251df7a6a..000000000 --- a/test/form/samples/tree-shake-literal-parameter/recursion-literal-object/_config.js +++ /dev/null @@ -1,3 +0,0 @@ -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 deleted file mode 100644 index f909ce360..000000000 --- a/test/form/samples/tree-shake-literal-parameter/recursion-literal-object/_expected.js +++ /dev/null @@ -1,22 +0,0 @@ -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 deleted file mode 100644 index 4f845cc4e..000000000 --- a/test/form/samples/tree-shake-literal-parameter/recursion-literal-object/main.js +++ /dev/null @@ -1,40 +0,0 @@ -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 deleted file mode 100644 index 251df7a6a..000000000 --- a/test/form/samples/tree-shake-literal-parameter/recursion-literal/_config.js +++ /dev/null @@ -1,3 +0,0 @@ -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 deleted file mode 100644 index 2fcab0594..000000000 --- a/test/form/samples/tree-shake-literal-parameter/recursion-literal/_expected.js +++ /dev/null @@ -1,13 +0,0 @@ -function fun1(enable) { - { - return 'fun1'; - } -} - -function fun2(enable) { - { - return fun1(); - } -} - -console.log(fun2()); \ No newline at end of file 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 deleted file mode 100644 index 1187cc47f..000000000 --- a/test/form/samples/tree-shake-literal-parameter/recursion-literal/main.js +++ /dev/null @@ -1,13 +0,0 @@ -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 deleted file mode 100644 index 74efd8ee3..000000000 --- a/test/form/samples/tree-shake-literal-parameter/reexport-function/_config.js +++ /dev/null @@ -1,3 +0,0 @@ -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 deleted file mode 100644 index fd105290a..000000000 --- a/test/form/samples/tree-shake-literal-parameter/reexport-function/_expected.js +++ /dev/null @@ -1,7 +0,0 @@ -function module2 (enable) { - { - return 'module2' - } -} - -console.log(module2()); \ No newline at end of file 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 deleted file mode 100644 index c83b279bb..000000000 --- a/test/form/samples/tree-shake-literal-parameter/reexport-function/main.js +++ /dev/null @@ -1,3 +0,0 @@ -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 deleted file mode 100644 index 01e152738..000000000 --- a/test/form/samples/tree-shake-literal-parameter/reexport-function/module1.js +++ /dev/null @@ -1 +0,0 @@ -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 deleted file mode 100644 index c4f4cacaf..000000000 --- a/test/form/samples/tree-shake-literal-parameter/reexport-function/module2.js +++ /dev/null @@ -1,5 +0,0 @@ -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 deleted file mode 100644 index e06ff5cdc..000000000 --- a/test/form/samples/tree-shake-literal-parameter/side-effect/_config.js +++ /dev/null @@ -1,3 +0,0 @@ -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 deleted file mode 100644 index 772756634..000000000 --- a/test/form/samples/tree-shake-literal-parameter/side-effect/_expected.js +++ /dev/null @@ -1,63 +0,0 @@ -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 deleted file mode 100644 index d7f3ba001..000000000 --- a/test/form/samples/tree-shake-literal-parameter/side-effect/main.js +++ /dev/null @@ -1,71 +0,0 @@ -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 deleted file mode 100644 index 027f90cf3..000000000 --- a/test/form/samples/tree-shake-literal-parameter/top-level/_config.js +++ /dev/null @@ -1,3 +0,0 @@ -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 deleted file mode 100644 index 70d050ab7..000000000 --- a/test/form/samples/tree-shake-literal-parameter/top-level/_expected.js +++ /dev/null @@ -1,23 +0,0 @@ -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 deleted file mode 100644 index 9f706606d..000000000 --- a/test/form/samples/tree-shake-literal-parameter/top-level/main.js +++ /dev/null @@ -1,23 +0,0 @@ -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/try-statement-deoptimization/deactivate-via-option/_expected.js b/test/form/samples/try-statement-deoptimization/deactivate-via-option/_expected.js index 7a1891aac..a8d430c8f 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,11 +6,13 @@ const mutated = {}; function test(callback) { try { + callback(); mutate(mutated); } catch {} } -test(); +test(() => { +}); try {} finally { console.log('retained'); diff --git a/test/function/samples/acorn-walk/_config.js b/test/function/samples/acorn-walk/_config.js deleted file mode 100644 index 02a5c20f5..000000000 --- a/test/function/samples/acorn-walk/_config.js +++ /dev/null @@ -1,3 +0,0 @@ -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 deleted file mode 100644 index 32da49051..000000000 --- a/test/function/samples/acorn-walk/main.js +++ /dev/null @@ -1,26 +0,0 @@ -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/reassigned-parameter/_config.js b/test/function/samples/reassigned-parameter/_config.js deleted file mode 100644 index 5923f0afe..000000000 --- a/test/function/samples/reassigned-parameter/_config.js +++ /dev/null @@ -1,3 +0,0 @@ -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 deleted file mode 100644 index f2c6fe7d3..000000000 --- a/test/function/samples/reassigned-parameter/main.js +++ /dev/null @@ -1,21 +0,0 @@ -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'); - From 1c404fa352b70007066e94ff4c1981f8046f8cef Mon Sep 17 00:00:00 2001 From: Lukas Taegert-Atkinson Date: Tue, 23 Apr 2024 15:04:16 +0200 Subject: [PATCH 35/45] 4.16.4 --- CHANGELOG.md | 12 ++++++++++++ browser/package.json | 2 +- package-lock.json | 4 ++-- package.json | 2 +- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 02b118925..37895bf32 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,17 @@ # rollup changelog +## 4.16.4 + +_2024-04-23_ + +### Bug Fixes + +- Revert function parameter tracking logic introduced in 4.16.0 to work on some remaining issues (#5487) + +### Pull Requests + +- [#5487](https://github.com/rollup/rollup/pull/5487): Revert function parameter tracking logic for now (@lukastaegert) + ## 4.16.3 _2024-04-23_ diff --git a/browser/package.json b/browser/package.json index 91f0a5274..440053949 100644 --- a/browser/package.json +++ b/browser/package.json @@ -1,6 +1,6 @@ { "name": "@rollup/browser", - "version": "4.16.3", + "version": "4.16.4", "description": "Next-generation ES module bundler browser build", "main": "dist/rollup.browser.js", "module": "dist/es/rollup.browser.js", diff --git a/package-lock.json b/package-lock.json index c12f8eaba..abd5fed2c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "rollup", - "version": "4.16.3", + "version": "4.16.4", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "rollup", - "version": "4.16.3", + "version": "4.16.4", "license": "MIT", "dependencies": { "@types/estree": "1.0.5" diff --git a/package.json b/package.json index a1a34975a..19438a9b9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rollup", - "version": "4.16.3", + "version": "4.16.4", "description": "Next-generation ES module bundler", "main": "dist/rollup.js", "module": "dist/es/rollup.js", From b9051a223aad3349546772e891b89c4e40fe5618 Mon Sep 17 00:00:00 2001 From: Benjamin Nickolls Date: Wed, 24 Apr 2024 11:17:48 +0100 Subject: [PATCH 36/45] Create FUNDING.json (#5489) OSC claiming rollup on Drips network. --- FUNDING.json | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 FUNDING.json diff --git a/FUNDING.json b/FUNDING.json new file mode 100644 index 000000000..fcb4f353d --- /dev/null +++ b/FUNDING.json @@ -0,0 +1,7 @@ +{ + "drips": { + "ethereum": { + "ownedBy": "0x3FF19163842E027ab536172B10123af20e3e4648" + } + } +} From b5560a78fb25b029c00d5eeed3b987fa28ea68de Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 26 Apr 2024 02:19:08 +0000 Subject: [PATCH 37/45] chore(deps): lock file maintenance minor/patch updates (#5492) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- package-lock.json | 418 +++++++++++++++++++------------------- package.json | 24 +-- rust/Cargo.lock | 149 ++++---------- rust/parse_ast/Cargo.toml | 8 +- 4 files changed, 268 insertions(+), 331 deletions(-) diff --git a/package-lock.json b/package-lock.json index abd5fed2c..0429f35a3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,7 +15,7 @@ "rollup": "dist/bin/rollup" }, "devDependencies": { - "@codemirror/commands": "^6.3.3", + "@codemirror/commands": "^6.5.0", "@codemirror/lang-javascript": "^6.2.2", "@codemirror/language": "^6.10.1", "@codemirror/search": "^6.5.6", @@ -23,7 +23,7 @@ "@codemirror/view": "^6.26.3", "@jridgewell/sourcemap-codec": "^1.4.15", "@mermaid-js/mermaid-cli": "^10.8.0", - "@napi-rs/cli": "^2.18.1", + "@napi-rs/cli": "^2.18.2", "@rollup/plugin-alias": "^5.1.0", "@rollup/plugin-buble": "^1.0.3", "@rollup/plugin-commonjs": "^25.0.7", @@ -34,13 +34,13 @@ "@rollup/plugin-typescript": "^11.1.6", "@rollup/pluginutils": "^5.1.0", "@shikijs/vitepress-twoslash": "^1.3.0", - "@types/eslint": "^8.56.9", + "@types/eslint": "^8.56.10", "@types/inquirer": "^9.0.7", "@types/mocha": "^10.0.6", "@types/node": "~18.18.14", "@types/yargs-parser": "^21.0.3", - "@typescript-eslint/eslint-plugin": "^7.7.0", - "@typescript-eslint/parser": "^7.7.0", + "@typescript-eslint/eslint-plugin": "^7.7.1", + "@typescript-eslint/parser": "^7.7.1", "@vue/eslint-config-prettier": "^9.0.0", "@vue/eslint-config-typescript": "^13.0.0", "acorn": "^8.11.3", @@ -65,11 +65,11 @@ "fs-extra": "^11.2.0", "github-api": "^3.4.0", "husky": "^9.0.11", - "inquirer": "^9.2.18", + "inquirer": "^9.2.19", "is-reference": "^3.0.2", "lint-staged": "^15.2.2", "locate-character": "^3.0.0", - "magic-string": "^0.30.9", + "magic-string": "^0.30.10", "mocha": "^10.4.0", "nyc": "^15.1.0", "pinia": "^2.1.7", @@ -77,7 +77,7 @@ "pretty-bytes": "^6.1.1", "pretty-ms": "^9.0.0", "requirejs": "^2.3.6", - "rollup": "^4.14.3", + "rollup": "^4.16.2", "rollup-plugin-license": "^3.3.1", "rollup-plugin-string": "^3.0.0", "semver": "^7.6.0", @@ -86,12 +86,12 @@ "source-map": "^0.7.4", "source-map-support": "^0.5.21", "systemjs": "^6.14.3", - "terser": "^5.30.3", + "terser": "^5.30.4", "tslib": "^2.6.2", "typescript": "^5.4.5", - "vite": "^5.2.9", - "vitepress": "^1.1.0", - "vue": "^3.4.22", + "vite": "^5.2.10", + "vitepress": "^1.1.3", + "vue": "^3.4.24", "wasm-pack": "^0.12.1", "weak-napi": "^2.0.2", "yargs-parser": "^21.1.1" @@ -722,9 +722,9 @@ } }, "node_modules/@codemirror/commands": { - "version": "6.4.0", - "resolved": "https://registry.npmjs.org/@codemirror/commands/-/commands-6.4.0.tgz", - "integrity": "sha512-HB3utD5GxCvEhSyj5EuG9KpuQQhFpxalh3lwrspyL/GeSNDe4c6JDxVzL12SJ+7gUknHjZzmq7OPCb9QPgiRmQ==", + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/@codemirror/commands/-/commands-6.5.0.tgz", + "integrity": "sha512-rK+sj4fCAN/QfcY9BEzYMgp4wwL/q5aj/VfNSoH1RWPF9XS/dUwBkvlL3hpWgEjOqlpdN1uLC9UkjJ4tmyjJYg==", "dev": true, "dependencies": { "@codemirror/language": "^6.0.0", @@ -1565,9 +1565,9 @@ } }, "node_modules/@lezer/javascript": { - "version": "1.4.14", - "resolved": "https://registry.npmjs.org/@lezer/javascript/-/javascript-1.4.14.tgz", - "integrity": "sha512-GEdUyspTRgc5dwIGebUk+f3BekvqEWVIYsIuAC3pA8e8wcikGwBZRWRa450L0s8noGWuULwnmi4yjxTnYz9PpA==", + "version": "1.4.15", + "resolved": "https://registry.npmjs.org/@lezer/javascript/-/javascript-1.4.15.tgz", + "integrity": "sha512-B082ZdjI0vo2AgLqD834GlRTE9gwRX8NzHzKq5uDwEnQ9Dq+A/CEhd3nf68tiNA2f9O+8jS1NeSTUYT9IAqcTw==", "dev": true, "dependencies": { "@lezer/common": "^1.2.0", @@ -1937,9 +1937,9 @@ } }, "node_modules/@rollup/rollup-android-arm-eabi": { - "version": "4.14.3", - "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.14.3.tgz", - "integrity": "sha512-X9alQ3XM6I9IlSlmC8ddAvMSyG1WuHk5oUnXGw+yUBs3BFoTizmG1La/Gr8fVJvDWAq+zlYTZ9DBgrlKRVY06g==", + "version": "4.16.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.16.4.tgz", + "integrity": "sha512-GkhjAaQ8oUTOKE4g4gsZ0u8K/IHU1+2WQSgS1TwTcYvL+sjbaQjNHFXbOJ6kgqGHIO1DfUhI/Sphi9GkRT9K+Q==", "cpu": [ "arm" ], @@ -1950,9 +1950,9 @@ ] }, "node_modules/@rollup/rollup-android-arm64": { - "version": "4.14.3", - "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.14.3.tgz", - "integrity": "sha512-eQK5JIi+POhFpzk+LnjKIy4Ks+pwJ+NXmPxOCSvOKSNRPONzKuUvWE+P9JxGZVxrtzm6BAYMaL50FFuPe0oWMQ==", + "version": "4.16.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.16.4.tgz", + "integrity": "sha512-Bvm6D+NPbGMQOcxvS1zUl8H7DWlywSXsphAeOnVeiZLQ+0J6Is8T7SrjGTH29KtYkiY9vld8ZnpV3G2EPbom+w==", "cpu": [ "arm64" ], @@ -1963,9 +1963,9 @@ ] }, "node_modules/@rollup/rollup-darwin-arm64": { - "version": "4.14.3", - "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.14.3.tgz", - "integrity": "sha512-Od4vE6f6CTT53yM1jgcLqNfItTsLt5zE46fdPaEmeFHvPs5SjZYlLpHrSiHEKR1+HdRfxuzXHjDOIxQyC3ptBA==", + "version": "4.16.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.16.4.tgz", + "integrity": "sha512-i5d64MlnYBO9EkCOGe5vPR/EeDwjnKOGGdd7zKFhU5y8haKhQZTN2DgVtpODDMxUr4t2K90wTUJg7ilgND6bXw==", "cpu": [ "arm64" ], @@ -1976,9 +1976,9 @@ ] }, "node_modules/@rollup/rollup-darwin-x64": { - "version": "4.14.3", - "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.14.3.tgz", - "integrity": "sha512-0IMAO21axJeNIrvS9lSe/PGthc8ZUS+zC53O0VhF5gMxfmcKAP4ESkKOCwEi6u2asUrt4mQv2rjY8QseIEb1aw==", + "version": "4.16.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.16.4.tgz", + "integrity": "sha512-WZupV1+CdUYehaZqjaFTClJI72fjJEgTXdf4NbW69I9XyvdmztUExBtcI2yIIU6hJtYvtwS6pkTkHJz+k08mAQ==", "cpu": [ "x64" ], @@ -1989,9 +1989,9 @@ ] }, "node_modules/@rollup/rollup-linux-arm-gnueabihf": { - "version": "4.14.3", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.14.3.tgz", - "integrity": "sha512-ge2DC7tHRHa3caVEoSbPRJpq7azhG+xYsd6u2MEnJ6XzPSzQsTKyXvh6iWjXRf7Rt9ykIUWHtl0Uz3T6yXPpKw==", + "version": "4.16.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.16.4.tgz", + "integrity": "sha512-ADm/xt86JUnmAfA9mBqFcRp//RVRt1ohGOYF6yL+IFCYqOBNwy5lbEK05xTsEoJq+/tJzg8ICUtS82WinJRuIw==", "cpu": [ "arm" ], @@ -2002,9 +2002,9 @@ ] }, "node_modules/@rollup/rollup-linux-arm-musleabihf": { - "version": "4.14.3", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.14.3.tgz", - "integrity": "sha512-ljcuiDI4V3ySuc7eSk4lQ9wU8J8r8KrOUvB2U+TtK0TiW6OFDmJ+DdIjjwZHIw9CNxzbmXY39wwpzYuFDwNXuw==", + "version": "4.16.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.16.4.tgz", + "integrity": "sha512-tJfJaXPiFAG+Jn3cutp7mCs1ePltuAgRqdDZrzb1aeE3TktWWJ+g7xK9SNlaSUFw6IU4QgOxAY4rA+wZUT5Wfg==", "cpu": [ "arm" ], @@ -2015,9 +2015,9 @@ ] }, "node_modules/@rollup/rollup-linux-arm64-gnu": { - "version": "4.14.3", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.14.3.tgz", - "integrity": "sha512-Eci2us9VTHm1eSyn5/eEpaC7eP/mp5n46gTRB3Aar3BgSvDQGJZuicyq6TsH4HngNBgVqC5sDYxOzTExSU+NjA==", + "version": "4.16.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.16.4.tgz", + "integrity": "sha512-7dy1BzQkgYlUTapDTvK997cgi0Orh5Iu7JlZVBy1MBURk7/HSbHkzRnXZa19ozy+wwD8/SlpJnOOckuNZtJR9w==", "cpu": [ "arm64" ], @@ -2028,9 +2028,9 @@ ] }, "node_modules/@rollup/rollup-linux-arm64-musl": { - "version": "4.14.3", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.14.3.tgz", - "integrity": "sha512-UrBoMLCq4E92/LCqlh+blpqMz5h1tJttPIniwUgOFJyjWI1qrtrDhhpHPuFxULlUmjFHfloWdixtDhSxJt5iKw==", + "version": "4.16.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.16.4.tgz", + "integrity": "sha512-zsFwdUw5XLD1gQe0aoU2HVceI6NEW7q7m05wA46eUAyrkeNYExObfRFQcvA6zw8lfRc5BHtan3tBpo+kqEOxmg==", "cpu": [ "arm64" ], @@ -2041,9 +2041,9 @@ ] }, "node_modules/@rollup/rollup-linux-powerpc64le-gnu": { - "version": "4.14.3", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-powerpc64le-gnu/-/rollup-linux-powerpc64le-gnu-4.14.3.tgz", - "integrity": "sha512-5aRjvsS8q1nWN8AoRfrq5+9IflC3P1leMoy4r2WjXyFqf3qcqsxRCfxtZIV58tCxd+Yv7WELPcO9mY9aeQyAmw==", + "version": "4.16.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-powerpc64le-gnu/-/rollup-linux-powerpc64le-gnu-4.16.4.tgz", + "integrity": "sha512-p8C3NnxXooRdNrdv6dBmRTddEapfESEUflpICDNKXpHvTjRRq1J82CbU5G3XfebIZyI3B0s074JHMWD36qOW6w==", "cpu": [ "ppc64" ], @@ -2054,9 +2054,9 @@ ] }, "node_modules/@rollup/rollup-linux-riscv64-gnu": { - "version": "4.14.3", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.14.3.tgz", - "integrity": "sha512-sk/Qh1j2/RJSX7FhEpJn8n0ndxy/uf0kI/9Zc4b1ELhqULVdTfN6HL31CDaTChiBAOgLcsJ1sgVZjWv8XNEsAQ==", + "version": "4.16.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.16.4.tgz", + "integrity": "sha512-Lh/8ckoar4s4Id2foY7jNgitTOUQczwMWNYi+Mjt0eQ9LKhr6sK477REqQkmy8YHY3Ca3A2JJVdXnfb3Rrwkng==", "cpu": [ "riscv64" ], @@ -2067,9 +2067,9 @@ ] }, "node_modules/@rollup/rollup-linux-s390x-gnu": { - "version": "4.14.3", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.14.3.tgz", - "integrity": "sha512-jOO/PEaDitOmY9TgkxF/TQIjXySQe5KVYB57H/8LRP/ux0ZoO8cSHCX17asMSv3ruwslXW/TLBcxyaUzGRHcqg==", + "version": "4.16.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.16.4.tgz", + "integrity": "sha512-1xwwn9ZCQYuqGmulGsTZoKrrn0z2fAur2ujE60QgyDpHmBbXbxLaQiEvzJWDrscRq43c8DnuHx3QorhMTZgisQ==", "cpu": [ "s390x" ], @@ -2080,9 +2080,9 @@ ] }, "node_modules/@rollup/rollup-linux-x64-gnu": { - "version": "4.14.3", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.14.3.tgz", - "integrity": "sha512-8ybV4Xjy59xLMyWo3GCfEGqtKV5M5gCSrZlxkPGvEPCGDLNla7v48S662HSGwRd6/2cSneMQWiv+QzcttLrrOA==", + "version": "4.16.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.16.4.tgz", + "integrity": "sha512-LuOGGKAJ7dfRtxVnO1i3qWc6N9sh0Em/8aZ3CezixSTM+E9Oq3OvTsvC4sm6wWjzpsIlOCnZjdluINKESflJLA==", "cpu": [ "x64" ], @@ -2093,9 +2093,9 @@ ] }, "node_modules/@rollup/rollup-linux-x64-musl": { - "version": "4.14.3", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.14.3.tgz", - "integrity": "sha512-s+xf1I46trOY10OqAtZ5Rm6lzHre/UiLA1J2uOhCFXWkbZrJRkYBPO6FhvGfHmdtQ3Bx793MNa7LvoWFAm93bg==", + "version": "4.16.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.16.4.tgz", + "integrity": "sha512-ch86i7KkJKkLybDP2AtySFTRi5fM3KXp0PnHocHuJMdZwu7BuyIKi35BE9guMlmTpwwBTB3ljHj9IQXnTCD0vA==", "cpu": [ "x64" ], @@ -2106,9 +2106,9 @@ ] }, "node_modules/@rollup/rollup-win32-arm64-msvc": { - "version": "4.14.3", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.14.3.tgz", - "integrity": "sha512-+4h2WrGOYsOumDQ5S2sYNyhVfrue+9tc9XcLWLh+Kw3UOxAvrfOrSMFon60KspcDdytkNDh7K2Vs6eMaYImAZg==", + "version": "4.16.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.16.4.tgz", + "integrity": "sha512-Ma4PwyLfOWZWayfEsNQzTDBVW8PZ6TUUN1uFTBQbF2Chv/+sjenE86lpiEwj2FiviSmSZ4Ap4MaAfl1ciF4aSA==", "cpu": [ "arm64" ], @@ -2119,9 +2119,9 @@ ] }, "node_modules/@rollup/rollup-win32-ia32-msvc": { - "version": "4.14.3", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.14.3.tgz", - "integrity": "sha512-T1l7y/bCeL/kUwh9OD4PQT4aM7Bq43vX05htPJJ46RTI4r5KNt6qJRzAfNfM+OYMNEVBWQzR2Gyk+FXLZfogGw==", + "version": "4.16.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.16.4.tgz", + "integrity": "sha512-9m/ZDrQsdo/c06uOlP3W9G2ENRVzgzbSXmXHT4hwVaDQhYcRpi9bgBT0FTG9OhESxwK0WjQxYOSfv40cU+T69w==", "cpu": [ "ia32" ], @@ -2132,9 +2132,9 @@ ] }, "node_modules/@rollup/rollup-win32-x64-msvc": { - "version": "4.14.3", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.14.3.tgz", - "integrity": "sha512-/BypzV0H1y1HzgYpxqRaXGBRqfodgoBBCcsrujT6QRcakDQdfU+Lq9PENPh5jB4I44YWq+0C2eHsHya+nZY1sA==", + "version": "4.16.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.16.4.tgz", + "integrity": "sha512-YunpoOAyGLDseanENHmbFvQSfVL5BxW3k7hhy0eN4rb3gS/ct75dVD0EXOWIqFT/nE8XYW6LP6vz6ctKRi0k9A==", "cpu": [ "x64" ], @@ -2408,16 +2408,16 @@ } }, "node_modules/@typescript-eslint/eslint-plugin": { - "version": "7.7.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-7.7.0.tgz", - "integrity": "sha512-GJWR0YnfrKnsRoluVO3PRb9r5aMZriiMMM/RHj5nnTrBy1/wIgk76XCtCKcnXGjpZQJQRFtGV9/0JJ6n30uwpQ==", + "version": "7.7.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-7.7.1.tgz", + "integrity": "sha512-KwfdWXJBOviaBVhxO3p5TJiLpNuh2iyXyjmWN0f1nU87pwyvfS0EmjC6ukQVYVFJd/K1+0NWGPDXiyEyQorn0Q==", "dev": true, "dependencies": { "@eslint-community/regexpp": "^4.10.0", - "@typescript-eslint/scope-manager": "7.7.0", - "@typescript-eslint/type-utils": "7.7.0", - "@typescript-eslint/utils": "7.7.0", - "@typescript-eslint/visitor-keys": "7.7.0", + "@typescript-eslint/scope-manager": "7.7.1", + "@typescript-eslint/type-utils": "7.7.1", + "@typescript-eslint/utils": "7.7.1", + "@typescript-eslint/visitor-keys": "7.7.1", "debug": "^4.3.4", "graphemer": "^1.4.0", "ignore": "^5.3.1", @@ -2443,15 +2443,15 @@ } }, "node_modules/@typescript-eslint/parser": { - "version": "7.7.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-7.7.0.tgz", - "integrity": "sha512-fNcDm3wSwVM8QYL4HKVBggdIPAy9Q41vcvC/GtDobw3c4ndVT3K6cqudUmjHPw8EAp4ufax0o58/xvWaP2FmTg==", + "version": "7.7.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-7.7.1.tgz", + "integrity": "sha512-vmPzBOOtz48F6JAGVS/kZYk4EkXao6iGrD838sp1w3NQQC0W8ry/q641KU4PrG7AKNAf56NOcR8GOpH8l9FPCw==", "dev": true, "dependencies": { - "@typescript-eslint/scope-manager": "7.7.0", - "@typescript-eslint/types": "7.7.0", - "@typescript-eslint/typescript-estree": "7.7.0", - "@typescript-eslint/visitor-keys": "7.7.0", + "@typescript-eslint/scope-manager": "7.7.1", + "@typescript-eslint/types": "7.7.1", + "@typescript-eslint/typescript-estree": "7.7.1", + "@typescript-eslint/visitor-keys": "7.7.1", "debug": "^4.3.4" }, "engines": { @@ -2471,13 +2471,13 @@ } }, "node_modules/@typescript-eslint/scope-manager": { - "version": "7.7.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-7.7.0.tgz", - "integrity": "sha512-/8INDn0YLInbe9Wt7dK4cXLDYp0fNHP5xKLHvZl3mOT5X17rK/YShXaiNmorl+/U4VKCVIjJnx4Ri5b0y+HClw==", + "version": "7.7.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-7.7.1.tgz", + "integrity": "sha512-PytBif2SF+9SpEUKynYn5g1RHFddJUcyynGpztX3l/ik7KmZEv19WCMhUBkHXPU9es/VWGD3/zg3wg90+Dh2rA==", "dev": true, "dependencies": { - "@typescript-eslint/types": "7.7.0", - "@typescript-eslint/visitor-keys": "7.7.0" + "@typescript-eslint/types": "7.7.1", + "@typescript-eslint/visitor-keys": "7.7.1" }, "engines": { "node": "^18.18.0 || >=20.0.0" @@ -2488,13 +2488,13 @@ } }, "node_modules/@typescript-eslint/type-utils": { - "version": "7.7.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-7.7.0.tgz", - "integrity": "sha512-bOp3ejoRYrhAlnT/bozNQi3nio9tIgv3U5C0mVDdZC7cpcQEDZXvq8inrHYghLVwuNABRqrMW5tzAv88Vy77Sg==", + "version": "7.7.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-7.7.1.tgz", + "integrity": "sha512-ZksJLW3WF7o75zaBPScdW1Gbkwhd/lyeXGf1kQCxJaOeITscoSl0MjynVvCzuV5boUz/3fOI06Lz8La55mu29Q==", "dev": true, "dependencies": { - "@typescript-eslint/typescript-estree": "7.7.0", - "@typescript-eslint/utils": "7.7.0", + "@typescript-eslint/typescript-estree": "7.7.1", + "@typescript-eslint/utils": "7.7.1", "debug": "^4.3.4", "ts-api-utils": "^1.3.0" }, @@ -2515,9 +2515,9 @@ } }, "node_modules/@typescript-eslint/types": { - "version": "7.7.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-7.7.0.tgz", - "integrity": "sha512-G01YPZ1Bd2hn+KPpIbrAhEWOn5lQBrjxkzHkWvP6NucMXFtfXoevK82hzQdpfuQYuhkvFDeQYbzXCjR1z9Z03w==", + "version": "7.7.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-7.7.1.tgz", + "integrity": "sha512-AmPmnGW1ZLTpWa+/2omPrPfR7BcbUU4oha5VIbSbS1a1Tv966bklvLNXxp3mrbc+P2j4MNOTfDffNsk4o0c6/w==", "dev": true, "engines": { "node": "^18.18.0 || >=20.0.0" @@ -2528,13 +2528,13 @@ } }, "node_modules/@typescript-eslint/typescript-estree": { - "version": "7.7.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-7.7.0.tgz", - "integrity": "sha512-8p71HQPE6CbxIBy2kWHqM1KGrC07pk6RJn40n0DSc6bMOBBREZxSDJ+BmRzc8B5OdaMh1ty3mkuWRg4sCFiDQQ==", + "version": "7.7.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-7.7.1.tgz", + "integrity": "sha512-CXe0JHCXru8Fa36dteXqmH2YxngKJjkQLjxzoj6LYwzZ7qZvgsLSc+eqItCrqIop8Vl2UKoAi0StVWu97FQZIQ==", "dev": true, "dependencies": { - "@typescript-eslint/types": "7.7.0", - "@typescript-eslint/visitor-keys": "7.7.0", + "@typescript-eslint/types": "7.7.1", + "@typescript-eslint/visitor-keys": "7.7.1", "debug": "^4.3.4", "globby": "^11.1.0", "is-glob": "^4.0.3", @@ -2556,17 +2556,17 @@ } }, "node_modules/@typescript-eslint/utils": { - "version": "7.7.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-7.7.0.tgz", - "integrity": "sha512-LKGAXMPQs8U/zMRFXDZOzmMKgFv3COlxUQ+2NMPhbqgVm6R1w+nU1i4836Pmxu9jZAuIeyySNrN/6Rc657ggig==", + "version": "7.7.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-7.7.1.tgz", + "integrity": "sha512-QUvBxPEaBXf41ZBbaidKICgVL8Hin0p6prQDu6bbetWo39BKbWJxRsErOzMNT1rXvTll+J7ChrbmMCXM9rsvOQ==", "dev": true, "dependencies": { "@eslint-community/eslint-utils": "^4.4.0", "@types/json-schema": "^7.0.15", "@types/semver": "^7.5.8", - "@typescript-eslint/scope-manager": "7.7.0", - "@typescript-eslint/types": "7.7.0", - "@typescript-eslint/typescript-estree": "7.7.0", + "@typescript-eslint/scope-manager": "7.7.1", + "@typescript-eslint/types": "7.7.1", + "@typescript-eslint/typescript-estree": "7.7.1", "semver": "^7.6.0" }, "engines": { @@ -2581,12 +2581,12 @@ } }, "node_modules/@typescript-eslint/visitor-keys": { - "version": "7.7.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-7.7.0.tgz", - "integrity": "sha512-h0WHOj8MhdhY8YWkzIF30R379y0NqyOHExI9N9KCzvmu05EgG4FumeYa3ccfKUSphyWkWQE1ybVrgz/Pbam6YA==", + "version": "7.7.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-7.7.1.tgz", + "integrity": "sha512-gBL3Eq25uADw1LQ9kVpf3hRM+DWzs0uZknHYK3hq4jcTPqVCClHGDnB6UUUV2SFeBeA4KWHWbbLqmbGcZ4FYbw==", "dev": true, "dependencies": { - "@typescript-eslint/types": "7.7.0", + "@typescript-eslint/types": "7.7.1", "eslint-visitor-keys": "^3.4.3" }, "engines": { @@ -2644,53 +2644,53 @@ } }, "node_modules/@vue/compiler-core": { - "version": "3.4.23", - "resolved": "https://registry.npmjs.org/@vue/compiler-core/-/compiler-core-3.4.23.tgz", - "integrity": "sha512-HAFmuVEwNqNdmk+w4VCQ2pkLk1Vw4XYiiyxEp3z/xvl14aLTUBw2OfVH3vBcx+FtGsynQLkkhK410Nah1N2yyQ==", + "version": "3.4.25", + "resolved": "https://registry.npmjs.org/@vue/compiler-core/-/compiler-core-3.4.25.tgz", + "integrity": "sha512-Y2pLLopaElgWnMNolgG8w3C5nNUVev80L7hdQ5iIKPtMJvhVpG0zhnBG/g3UajJmZdvW0fktyZTotEHD1Srhbg==", "dev": true, "dependencies": { - "@babel/parser": "^7.24.1", - "@vue/shared": "3.4.23", + "@babel/parser": "^7.24.4", + "@vue/shared": "3.4.25", "entities": "^4.5.0", "estree-walker": "^2.0.2", "source-map-js": "^1.2.0" } }, "node_modules/@vue/compiler-dom": { - "version": "3.4.23", - "resolved": "https://registry.npmjs.org/@vue/compiler-dom/-/compiler-dom-3.4.23.tgz", - "integrity": "sha512-t0b9WSTnCRrzsBGrDd1LNR5HGzYTr7LX3z6nNBG+KGvZLqrT0mY6NsMzOqlVMBKKXKVuusbbB5aOOFgTY+senw==", + "version": "3.4.25", + "resolved": "https://registry.npmjs.org/@vue/compiler-dom/-/compiler-dom-3.4.25.tgz", + "integrity": "sha512-Ugz5DusW57+HjllAugLci19NsDK+VyjGvmbB2TXaTcSlQxwL++2PETHx/+Qv6qFwNLzSt7HKepPe4DcTE3pBWg==", "dev": true, "dependencies": { - "@vue/compiler-core": "3.4.23", - "@vue/shared": "3.4.23" + "@vue/compiler-core": "3.4.25", + "@vue/shared": "3.4.25" } }, "node_modules/@vue/compiler-sfc": { - "version": "3.4.23", - "resolved": "https://registry.npmjs.org/@vue/compiler-sfc/-/compiler-sfc-3.4.23.tgz", - "integrity": "sha512-fSDTKTfzaRX1kNAUiaj8JB4AokikzStWgHooMhaxyjZerw624L+IAP/fvI4ZwMpwIh8f08PVzEnu4rg8/Npssw==", + "version": "3.4.25", + "resolved": "https://registry.npmjs.org/@vue/compiler-sfc/-/compiler-sfc-3.4.25.tgz", + "integrity": "sha512-m7rryuqzIoQpOBZ18wKyq05IwL6qEpZxFZfRxlNYuIPDqywrXQxgUwLXIvoU72gs6cRdY6wHD0WVZIFE4OEaAQ==", "dev": true, "dependencies": { - "@babel/parser": "^7.24.1", - "@vue/compiler-core": "3.4.23", - "@vue/compiler-dom": "3.4.23", - "@vue/compiler-ssr": "3.4.23", - "@vue/shared": "3.4.23", + "@babel/parser": "^7.24.4", + "@vue/compiler-core": "3.4.25", + "@vue/compiler-dom": "3.4.25", + "@vue/compiler-ssr": "3.4.25", + "@vue/shared": "3.4.25", "estree-walker": "^2.0.2", - "magic-string": "^0.30.8", + "magic-string": "^0.30.10", "postcss": "^8.4.38", "source-map-js": "^1.2.0" } }, "node_modules/@vue/compiler-ssr": { - "version": "3.4.23", - "resolved": "https://registry.npmjs.org/@vue/compiler-ssr/-/compiler-ssr-3.4.23.tgz", - "integrity": "sha512-hb6Uj2cYs+tfqz71Wj6h3E5t6OKvb4MVcM2Nl5i/z1nv1gjEhw+zYaNOV+Xwn+SSN/VZM0DgANw5TuJfxfezPg==", + "version": "3.4.25", + "resolved": "https://registry.npmjs.org/@vue/compiler-ssr/-/compiler-ssr-3.4.25.tgz", + "integrity": "sha512-H2ohvM/Pf6LelGxDBnfbbXFPyM4NE3hrw0e/EpwuSiYu8c819wx+SVGdJ65p/sFrYDd6OnSDxN1MB2mN07hRSQ==", "dev": true, "dependencies": { - "@vue/compiler-dom": "3.4.23", - "@vue/shared": "3.4.23" + "@vue/compiler-dom": "3.4.25", + "@vue/shared": "3.4.25" } }, "node_modules/@vue/devtools-api": { @@ -2700,12 +2700,12 @@ "dev": true }, "node_modules/@vue/devtools-kit": { - "version": "7.0.27", - "resolved": "https://registry.npmjs.org/@vue/devtools-kit/-/devtools-kit-7.0.27.tgz", - "integrity": "sha512-/A5xM38pPCFX5Yhl/lRFAzjyK6VNsH670nww2WbjFKWqlu3I+lMxWKzQkCW6A1V8bduITgl2kHORfg2gTw6QaA==", + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/@vue/devtools-kit/-/devtools-kit-7.1.2.tgz", + "integrity": "sha512-UTrcUSOhlI9eXqbPMHUWwA6NQiiPT3onzXsVk2JHGR8ZFFSkzsWTTpHyVA1woG8zvgu2HNV/wigW2k87p858zw==", "dev": true, "dependencies": { - "@vue/devtools-shared": "^7.0.27", + "@vue/devtools-shared": "^7.1.2", "hookable": "^5.5.3", "mitt": "^3.0.1", "perfect-debounce": "^1.0.0", @@ -2722,9 +2722,9 @@ "dev": true }, "node_modules/@vue/devtools-shared": { - "version": "7.0.27", - "resolved": "https://registry.npmjs.org/@vue/devtools-shared/-/devtools-shared-7.0.27.tgz", - "integrity": "sha512-4VxtmZ6yjhiSloqZZq2UYU0TBGxOJ8GxWvp5OlAH70zYqi0FIAyWGPkOhvfoZ7DKQyv2UU0mmKzFHjsEkelGyQ==", + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/@vue/devtools-shared/-/devtools-shared-7.1.2.tgz", + "integrity": "sha512-r9cUf93VMhKSsxF2/cBbf6Lm1nRBx+r1pRuji5CiAf3JIPYPOjeEqJ13OuwP1fauYh1tyBFcCxt3eJPvHT59gg==", "dev": true, "dependencies": { "rfdc": "^1.3.1" @@ -2794,52 +2794,52 @@ } }, "node_modules/@vue/reactivity": { - "version": "3.4.23", - "resolved": "https://registry.npmjs.org/@vue/reactivity/-/reactivity-3.4.23.tgz", - "integrity": "sha512-GlXR9PL+23fQ3IqnbSQ8OQKLodjqCyoCrmdLKZk3BP7jN6prWheAfU7a3mrltewTkoBm+N7qMEb372VHIkQRMQ==", + "version": "3.4.25", + "resolved": "https://registry.npmjs.org/@vue/reactivity/-/reactivity-3.4.25.tgz", + "integrity": "sha512-mKbEtKr1iTxZkAG3vm3BtKHAOhuI4zzsVcN0epDldU/THsrvfXRKzq+lZnjczZGnTdh3ojd86/WrP+u9M51pWQ==", "dev": true, "dependencies": { - "@vue/shared": "3.4.23" + "@vue/shared": "3.4.25" } }, "node_modules/@vue/runtime-core": { - "version": "3.4.23", - "resolved": "https://registry.npmjs.org/@vue/runtime-core/-/runtime-core-3.4.23.tgz", - "integrity": "sha512-FeQ9MZEXoFzFkFiw9MQQ/FWs3srvrP+SjDKSeRIiQHIhtkzoj0X4rWQlRNHbGuSwLra6pMyjAttwixNMjc/xLw==", + "version": "3.4.25", + "resolved": "https://registry.npmjs.org/@vue/runtime-core/-/runtime-core-3.4.25.tgz", + "integrity": "sha512-3qhsTqbEh8BMH3pXf009epCI5E7bKu28fJLi9O6W+ZGt/6xgSfMuGPqa5HRbUxLoehTNp5uWvzCr60KuiRIL0Q==", "dev": true, "dependencies": { - "@vue/reactivity": "3.4.23", - "@vue/shared": "3.4.23" + "@vue/reactivity": "3.4.25", + "@vue/shared": "3.4.25" } }, "node_modules/@vue/runtime-dom": { - "version": "3.4.23", - "resolved": "https://registry.npmjs.org/@vue/runtime-dom/-/runtime-dom-3.4.23.tgz", - "integrity": "sha512-RXJFwwykZWBkMiTPSLEWU3kgVLNAfActBfWFlZd0y79FTUxexogd0PLG4HH2LfOktjRxV47Nulygh0JFXe5f9A==", + "version": "3.4.25", + "resolved": "https://registry.npmjs.org/@vue/runtime-dom/-/runtime-dom-3.4.25.tgz", + "integrity": "sha512-ode0sj77kuwXwSc+2Yhk8JMHZh1sZp9F/51wdBiz3KGaWltbKtdihlJFhQG4H6AY+A06zzeMLkq6qu8uDSsaoA==", "dev": true, "dependencies": { - "@vue/runtime-core": "3.4.23", - "@vue/shared": "3.4.23", + "@vue/runtime-core": "3.4.25", + "@vue/shared": "3.4.25", "csstype": "^3.1.3" } }, "node_modules/@vue/server-renderer": { - "version": "3.4.23", - "resolved": "https://registry.npmjs.org/@vue/server-renderer/-/server-renderer-3.4.23.tgz", - "integrity": "sha512-LDwGHtnIzvKFNS8dPJ1SSU5Gvm36p2ck8wCZc52fc3k/IfjKcwCyrWEf0Yag/2wTFUBXrqizfhK9c/mC367dXQ==", + "version": "3.4.25", + "resolved": "https://registry.npmjs.org/@vue/server-renderer/-/server-renderer-3.4.25.tgz", + "integrity": "sha512-8VTwq0Zcu3K4dWV0jOwIVINESE/gha3ifYCOKEhxOj6MEl5K5y8J8clQncTcDhKF+9U765nRw4UdUEXvrGhyVQ==", "dev": true, "dependencies": { - "@vue/compiler-ssr": "3.4.23", - "@vue/shared": "3.4.23" + "@vue/compiler-ssr": "3.4.25", + "@vue/shared": "3.4.25" }, "peerDependencies": { - "vue": "3.4.23" + "vue": "3.4.25" } }, "node_modules/@vue/shared": { - "version": "3.4.23", - "resolved": "https://registry.npmjs.org/@vue/shared/-/shared-3.4.23.tgz", - "integrity": "sha512-wBQ0gvf+SMwsCQOyusNw/GoXPV47WGd1xB5A1Pgzy0sQ3Bi5r5xm3n+92y3gCnB3MWqnRDdvfkRGxhKtbBRNgg==", + "version": "3.4.25", + "resolved": "https://registry.npmjs.org/@vue/shared/-/shared-3.4.25.tgz", + "integrity": "sha512-k0yappJ77g2+KNrIaF0FFnzwLvUBLUYr8VOwz+/6vLsmItFp51AcxLL7Ey3iPd7BIRyWPOcqUjMnm7OkahXllA==", "dev": true }, "node_modules/@vueuse/core": { @@ -3711,9 +3711,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001611", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001611.tgz", - "integrity": "sha512-19NuN1/3PjA3QI8Eki55N8my4LzfkMCRLgCVfrl/slbSAchQfV0+GwjPrK3rq37As4UCLlM/DHajbKkAqbv92Q==", + "version": "1.0.30001612", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001612.tgz", + "integrity": "sha512-lFgnZ07UhaCcsSZgWW0K5j4e69dK1u/ltrL9lTUiFOwNHs12S3UMIEYgBV0Z6C6hRDev7iRnMzzYmKabYdXF9g==", "dev": true, "funding": [ { @@ -4550,9 +4550,9 @@ } }, "node_modules/electron-to-chromium": { - "version": "1.4.744", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.744.tgz", - "integrity": "sha512-nAGcF0yeKKfrP13LMFr5U1eghfFSvFLg302VUFzWlcjPOnUYd52yU5x6PBYrujhNbc4jYmZFrGZFK+xasaEzVA==", + "version": "1.4.749", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.749.tgz", + "integrity": "sha512-LRMMrM9ITOvue0PoBrvNIraVmuDbJV5QC9ierz/z5VilMdPOVMjOtpICNld3PuXuTZ3CHH/UPxX9gHhAPwi+0Q==", "dev": true }, "node_modules/emoji-regex": { @@ -7761,9 +7761,9 @@ } }, "node_modules/micromark-core-commonmark": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/micromark-core-commonmark/-/micromark-core-commonmark-2.0.0.tgz", - "integrity": "sha512-jThOz/pVmAYUtkroV3D5c1osFXAMv9e0ypGDOIZuCeAe91/sD6BoE2Sjzt30yuXtwOYUmySOhMas/PVyh02itA==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-core-commonmark/-/micromark-core-commonmark-2.0.1.tgz", + "integrity": "sha512-CUQyKr1e///ZODyD1U3xit6zXwy1a8q2a1S1HKtIlmgvurrEpaw/Y9y6KSIbF8P59cn/NjzHyO+Q2fAyYLQrAA==", "dev": true, "funding": [ { @@ -9594,7 +9594,7 @@ "version": "19.11.1", "resolved": "https://registry.npmjs.org/puppeteer/-/puppeteer-19.11.1.tgz", "integrity": "sha512-39olGaX2djYUdhaQQHDZ0T0GwEp+5f9UB9HmEP0qHfdQHIq0xGQZuAZ5TLnJIc/88SrPLpEflPC+xUqOTv3c5g==", - "deprecated": "< 21.8.0 is no longer supported", + "deprecated": "< 21.9.0 is no longer supported", "dev": true, "hasInstallScript": true, "dependencies": { @@ -10104,9 +10104,9 @@ } }, "node_modules/rollup": { - "version": "4.14.3", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.14.3.tgz", - "integrity": "sha512-ag5tTQKYsj1bhrFC9+OEWqb5O6VYgtQDO9hPDBMmIbePwhfSr+ExlcU741t8Dhw5DkPCQf6noz0jb36D6W9/hw==", + "version": "4.16.4", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.16.4.tgz", + "integrity": "sha512-kuaTJSUbz+Wsb2ATGvEknkI12XV40vIiHmLuFlejoo7HtDok/O5eDDD0UpCVY5bBX5U5RYo8wWP83H7ZsqVEnA==", "dev": true, "dependencies": { "@types/estree": "1.0.5" @@ -10119,22 +10119,22 @@ "npm": ">=8.0.0" }, "optionalDependencies": { - "@rollup/rollup-android-arm-eabi": "4.14.3", - "@rollup/rollup-android-arm64": "4.14.3", - "@rollup/rollup-darwin-arm64": "4.14.3", - "@rollup/rollup-darwin-x64": "4.14.3", - "@rollup/rollup-linux-arm-gnueabihf": "4.14.3", - "@rollup/rollup-linux-arm-musleabihf": "4.14.3", - "@rollup/rollup-linux-arm64-gnu": "4.14.3", - "@rollup/rollup-linux-arm64-musl": "4.14.3", - "@rollup/rollup-linux-powerpc64le-gnu": "4.14.3", - "@rollup/rollup-linux-riscv64-gnu": "4.14.3", - "@rollup/rollup-linux-s390x-gnu": "4.14.3", - "@rollup/rollup-linux-x64-gnu": "4.14.3", - "@rollup/rollup-linux-x64-musl": "4.14.3", - "@rollup/rollup-win32-arm64-msvc": "4.14.3", - "@rollup/rollup-win32-ia32-msvc": "4.14.3", - "@rollup/rollup-win32-x64-msvc": "4.14.3", + "@rollup/rollup-android-arm-eabi": "4.16.4", + "@rollup/rollup-android-arm64": "4.16.4", + "@rollup/rollup-darwin-arm64": "4.16.4", + "@rollup/rollup-darwin-x64": "4.16.4", + "@rollup/rollup-linux-arm-gnueabihf": "4.16.4", + "@rollup/rollup-linux-arm-musleabihf": "4.16.4", + "@rollup/rollup-linux-arm64-gnu": "4.16.4", + "@rollup/rollup-linux-arm64-musl": "4.16.4", + "@rollup/rollup-linux-powerpc64le-gnu": "4.16.4", + "@rollup/rollup-linux-riscv64-gnu": "4.16.4", + "@rollup/rollup-linux-s390x-gnu": "4.16.4", + "@rollup/rollup-linux-x64-gnu": "4.16.4", + "@rollup/rollup-linux-x64-musl": "4.16.4", + "@rollup/rollup-win32-arm64-msvc": "4.16.4", + "@rollup/rollup-win32-ia32-msvc": "4.16.4", + "@rollup/rollup-win32-x64-msvc": "4.16.4", "fsevents": "~2.3.2" } }, @@ -11042,9 +11042,9 @@ "dev": true }, "node_modules/terser": { - "version": "5.30.3", - "resolved": "https://registry.npmjs.org/terser/-/terser-5.30.3.tgz", - "integrity": "sha512-STdUgOUx8rLbMGO9IOwHLpCqolkDITFFQSMYYwKE1N2lY6MVSaeoi10z/EhWxRc6ybqoVmKSkhKYH/XUpl7vSA==", + "version": "5.30.4", + "resolved": "https://registry.npmjs.org/terser/-/terser-5.30.4.tgz", + "integrity": "sha512-xRdd0v64a8mFK9bnsKVdoNP9GQIKUAaJPTaqEQDL4w/J8WaW4sWXXoMZ+6SimPkfT5bElreXf8m9HnmPc3E1BQ==", "dev": true, "dependencies": { "@jridgewell/source-map": "^0.3.3", @@ -11657,9 +11657,9 @@ } }, "node_modules/vite": { - "version": "5.2.9", - "resolved": "https://registry.npmjs.org/vite/-/vite-5.2.9.tgz", - "integrity": "sha512-uOQWfuZBlc6Y3W/DTuQ1Sr+oIXWvqljLvS881SVmAj00d5RdgShLcuXWxseWPd4HXwiYBFW/vXHfKFeqj9uQnw==", + "version": "5.2.10", + "resolved": "https://registry.npmjs.org/vite/-/vite-5.2.10.tgz", + "integrity": "sha512-PAzgUZbP7msvQvqdSD+ErD5qGnSFiGOoWmV5yAKUEI0kdhjbH6nMWVyZQC/hSc4aXwc0oJ9aEdIiF9Oje0JFCw==", "dev": true, "dependencies": { "esbuild": "^0.20.1", @@ -11750,25 +11750,25 @@ } }, "node_modules/vitepress/node_modules/@vue/devtools-api": { - "version": "7.0.27", - "resolved": "https://registry.npmjs.org/@vue/devtools-api/-/devtools-api-7.0.27.tgz", - "integrity": "sha512-BFCFCusSDcw2UcOFD/QeK7OxD1x2C/m+uAN30Q7jLKECSW53hmz0urzJmX834GuWDZX/hIxkyUKnLLfEIP1c/w==", + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/@vue/devtools-api/-/devtools-api-7.1.2.tgz", + "integrity": "sha512-AKd49cN3BdRgttmX5Aw8op7sx6jmaPwaILcDjaa05UKc1yIHDYST7P8yGZs6zd2pKFETAQz40gmyG7+b57slsQ==", "dev": true, "dependencies": { - "@vue/devtools-kit": "^7.0.27" + "@vue/devtools-kit": "^7.1.2" } }, "node_modules/vue": { - "version": "3.4.23", - "resolved": "https://registry.npmjs.org/vue/-/vue-3.4.23.tgz", - "integrity": "sha512-X1y6yyGJ28LMUBJ0k/qIeKHstGd+BlWQEOT40x3auJFTmpIhpbKLgN7EFsqalnJXq1Km5ybDEsp6BhuWKciUDg==", + "version": "3.4.25", + "resolved": "https://registry.npmjs.org/vue/-/vue-3.4.25.tgz", + "integrity": "sha512-HWyDqoBHMgav/OKiYA2ZQg+kjfMgLt/T0vg4cbIF7JbXAjDexRf5JRg+PWAfrAkSmTd2I8aPSXtooBFWHB98cg==", "dev": true, "dependencies": { - "@vue/compiler-dom": "3.4.23", - "@vue/compiler-sfc": "3.4.23", - "@vue/runtime-dom": "3.4.23", - "@vue/server-renderer": "3.4.23", - "@vue/shared": "3.4.23" + "@vue/compiler-dom": "3.4.25", + "@vue/compiler-sfc": "3.4.25", + "@vue/runtime-dom": "3.4.25", + "@vue/server-renderer": "3.4.25", + "@vue/shared": "3.4.25" }, "peerDependencies": { "typescript": "*" diff --git a/package.json b/package.json index 19438a9b9..b9121e868 100644 --- a/package.json +++ b/package.json @@ -113,7 +113,7 @@ "core-js": "We only update manually as every update requires a snapshot update" }, "devDependencies": { - "@codemirror/commands": "^6.3.3", + "@codemirror/commands": "^6.5.0", "@codemirror/lang-javascript": "^6.2.2", "@codemirror/language": "^6.10.1", "@codemirror/search": "^6.5.6", @@ -121,7 +121,7 @@ "@codemirror/view": "^6.26.3", "@jridgewell/sourcemap-codec": "^1.4.15", "@mermaid-js/mermaid-cli": "^10.8.0", - "@napi-rs/cli": "^2.18.1", + "@napi-rs/cli": "^2.18.2", "@rollup/plugin-alias": "^5.1.0", "@rollup/plugin-buble": "^1.0.3", "@rollup/plugin-commonjs": "^25.0.7", @@ -132,13 +132,13 @@ "@rollup/plugin-typescript": "^11.1.6", "@rollup/pluginutils": "^5.1.0", "@shikijs/vitepress-twoslash": "^1.3.0", - "@types/eslint": "^8.56.9", + "@types/eslint": "^8.56.10", "@types/inquirer": "^9.0.7", "@types/mocha": "^10.0.6", "@types/node": "~18.18.14", "@types/yargs-parser": "^21.0.3", - "@typescript-eslint/eslint-plugin": "^7.7.0", - "@typescript-eslint/parser": "^7.7.0", + "@typescript-eslint/eslint-plugin": "^7.7.1", + "@typescript-eslint/parser": "^7.7.1", "@vue/eslint-config-prettier": "^9.0.0", "@vue/eslint-config-typescript": "^13.0.0", "acorn": "^8.11.3", @@ -163,11 +163,11 @@ "fs-extra": "^11.2.0", "github-api": "^3.4.0", "husky": "^9.0.11", - "inquirer": "^9.2.18", + "inquirer": "^9.2.19", "is-reference": "^3.0.2", "lint-staged": "^15.2.2", "locate-character": "^3.0.0", - "magic-string": "^0.30.9", + "magic-string": "^0.30.10", "mocha": "^10.4.0", "nyc": "^15.1.0", "pinia": "^2.1.7", @@ -175,7 +175,7 @@ "pretty-bytes": "^6.1.1", "pretty-ms": "^9.0.0", "requirejs": "^2.3.6", - "rollup": "^4.14.3", + "rollup": "^4.16.2", "rollup-plugin-license": "^3.3.1", "rollup-plugin-string": "^3.0.0", "semver": "^7.6.0", @@ -184,12 +184,12 @@ "source-map": "^0.7.4", "source-map-support": "^0.5.21", "systemjs": "^6.14.3", - "terser": "^5.30.3", + "terser": "^5.30.4", "tslib": "^2.6.2", "typescript": "^5.4.5", - "vite": "^5.2.9", - "vitepress": "^1.1.0", - "vue": "^3.4.22", + "vite": "^5.2.10", + "vitepress": "^1.1.3", + "vue": "^3.4.24", "wasm-pack": "^0.12.1", "weak-napi": "^2.0.2", "yargs-parser": "^21.1.1" diff --git a/rust/Cargo.lock b/rust/Cargo.lock index bcb749f12..80600e273 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -117,12 +117,6 @@ dependencies = [ "xxhash", ] -[[package]] -name = "bitflags" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" - [[package]] name = "bitflags" version = "2.5.0" @@ -149,9 +143,9 @@ checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" [[package]] name = "cc" -version = "1.0.94" +version = "1.0.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17f6e324229dc011159fcc089755d1e2e216a90d43a7dea6853ca740b84f35e7" +checksum = "d32a725bc159af97c3e629873bb9f88fb8cf8a4867175f76dc987815ea07c83b" [[package]] name = "cfg-if" @@ -368,14 +362,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c2a198fb6b0eada2a8df47933734e6d35d350665a33a3593d7164fa52c75c19" dependencies = [ "cfg-if", - "windows-targets 0.52.5", + "windows-targets", ] [[package]] name = "lock_api" -version = "0.4.11" +version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45" +checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" dependencies = [ "autocfg", "scopeguard", @@ -419,7 +413,7 @@ version = "2.16.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "da1edd9510299935e4f52a24d1e69ebd224157e3e962c6c847edec5c2e4f786f" dependencies = [ - "bitflags 2.5.0", + "bitflags", "ctor", "napi-derive", "napi-sys", @@ -530,9 +524,9 @@ checksum = "7f222829ae9293e33a9f5e9f440c6760a3d450a64affe1846486b140db81c1f4" [[package]] name = "parking_lot" -version = "0.12.1" +version = "0.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" +checksum = "7e4af0ca4f6caed20e900d564c242b8e5d4903fdacf31d3daf527b66fe6f42fb" dependencies = [ "lock_api", "parking_lot_core", @@ -540,15 +534,15 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.9.9" +version = "0.9.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e" +checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" dependencies = [ "cfg-if", "libc", "redox_syscall", "smallvec", - "windows-targets 0.48.5", + "windows-targets", ] [[package]] @@ -690,11 +684,11 @@ checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" [[package]] name = "redox_syscall" -version = "0.4.1" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" +checksum = "469052894dcb553421e483e4209ee581a45100d31b4018de03e5a7ad86374a7e" dependencies = [ - "bitflags 1.3.2", + "bitflags", ] [[package]] @@ -961,9 +955,9 @@ dependencies = [ [[package]] name = "swc_compiler_base" -version = "0.7.20" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d7a0a78d52886c01786246fad54aa614cc145154d18607ddda72a180d1cb56c" +checksum = "10efbe9caf469304b3410e9701f529b748b7d7649409a30b5b9a1516e5d9df67" dependencies = [ "anyhow", "base64", @@ -1011,11 +1005,11 @@ dependencies = [ [[package]] name = "swc_ecma_ast" -version = "0.112.8" +version = "0.113.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1d5c33c22ad50e8e34b3080a6fb133316d2eaa7d00400fc5018151f5ca44c5a" +checksum = "f99fdda741656887f4cf75c1cee249a5f0374d67d30acc2b073182e902546ff2" dependencies = [ - "bitflags 2.5.0", + "bitflags", "is-macro", "num-bigint", "phf", @@ -1029,9 +1023,9 @@ dependencies = [ [[package]] name = "swc_ecma_codegen" -version = "0.148.17" +version = "0.149.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7188b2848402ce983f6c618a829b4ceb18d21eed7986782a7b7028cc234ede6b" +checksum = "5c21b8ae99bc3b95c6f7909915cd1e5994bec4e5b576f2e2a6879e56f2770760" dependencies = [ "memchr", "num-bigint", @@ -1060,9 +1054,9 @@ dependencies = [ [[package]] name = "swc_ecma_minifier" -version = "0.192.23" +version = "0.193.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1feab97d24c9931c5e88dca7730e6a6d4c7689ced9ba05814d9092651b3534db" +checksum = "3b0f521603b4a32a25d9a6c9bdc9c06a053dc1708f4952faab1c41bbc717e644" dependencies = [ "arrayvec", "indexmap", @@ -1093,9 +1087,9 @@ dependencies = [ [[package]] name = "swc_ecma_parser" -version = "0.143.16" +version = "0.144.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40b7faa481ac015b330f1c4bc8df2c9947242020e23ccdb10bc7a8ef84342509" +checksum = "3da9f3a58f0a64410f4006eb1fdb64d190ad3cc6cd12a7bf1f0dbb916e4ca4c7" dependencies = [ "either", "new_debug_unreachable", @@ -1115,12 +1109,12 @@ dependencies = [ [[package]] name = "swc_ecma_transforms_base" -version = "0.137.21" +version = "0.138.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "660badfe2eed8b6213ec9dcd71aa0786f8fb46ffa012e0313bcba1fe4a9a5c73" +checksum = "91771e358664649cf2cabec86a270bd9ce267f5213f299cacb255951b5edf06b" dependencies = [ "better_scoped_tls", - "bitflags 2.5.0", + "bitflags", "indexmap", "once_cell", "phf", @@ -1150,9 +1144,9 @@ dependencies = [ [[package]] name = "swc_ecma_transforms_optimization" -version = "0.198.22" +version = "0.199.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73e8de92a02fbd61965c723669f9d425dc1544831507abd78d9fca24c3974324" +checksum = "ba0d1c320c74b97e6f79f8ff5bae05b78cc211492b29654994963e4f1fe4a01f" dependencies = [ "dashmap", "indexmap", @@ -1174,9 +1168,9 @@ dependencies = [ [[package]] name = "swc_ecma_usage_analyzer" -version = "0.23.14" +version = "0.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b82af8ae5c6e5c1c1bdef70d5fb3ef16917985031f8688a7342c10a2123cfa6b" +checksum = "fbf2ab496ed1d5006758c27cadf3273798a6fe740fdf1b09b78f66cc252d40ae" dependencies = [ "indexmap", "rustc-hash", @@ -1191,9 +1185,9 @@ dependencies = [ [[package]] name = "swc_ecma_utils" -version = "0.127.20" +version = "0.128.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15d40abfc4f3a7bfdf54d11ac705cc9dd0836c48bf085b359143b4d40b50cb31" +checksum = "cd533f5751b7a8673bd843151c4e6e64a2dcf6c1f65331401e88f244c0e85de7" dependencies = [ "indexmap", "num_cpus", @@ -1209,9 +1203,9 @@ dependencies = [ [[package]] name = "swc_ecma_visit" -version = "0.98.7" +version = "0.99.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93692bdcdbb63db8f5e10fea5d202b5487cb27eb443aec424f4335c88f9864af" +checksum = "0c74008ebc5e0d3d9a1b3df54083ddbff1a375cfadff857da1fdc7837b48c52d" dependencies = [ "num-bigint", "swc_atoms", @@ -1516,67 +1510,34 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" -[[package]] -name = "windows-targets" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" -dependencies = [ - "windows_aarch64_gnullvm 0.48.5", - "windows_aarch64_msvc 0.48.5", - "windows_i686_gnu 0.48.5", - "windows_i686_msvc 0.48.5", - "windows_x86_64_gnu 0.48.5", - "windows_x86_64_gnullvm 0.48.5", - "windows_x86_64_msvc 0.48.5", -] - [[package]] name = "windows-targets" version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" dependencies = [ - "windows_aarch64_gnullvm 0.52.5", - "windows_aarch64_msvc 0.52.5", - "windows_i686_gnu 0.52.5", + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", "windows_i686_gnullvm", - "windows_i686_msvc 0.52.5", - "windows_x86_64_gnu 0.52.5", - "windows_x86_64_gnullvm 0.52.5", - "windows_x86_64_msvc 0.52.5", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", ] -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" - [[package]] name = "windows_aarch64_gnullvm" version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" -[[package]] -name = "windows_aarch64_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" - [[package]] name = "windows_aarch64_msvc" version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" -[[package]] -name = "windows_i686_gnu" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" - [[package]] name = "windows_i686_gnu" version = "0.52.5" @@ -1589,48 +1550,24 @@ version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" -[[package]] -name = "windows_i686_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" - [[package]] name = "windows_i686_msvc" version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" -[[package]] -name = "windows_x86_64_gnu" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" - [[package]] name = "windows_x86_64_gnu" version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" - [[package]] name = "windows_x86_64_gnullvm" version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" -[[package]] -name = "windows_x86_64_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" - [[package]] name = "windows_x86_64_msvc" version = "0.52.5" diff --git a/rust/parse_ast/Cargo.toml b/rust/parse_ast/Cargo.toml index 0dcf71b55..b086383ee 100644 --- a/rust/parse_ast/Cargo.toml +++ b/rust/parse_ast/Cargo.toml @@ -8,8 +8,8 @@ edition = "2021" [dependencies] anyhow = "1.0.82" swc_atoms = "0.6.7" -swc_compiler_base = "0.7.20" +swc_compiler_base = "0.8.0" swc_common = { version = "0.33.25", features = ["ahash", "parking_lot"] } -swc_ecma_ast = "0.112.8" -swc_ecma_parser = "0.143.16" -parking_lot = "0.12.1" +swc_ecma_ast = "0.113.0" +swc_ecma_parser = "0.144.0" +parking_lot = "0.12.2" From 778066d5af3d1a22232ea452516e48a0274a4995 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 26 Apr 2024 07:48:34 +0000 Subject: [PATCH 38/45] chore(deps): lock file maintenance minor/patch updates (#5493) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 0429f35a3..2b7785364 100644 --- a/package-lock.json +++ b/package-lock.json @@ -77,7 +77,7 @@ "pretty-bytes": "^6.1.1", "pretty-ms": "^9.0.0", "requirejs": "^2.3.6", - "rollup": "^4.16.2", + "rollup": "^4.16.3", "rollup-plugin-license": "^3.3.1", "rollup-plugin-string": "^3.0.0", "semver": "^7.6.0", diff --git a/package.json b/package.json index b9121e868..a9821e0b0 100644 --- a/package.json +++ b/package.json @@ -175,7 +175,7 @@ "pretty-bytes": "^6.1.1", "pretty-ms": "^9.0.0", "requirejs": "^2.3.6", - "rollup": "^4.16.2", + "rollup": "^4.16.3", "rollup-plugin-license": "^3.3.1", "rollup-plugin-string": "^3.0.0", "semver": "^7.6.0", From d98e59d796d447db3a279dc143e78b526896d594 Mon Sep 17 00:00:00 2001 From: liuly Date: Sat, 27 Apr 2024 12:27:47 +0800 Subject: [PATCH 39/45] feature(fix): function parameter tracking (#5483) * feat: re-init function parameter tracking Revert "Revert function parameter tracking logic for now (#5487)" This reverts commit 74da135569868881001635dc6762013f23ce5613. * refactor: see #5483 comments. squashed with some style commits style: move deoptimizeCache logic style: naming style: naming remove useless comment style: small update * make sure every addUsedPlace has a requestTreeshakingPass This is to make sure if onlyFunctionCallUsed becomes false, there is a new tree-shaking pass to deoptimize it * fix: missing reassigned guard --- src/ast/nodes/ArrowFunctionExpression.ts | 10 +- src/ast/nodes/CallExpression.ts | 23 ++-- src/ast/nodes/FunctionDeclaration.ts | 5 + src/ast/nodes/FunctionExpression.ts | 9 ++ src/ast/nodes/Identifier.ts | 6 + src/ast/nodes/MemberExpression.ts | 4 + src/ast/nodes/UpdateExpression.ts | 2 +- src/ast/nodes/shared/FunctionBase.ts | 49 +++++++ src/ast/variables/ExportDefaultVariable.ts | 10 ++ src/ast/variables/GlobalVariable.ts | 9 +- src/ast/variables/LocalVariable.ts | 4 +- src/ast/variables/ParameterVariable.ts | 123 +++++++++++++++++- src/ast/variables/Variable.ts | 31 ++++- .../_expected/amd/dep1.js | 5 +- .../_expected/cjs/dep1.js | 5 +- .../_expected/es/dep1.js | 5 +- .../_expected/system/dep1.js | 5 +- .../dep1.js | 3 +- .../amd/_virtual/_commonjsHelpers.js | 2 +- .../cjs/_virtual/_commonjsHelpers.js | 2 +- .../_expected/es/_virtual/_commonjsHelpers.js | 2 +- .../system/_virtual/_commonjsHelpers.js | 2 +- .../deopt-string-concatenation/_expected.js | 1 + .../deopt-string-concatenation/main.js | 1 + .../_config.js | 3 + .../_expected.js | 16 +++ .../main.js | 16 +++ .../samples/side-effect-h/_expected/amd.js | 1 + .../samples/side-effect-h/_expected/cjs.js | 1 + .../samples/side-effect-h/_expected/es.js | 1 + .../samples/side-effect-h/_expected/iife.js | 1 + .../samples/side-effect-h/_expected/system.js | 1 + .../samples/side-effect-h/_expected/umd.js | 1 + test/form/samples/side-effect-h/main.js | 1 + .../_expected/amd.js | 1 + .../_expected/cjs.js | 1 + .../_expected/es.js | 1 + .../_expected/iife.js | 1 + .../_expected/system.js | 1 + .../_expected/umd.js | 1 + .../side-effects-return-statements/main.js | 1 + .../samples/supports-es5-shim/_expected.js | 2 - .../samples/supports-es6-shim/_expected.js | 2 +- .../argument-assignment/_config.js | 3 + .../argument-assignment/_expected.js | 15 +++ .../argument-assignment/main.js | 15 +++ .../do-not-optimize/_config.js | 3 + .../do-not-optimize/_expected.js | 18 +++ .../do-not-optimize/main.js | 16 +++ .../expression-cache/_config.js | 3 + .../expression-cache/_expected.js | 14 ++ .../expression-cache/main.js | 16 +++ .../iife/_config.js | 3 + .../iife/_expected.js | 32 +++++ .../tree-shake-literal-parameter/iife/main.js | 38 ++++++ .../import-function/_config.js | 3 + .../import-function/_expected.js | 70 ++++++++++ .../import-function/arrow_lib.js | 30 +++++ .../import-function/lib.js | 37 ++++++ .../import-function/main.js | 17 +++ .../indirect-import-function/_config.js | 3 + .../indirect-import-function/_expected.js | 14 ++ .../define_and_export_default.js | 7 + .../import_then_export.js | 3 + .../import_then_export_sub.js | 5 + .../indirect-import-function/main.js | 5 + .../recursion-literal-object/_config.js | 3 + .../recursion-literal-object/_expected.js | 22 ++++ .../recursion-literal-object/main.js | 40 ++++++ .../recursion-literal/_config.js | 3 + .../recursion-literal/_expected.js | 13 ++ .../recursion-literal/main.js | 13 ++ .../reexport-function/_config.js | 3 + .../reexport-function/_expected.js | 7 + .../reexport-function/main.js | 3 + .../reexport-function/module1.js | 1 + .../reexport-function/module2.js | 5 + .../side-effect/_config.js | 3 + .../side-effect/_expected.js | 63 +++++++++ .../side-effect/main.js | 71 ++++++++++ .../top-level/_config.js | 3 + .../top-level/_expected.js | 23 ++++ .../top-level/main.js | 23 ++++ .../deactivate-via-option/_expected.js | 4 +- test/function/samples/acorn-walk/_config.js | 3 + test/function/samples/acorn-walk/main.js | 26 ++++ .../_config.js | 3 + .../reassigned-parameter-side-effect/main.js | 14 ++ .../samples/reassigned-parameter/_config.js | 3 + .../samples/reassigned-parameter/main.js | 21 +++ 90 files changed, 1069 insertions(+), 45 deletions(-) create mode 100644 test/form/samples/request-tree-shaking-before-render/_config.js create mode 100644 test/form/samples/request-tree-shaking-before-render/_expected.js create mode 100644 test/form/samples/request-tree-shaking-before-render/main.js create mode 100644 test/form/samples/tree-shake-literal-parameter/argument-assignment/_config.js create mode 100644 test/form/samples/tree-shake-literal-parameter/argument-assignment/_expected.js create mode 100644 test/form/samples/tree-shake-literal-parameter/argument-assignment/main.js create mode 100644 test/form/samples/tree-shake-literal-parameter/do-not-optimize/_config.js create mode 100644 test/form/samples/tree-shake-literal-parameter/do-not-optimize/_expected.js create mode 100644 test/form/samples/tree-shake-literal-parameter/do-not-optimize/main.js create mode 100644 test/form/samples/tree-shake-literal-parameter/expression-cache/_config.js create mode 100644 test/form/samples/tree-shake-literal-parameter/expression-cache/_expected.js create mode 100644 test/form/samples/tree-shake-literal-parameter/expression-cache/main.js create mode 100644 test/form/samples/tree-shake-literal-parameter/iife/_config.js create mode 100644 test/form/samples/tree-shake-literal-parameter/iife/_expected.js create mode 100644 test/form/samples/tree-shake-literal-parameter/iife/main.js create mode 100644 test/form/samples/tree-shake-literal-parameter/import-function/_config.js create mode 100644 test/form/samples/tree-shake-literal-parameter/import-function/_expected.js create mode 100644 test/form/samples/tree-shake-literal-parameter/import-function/arrow_lib.js create mode 100644 test/form/samples/tree-shake-literal-parameter/import-function/lib.js create mode 100644 test/form/samples/tree-shake-literal-parameter/import-function/main.js create mode 100644 test/form/samples/tree-shake-literal-parameter/indirect-import-function/_config.js create mode 100644 test/form/samples/tree-shake-literal-parameter/indirect-import-function/_expected.js create mode 100644 test/form/samples/tree-shake-literal-parameter/indirect-import-function/define_and_export_default.js create mode 100644 test/form/samples/tree-shake-literal-parameter/indirect-import-function/import_then_export.js create mode 100644 test/form/samples/tree-shake-literal-parameter/indirect-import-function/import_then_export_sub.js create mode 100644 test/form/samples/tree-shake-literal-parameter/indirect-import-function/main.js create mode 100644 test/form/samples/tree-shake-literal-parameter/recursion-literal-object/_config.js create mode 100644 test/form/samples/tree-shake-literal-parameter/recursion-literal-object/_expected.js create mode 100644 test/form/samples/tree-shake-literal-parameter/recursion-literal-object/main.js create mode 100644 test/form/samples/tree-shake-literal-parameter/recursion-literal/_config.js create mode 100644 test/form/samples/tree-shake-literal-parameter/recursion-literal/_expected.js create mode 100644 test/form/samples/tree-shake-literal-parameter/recursion-literal/main.js create mode 100644 test/form/samples/tree-shake-literal-parameter/reexport-function/_config.js create mode 100644 test/form/samples/tree-shake-literal-parameter/reexport-function/_expected.js create mode 100644 test/form/samples/tree-shake-literal-parameter/reexport-function/main.js create mode 100644 test/form/samples/tree-shake-literal-parameter/reexport-function/module1.js create mode 100644 test/form/samples/tree-shake-literal-parameter/reexport-function/module2.js create mode 100644 test/form/samples/tree-shake-literal-parameter/side-effect/_config.js create mode 100644 test/form/samples/tree-shake-literal-parameter/side-effect/_expected.js create mode 100644 test/form/samples/tree-shake-literal-parameter/side-effect/main.js create mode 100644 test/form/samples/tree-shake-literal-parameter/top-level/_config.js create mode 100644 test/form/samples/tree-shake-literal-parameter/top-level/_expected.js create mode 100644 test/form/samples/tree-shake-literal-parameter/top-level/main.js create mode 100644 test/function/samples/acorn-walk/_config.js create mode 100644 test/function/samples/acorn-walk/main.js create mode 100644 test/function/samples/reassigned-parameter-side-effect/_config.js create mode 100644 test/function/samples/reassigned-parameter-side-effect/main.js create mode 100644 test/function/samples/reassigned-parameter/_config.js create mode 100644 test/function/samples/reassigned-parameter/main.js diff --git a/src/ast/nodes/ArrowFunctionExpression.ts b/src/ast/nodes/ArrowFunctionExpression.ts index 8bf2df385..c99578c87 100644 --- a/src/ast/nodes/ArrowFunctionExpression.ts +++ b/src/ast/nodes/ArrowFunctionExpression.ts @@ -5,8 +5,9 @@ import type ChildScope from '../scopes/ChildScope'; import ReturnValueScope from '../scopes/ReturnValueScope'; import { type ObjectPath } from '../utils/PathTracker'; import type BlockStatement from './BlockStatement'; +import type CallExpression from './CallExpression'; import Identifier from './Identifier'; -import type * as NodeType from './NodeType'; +import * as NodeType from './NodeType'; import { Flag, isFlagSet, setFlag } from './shared/BitFlags'; import FunctionBase from './shared/FunctionBase'; import type { ExpressionNode, IncludeChildren } from './shared/Node'; @@ -67,6 +68,13 @@ export default class ArrowFunctionExpression extends FunctionBase { return false; } + protected onlyFunctionCallUsed(): boolean { + const isIIFE = + this.parent.type === NodeType.CallExpression && + (this.parent as CallExpression).callee === this; + return isIIFE || super.onlyFunctionCallUsed(); + } + include(context: InclusionContext, includeChildrenRecursively: IncludeChildren): void { super.include(context, includeChildrenRecursively); for (const parameter of this.params) { diff --git a/src/ast/nodes/CallExpression.ts b/src/ast/nodes/CallExpression.ts index 737f1a21e..85ddcaeaf 100644 --- a/src/ast/nodes/CallExpression.ts +++ b/src/ast/nodes/CallExpression.ts @@ -63,20 +63,17 @@ export default class CallExpression } hasEffects(context: HasEffectsContext): boolean { - try { - for (const argument of this.arguments) { - if (argument.hasEffects(context)) return true; - } - if (this.annotationPure) { - return false; - } - return ( - this.callee.hasEffects(context) || - this.callee.hasEffectsOnInteractionAtPath(EMPTY_PATH, this.interaction, context) - ); - } finally { - if (!this.deoptimized) this.applyDeoptimizations(); + if (!this.deoptimized) this.applyDeoptimizations(); + for (const argument of this.arguments) { + if (argument.hasEffects(context)) return true; } + if (this.annotationPure) { + return false; + } + return ( + this.callee.hasEffects(context) || + this.callee.hasEffectsOnInteractionAtPath(EMPTY_PATH, this.interaction, context) + ); } include(context: InclusionContext, includeChildrenRecursively: IncludeChildren): void { diff --git a/src/ast/nodes/FunctionDeclaration.ts b/src/ast/nodes/FunctionDeclaration.ts index 4f75fce15..9cfa8b21b 100644 --- a/src/ast/nodes/FunctionDeclaration.ts +++ b/src/ast/nodes/FunctionDeclaration.ts @@ -14,6 +14,11 @@ export default class FunctionDeclaration extends FunctionNode { } } + 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 Identifier(this, this.scope.parent as ChildScope).parseNode( diff --git a/src/ast/nodes/FunctionExpression.ts b/src/ast/nodes/FunctionExpression.ts index be7c5e431..85b2b5cb4 100644 --- a/src/ast/nodes/FunctionExpression.ts +++ b/src/ast/nodes/FunctionExpression.ts @@ -2,6 +2,7 @@ import type MagicString from 'magic-string'; import { BLANK } from '../../utils/blank'; 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'; @@ -25,6 +26,14 @@ export default class FunctionExpression extends FunctionNode { 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, diff --git a/src/ast/nodes/Identifier.ts b/src/ast/nodes/Identifier.ts index 11147f3fb..8bc4ffcd8 100644 --- a/src/ast/nodes/Identifier.ts +++ b/src/ast/nodes/Identifier.ts @@ -60,10 +60,12 @@ export default class Identifier extends NodeBase implements PatternNode { } } + private isReferenceVariable = false; bind(): void { if (!this.variable && isReference(this, this.parent as NodeWithFieldDefinition)) { this.variable = this.scope.findVariable(this.name); this.variable.addReference(this); + this.isReferenceVariable = true; } } @@ -295,6 +297,10 @@ export default class Identifier extends NodeBase implements PatternNode { this.variable.consolidateInitializers(); this.scope.context.requestTreeshakingPass(); } + if (this.isReferenceVariable) { + this.variable!.addUsedPlace(this); + this.scope.context.requestTreeshakingPass(); + } } private getVariableRespectingTDZ(): ExpressionEntity | null { diff --git a/src/ast/nodes/MemberExpression.ts b/src/ast/nodes/MemberExpression.ts index 5c32a896b..7d6c62047 100644 --- a/src/ast/nodes/MemberExpression.ts +++ b/src/ast/nodes/MemberExpression.ts @@ -396,6 +396,10 @@ export default class MemberExpression ); this.scope.context.requestTreeshakingPass(); } + if (this.variable) { + this.variable.addUsedPlace(this); + this.scope.context.requestTreeshakingPass(); + } } private applyAssignmentDeoptimization(): void { diff --git a/src/ast/nodes/UpdateExpression.ts b/src/ast/nodes/UpdateExpression.ts index 2d7b0613f..860bdd927 100644 --- a/src/ast/nodes/UpdateExpression.ts +++ b/src/ast/nodes/UpdateExpression.ts @@ -87,7 +87,7 @@ export default class UpdateExpression extends NodeBase { this.argument.deoptimizePath(EMPTY_PATH); if (this.argument instanceof Identifier) { const variable = this.scope.findVariable(this.argument.name); - variable.isReassigned = true; + variable.markReassigned(); } this.scope.context.requestTreeshakingPass(); } diff --git a/src/ast/nodes/shared/FunctionBase.ts b/src/ast/nodes/shared/FunctionBase.ts index 55b9f7f3d..e6fc3fb83 100644 --- a/src/ast/nodes/shared/FunctionBase.ts +++ b/src/ast/nodes/shared/FunctionBase.ts @@ -10,11 +10,16 @@ import { import type ReturnValueScope from '../../scopes/ReturnValueScope'; import type { ObjectPath, PathTracker } from '../../utils/PathTracker'; import { 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 Identifier from '../Identifier'; +import * as NodeType from '../NodeType'; import RestElement from '../RestElement'; import type SpreadElement from '../SpreadElement'; +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'; @@ -27,6 +32,8 @@ import { import type { ObjectEntity } from './ObjectEntity'; import type { PatternNode } from './Pattern'; +type InteractionCalledArguments = NodeInteractionCalled['args']; + export default abstract class FunctionBase extends NodeBase { declare body: BlockStatement | ExpressionNode; declare params: PatternNode[]; @@ -57,6 +64,27 @@ export default abstract class FunctionBase extends NodeBase { this.flags = setFlag(this.flags, Flag.generator, value); } + private updateParameterVariableValues(_arguments: InteractionCalledArguments): void { + for (let position = 0; position < this.params.length; position++) { + const parameter = this.params[position]; + if (!(parameter instanceof Identifier)) { + continue; + } + const parameterVariable = parameter.variable as ParameterVariable; + const argument = _arguments[position + 1] ?? UNDEFINED_EXPRESSION; + parameterVariable.updateKnownValue(argument); + } + } + + private deoptimizeParameterVariableValues() { + for (const parameter of this.params) { + if (parameter instanceof Identifier) { + const parameterVariable = parameter.variable as ParameterVariable; + parameterVariable.markReassigned(); + } + } + } + protected objectEntity: ObjectEntity | null = null; deoptimizeArgumentsOnInteractionAtPath( @@ -84,6 +112,7 @@ export default abstract class FunctionBase extends NodeBase { this.addArgumentToBeDeoptimized(argument); } } + this.updateParameterVariableValues(args); } else { this.getObjectEntity().deoptimizeArgumentsOnInteractionAtPath( interaction, @@ -102,6 +131,7 @@ export default abstract class FunctionBase extends NodeBase { for (const parameterList of this.scope.parameters) { for (const parameter of parameterList) { parameter.deoptimizePath(UNKNOWN_PATH); + parameter.markReassigned(); } } } @@ -180,7 +210,26 @@ export default abstract class FunctionBase extends NodeBase { 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.parameterVariableValuesDeoptimized && !this.onlyFunctionCallUsed()) { + this.parameterVariableValuesDeoptimized = true; + this.deoptimizeParameterVariableValues(); + } if (!this.deoptimized) this.applyDeoptimizations(); this.included = true; const { brokenFlow } = context; diff --git a/src/ast/variables/ExportDefaultVariable.ts b/src/ast/variables/ExportDefaultVariable.ts index 979405b57..70810936e 100644 --- a/src/ast/variables/ExportDefaultVariable.ts +++ b/src/ast/variables/ExportDefaultVariable.ts @@ -3,6 +3,7 @@ import ClassDeclaration from '../nodes/ClassDeclaration'; import type ExportDefaultDeclaration from '../nodes/ExportDefaultDeclaration'; import FunctionDeclaration from '../nodes/FunctionDeclaration'; import Identifier, { type IdentifierWithVariable } from '../nodes/Identifier'; +import type { NodeBase } from '../nodes/shared/Node'; import LocalVariable from './LocalVariable'; import UndefinedVariable from './UndefinedVariable'; import type Variable from './Variable'; @@ -37,6 +38,15 @@ export default class ExportDefaultVariable extends LocalVariable { } } + addUsedPlace(usedPlace: NodeBase): void { + const original = this.getOriginalVariable(); + if (original === this) { + super.addUsedPlace(usedPlace); + } else { + original.addUsedPlace(usedPlace); + } + } + forbidName(name: string) { const original = this.getOriginalVariable(); if (original === this) { diff --git a/src/ast/variables/GlobalVariable.ts b/src/ast/variables/GlobalVariable.ts index d55ed63ae..4f168ac8f 100644 --- a/src/ast/variables/GlobalVariable.ts +++ b/src/ast/variables/GlobalVariable.ts @@ -13,9 +13,12 @@ import type { ObjectPath, PathTracker } from '../utils/PathTracker'; import Variable from './Variable'; export default class GlobalVariable extends Variable { - // Ensure we use live-bindings for globals as we do not know if they have - // been reassigned - 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, diff --git a/src/ast/variables/LocalVariable.ts b/src/ast/variables/LocalVariable.ts index fe5bd4884..83b32a81e 100644 --- a/src/ast/variables/LocalVariable.ts +++ b/src/ast/variables/LocalVariable.ts @@ -91,7 +91,7 @@ export default class LocalVariable extends Variable { return; } if (path.length === 0) { - this.isReassigned = true; + this.markReassigned(); const expressionsToBeDeoptimized = this.expressionsToBeDeoptimized; this.expressionsToBeDeoptimized = EMPTY_ARRAY as unknown as DeoptimizableEntity[]; for (const expression of expressionsToBeDeoptimized) { @@ -222,7 +222,7 @@ export default class LocalVariable extends Variable { if (this.additionalInitializers === null) { this.additionalInitializers = [this.init]; this.init = UNKNOWN_EXPRESSION; - this.isReassigned = true; + this.markReassigned(); } return this.additionalInitializers; } diff --git a/src/ast/variables/ParameterVariable.ts b/src/ast/variables/ParameterVariable.ts index 94f3feb90..a17bf3b11 100644 --- a/src/ast/variables/ParameterVariable.ts +++ b/src/ast/variables/ParameterVariable.ts @@ -1,17 +1,21 @@ import type { AstContext } from '../../Module'; import { EMPTY_ARRAY } from '../../utils/blank'; +import type { DeoptimizableEntity } from '../DeoptimizableEntity'; +import type { HasEffectsContext } from '../ExecutionContext'; import type { NodeInteraction } from '../NodeInteractions'; -import { INTERACTION_CALLED } from '../NodeInteractions'; +import { INTERACTION_ASSIGNED, INTERACTION_CALLED } from '../NodeInteractions'; import type ExportDefaultDeclaration from '../nodes/ExportDefaultDeclaration'; -import type Identifier from '../nodes/Identifier'; -import type { ExpressionEntity } from '../nodes/shared/Expression'; +import Identifier from '../nodes/Identifier'; +import type { ExpressionEntity, LiteralValueOrUnknown } from '../nodes/shared/Expression'; import { deoptimizeInteraction, UNKNOWN_EXPRESSION, - UNKNOWN_RETURN_EXPRESSION + UNKNOWN_RETURN_EXPRESSION, + UnknownValue } from '../nodes/shared/Expression'; import type { ObjectPath, ObjectPathKey } from '../utils/PathTracker'; import { + EMPTY_PATH, PathTracker, SHARED_RECURSION_TRACKER, UNKNOWN_PATH, @@ -35,6 +39,7 @@ export default class ParameterVariable extends LocalVariable { private deoptimizations = new PathTracker(); private deoptimizedFields = new Set(); private entitiesToBeDeoptimized = new Set(); + private expressionsUseTheKnownValue: DeoptimizableEntity[] = []; constructor( name: string, @@ -71,6 +76,110 @@ export default class ParameterVariable extends LocalVariable { } } + markReassigned(): void { + if (this.isReassigned) { + return; + } + super.markReassigned(); + for (const expression of this.expressionsUseTheKnownValue) { + expression.deoptimizeCache(); + } + this.expressionsUseTheKnownValue = EMPTY_ARRAY as unknown as DeoptimizableEntity[]; + } + + deoptimizeCache(): void { + this.markReassigned(); + } + + private knownValue: ExpressionEntity | null = null; + private knownValueLiteral: LiteralValueOrUnknown = UnknownValue; + /** + * 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 + */ + updateKnownValue(argument: ExpressionEntity) { + if (this.isReassigned) { + return; + } + + if (this.knownValue === null) { + this.knownValue = argument; + this.knownValueLiteral = argument.getLiteralValueAtPath( + EMPTY_PATH, + 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 oldValue = this.knownValueLiteral; + if (typeof oldValue === 'symbol') { + this.markReassigned(); + return; + } + // add tracking for the new argument + const newValue = argument.getLiteralValueAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, this); + if (newValue !== oldValue) { + this.markReassigned(); + } + } + + private frozenValue: ExpressionEntity | null = null; + /** + * 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 { + if (this.frozenValue === null) { + this.frozenValue = this.knownValue || UNKNOWN_EXPRESSION; + } + return this.frozenValue; + } + + getLiteralValueAtPath( + path: ObjectPath, + recursionTracker: PathTracker, + origin: DeoptimizableEntity + ): LiteralValueOrUnknown { + if (this.isReassigned) { + return UnknownValue; + } + const knownValue = this.getKnownValue(); + this.expressionsUseTheKnownValue.push(origin); + return recursionTracker.withTrackedEntityAtPath( + path, + knownValue, + () => knownValue.getLiteralValueAtPath(path, recursionTracker, origin), + UnknownValue + ); + } + + hasEffectsOnInteractionAtPath( + path: ObjectPath, + interaction: NodeInteraction, + context: HasEffectsContext + ): boolean { + if (this.isReassigned || interaction.type === INTERACTION_ASSIGNED) { + return super.hasEffectsOnInteractionAtPath(path, interaction, context); + } + const knownValue = this.getKnownValue(); + return knownValue.hasEffectsOnInteractionAtPath(path, interaction, context); + } + deoptimizeArgumentsOnInteractionAtPath(interaction: NodeInteraction, path: ObjectPath): void { // For performance reasons, we fully deoptimize all deeper interactions if ( @@ -98,7 +207,11 @@ export default class ParameterVariable extends LocalVariable { } deoptimizePath(path: ObjectPath): void { - if (path.length === 0 || this.deoptimizedFields.has(UnknownKey)) { + if (path.length === 0) { + this.markReassigned(); + return; + } + if (this.deoptimizedFields.has(UnknownKey)) { return; } const key = path[0]; diff --git a/src/ast/variables/Variable.ts b/src/ast/variables/Variable.ts index 521ff1f9b..0cd2e40dd 100644 --- a/src/ast/variables/Variable.ts +++ b/src/ast/variables/Variable.ts @@ -4,8 +4,11 @@ import type { RenderOptions } from '../../utils/renderHelpers'; import type { HasEffectsContext } from '../ExecutionContext'; import type { NodeInteraction } from '../NodeInteractions'; import { INTERACTION_ACCESSED } from '../NodeInteractions'; +import type CallExpression from '../nodes/CallExpression'; import type Identifier from '../nodes/Identifier'; +import * as NodeType from '../nodes/NodeType'; import { ExpressionEntity } from '../nodes/shared/Expression'; +import type { NodeBase } from '../nodes/shared/Node'; import type { VariableKind } from '../nodes/shared/VariableKinds'; import type { ObjectPath } from '../utils/PathTracker'; @@ -16,7 +19,6 @@ export default class Variable extends ExpressionEntity { isId = false; // both NamespaceVariable and ExternalVariable can be namespaces declare isNamespace?: boolean; - isReassigned = false; kind: VariableKind | null = null; declare module?: Module | ExternalModule; renderBaseName: string | null = null; @@ -24,6 +26,11 @@ export default class Variable extends ExpressionEntity { private renderedLikeHoisted?: Variable; + readonly isReassigned = false; + markReassigned() { + (this as { isReassigned: boolean }).isReassigned = true; + } + constructor(public name: string) { super(); } @@ -34,6 +41,28 @@ export default class Variable extends ExpressionEntity { */ addReference(_identifier: Identifier): void {} + 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; + } + + /** + * 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; + } + } + /** * Prevent this variable from being renamed to this name to avoid name * collisions 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 1ebb9552c..c0bb33a62 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 @@ -5,12 +5,13 @@ define(['exports'], (function (exports) { 'use strict'; 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/dep1.js b/test/chunking-form/samples/missing-export-reused-deconflicting/_expected/cjs/dep1.js index a024bcd6f..31b08b56a 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 @@ -5,11 +5,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); exports.missing1 = _missingExportShim; 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 99f4196bf..d9c8b65f0 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 fb77b0059..24aa7ab54 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 @@ -8,12 +8,13 @@ System.register([], (function (exports) { 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/dep1.js b/test/chunking-form/samples/missing-export-reused-deconflicting/dep1.js index 84e22e0fe..f0751ef4c 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/preserve-modules-commonjs/_expected/amd/_virtual/_commonjsHelpers.js b/test/chunking-form/samples/preserve-modules-commonjs/_expected/amd/_virtual/_commonjsHelpers.js index f35ac4ef0..25ed6cf37 100644 --- 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 @@ -1,7 +1,7 @@ define(['exports'], (function (exports) { 'use strict'; function getDefaultExportFromCjs (x) { - return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; + return 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/_commonjsHelpers.js b/test/chunking-form/samples/preserve-modules-commonjs/_expected/cjs/_virtual/_commonjsHelpers.js index ceeaa4d07..fc314aed4 100644 --- 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 @@ -1,7 +1,7 @@ 'use strict'; function getDefaultExportFromCjs (x) { - return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; + return 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/es/_virtual/_commonjsHelpers.js b/test/chunking-form/samples/preserve-modules-commonjs/_expected/es/_virtual/_commonjsHelpers.js index 7b7c5f4f5..5fea8b909 100644 --- 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 @@ -1,5 +1,5 @@ function getDefaultExportFromCjs (x) { - return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; + return x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; } export { getDefaultExportFromCjs }; 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 index dd2c5886a..15f3676f9 100644 --- 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 @@ -6,7 +6,7 @@ System.register([], (function (exports) { exports("getDefaultExportFromCjs", getDefaultExportFromCjs); function getDefaultExportFromCjs (x) { - return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; + return x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; } }) diff --git a/test/form/samples/deopt-string-concatenation/_expected.js b/test/form/samples/deopt-string-concatenation/_expected.js index 68a30dc4f..42785de73 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 68a30dc4f..42785de73 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/request-tree-shaking-before-render/_config.js b/test/form/samples/request-tree-shaking-before-render/_config.js new file mode 100644 index 000000000..00d3b4e06 --- /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 000000000..f02682756 --- /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 000000000..85b8d4935 --- /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/side-effect-h/_expected/amd.js b/test/form/samples/side-effect-h/_expected/amd.js index d3a055b34..e46b7cd7c 100644 --- a/test/form/samples/side-effect-h/_expected/amd.js +++ b/test/form/samples/side-effect-h/_expected/amd.js @@ -7,6 +7,7 @@ define((function () { 'use strict'; } foo(); + foo(true); var main = 42; diff --git a/test/form/samples/side-effect-h/_expected/cjs.js b/test/form/samples/side-effect-h/_expected/cjs.js index 1d437295c..4862e7aa0 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 1d5410d07..39c215e33 100644 --- a/test/form/samples/side-effect-h/_expected/es.js +++ b/test/form/samples/side-effect-h/_expected/es.js @@ -5,6 +5,7 @@ function foo ( ok ) { } foo(); +foo(true); var main = 42; diff --git a/test/form/samples/side-effect-h/_expected/iife.js b/test/form/samples/side-effect-h/_expected/iife.js index 083d37914..b6fc61fb4 100644 --- a/test/form/samples/side-effect-h/_expected/iife.js +++ b/test/form/samples/side-effect-h/_expected/iife.js @@ -8,6 +8,7 @@ var myBundle = (function () { } foo(); + foo(true); var main = 42; diff --git a/test/form/samples/side-effect-h/_expected/system.js b/test/form/samples/side-effect-h/_expected/system.js index dcb761aa7..6ace3fb0f 100644 --- a/test/form/samples/side-effect-h/_expected/system.js +++ b/test/form/samples/side-effect-h/_expected/system.js @@ -10,6 +10,7 @@ System.register('myBundle', [], (function (exports) { } foo(); + foo(true); 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 770859846..f72ccce31 100644 --- a/test/form/samples/side-effect-h/_expected/umd.js +++ b/test/form/samples/side-effect-h/_expected/umd.js @@ -11,6 +11,7 @@ } foo(); + foo(true); var main = 42; diff --git a/test/form/samples/side-effect-h/main.js b/test/form/samples/side-effect-h/main.js index 16d734691..b736c13f9 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-effects-return-statements/_expected/amd.js b/test/form/samples/side-effects-return-statements/_expected/amd.js index dcdb995d3..1633b0ab0 100644 --- a/test/form/samples/side-effects-return-statements/_expected/amd.js +++ b/test/form/samples/side-effects-return-statements/_expected/amd.js @@ -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 7dd6e8130..93d4ccf36 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 38f357c97..9898b0d0f 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 c9da6fbbc..81b64ec81 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 968b34163..096bcc73f 100644 --- a/test/form/samples/side-effects-return-statements/_expected/system.js +++ b/test/form/samples/side-effects-return-statements/_expected/system.js @@ -11,6 +11,7 @@ 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 97a5be316..fc3ff304a 100644 --- a/test/form/samples/side-effects-return-statements/_expected/umd.js +++ b/test/form/samples/side-effects-return-statements/_expected/umd.js @@ -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 8e6b3b54f..a1e68e5d6 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/supports-es5-shim/_expected.js b/test/form/samples/supports-es5-shim/_expected.js index bc68debf9..645169277 100644 --- a/test/form/samples/supports-es5-shim/_expected.js +++ b/test/form/samples/supports-es5-shim/_expected.js @@ -2202,7 +2202,6 @@ var es5Shim = {exports: {}}; // eslint-disable-next-line no-global-assign, no-implicit-globals parseInt = (function (origParseInt) { return function parseInt(str, radix) { - if (this instanceof parseInt) { new origParseInt(); } // eslint-disable-line new-cap, no-new, max-statements-per-line var string = trim(String(str)); var defaultedRadix = $Number(radix) || (hexRegex.test(string) ? 16 : 10); return origParseInt(string, defaultedRadix); @@ -2233,7 +2232,6 @@ var es5Shim = {exports: {}}; // eslint-disable-next-line no-global-assign, no-implicit-globals parseInt = (function (origParseInt) { return function parseInt(str, radix) { - if (this instanceof parseInt) { new origParseInt(); } // eslint-disable-line new-cap, no-new, max-statements-per-line var isSym = typeof str === 'symbol'; if (!isSym && str && typeof str === 'object') { try { diff --git a/test/form/samples/supports-es6-shim/_expected.js b/test/form/samples/supports-es6-shim/_expected.js index ae2951820..84fb3b7f0 100644 --- a/test/form/samples/supports-es6-shim/_expected.js +++ b/test/form/samples/supports-es6-shim/_expected.js @@ -2057,7 +2057,7 @@ var es6Shim = {exports: {}}; }; var withinULPDistance = function withinULPDistance(result, expected, distance) { - return _abs(1 - (result / expected)) / Number.EPSILON < (distance || 8); + return _abs(1 - (result / expected)) / Number.EPSILON < (8); }; defineProperties(Math, MathShims); 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 000000000..1a210baea --- /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 000000000..f7cb2c16d --- /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 000000000..d9b364653 --- /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 000000000..d16519b09 --- /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 000000000..8e1230c75 --- /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 000000000..079d60a1b --- /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 000000000..697aea54b --- /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 000000000..8cee56182 --- /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 000000000..4c1f739a1 --- /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 000000000..789458177 --- /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 000000000..3e6eaeced --- /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 000000000..844a193c3 --- /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 000000000..e4a54b5f9 --- /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 000000000..f9d8a0fd9 --- /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 000000000..8b85efc44 --- /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 000000000..be4b8a63c --- /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 000000000..fcd0b9dcb --- /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 000000000..43454f74b --- /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 000000000..39872a4cf --- /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 000000000..b52e1846d --- /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 000000000..30e7e2b91 --- /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 000000000..2afc49468 --- /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 000000000..ad0e9fb26 --- /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 000000000..251df7a6a --- /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 000000000..f909ce360 --- /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 000000000..4f845cc4e --- /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 000000000..251df7a6a --- /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 000000000..2fcab0594 --- /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()); \ No newline at end of file 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 000000000..1187cc47f --- /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 000000000..74efd8ee3 --- /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 000000000..fd105290a --- /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()); \ No newline at end of file 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 000000000..c83b279bb --- /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 000000000..01e152738 --- /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 000000000..c4f4cacaf --- /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 000000000..e06ff5cdc --- /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 000000000..772756634 --- /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 000000000..d7f3ba001 --- /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 000000000..027f90cf3 --- /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 000000000..70d050ab7 --- /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 000000000..9f706606d --- /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/try-statement-deoptimization/deactivate-via-option/_expected.js b/test/form/samples/try-statement-deoptimization/deactivate-via-option/_expected.js index a8d430c8f..7a1891aac 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/function/samples/acorn-walk/_config.js b/test/function/samples/acorn-walk/_config.js new file mode 100644 index 000000000..02a5c20f5 --- /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 000000000..32da49051 --- /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/reassigned-parameter-side-effect/_config.js b/test/function/samples/reassigned-parameter-side-effect/_config.js new file mode 100644 index 000000000..a1ffc02b2 --- /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 000000000..b8d99e0d2 --- /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 000000000..5923f0afe --- /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 000000000..f2c6fe7d3 --- /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'); + From db192728df396a10a48841d07687d4354b9b9ed1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BF=A0=20/=20green?= Date: Sat, 27 Apr 2024 13:29:24 +0900 Subject: [PATCH 40/45] Use opt-level=z for browser wasm (#5494) --- package-lock.json | 19 +++++++++++++++++++ package.json | 3 ++- wasm/bindings_wasm.d.ts | 8 ++++---- wasm/bindings_wasm_bg.wasm.d.ts | 8 ++++---- 4 files changed, 29 insertions(+), 9 deletions(-) diff --git a/package-lock.json b/package-lock.json index 2b7785364..c5d83c201 100644 --- a/package-lock.json +++ b/package-lock.json @@ -51,6 +51,7 @@ "colorette": "^2.0.20", "concurrently": "^8.2.2", "core-js": "3.36.0", + "cross-env": "^7.0.3", "date-time": "^4.0.0", "es5-shim": "^4.6.7", "es6-shim": "^0.35.8", @@ -4235,6 +4236,24 @@ "integrity": "sha512-VQ2MBenTq1fWZUH9DJNGti7kKv6EeAuYr3cLwxUWhIu1baTaXh4Ib5W2CqHVqib4/MqbYGJqiL3Zb8GJZr3l4g==", "dev": true }, + "node_modules/cross-env": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/cross-env/-/cross-env-7.0.3.tgz", + "integrity": "sha512-+/HKd6EgcQCJGh2PSjZuUitQBQynKor4wrFbRg4DtAgS1aWO+gU52xpH7M9ScGgXSYmAVS9bIJ8EzuaGw0oNAw==", + "dev": true, + "dependencies": { + "cross-spawn": "^7.0.1" + }, + "bin": { + "cross-env": "src/bin/cross-env.js", + "cross-env-shell": "src/bin/cross-env-shell.js" + }, + "engines": { + "node": ">=10.14", + "npm": ">=6", + "yarn": ">=1" + } + }, "node_modules/cross-fetch": { "version": "3.1.5", "resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-3.1.5.tgz", diff --git a/package.json b/package.json index a9821e0b0..2751cc14c 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "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 --platform --dts native.d.ts --js false --cargo-cwd rust -p bindings_napi --cargo-name bindings_napi", - "build:wasm": "wasm-pack build rust/bindings_wasm --out-dir ../../wasm --target web --no-pack && shx rm wasm/.gitignore", + "build:wasm": "cross-env RUSTFLAGS=\"-C opt-level=z\" 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", @@ -149,6 +149,7 @@ "colorette": "^2.0.20", "concurrently": "^8.2.2", "core-js": "3.36.0", + "cross-env": "^7.0.3", "date-time": "^4.0.0", "es5-shim": "^4.6.7", "es6-shim": "^0.35.8", diff --git a/wasm/bindings_wasm.d.ts b/wasm/bindings_wasm.d.ts index cbf20a765..5feec2627 100644 --- a/wasm/bindings_wasm.d.ts +++ b/wasm/bindings_wasm.d.ts @@ -31,10 +31,10 @@ export interface InitOutput { readonly xxhashBase36: (a: number, b: number) => void; readonly xxhashBase16: (a: number, b: number) => void; readonly __wbindgen_add_to_stack_pointer: (a: number) => number; - readonly __wbindgen_malloc: (a: number, b: number) => number; - readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number; - readonly __wbindgen_free: (a: number, b: number, c: number) => void; - readonly __wbindgen_exn_store: (a: number) => void; + readonly __wbindgen_export_0: (a: number, b: number) => number; + readonly __wbindgen_export_1: (a: number, b: number, c: number, d: number) => number; + readonly __wbindgen_export_2: (a: number, b: number, c: number) => void; + readonly __wbindgen_export_3: (a: number) => void; } export type SyncInitInput = BufferSource | WebAssembly.Module; diff --git a/wasm/bindings_wasm_bg.wasm.d.ts b/wasm/bindings_wasm_bg.wasm.d.ts index af58c9386..d9dad8cd6 100644 --- a/wasm/bindings_wasm_bg.wasm.d.ts +++ b/wasm/bindings_wasm_bg.wasm.d.ts @@ -6,7 +6,7 @@ export function xxhashBase64Url(a: number, b: number): void; export function xxhashBase36(a: number, b: number): void; export function xxhashBase16(a: number, b: number): void; export function __wbindgen_add_to_stack_pointer(a: number): number; -export function __wbindgen_malloc(a: number, b: number): number; -export function __wbindgen_realloc(a: number, b: number, c: number, d: number): number; -export function __wbindgen_free(a: number, b: number, c: number): void; -export function __wbindgen_exn_store(a: number): void; +export function __wbindgen_export_0(a: number, b: number): number; +export function __wbindgen_export_1(a: number, b: number, c: number, d: number): number; +export function __wbindgen_export_2(a: number, b: number, c: number): void; +export function __wbindgen_export_3(a: number): void; From 82ec9b431ae601eebba4dd4424f7b538c8949697 Mon Sep 17 00:00:00 2001 From: XiaoPi <530257315@qq.com> Date: Sat, 27 Apr 2024 12:35:26 +0800 Subject: [PATCH 41/45] Report performance in CI (#5488) * Report performance in CI * Include the report of executing perf-report/index.js * Remove all ANSI styles * Report added or removed tree-shaking stages --- .github/workflows/performance-report.yml | 151 ++++++++++++++++++++++ package.json | 2 +- scripts/{perf.js => perf-report/index.js} | 80 +++++++++--- scripts/perf-report/report-collector.js | 47 +++++++ scripts/perf-report/rollup-artefacts.js | 3 + 5 files changed, 265 insertions(+), 18 deletions(-) create mode 100644 .github/workflows/performance-report.yml rename scripts/{perf.js => perf-report/index.js} (75%) create mode 100644 scripts/perf-report/report-collector.js create mode 100644 scripts/perf-report/rollup-artefacts.js diff --git a/.github/workflows/performance-report.yml b/.github/workflows/performance-report.yml new file mode 100644 index 000000000..6e4a8bdf6 --- /dev/null +++ b/.github/workflows/performance-report.yml @@ -0,0 +1,151 @@ +name: Performance Report +env: + BUILD_BOOTSTRAP_CJS: mv dist dist-build && node dist-build/bin/rollup --config rollup.config.ts --configPlugin typescript --configTest --forceExit && rm -rf dist-build + +on: + pull_request: + types: + - synchronize + - opened + - reopened + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +permissions: + contents: read + +jobs: + build-artefacts: + strategy: + matrix: + settings: + - name: current + ref: refs/pull/${{ github.event.number }}/merge + - name: previous + ref: ${{github.event.pull_request.base.ref}} + name: Build ${{matrix.settings.name}} artefact + runs-on: ubuntu-latest + steps: + - name: Checkout Commit + uses: actions/checkout@v4 + with: + ref: ${{matrix.settings.ref}} + - name: Install Toolchain + uses: dtolnay/rust-toolchain@stable + with: + toolchain: nightly-2023-10-05 + targets: x86_64-unknown-linux-gnu + - name: Cache cargo + uses: actions/cache@v4 + with: + path: | + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + .cargo-cache + rust/target/ + key: cargo-cache-${{ hashFiles('rust/Cargo.lock') }} + restore-keys: cargo-cache + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: 18 + - name: Cache Node Modules + id: cache-node-modules + uses: actions/cache@v4 + with: + path: node_modules + key: node-modules-${{ runner.os }}-${{ hashFiles('package-lock.json') }} + - name: Install dependencies + if: steps.cache-node-modules.outputs.cache-hit != 'true' + run: npm ci --ignore-scripts + - name: Build artefacts 123 + run: npm exec -- concurrently -c green,blue 'npm:build:napi -- --release' 'npm:build:cjs' && npm run build:copy-native && ${{env.BUILD_BOOTSTRAP_CJS}} && npm run build:copy-native + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: ${{ matrix.settings.name }} + path: dist/ + if-no-files-found: error + + report: + needs: build-artefacts + permissions: + pull-requests: write + runs-on: ubuntu-latest + name: Report Performance + steps: + - name: Checkout Commit + uses: actions/checkout@v4 + with: + ref: refs/pull/${{ github.event.number }}/merge + - name: Install Toolchain + uses: dtolnay/rust-toolchain@stable + with: + toolchain: nightly-2023-10-05 + targets: x86_64-unknown-linux-gnu + - name: Cache cargo + uses: actions/cache@v4 + with: + path: | + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + .cargo-cache + rust/target/ + key: cargo-cache-${{ hashFiles('rust/Cargo.lock') }} + restore-keys: cargo-cache + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: 18 + - name: Cache Node Modules + id: cache-node-modules + uses: actions/cache@v4 + with: + path: node_modules + key: node-modules-${{ runner.os }}-${{ hashFiles('package-lock.json') }} + - name: Install dependencies + if: steps.cache-node-modules.outputs.cache-hit != 'true' + run: npm ci --ignore-scripts + - name: Download all artifacts + uses: actions/download-artifact@v4 + with: + path: _benchmark + - name: Change rollup import in internal benchmark + run: | + echo "export { rollup as previousRollup, VERSION as previousVersion } from '../../_benchmark/previous/rollup.js';" > ./scripts/perf-report/rollup-artefacts.js + echo "export { rollup as newRollup } from '../../_benchmark/current/rollup.js';" >> ./scripts/perf-report/rollup-artefacts.js + - name: Run internal benchmark + run: node --expose-gc scripts/perf-report/index.js + - name: Install benchmark tool + run: cargo install --locked hyperfine + - name: Run Rough benchmark + run: | + hyperfine --warmup 1 --export-markdown _benchmark/rough-report.md --show-output --runs 3 \ + 'node _benchmark/previous/bin/rollup -i ./perf/entry.js -o _benchmark/result/previous.js' \ + 'node _benchmark/current/bin/rollup -i ./perf/entry.js -o _benchmark/result/current.js' + - name: Combine bechmark reports + run: | + echo "# Performance report!" > _benchmark/result.md + echo "## Rough benchmark" >> _benchmark/result.md + cat _benchmark/rough-report.md >> _benchmark/result.md + echo "## Internal benchmark" >> _benchmark/result.md + cat _benchmark/internal-report.md >> _benchmark/result.md + - name: Find Performance report + uses: peter-evans/find-comment@v3 + id: findPerformanceReport + with: + issue-number: ${{ github.event.number }} + comment-author: 'github-actions[bot]' + body-includes: 'Performance report' + - name: Create or update Performance report + uses: peter-evans/create-or-update-comment@v4 + id: createOrUpdatePerformanceReport + with: + comment-id: ${{ steps.findPerformanceReport.outputs.comment-id }} + issue-number: ${{ github.event.number }} + edit-mode: replace + body-path: _benchmark/result.md diff --git a/package.json b/package.json index 2751cc14c..62cdaaf6b 100644 --- a/package.json +++ b/package.json @@ -66,7 +66,7 @@ "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 && node --expose-gc scripts/perf.js", + "perf": "npm run build && node --expose-gc scripts/perf-report/index.js", "prepare": "husky && node scripts/check-release.js || npm run build:prepare", "prepublishOnly": "node scripts/check-release.js && node scripts/prepublish.js", "postpublish": "node scripts/postpublish.js", diff --git a/scripts/perf.js b/scripts/perf-report/index.js similarity index 75% rename from scripts/perf.js rename to scripts/perf-report/index.js index e8aba413b..f06e72342 100644 --- a/scripts/perf.js +++ b/scripts/perf-report/index.js @@ -5,10 +5,9 @@ import { chdir } from 'node:process'; import { fileURLToPath } from 'node:url'; import { createColors } from 'colorette'; import prettyBytes from 'pretty-bytes'; -import { rollup as previousRollup, VERSION as previousVersion } from 'rollup'; -// eslint-disable-next-line import/no-unresolved -import { rollup as newRollup } from '../dist/rollup.js'; -import { runWithEcho } from './helpers.js'; +import { runWithEcho } from '../helpers.js'; +import reportCollector from './report-collector.js'; +import { newRollup, previousRollup, previousVersion } from './rollup-artefacts.js'; /** * @typedef {Record} CollectedTimings @@ -18,7 +17,7 @@ import { runWithEcho } from './helpers.js'; * @typedef {Record} AccumulatedTimings */ -const PERF_DIRECTORY = new URL('../perf/', import.meta.url); +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 } = createColors(); @@ -91,10 +90,12 @@ async function calculatePrintAndPersistTimings() { ); clearLines(numberOfLinesToClear); } + reportCollector.startRecord(); printMeasurements( getAverage(accumulatedNewTimings, RUNS_TO_AVERAGE), getAverage(accumulatedPreviousTimings, RUNS_TO_AVERAGE) ); + await reportCollector.outputMsg(); } /** @@ -172,9 +173,16 @@ function getSingleAverage(times, runs, discarded) { * @return {number} */ function printMeasurements(newAverage, previousAverage, filter = /.*/) { - const printedLabels = Object.keys(newAverage).filter(label => filter.test(label)); - console.info(''); - for (const label of printedLabels) { + 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} */ @@ -185,16 +193,54 @@ function printMeasurements(newAverage, previousAverage, filter = /.*/) { color = underline; } } - console.info( - color( - `${label}: ${getFormattedTime( - newAverage[label].time, - previousAverage[label]?.time - )}, ${getFormattedMemory(newAverage[label].memory, previousAverage[label]?.memory)}` - ) - ); + 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}`; } - return printedLabels.length + 2; +} + +/** + * @param {string} label + */ +function isTreeShakingLabel(label) { + return label.startsWith('treeshaking pass'); } /** diff --git a/scripts/perf-report/report-collector.js b/scripts/perf-report/report-collector.js new file mode 100644 index 000000000..5201c0388 --- /dev/null +++ b/scripts/perf-report/report-collector.js @@ -0,0 +1,47 @@ +import { 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; + } + this.#messageList.push(message); + } + outputMsg() { + if (process.env.CI) { + return writeFile( + fileURLToPath(new URL('../../_benchmark/internal-report.md', import.meta.url)), + removeAnsiStyles(this.#messageList.join('\n')) + ); + } + } +})(); + +/** + * @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 000000000..936e44ce4 --- /dev/null +++ b/scripts/perf-report/rollup-artefacts.js @@ -0,0 +1,3 @@ +export { rollup as previousRollup, VERSION as previousVersion } from 'rollup'; +// eslint-disable-next-line import/no-unresolved +export { rollup as newRollup } from '../../dist/rollup.js'; From 8b30a5bbb8f654e9d497c26f1b851a0b93794b96 Mon Sep 17 00:00:00 2001 From: Lukas Taegert-Atkinson Date: Sat, 27 Apr 2024 13:19:05 +0200 Subject: [PATCH 42/45] Explicitly specify both Mac targets as runners switched arch --- .github/workflows/build-and-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-tests.yml b/.github/workflows/build-and-tests.yml index d683dd039..13cb4e17e 100644 --- a/.github/workflows/build-and-tests.yml +++ b/.github/workflows/build-and-tests.yml @@ -106,7 +106,7 @@ jobs: target: x86_64-apple-darwin build: >- set -e && - npm run build:napi -- --release + npm run build:napi -- --release --target x86_64-apple-darwin - host: macos-latest target: aarch64-apple-darwin build: >- From 91352494fc722bcd5e8e922cd1497b34aec57a67 Mon Sep 17 00:00:00 2001 From: Lukas Taegert-Atkinson Date: Sat, 27 Apr 2024 13:19:47 +0200 Subject: [PATCH 43/45] 4.17.0 --- CHANGELOG.md | 21 +++++++++++++++++++++ browser/package.json | 2 +- package-lock.json | 4 ++-- package.json | 2 +- 4 files changed, 25 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 37895bf32..e0db25d2e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,26 @@ # rollup changelog +## 4.17.0 + +_2024-04-27_ + +### Features + +- Track function call arguments to optimize functions only called once or with the same literal values (re-release from 4.16.0) (#5483) + +### Bug Fixes + +- Reduce browser WASM size to a fraction by changing optimization settings (#5494) + +### Pull Requests + +- [#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) + ## 4.16.4 _2024-04-23_ diff --git a/browser/package.json b/browser/package.json index 440053949..2c7a0cbe6 100644 --- a/browser/package.json +++ b/browser/package.json @@ -1,6 +1,6 @@ { "name": "@rollup/browser", - "version": "4.16.4", + "version": "4.17.0", "description": "Next-generation ES module bundler browser build", "main": "dist/rollup.browser.js", "module": "dist/es/rollup.browser.js", diff --git a/package-lock.json b/package-lock.json index c5d83c201..9134130bf 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "rollup", - "version": "4.16.4", + "version": "4.17.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "rollup", - "version": "4.16.4", + "version": "4.17.0", "license": "MIT", "dependencies": { "@types/estree": "1.0.5" diff --git a/package.json b/package.json index 62cdaaf6b..53477f75a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rollup", - "version": "4.16.4", + "version": "4.17.0", "description": "Next-generation ES module bundler", "main": "dist/rollup.js", "module": "dist/es/rollup.js", From 2a604f05e26e496df0934fe69a65648204a19494 Mon Sep 17 00:00:00 2001 From: waynzh Date: Mon, 29 Apr 2024 15:54:58 +0800 Subject: [PATCH 44/45] docs(cn): resolve conflicts --- README.md | 70 -------------- docs/command-line-interface/index.md | 124 +----------------------- docs/configuration-options/index.md | 36 ++----- docs/javascript-api/index.md | 140 ++------------------------- docs/plugin-development/index.md | 16 +-- 5 files changed, 24 insertions(+), 362 deletions(-) diff --git a/README.md b/README.md index f958dae75..52866181f 100644 --- a/README.md +++ b/README.md @@ -48,77 +48,7 @@

-<<<<<<< HEAD ## Rollup 贡献者 -======= -These commands assume the entry point to your application is named main.js, and that you'd like all imports compiled into a single file named bundle.js. - -For browsers: - -```bash -# compile to a