diff --git a/.github/workflows/build-and-tests.yml b/.github/workflows/build-and-tests.yml
index 40e49e88d..b0bf600e1 100644
--- a/.github/workflows/build-and-tests.yml
+++ b/.github/workflows/build-and-tests.yml
@@ -104,15 +104,13 @@ jobs:
target: x86_64-apple-darwin
build: >-
set -e &&
- npm run build:napi -- --release &&
- strip -x *.node
+ npm run build:napi -- --release --target x86_64-apple-darwin
- 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
@@ -121,14 +119,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
@@ -137,8 +134,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
@@ -147,8 +149,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
@@ -157,20 +158,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: |
@@ -179,8 +177,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: |
@@ -189,8 +186,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: |
@@ -200,8 +196,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
@@ -273,6 +268,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:
@@ -352,8 +441,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:
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/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/CHANGELOG.md b/CHANGELOG.md
index 8da23f4c9..e0db25d2e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,166 @@
# 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_
+
+### 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_
+
+### 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_
+
+### 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_
+
+### 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_
+
+### 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_
+
+### 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_
+
+### 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_
+
+### 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_
+
+### 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_
+
+### 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/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/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"
+ }
+ }
+}
diff --git a/README.md b/README.md
index 883242200..52866181f 100644
--- a/README.md
+++ b/README.md
@@ -50,7 +50,7 @@
## Rollup 贡献者
-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).
## Rollup 赞助者
diff --git a/browser/package.json b/browser/package.json
index 326289b2e..2c7a0cbe6 100644
--- a/browser/package.json
+++ b/browser/package.json
@@ -1,6 +1,6 @@
{
"name": "@rollup/browser",
- "version": "4.13.2",
+ "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/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/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/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/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/.vitepress/config.ts b/docs/.vitepress/config.ts
index 97c815b4b..2b8c43c89 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 980d657d4..a3c3878b8 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';
@@ -9,6 +12,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 7c2ff2de0..aae237f18 100755
--- a/docs/command-line-interface/index.md
+++ b/docs/command-line-interface/index.md
@@ -12,7 +12,9 @@ Rollup 通常应该从命令行使用。你可以提供一个可选的 Rollup
Rollup 配置文件是可选的,但它们非常强大和方便,因此**推荐**使用。配置文件是一个 ES 模块,它导出一个默认对象,其中包含所需的选项:
-```javascript
+```javascript twoslash
+/** @type {import('rollup').RollupOptions} */
+// ---cut---
export default {
input: 'src/main.js',
output: {
@@ -36,10 +38,13 @@ rollup --config rollup.config.ts --configPlugin typescript
配置文件支持下面列出的选项。有关每个选项的详细信息,请参阅[选项大全](../configuration-options/index.md):
-```javascript
+```javascript twoslash
// rollup.config.js
// 可以是数组(即多个输入源)
+// ---cut-start---
+/** @type {import('rollup').RollupOptions} */
+// ---cut-end---
export default {
// 核心输入选项
external,
@@ -92,6 +97,7 @@ export default {
generatedCode,
hashCharacters,
hoistTransitiveImports,
+ importAttributesKey,
inlineDynamicImports,
interop,
intro,
@@ -139,9 +145,12 @@ export default {
你可以从配置文件中导出一个**数组**,以便一次从多个不相关的输入进行打包,即使在监视模式下也可以。要使用相同的输入打出不同的包,你需要为每个输入提供一个输出选项数组:
-```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 +205,14 @@ rollup --config
你还可以导出一个返回任何上述配置格式的函数。该函数将传递当前的命令行参数,以便你可以动态地调整你的配置以遵循例如 [`--silent`](#silent)。如果你使用 `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 +225,30 @@ export default commandLineArgs => {
默认情况下,命令行参数将始终覆盖从配置文件中导出的相应值。如果你想更改这种行为,可以通过从 `commandLineArgs` 对象中删除它们来让 Rollup 忽略命令行参数:
-```javascript
+```javascript twoslash
// rollup.config.js
+// ---cut-start---
+/** @type {import('rollup').RollupOptionsFunction} */
+// ---cut-end---
export default commandLineArgs => {
- const inputBase = commandLineArgs.input || 'main.js';
-
- // 这会使 Rollup 忽略 CLI 参数
- delete commandLineArgs.input;
- return {
- input: 'src/entries/' + inputBase,
- output: { ... }
- }
-}
+ const inputBase = commandLineArgs.input || 'main.js';
+
+ // 这会使 Rollup 忽略 CLI 参数
+ delete commandLineArgs.input;
+ return {
+ input: 'src/entries/' + inputBase,
+ output: {
+ /* ... */
+ }
+ };
+};
```
### 填写配置时的智能提示 {#config-intellisense}
由于 Rollup 随附了 TypeScript 类型定义,因此你可以使用 JSDoc 类型提示来利用你的 IDE 的智能感知功能:
-```javascript
+```javascript twoslash
// rollup.config.js
/**
* @type {import('rollup').RollupOptions}
@@ -244,7 +261,7 @@ export default config;
或者,你可以使用 `defineConfig` 辅助函数,它应该提供无需 JSDoc 注释即可使用智能感知的功能:
-```javascript
+```javascript twoslash
// rollup.config.js
import { defineConfig } from 'rollup';
@@ -261,7 +278,7 @@ export default defineConfig({
你还可以通过 [`--configPlugin`](#configplugin-plugin) 选项直接使用 TypeScript 编写配置文件。使用 TypeScript,你可以直接导入 `RollupOptions` 类型:
-```typescript
+```typescript twoslash
import type { RollupOptions } from 'rollup';
const config: RollupOptions = {
@@ -298,14 +315,14 @@ rollup --config node:my-special-config
对于 CommonJS 文件,人们经常使用 `__dirname` 访问当前目录并将相对路径解析为绝对路径。这在原生 ES 模块中不被支持。相反,我们建议使用以下方法 (例如生成外部模块的绝对 id):
-```js
+```js twoslash
// rollup.config.js
-import { fileURLToPath } from 'node:url'
+import { fileURLToPath } from 'node:url';
export default {
- ...,
- // 为 /src/some-file.js 生成绝对路径
- external: [fileURLToPath(new URL('src/some-file.js', import.meta.url))]
+ /* ..., */
+ // 为 /src/some-file.js 生成绝对路径
+ external: [fileURLToPath(new URL('src/some-file.js', import.meta.url))]
};
```
@@ -315,7 +332,7 @@ export default {
- 对于 Node 17.5+,你可以使用导入断言
- ```js
+ ```js twoslash
import pkg from './package.json' assert { type: 'json' };
export default {
@@ -327,7 +344,7 @@ export default {
- 对于旧一些的 Node 版本,你可以使用 `createRequire`
- ```js
+ ```js twoslash
import { createRequire } from 'node:module';
const require = createRequire(import.meta.url);
const pkg = require('./package.json');
@@ -337,7 +354,7 @@ export default {
- 或者直接从磁盘读取并解析其内容
- ```js
+ ```js twoslash
// rollup.config.mjs
import { readFileSync } from 'node:fs';
@@ -386,7 +403,7 @@ export default {
--no-esModule 不添加 __esModule 属性
--exports 指定导出模式(auto、default、named、none)
--extend 扩展由 --name 定义的全局变量
---no-externalImportAssertions 在 "es" 输出中省略导入断言
+--no-externalImportAttributes 在 "es" 格式输出中省略导入属性
--no-externalLiveBindings 不生成支持实时绑定的代码
--failAfterWarnings 如果生成的构建产生警告,则退出并显示错误
--filterLogs 过滤日志信息
@@ -401,6 +418,7 @@ export default {
--generatedCode.symbols 在生成的代码中使用符号
--hashCharacters 使用指定的字符集来生成文件的哈希值
--no-hoistTransitiveImports 不将中转导入提升到入口块中
+--importAttributesKey 使用特定的关键词作为导入属性
--no-indent 不缩进结果
--inlineDynamicImports 使用动态导入时创建单次打包
--no-interop 不包括交互操作块
diff --git a/docs/configuration-options/index.md b/docs/configuration-options/index.md
index 1321a83a6..5256e09a2 100755
--- a/docs/configuration-options/index.md
+++ b/docs/configuration-options/index.md
@@ -20,10 +20,13 @@ title: 配置选项
1. 外部依赖的名称,需要和引入语句中写法完全一致。例如,如果想标记 `import "dependency.js"` 为外部依赖,就需要使用 `"dependency.js"` 作为模块 ID;而如果要标记 `import "dependency"` 为外部依赖,则使用 `"dependency"`。
2. 解析过的模块 ID(如文件的绝对路径)。
-```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 @@ console.log(x);
请注意,当选项的值使用对象形式时,可以通过在名称中添加 `/` 来将入口文件放入不同的子文件夹。以下例子将根据 `entry-a.js` 和 `entry-b/index.js`,产生至少两个入口 chunks,即 `index.js`文件将输出在 `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'
+ }
};
```
如果你想将一组文件转换为另一种格式,并同时保持文件结构和导出签名,推荐的方法是将每个文件变成一个入口文件,而不是使用 [`output.preserveModules`](#output-preservemodules),后者可能会导出被除屑优化,并产生由插件创建的虚拟文件。你可以动态地处理,例如通过 `glob` 包。
-```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';
我们需要告诉 Rollup `jquery` 是外部依赖,`jquery` 模块的 ID 为全局变量 `$`:
-```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:_
要告诉 Rollup 用全局变量替换本地文件时,请使用一个绝对路径的 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 {
对于输出格式为 `iife` / `umd` 的 bundle 来说,若想要使用全局变量名来表示你的 bundle 时,该选项是必要的。同一页面上的其他脚本可以使用这个变量名来访问你的 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 @@ this.a.b.c = ...
以下是一个使用压缩插件作用于其中一个输出的例子:
-```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 {
关于如何使用插件的更多信息,请查看 [使用插件](../tutorial/index.md#using-plugins)章节,关于如何编写你自己的插件,请查看 [插件](../plugin-development/index.md)章节(试试看吧,它并不像听起来那么困难,你可以通过 Rollup 插件做很多拓展)。对于从包中引入的插件,记住要调用引入的插件函数(即调用 `commonjs()`,而不仅仅是 `commonjs`)。返回值为假的插件将被忽略,这样可以用来灵活启用或禁用插件。嵌套的插件将扁平化。异步插件将等待和被解决。
-```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 () => ({
该选项用于指定之前 bundle 的 `cache` 属性。使用该设置,Rollup 将只会对改变的模块重新分析,从而加速观察模式中后续的构建。将此选项明确设置为 `false` 将阻止 bundle 生成 `cache` 属性,也将导致插件的缓存失效。
-```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 @@ interface RollupLog {
如果不调用默认处理程序,日志将不会打印到控制台。此外,您可以通过调用不同级别的默认处理程序来改变日志级别。使用附加级别 `"error"` 将把日志转换为一个抛出的错误,该错误具有附加的所有日志属性。
-```js
+```js twoslash
// rollup.config.js
+// ---cut-start---
+/** @type {import('rollup').RollupOptions} */
+// ---cut-end---
export default {
//...
onLog(level, log, handler) {
@@ -502,8 +536,11 @@ export default {
一些日志也有 `loc` 和 `frame` 属性,允许你定位日志的源:
-```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 @@ export default {
`chunk` 是可变的,在这个钩子中应用的变化将传递到其他插件和生成的 bundle 中。这意味着如果你在这个钩子中增加或删除引入或导出,你应该更新 `imports`、`importedBindings` 以及 `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 @@ export default {
虽然 CommonJS 输出最初只支持 `require(…)` 语法来引入依赖,但最近的 Node 版本也开始支持 `import(…)` 语法,这是从 CommonJS 文件中引入 ES 模块的唯一方法。如果这个选项默认值为 `true`,表示 Rollup 会在 CommonJS 输出中保持外部依赖以 `import(…)` 表达式动态引入。将值设置为 `false`,以使用 `require(…)` 语法重写动态引入。
-```js
+```js twoslash
// 输入
import('external').then(console.log);
@@ -721,7 +761,7 @@ Promise.resolve()
该选项表示在某些地方和辅助函数中使用 `const` 而不是 `var`。由于代码块的作用域,会使 Rollup 产生更有效的辅助函数。
-```js
+```js twoslash
// 输入
export * from 'external';
@@ -760,7 +800,7 @@ for (const k in external) {
该选项表示当属性名称与值匹配时,是否允许在对象中使用别名。
-```javascript
+```javascript twoslash
// input
const foo = 1;
export { foo, foo as bar };
@@ -797,7 +837,10 @@ System.register('bundle', [], function (exports) {
该选项可以选择上面列出的预设之一,同时覆盖一些选项。
-```js
+```js twoslash
+// ---cut-start---
+/** @type {import('rollup').RollupOptions} */
+// ---cut-end---
export default {
// ...
output: {
@@ -887,6 +930,16 @@ exports.foo = foo;
默认情况下,创建多个 chunk 时,入口 chunk 的可传递引入将以空引入的形式被打包。详细信息和背景请查看 ["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)。该选项的值为 `false` 将禁用此行为。当使用 [`output.preserveModules`](#output-preservemodules) 选项时,该选项会被忽略,使得永远不会取消引入。
+### output.importAttributesKey
+
+| | |
+| -----: | :----------------------------- |
+| 类型: | `"with" \| "assert"` |
+| CLI: | `--importAttributesKey ` |
+| 默认: | `"assert"` |
+
+该选项决定 Rollup 用于导入属性的关键词集合。
+
### output.inlineDynamicImports {#output-inlinedynamicimports}
| | |
@@ -919,7 +972,7 @@ import('external2').then(console.log);
- `"default"` 意为所需的值应该被视为引入模块的默认出口,就像在 NodeJS 中从 ES 模块上下文引入 CommonJS 一样。其也支持命名的引入,它们被视为默认引入的属性。为了创建命名空间对象,Rollup 注入了这些辅助函数:
- ```js
+ ```js twoslash
var external = require('external1');
function _interopNamespaceDefault(e) {
@@ -973,7 +1026,7 @@ import('external2').then(console.log);
- `"auto"` 结合了 `"esModule"` 和 `"default"`,通过注入辅助函数,其包含在运行时检测所需的值是否包含 [`__esModule` 属性](#output-esmodule) 的代码。添加这个属性是 TypeScript `esModuleInterop`、Babel 和其他工具实现的一种解决方式,标志着所需值是 ES 模块编译后的命名空间:
- ```js
+ ```js twoslash
var external = require('external1');
function _interopNamespace(e) {
@@ -1035,7 +1088,7 @@ import('external2').then(console.log);
- `compat` 等同于 `"auto"`,只是它对默认导出使用了一个稍微不同的辅助函数,其检查是否存在一个 `default` 属性而不是 `__esModule` 属性。除了 CommonJS 模块导出的属性 `"default"` 不应该是默认导出的这种罕见情况,该值通常有助于使互操作“正常工作”,因为它不依赖于特异的实现,而是使用鸭子类型(duck-typing):
- ```js
+ ```js twoslash
var external = require('external1');
function _interopNamespaceCompat(e) {
@@ -1131,11 +1184,14 @@ import('external2').then(console.log);
例如,如果所有的依赖都是 CommonJs,下面的配置将确保只允许从 Node 内置的命名引入:
- ```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 +1220,10 @@ import('external2').then(console.log);
除了在特定格式中代码不同外,该选项功能和 [`output.banner/output.footer`](#output-banner-output-footer) 类似。
-```js
+```js twoslash
+// ---cut-start---
+/** @type {import('rollup').RollupOptions} */
+// ---cut-end---
export default {
//...,
output: {
@@ -1196,7 +1255,10 @@ export default {
当该选项值为函数形式时,每个被解析的模块都会经过该函数处理。如果函数返回字符串,那么该模块及其所有依赖将被添加到以返回字符串命名的自定义 chunk 中。例如,以下例子会创建一个命名为 `vendor` 的 chunk,它包含所有在 `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 +1290,18 @@ function getTranslatedStrings(currentLanguage) {
下面代码将会合并所有仅由单个入口使用的相一语言文件:
-```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]; // 例如 “en”
+// ---cut-start---
+ /** @type {string[]} */
+// ---cut-end---
const dependentEntryPoints = [];
// 在这里,我们使用 Set 一次性处理每个依赖模块
@@ -1240,6 +1309,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 +1336,7 @@ function manualChunks(id, { getModuleInfo }) {
}
}
```
+
### output.minifyInternalExports {#output-minifyinternalexports}
@@ -1336,13 +1409,16 @@ console.log(importantValue);
该选项用于将外部依赖 ID 映射为路径。其中,外部依赖 ID 是指该选项 [无法解析](../troubleshooting/index.md#warning-treating-module-as-external-dependency) 的模块或者通过 [`external`](#external) 选项明确指定的模块。`output.paths` 提供的路径会取代模块 ID,在生成的 bundle 中使用,比如你可以从 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 +1502,10 @@ console.log(main.default); // 42
例如,给定以下配置:
-```javascript
+```javascript twoslash
+// ---cut-start---
+/** @type {import('rollup').RollupOptions} */
+// ---cut-end---
export default {
input: ['src/module.js', `src/another/module.js`],
output: [
@@ -1508,8 +1587,11 @@ export default {
该选项决定是否忽略 sourcemap 中列出的源文件,用于填充 [`x_google_ignoreList` source map 扩展](https://developer.chrome.com/articles/x-google-ignore-list/)。`relativeSourcePath` 是生成的 `.map` 文件到相应源文件的相对路径,而 `sourcemapPath` 是生成的 sourcemap 文件的绝对路径。
-```js
+```js twoslash
import path from 'node:path';
+// ---cut-start---
+/** @type {import('rollup').RollupOptions} */
+// ---cut-end---
export default {
input: 'src/main',
output: [
@@ -1536,8 +1618,11 @@ export default {
该选项用于 sourcemap 的路径转换。其中,`relativeSourcePath` 是指从生成的 `.map` 文件到相对应的源文件的相对路径,而 `sourcemapPath` 是指生成 sourcemap 文件的绝对路径。
-```js
+```js twoslash
import path from 'node:path';
+// ---cut-start---
+/** @type {import('rollup').RollupOptions} */
+// ---cut-end---
export default {
input: 'src/main',
output: [
@@ -1702,14 +1787,19 @@ console.log(shared);
该选项用于设置 AMD/UMD bundle 的 ID:
-```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 +1814,19 @@ export default {
该选项用于设置 chunk ID 的 ID(去除“.js”扩展名后)。
-```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 +1844,20 @@ export default {
只在 [`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 +1873,19 @@ export default {
该选项用于指定代替 `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 +1901,19 @@ export default {
该选项决定为生成的 chunk 和本地 AMD 模块的引入添加 `.js` 扩展名:
-```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 +2048,17 @@ exports.x = external.x;
该选项用于指定代码缩进的缩进字符串(在 `amd`,`iife`,`umd` 和 `system` 格式中)。它的值可以是 `false` (没有缩进)或 `true` (默认值——自动缩进)。
-```js
+```js twoslash
// rollup.config.js
+// ---cut-start---
+/** @type {import('rollup').RollupOptions} */
+// ---cut-end---
export default {
- ...,
- output: {
- ...,
- indent: false
- }
+ // ...
+ output: {
+ // ...
+ indent: false
+ }
};
```
@@ -2217,8 +2330,11 @@ logIfEnabled(); // 需要保留,因为它展示日志
除了任何与该名称相匹配的函数,纯函数上的任何属性以及从纯函数返回的任何函数也将被视为纯函数,访问任何属性都不会被检查出副作用。
-```js
+```js twoslash
// rollup.config.js
+// ---cut-start---
+/** @type {import('rollup').RollupOptions} */
+// ---cut-end---
export default {
treeshake: {
preset: 'smallest',
@@ -2339,7 +2455,10 @@ console.log(foo);
该选项可以选择上面列出的预设之一,同时覆盖一些选项。
-```js
+```js twoslash
+// ---cut-start---
+/** @type {import('rollup').RollupOptions} */
+// ---cut-end---
export default {
treeshake: {
preset: 'smallest',
@@ -2526,8 +2645,11 @@ interface WatcherOptions {
该选项用于指定观察模式(watch mode)的选项,或防止 Rollup 配置被观察。指定该选项为 `false`,将仅对 Rollup 使用数组配置时有效。在这种情况下,Rollup 配置将不会根据观察模式中的变更构建或重新构建,而是在 Rollup 运行时定期构建:
-```js
+```js twoslash
// rollup.config.js
+// ---cut-start---
+/** @type {import('rollup').RollupOptions[]} */
+// ---cut-end---
export default [
{
input: 'main.js',
@@ -2580,13 +2702,16 @@ export default [
该选项用于指定不需要被 watch 的文件:
-```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 +2724,16 @@ export default {
该选项用于限制只能对指定文件进行观察。请注意,该选项只过滤模块图中的文件,不允许添加额外的观察文件:
-```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 cd5860d05..b9ada7a7c 100755
--- a/docs/faqs/index.md
+++ b/docs/faqs/index.md
@@ -134,7 +134,10 @@ import * as rollup from 'https://unpkg.com/@rollup/browser/dist/es/rollup.browse
这将创建一个全局变量 `window.rollup`。由于浏览器构建无法访问文件系统,因此你需要提供解析和加载要捆绑的所有模块的插件。以下是一个虚构的示例:
-```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
此示例仅支持两个导入,`"main.js"` 和 `"foo.js"`,不支持相对导入。以下是另一个示例,它使用绝对 URL 作为入口点,并支持相对导入。在这种情况下,我们只是重新打包 Rollup 本身,但它可以用于任何其他公开 ES 模块的 URL:
-```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 89607856c..e268b18c0 100755
--- a/docs/javascript-api/index.md
+++ b/docs/javascript-api/index.md
@@ -18,41 +18,63 @@ Rollup 提供了一个可从 Node.js 使用的 JavaScript API。你很少需要
如果任一阶段发生错误,它将返回一个 Promise,该 Promise 被 reject 得到一个 Error,你可以通过它们的 `code` 属性来识别。除了 `code` 和 `message`,许多错误还有其他属性,你可以用于自定义报告,见 [`utils/logs.ts`](https://github.com/rollup/rollup/blob/master/src/utils/logs.ts) 以获取完整的错误和日志列表,以及它们的代码和属性。
-```javascript
+
+```javascript twoslash
import { rollup } from 'rollup';
// 请继续浏览下面的内容获取更多关于这个选项的细节
-const inputOptions = {...};
+// ---cut-start---
+/** @type {import('rollup').InputOptions} */
+// ---cut-end---
+const inputOptions = {
+ /* ... */
+};
// 你可以从相同的输入创建多个输出,
// 以生成例如 CommonJS 和 ESM 这样的不同格式
-const outputOptionsList = [{...}, {...}];
+// ---cut-start---
+/** @type {import('rollup').OutputOptions[]} */
+// ---cut-end---
+const outputOptionsList = [
+ {
+ /* ... */
+ },
+ {
+ /* ... */
+ }
+];
build();
async function build() {
- let bundle;
- let buildFailed = false;
- try {
- // 启动一次打包
- bundle = await rollup(inputOptions);
-
- // 一个文件名数组,表示此产物所依赖的文件
- console.log(bundle.watchFiles);
-
- await generateOutputs(bundle);
- } catch (error) {
- buildFailed = true;
- // 进行一些错误报告
- console.error(error);
- }
- if (bundle) {
- // 关闭打包过程
- await bundle.close();
- }
- process.exit(buildFailed ? 1 : 0);
+// ---cut-start---
+ /** @type {import('rollup').RollupBuild} */
+// ---cut-end---
+ let bundle;
+ let buildFailed = false;
+ try {
+ // 启动一次打包
+ bundle = await rollup(inputOptions);
+
+ // 一个文件名数组,表示此产物所依赖的文件
+ console.log(bundle.watchFiles);
+
+ await generateOutputs(bundle);
+ } catch (error) {
+ buildFailed = true;
+ // 进行一些错误报告
+ console.error(error);
+ }
+ if (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) {
// 生成特定于输出的内存中代码
@@ -104,12 +126,16 @@ async function generateOutputs(bundle) {
}
}
```
+
### inputOptions 对象 {#inputoptions-object}
`inputOptions` 对象可以包含以下属性(有关详细信息,请参见 [选项大全](../configuration-options/index.md)):
-```js
+```js twoslash
+// ---cut-start---
+/** @type {import('rollup').InputOptions} */
+// ---cut-end---
const inputOptions = {
// 核心输入选项
external,
@@ -144,7 +170,10 @@ const inputOptions = {
`outputOptions` 对象可以包含以下属性(有关详细信息,请参见 [选项大全](../configuration-options/index.md)):
-```js
+```js twoslash
+// ---cut-start---
+/** @type {import('rollup').OutputOptions} */
+// ---cut-end---
const outputOptions = {
// 核心输出选项
dir,
@@ -167,6 +196,7 @@ const outputOptions = {
generatedCode,
hashCharacters,
hoistTransitiveImports,
+ importAttributesKey,
inlineDynamicImports,
interop,
intro,
@@ -207,55 +237,66 @@ const outputOptions = {
Rollup 还提供了一个 `rollup.watch` 函数,当检测到磁盘上的某个模块已更改时,它将重新打包。当你在命令行中使用 `--watch` 标志运行 Rollup 时,它会在内部使用。请注意,当通过 JavaScript API 使用观察模式时,你需要在响应 `BUNDLE_END` 事件时调用 `event.result.close()`,以允许插件在 [`closeBundle`](../plugin-development/index.md#closebundle) 钩子中清理资源,见下文。
-```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 可以是以下之一:
- // START - 监视器正在(重新)启动
- // BUNDLE_START - 单次打包
- // * 如果存在,event.input 将是输入选项对象
- // * event.output 包含生成的输出的 "file"
- // 或 "dir" 选项值的数组
- // BUNDLE_END - 完成打包
- // * 如果存在,event.input 将是输入选项对象
- // * event.output 包含生成的输出的 "file"
- // 或 "dir" 选项值的数组
- // * event.duration 是构建持续时间(以毫秒为单位)
- // * event.result 包含 bundle 对象,
- // 可以通过调用 bundle.generate
- // 或 bundle.write 来生成其他输出。
- // 当使用 watch.skipWrite 选项时,这尤其重要。
- // 生成输出后,你应该调用 "event.result.close()",
- // 或者如果你不生成输出,也应该调用。
- // 这将允许插件通过
- // "closeBundle" 钩子清理资源。
- // END - 完成所有产物的构建
- // ERROR - 在打包时遇到错误
- // * event.error 包含抛出的错误
- // * 对于构建错误,event.result 为 null,
- // 对于输出生成错误,它包含 bundle 对象。
- // 与 "BUNDLE_END" 一样,如果存在,
- // 你应该在完成后调用 "event.result.close()"。
- // 如果从事件处理程序返回一个 Promise,则 Rollup
- // 将等待 Promise 解析后再继续。
+ // event.code 可以是以下之一:
+ // START - 监视器正在(重新)启动
+ // BUNDLE_START - 单次打包
+ // * 如果存在,event.input 将是输入选项对象
+ // * event.output 包含生成的输出的 "file"
+ // 或 "dir" 选项值的数组
+ // BUNDLE_END - 完成打包
+ // * 如果存在,event.input 将是输入选项对象
+ // * event.output 包含生成的输出的 "file"
+ // 或 "dir" 选项值的数组
+ // * event.duration 是构建持续时间(以毫秒为单位)
+ // * event.result 包含 bundle 对象,
+ // 可以通过调用 bundle.generate
+ // 或 bundle.write 来生成其他输出。
+ // 当使用 watch.skipWrite 选项时,这尤其重要。
+ // 生成输出后,你应该调用 "event.result.close()",
+ // 或者如果你不生成输出,也应该调用。
+ // 这将允许插件通过
+ // "closeBundle" 钩子清理资源。
+ // END - 完成所有产物的构建
+ // ERROR - 在打包时遇到错误
+ // * event.error 包含抛出的错误
+ // * 对于构建错误,event.result 为 null,
+ // 对于输出生成错误,它包含 bundle 对象。
+ // 与 "BUNDLE_END" 一样,如果存在,
+ // 你应该在完成后调用 "event.result.close()"。
+ // 如果从事件处理程序返回一个 Promise,则 Rollup
+ // 将等待 Promise 解析后再继续。
});
// 这将确保在每次运行后正确关闭打包
watcher.on('event', ({ result }) => {
- if (result) {
- result.close();
- }
+ if (result) {
+ result.close();
+ }
});
// 此外,你可以挂钩以下内容。
// 同样,返回 Promise 以使 Rollup 在该阶段等待:
-watcher.on('change', (id, { event }) => { /* 更改了一个文件 */ })
-watcher.on('restart', () => { /* 新触发了一次运行 */ })
-watcher.on('close', () => { /* 监视器被关闭了,请看下面的代码 */ })
+watcher.on('change', (id, { event }) => {
+ /* 更改了一个文件 */
+});
+watcher.on('restart', () => {
+ /* 新触发了一次运行 */
+});
+watcher.on('close', () => {
+ /* 监视器被关闭了,请看下面的代码 */
+});
// 停止监听
watcher.close();
@@ -265,7 +306,10 @@ watcher.close();
`watchOptions` 参数是一个配置(或配置数组),你可以从配置文件中导出它。
-```js
+```js twoslash
+// ---cut-start---
+/** @type {import('rollup').RollupWatchOptions} */
+// ---cut-end---
const watchOptions = {
...inputOptions,
output: [outputOptions],
@@ -286,7 +330,7 @@ const watchOptions = {
rollup 通过一个单独的入口点公开了它用来在命令行界面中加载配置文件的工具函数,为加载配置提供帮助,此工具函数接收一个解析过的 `fileName` (文件路径)和可选的包含命令行参数的对象:
-```js
+```js twoslash
const { loadConfigFile } = require('rollup/loadConfigFile');
const path = require('node:path');
const rollup = require('rollup');
@@ -322,7 +366,7 @@ loadConfigFile(path.resolve(__dirname, 'rollup.config.js'), {
虽然命令行界面提供了通过 [`--filterLogs`](../command-line-interface/index.md#filterlogs-filter) 标志对日志进行强大过滤的方式,但在使用 JavaScript API 时,直接使用此功能是不可用的。然而,Rollup 提供了一个辅助函数 `getLogFilter`,可以使用与 CLI 相同的语法生成过滤器。这在指定自定义的 `onLog` 处理方法以及希望为第三方系统提供与 Rollup CLI 类似的过滤功能体验时非常有用。该函数接受一个字符串数组作为参数。需要注意的是,它不会像 CLI 那样拆分以逗号分隔的过滤器列表。
-```js
+```js twoslash
// rollup.config.mjs
import { getLogFilter } from 'rollup/getLogFilter';
@@ -343,7 +387,7 @@ export default {
为了使用 Rollup 的解析器解析任意代码,插件可以使用 [`this.parse`](../plugin-development/index.md#this-parse) 。为了在 Rollup 构建的上下文之外使用这个功能,解析器也作为一个单独的导出项暴露出来。它的签名与 `this.parse` 相同:
-```js
+```js twoslash
import { parseAst } from 'rollup/parseAst';
import assert from 'node:assert';
@@ -374,7 +418,7 @@ assert.deepEqual(
在 Rollup 的非 wasm 版本中,还有一个异步版本在不同的线程中进行解析:
-```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 4cd15cead..7dd18371d 100644
--- a/docs/plugin-development/index.md
+++ b/docs/plugin-development/index.md
@@ -18,8 +18,11 @@ Rollup 插件是一个对象,具有 [属性](#properties)、[构建钩子](#bu
以下插件将拦截任何不通过访问文件系统的 `virtual-module` 导入。例如,如果你想在浏览器中使用 Rollup,则需要这样做。它甚至可以用来替换入口点,如示例所示。
-```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', // 此名称将出现在警告和错误中
@@ -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', // 由我们的插件解析
@@ -94,7 +97,10 @@ export default ({
- `order: "pre" | "post" | null`
如果有多个插件实现此钩子,则可以先运行此插件(`"pre"`),最后运行此插件(`"post"`),或在用户指定的位置运行(没有值或 `null`)。
- ```js
+ ```js twoslash
+ // ---cut-start---
+ /** @returns {import('rollup').Plugin} */
+ // ---cut-end---
export default function resolveFirst() {
return {
name: 'resolve-first',
@@ -117,10 +123,13 @@ export default ({
当你需要在不同的 [`writeBundle`](#writebundle) 钩子中运行多个命令行工具并相互依赖时,这可能很有用(请注意,如果可能,建议在顺序 [`generateBundle`](#generatebundle) 钩子中添加/删除文件,这样更快,适用于纯内存构建,并允许其他内存构建插件查看文件)。你可以将此选项与 `order` 结合使用进行排序。
- ```js
- import { resolve } from 'node:path';
+ ```js twoslash
+ import path from 'node:path';
import { readdir } from 'node:fs/promises';
+ // ---cut-start---
+ /** @returns {import('rollup').Plugin} */
+ // ---cut-end---
export default function getFilesOnDisk() {
return {
name: 'getFilesOnDisk',
@@ -128,7 +137,7 @@ export default ({
sequential: true,
order: 'post',
async handler({ dir }) {
- const topLevelFiles = await readdir(resolve(dir));
+ const topLevelFiles = await readdir(path.resolve(dir));
console.log(topLevelFiles);
}
}
@@ -352,7 +361,10 @@ interface SourceDescription {
如果此钩子返回 `false`,日志将会被过滤。否则,日志将会传递给下一个插件的 `onLog` 钩子、`onLog` 选项或打印到控制台。插件还可以通过将日志传递给 [`this.error`](#this-error)、[`this.warn`](#this-warn)、[`this.info`](#this-info) 或 [`this.debug`](#this-debug) 并返回 `false` 来改变日志的级别或将日志转换为报错。请注意,与其他插件钩子不同,这些函数不会添加或更改日志的属性,例如插件名称。另外,由 `onLog` 钩子生成的日志不会再次传递给同一个插件的 `onLog` 钩子。如果另一个插件在其自己的 `onLog` 钩子中对这样的日志做出响应并生成了另一个日志,那么这个日志也不会传递给原始的 `onLog` 钩子。
-```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 @@ import { foo } from '../bar.js';
例如,你可以将其用作为入口点定义自定义代理模块的机制。以下插件将所有入口点代理到注入 polyfill 导入的模块中。
-```js
+```js twoslash
// 我们在 polyfill id 前面加上 \0,
// 以告诉其他插件不要尝试加载或转换它
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 @@ function injectPolyfillPlugin() {
如果返回一个对象,则可以将导入解析为不同的 id,同时将其从产物中排除。这使你可以将依赖项替换为外部依赖项,而无需用户手动通过 `external` 选项将它们挪到产物“之外” :
-```js
+```js twoslash
+// ---cut-start---
+/** @returns {import('rollup').Plugin} */
+// ---cut-end---
function externalizeDependencyPlugin() {
return {
name: 'externalize-dependency',
@@ -823,7 +844,10 @@ flowchart TB
以下插件将使用当前时间戳使块 `foo` 的哈希无效:
-```js
+```js twoslash
+// ---cut-start---
+/** @returns {import('rollup').Plugin} */
+// ---cut-end---
function augmentWithDatePlugin() {
return {
name: 'augment-with-date',
@@ -1017,7 +1041,10 @@ type renderDynamicImportHook = (options: {
以下代码将使用自定义处理程序替换所有动态导入,添加 `import.meta.url` 作为第二个参数,以允许处理程序正确解析相对导入:
-```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);
下一个插件将确保所有 `esm-lib` 的动态导入都被标记为外部模块,并保留为导入表达式,以便允许 CommonJS 构建在 Node 13+中导入 ES 模块,参见 Node 文档中的 [从 CommonJS 导入 ES 模块](https://nodejs.org/api/esm.html#esm_import_expressions)。
-```js
+```js twoslash
+// ---cut-start---
+/** @returns {import('rollup').Plugin} */
+// ---cut-end---
function retainImportExpressionPlugin() {
return {
name: 'retain-import-expression',
@@ -1116,7 +1146,10 @@ type ResolveFileUrlHook = (options: {
以下插件将始终相对于当前文档解析所有文件:
-```js
+```js twoslash
+// ---cut-start---
+/** @returns {import('rollup').Plugin} */
+// ---cut-end---
function resolveToDocumentPlugin() {
return {
name: 'resolve-to-document',
@@ -1142,7 +1175,10 @@ function resolveToDocumentPlugin() {
这种行为可以通过这个钩子进行更改,包括 ES 模块。对于每个 `import.meta<.someProperty>` 的出现,都会调用这个钩子,并传入属性的名称或者如果直接访问 `import.meta` 则为 `null`。例如,以下代码将使用原始模块相对路径到当前工作目录的解析 `import.meta.url`,并在运行时再次将此路径解析为当前文档的基本 URL:
-```js
+```js twoslash
+// ---cut-start---
+/** @returns {import('rollup').Plugin} */
+// ---cut-end---
function importMetaUrlCurrentModulePlugin() {
return {
name: 'import-meta-url-current-module',
@@ -1198,7 +1234,10 @@ function importMetaUrlCurrentModulePlugin() {
只有当 [`logLevel`](../configuration-options/index.md#loglevel) 选项被显式设置为 `"debug"` 时,这些日志才会被处理,否则不会有任何操作。因此,鼓励在插件中添加有用的调试日志,以帮助发现问题,但默认情况下它们将不被展示。如果需要进行大量计算来生成日志,请确保使用函数形式,以便只在实际处理日志时再执行这些计算。
-```js
+```js twoslash
+// ---cut-start---
+/** @returns {import('rollup').Plugin} */
+// ---cut-end---
function plugin() {
return {
name: 'test',
@@ -1265,10 +1304,25 @@ interface EmittedAsset {
默认情况下,Rollup 假定生成的代码块独立于其他入口点执行,甚至可能在任何其他代码执行之前执行。这意味着如果生成的代码块与现有入口点共享依赖关系,Rollup 将为这些入口点之间共享的依赖项创建一个额外的代码块。提供一个非空的模块 id 数组作为 `implicitlyLoadedAfterOneOf` 的值将改变这种行为,通过为 Rollup 提供额外的信息,在某些情况下防止这种情况发生。这些 id 将像 `id` 属性一样被解析,如果提供了 `importer` 属性,则会尊重它。现在,Rollup 将假定生成的代码块仅在已经执行了至少一个导致 `implicitlyLoadedAfterOneOf` 中的一个 id 被加载的入口点时才会执行,创建与通过动态导入从 `implicitlyLoadedAfterOneOf` 中的模块到达新生成的代码块时相同的代码块。下面是一个使用此功能创建简单 HTML 文件的示例,其中包含多个脚本,创建优化的代码块以遵守它们的执行顺序:
-```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 {
}
};
```
+
如果没有动态导入,这将创建三个块,其中第一个块包含 `src/entry1` 的所有依赖项,第二个块仅包含 `src/entry2` 的依赖项,这些依赖项不包含在第一个块中,并从第一个块中导入它们,第三个块也是同样的情况。
@@ -1328,7 +1386,10 @@ export default {
要在导入中引用预构建的块,我们需要在 [`resolveId`](#resolveid) 钩子中将 "module" 标记为外部,因为预构建的块不是模块图的一部分。相反,它们的行为类似于具有块元数据的资源:
-```js
+```js twoslash
+// ---cut-start---
+/** @returns {import('rollup').Plugin} */
+// ---cut-end---
function emitPrebuiltChunkPlugin() {
return {
name: 'emit-prebuilt-chunk',
@@ -1376,7 +1437,10 @@ import { foo } from './my-prebuilt-chunk.js';
在 [`onLog`](#onlog) 钩子中,这个函数是将警告转换为错误的简单方法,同时保留警告的所有附加属性:
-```js
+```js twoslash
+// ---cut-start---
+/** @returns {import('rollup').Plugin} */
+// ---cut-end---
function myPlugin() {
return {
name: 'my-plugin',
@@ -1523,7 +1587,10 @@ type Load = (options: {
请注意,关于 `assertions`、`meta`、`moduleSideEffects` 和 `syntheticNamedExports` 选项,与 `resolveId` 钩子相同的限制适用:仅当模块尚未加载时,它们的值才会生效。因此,非常重要的是首先使用 `this.resolve` 查找任何插件是否想要在其 `resolveId` 钩子中设置这些选项的特殊值,并在适当时将这些选项传递给 `this.load`。下面的示例展示了如何处理包含特殊代码注释的模块以添加代理模块。请注意重新导出默认导出的特殊处理:
-```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 @@ export default function addProxyPlugin() {
这里是另一个更详细的示例,其中我们通过 `resolveDependencies` 选项和对 `this.load` 的重复调用来扫描整个依赖子图。我们使用已处理模块 ID 的 `Set` 来处理循环依赖关系。插件的目标是向每个动态导入的块添加日志,该日志仅列出块中的所有模块。虽然这只是一个玩具示例,但该技术可以用于例如为子图中导入的所有 CSS 创建单个样式标记。
-```js
+```js twoslash
// 前导的 \0 指示其他插件不要尝试解析、加载
// 或转换我们的代理模块
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 @@ this.debug(() => generateExpensiveDebugLog());
以下示例将检测 `.svg` 文件的导入,将导入的文件作为资源产出,并返回它们的 URL,例如用作 `img` 标签的 `src` 属性:
-```js
+```js twoslash
+// ---cut-start---
+/** @returns {import('rollup').Plugin} */
+// ---cut-end---
function svgResolverPlugin() {
return {
name: 'svg-resolver',
@@ -1807,7 +1880,10 @@ if (COMPILER_FLAG) {
如果插件将 `COMPLIER_FLAG` 替换为 `false`,那么我们将得到一个意外的结果:未引用的静态资源仍然会被产出但未使用。我们可以通过在调用 [`this.emitFile`](#this-emitfile) 时将 `needsCodeReference` 设置为 `true` 来解决这个问题,如下面的代码所示:
-```js
+```js twoslash
+// ---cut-start---
+/** @returns {import('rollup').Plugin} */
+// ---cut-end---
function svgResolverPlugin() {
return {
/* ... */
@@ -1832,9 +1908,12 @@ function svgResolverPlugin() {
以下示例将检测以 `register-paint-worklet:` 为前缀的导入,并生成必要的代码和单独的块以生成 CSS 绘制工作流。请注意,这仅适用于现代浏览器,并且仅在输出格式设置为 `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 @@ export const size = 6;
(使用 [@rollup/pluginutils](https://github.com/rollup/plugins/tree/master/packages/pluginutils) 获取常用函数,并按推荐方式实现转换器。)
-```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 @@ console.log(__synthetic);
自定义解析器选项提供了一种解决方案,允许在通过 `this resolve` 手动解析模块时为插件传递附加选项。这发生在不更改 ID 的情况下,因此如果目标插件不存在,则不会影响其他插件正确解析模块的能力。
-```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 @@ function resolvingPlugin() {
插件可以使用 [`resolveId`](#resolveid)、[`load`](#load) 和 [`transform`](#transform) 钩子通过自己和其他插件为模块添加自定义元数据,并通过 [`this.getModuleInfo`](#this-getmoduleinfo)、[`this.load`](#this-load) 和 [`moduleParsed`](#moduleparsed) 钩子访问该元数据。此元数据应始终是可 JSON.stringify 的,并将在缓存中持久化,例如在监视模式下。
-```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 @@ function readingPlugin() {
模块的 `meta` 对象在 Rollup 开始加载模块时创建,并在模块的每个生命周期钩子中更新。如果你存储对此对象的引用,则还可以手动更新它。要访问尚未加载的模块的元数据对象,可以通过 [`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() {
对于任何其他类型的插件间通信,我们推荐以下模式。请注意,`api` 永远不会与任何即将推出的插件钩子冲突。
-```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/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/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/docs/tools/index.md b/docs/tools/index.md
index 1deffa34c..3bdf3a04e 100755
--- a/docs/tools/index.md
+++ b/docs/tools/index.md
@@ -54,10 +54,13 @@ npm install --save-dev @rollup/plugin-node-resolve
…然后将它添加到我们的配置文件中:
-```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 @@ import _ from 'lodash';
以下是配置文件:
-```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 @@ export default {
`external` 键接受模块名称的数组或一个函数,该函数接受模块名称并返回 true,如果应将其视为外部导入。例如:
-```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 返回的 Promise 被 gulp 所理解,因此集成相对容易。
语法与配置文件非常相似,但属性被分成两个不同的操作,对应于 [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', () => {
你也可能会用到 `async/await` 语法:
-```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 b37a83df0..6094a4875 100644
--- a/docs/troubleshooting/index.md
+++ b/docs/troubleshooting/index.md
@@ -78,8 +78,11 @@ import moment from 'moment';
不会导致 `moment` 被打包到你的包中——相反,它将是运行时需要的外部依赖项。如果这就是你想要的,你可以用 `external` 选项消除这个警告,这会让你的意图更加明确:
-```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 @@ export default {
对于大型项目,在 macOS 上以监视模式运行 Rollup 时可能会遇到 EMFILE 错误。如果你遇到这种情况,禁用 FSEvents 可能会消除问题:
-```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 02f115cad..495d17631 100755
--- a/docs/tutorial/index.md
+++ b/docs/tutorial/index.md
@@ -96,8 +96,11 @@ node
在项目根目录中创建一个名为 `rollup.config.mjs` 的文件,并添加以下代码:
-```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 () {
在 `rollup.config.mjs` 文件中加入 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
编辑你的 `rollup.config.mjs` 文件,添加另一个最小化压缩的输出。我们选择 `iife` 作为格式。该格式会将代码封装起来,以便可以通过浏览器中的 `script` 标签使用,同时避免与其他代码产生不必要的交互。由于设置了一个导出,因此我们需要提供一个全局变量的名称,该变量将由我们的产物创建,以便其他代码可以通过此变量访问我们的导出。
-```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/native.js b/native.js
index 492a52b2c..e0d54b8cf 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;
@@ -14,9 +14,9 @@ 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' },
- 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' }
@@ -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 {
@@ -96,9 +66,38 @@ 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() {
+ 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;
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/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..a71691020
--- /dev/null
+++ b/npm/linux-arm-musleabihf/package.json
@@ -0,0 +1,22 @@
+{
+ "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",
+ "libc": [
+ "musl"
+ ],
+ "main": "./rollup.linux-arm-musleabihf.node"
+}
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"
diff --git a/package-lock.json b/package-lock.json
index a3c677778..9134130bf 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "rollup",
- "version": "4.13.2",
+ "version": "4.17.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "rollup",
- "version": "4.13.2",
+ "version": "4.17.0",
"license": "MIT",
"dependencies": {
"@types/estree": "1.0.5"
@@ -15,15 +15,15 @@
"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",
"@codemirror/state": "^6.4.1",
- "@codemirror/view": "^6.26.0",
+ "@codemirror/view": "^6.26.3",
"@jridgewell/sourcemap-codec": "^1.4.15",
"@mermaid-js/mermaid-cli": "^10.8.0",
- "@napi-rs/cli": "^2.18.0",
+ "@napi-rs/cli": "^2.18.2",
"@rollup/plugin-alias": "^5.1.0",
"@rollup/plugin-buble": "^1.0.3",
"@rollup/plugin-commonjs": "^25.0.7",
@@ -33,13 +33,14 @@
"@rollup/plugin-terser": "^0.4.4",
"@rollup/plugin-typescript": "^11.1.6",
"@rollup/pluginutils": "^5.1.0",
- "@types/eslint": "^8.56.6",
+ "@shikijs/vitepress-twoslash": "^1.3.0",
+ "@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.4.0",
- "@typescript-eslint/parser": "^7.4.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",
@@ -50,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",
@@ -57,26 +59,26 @@
"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-vue": "^9.24.0",
+ "eslint-plugin-unicorn": "^52.0.0",
+ "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.16",
+ "inquirer": "^9.2.19",
"is-reference": "^3.0.2",
"lint-staged": "^15.2.2",
"locate-character": "^3.0.0",
- "magic-string": "^0.30.8",
- "mocha": "^10.3.0",
+ "magic-string": "^0.30.10",
+ "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.16.3",
"rollup-plugin-license": "^3.3.1",
"rollup-plugin-string": "^3.0.0",
"semver": "^7.6.0",
@@ -85,12 +87,12 @@
"source-map": "^0.7.4",
"source-map-support": "^0.5.21",
"systemjs": "^6.14.3",
- "terser": "^5.29.2",
+ "terser": "^5.30.4",
"tslib": "^2.6.2",
- "typescript": "^5.4.3",
- "vite": "^5.2.6",
- "vitepress": "^1.0.1",
- "vue": "^3.4.21",
+ "typescript": "^5.4.5",
+ "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"
@@ -158,151 +160,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": {
@@ -332,27 +334,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",
@@ -377,9 +379,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",
@@ -536,9 +538,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",
@@ -621,9 +623,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"
@@ -633,9 +635,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"
@@ -703,9 +705,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",
@@ -721,9 +723,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.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",
@@ -790,9 +792,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.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",
@@ -1294,6 +1296,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",
@@ -1344,11 +1370,20 @@
}
},
"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/@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",
@@ -1531,9 +1566,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.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",
@@ -1580,9 +1615,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.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"
@@ -1903,9 +1938,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.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"
],
@@ -1916,9 +1951,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.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"
],
@@ -1929,9 +1964,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.16.4",
+ "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.16.4.tgz",
+ "integrity": "sha512-i5d64MlnYBO9EkCOGe5vPR/EeDwjnKOGGdd7zKFhU5y8haKhQZTN2DgVtpODDMxUr4t2K90wTUJg7ilgND6bXw==",
"cpu": [
"arm64"
],
@@ -1942,9 +1977,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.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"
],
@@ -1955,9 +1990,22 @@
]
},
"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.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"
+ ],
+ "dev": true,
+ "optional": true,
+ "os": [
+ "linux"
+ ]
+ },
+ "node_modules/@rollup/rollup-linux-arm-musleabihf": {
+ "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"
],
@@ -1968,9 +2016,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.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"
],
@@ -1981,9 +2029,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.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"
],
@@ -1994,11 +2042,11 @@
]
},
"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.16.4",
+ "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-powerpc64le-gnu/-/rollup-linux-powerpc64le-gnu-4.16.4.tgz",
+ "integrity": "sha512-p8C3NnxXooRdNrdv6dBmRTddEapfESEUflpICDNKXpHvTjRRq1J82CbU5G3XfebIZyI3B0s074JHMWD36qOW6w==",
"cpu": [
- "ppc64le"
+ "ppc64"
],
"dev": true,
"optional": true,
@@ -2007,9 +2055,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.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"
],
@@ -2020,9 +2068,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.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"
],
@@ -2033,9 +2081,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.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"
],
@@ -2046,9 +2094,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.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"
],
@@ -2059,9 +2107,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.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"
],
@@ -2072,9 +2120,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.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"
],
@@ -2085,9 +2133,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.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"
],
@@ -2098,18 +2146,45 @@
]
},
"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.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.1",
- "resolved": "https://registry.npmjs.org/@shikijs/transformers/-/transformers-1.2.1.tgz",
- "integrity": "sha512-H7cVtrdv6BW2kx83t2IQgP5ri1IA50mE3QnzgJ0AvOKCGtCEieXu0JIP3245cgjNLrL+LBwb8DtTXdky1iQL9Q==",
+ "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.3.0"
+ }
+ },
+ "node_modules/@shikijs/twoslash": {
+ "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": {
- "shiki": "1.2.1"
+ "@shikijs/core": "1.3.0",
+ "twoslash": "^0.2.5"
+ }
+ },
+ "node_modules/@shikijs/vitepress-twoslash": {
+ "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.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.3.0",
+ "twoslash": "^0.2.5",
+ "twoslash-vue": "^0.2.5",
+ "vue": "^3.4.21"
}
},
"node_modules/@types/buble": {
@@ -2130,10 +2205,19 @@
"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",
- "integrity": "sha512-ymwc+qb1XkjT/gfoQwxIeHZ6ixH23A+tCT2ADSA/DPVKzAjwYkTXBMCQ/f6fe4wEa85Lhp26VPeUxI7wMhAi7A==",
+ "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": "*",
@@ -2170,6 +2254,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",
@@ -2199,15 +2292,24 @@
"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": "*",
"@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 +2328,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 +2380,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",
@@ -2295,22 +2409,22 @@
}
},
"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.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.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",
+ "@eslint-community/regexpp": "^4.10.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.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"
@@ -2330,15 +2444,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.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.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.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": {
@@ -2358,13 +2472,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.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.4.0",
- "@typescript-eslint/visitor-keys": "7.4.0"
+ "@typescript-eslint/types": "7.7.1",
+ "@typescript-eslint/visitor-keys": "7.7.1"
},
"engines": {
"node": "^18.18.0 || >=20.0.0"
@@ -2375,15 +2489,15 @@
}
},
"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.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.4.0",
- "@typescript-eslint/utils": "7.4.0",
+ "@typescript-eslint/typescript-estree": "7.7.1",
+ "@typescript-eslint/utils": "7.7.1",
"debug": "^4.3.4",
- "ts-api-utils": "^1.0.1"
+ "ts-api-utils": "^1.3.0"
},
"engines": {
"node": "^18.18.0 || >=20.0.0"
@@ -2402,9 +2516,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.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"
@@ -2415,19 +2529,19 @@
}
},
"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.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.4.0",
- "@typescript-eslint/visitor-keys": "7.4.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",
- "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"
@@ -2443,18 +2557,18 @@
}
},
"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.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.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",
- "semver": "^7.5.4"
+ "@types/json-schema": "^7.0.15",
+ "@types/semver": "^7.5.8",
+ "@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": {
"node": "^18.18.0 || >=20.0.0"
@@ -2468,13 +2582,13 @@
}
},
"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.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.4.0",
- "eslint-visitor-keys": "^3.4.1"
+ "@typescript-eslint/types": "7.7.1",
+ "eslint-visitor-keys": "^3.4.3"
},
"engines": {
"node": "^18.18.0 || >=20.0.0"
@@ -2484,6 +2598,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,54 +2626,72 @@
"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",
- "integrity": "sha512-MjXawxZf2SbZszLPYxaFCjxfibYrzr3eYbKxwpLR9EQN+oaziSu3qKVbwBERj1IFIB8OLUewxB5m/BFzi613og==",
+ "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.23.9",
- "@vue/shared": "3.4.21",
+ "@babel/parser": "^7.24.4",
+ "@vue/shared": "3.4.25",
"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.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.21",
- "@vue/shared": "3.4.21"
+ "@vue/compiler-core": "3.4.25",
+ "@vue/shared": "3.4.25"
}
},
"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.25",
+ "resolved": "https://registry.npmjs.org/@vue/compiler-sfc/-/compiler-sfc-3.4.25.tgz",
+ "integrity": "sha512-m7rryuqzIoQpOBZ18wKyq05IwL6qEpZxFZfRxlNYuIPDqywrXQxgUwLXIvoU72gs6cRdY6wHD0WVZIFE4OEaAQ==",
"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.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.7",
- "postcss": "^8.4.35",
- "source-map-js": "^1.0.2"
+ "magic-string": "^0.30.10",
+ "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.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.21",
- "@vue/shared": "3.4.21"
+ "@vue/compiler-dom": "3.4.25",
+ "@vue/shared": "3.4.25"
}
},
"node_modules/@vue/devtools-api": {
@@ -2560,12 +2701,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.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.25",
+ "@vue/devtools-shared": "^7.1.2",
"hookable": "^5.5.3",
"mitt": "^3.0.1",
"perfect-debounce": "^1.0.0",
@@ -2582,9 +2723,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.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"
@@ -2628,53 +2769,78 @@
}
}
},
+ "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",
- "integrity": "sha512-UhenImdc0L0/4ahGCyEzc/pZNwVgcglGy9HVzJ1Bq2Mm9qXOpP8RyNTjookw/gOCUlXSEtuZ2fUg5nrHcoqJcw==",
+ "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.21"
+ "@vue/shared": "3.4.25"
}
},
"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.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.21",
- "@vue/shared": "3.4.21"
+ "@vue/reactivity": "3.4.25",
+ "@vue/shared": "3.4.25"
}
},
"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.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.21",
- "@vue/shared": "3.4.21",
+ "@vue/runtime-core": "3.4.25",
+ "@vue/shared": "3.4.25",
"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.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.21",
- "@vue/shared": "3.4.21"
+ "@vue/compiler-ssr": "3.4.25",
+ "@vue/shared": "3.4.25"
},
"peerDependencies": {
- "vue": "3.4.21"
+ "vue": "3.4.25"
}
},
"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.25",
+ "resolved": "https://registry.npmjs.org/@vue/shared/-/shared-3.4.25.tgz",
+ "integrity": "sha512-k0yappJ77g2+KNrIaF0FFnzwLvUBLUYr8VOwz+/6vLsmItFp51AcxLL7Ey3iPd7BIRyWPOcqUjMnm7OkahXllA==",
"dev": true
},
"node_modules/@vueuse/core": {
@@ -2929,26 +3095,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": {
@@ -3546,9 +3712,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.30001612",
+ "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001612.tgz",
+ "integrity": "sha512-lFgnZ07UhaCcsSZgWW0K5j4e69dK1u/ltrL9lTUiFOwNHs12S3UMIEYgBV0Z6C6hRDev7iRnMzzYmKabYdXF9g==",
"dev": true,
"funding": [
{
@@ -3565,6 +3731,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 +3753,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 +4082,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",
@@ -4008,9 +4200,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"
@@ -4044,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",
@@ -4167,6 +4377,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 +4409,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 +4507,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",
@@ -4318,9 +4569,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.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": {
@@ -4366,9 +4617,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",
@@ -4410,11 +4661,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"
},
@@ -4796,9 +5047,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",
@@ -4829,9 +5080,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.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",
@@ -4847,7 +5098,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": {
@@ -5187,30 +5438,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",
@@ -5328,6 +5555,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",
@@ -6062,18 +6308,18 @@
"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.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",
@@ -7168,6 +7414,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",
@@ -7178,15 +7434,12 @@
}
},
"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.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": {
@@ -7210,6 +7463,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,65 +7508,728 @@
"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/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/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-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": {
- "braces": "^3.0.2",
- "picomatch": "^2.3.1"
+ "@types/mdast": "^4.0.0",
+ "escape-string-regexp": "^5.0.0",
+ "unist-util-is": "^6.0.0",
+ "unist-util-visit-parents": "^6.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-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": ">= 0.6"
+ "node": ">=12"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
}
},
- "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-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": {
- "mime-db": "1.52.0"
+ "@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": ">= 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": {
+ "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": ">=12"
+ "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": {
- "url": "https://github.com/sponsors/sindresorhus"
+ "type": "opencollective",
+ "url": "https://opencollective.com/unified"
+ }
+ },
+ "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": {
+ "@types/mdast": "^4.0.0",
+ "ccount": "^2.0.0",
+ "devlop": "^1.0.0",
+ "mdast-util-find-and-replace": "^3.0.0",
+ "micromark-util-character": "^2.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/unified"
+ }
+ },
+ "node_modules/mdast-util-gfm-footnote": {
+ "version": "2.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,
+ "dependencies": {
+ "@types/mdast": "^4.0.0",
+ "devlop": "^1.1.0",
+ "mdast-util-from-markdown": "^2.0.0",
+ "mdast-util-to-markdown": "^2.0.0",
+ "micromark-util-normalize-identifier": "^2.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/unified"
+ }
+ },
+ "node_modules/mdast-util-gfm-strikethrough": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/mdast-util-gfm-strikethrough/-/mdast-util-gfm-strikethrough-2.0.0.tgz",
+ "integrity": "sha512-mKKb915TF+OC5ptj5bJ7WFRPdYtuHv0yTRxK2tJvi+BDqbkiG7h7u/9SI89nRAYcmap2xHQL9D+QG/6wSrTtXg==",
+ "dev": true,
+ "dependencies": {
+ "@types/mdast": "^4.0.0",
+ "mdast-util-from-markdown": "^2.0.0",
+ "mdast-util-to-markdown": "^2.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/unified"
+ }
+ },
+ "node_modules/mdast-util-gfm-table": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/mdast-util-gfm-table/-/mdast-util-gfm-table-2.0.0.tgz",
+ "integrity": "sha512-78UEvebzz/rJIxLvE7ZtDd/vIQ0RHv+3Mh5DR96p7cS7HsBhYIICDBCu8csTNWNO6tBWfqXPWekRuj2FNOGOZg==",
+ "dev": true,
+ "dependencies": {
+ "@types/mdast": "^4.0.0",
+ "devlop": "^1.0.0",
+ "markdown-table": "^3.0.0",
+ "mdast-util-from-markdown": "^2.0.0",
+ "mdast-util-to-markdown": "^2.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/unified"
+ }
+ },
+ "node_modules/mdast-util-gfm-task-list-item": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/mdast-util-gfm-task-list-item/-/mdast-util-gfm-task-list-item-2.0.0.tgz",
+ "integrity": "sha512-IrtvNvjxC1o06taBAVJznEnkiHxLFTzgonUdy8hzFVeDun0uTjxxrRGVaNFqkU1wJR3RBPEfsxmU6jDWPofrTQ==",
+ "dev": true,
+ "dependencies": {
+ "@types/mdast": "^4.0.0",
+ "devlop": "^1.0.0",
+ "mdast-util-from-markdown": "^2.0.0",
+ "mdast-util-to-markdown": "^2.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/unified"
+ }
+ },
+ "node_modules/mdast-util-phrasing": {
+ "version": "4.1.0",
+ "resolved": "https://registry.npmjs.org/mdast-util-phrasing/-/mdast-util-phrasing-4.1.0.tgz",
+ "integrity": "sha512-TqICwyvJJpBwvGAMZjj4J2n0X8QWp21b9l0o7eXyVJ25YNWYbJDVIyD1bZXE6WtV6RmKJVYmQAKWa0zWOABz2w==",
+ "dev": true,
+ "dependencies": {
+ "@types/mdast": "^4.0.0",
+ "unist-util-is": "^6.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/unified"
+ }
+ },
+ "node_modules/mdast-util-to-hast": {
+ "version": "13.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.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": [
+ {
+ "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.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": [
+ {
+ "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": {
@@ -7316,9 +8242,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"
@@ -7604,6 +8530,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 +9225,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",
@@ -8553,9 +9491,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",
@@ -8675,7 +9613,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": {
@@ -9185,9 +10123,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.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"
@@ -9200,21 +10138,22 @@
"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.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"
}
},
@@ -9596,12 +10535,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.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.1"
+ "@shikijs/core": "1.3.0"
}
},
"node_modules/shx": {
@@ -9679,9 +10618,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": {
@@ -10122,9 +11061,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.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",
@@ -10273,6 +11212,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 +11273,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",
@@ -10431,9 +11416,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.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",
@@ -10514,6 +11499,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,14 +11646,43 @@
"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",
- "integrity": "sha512-FPtnxFlSIKYjZ2eosBQamz4CbyrTizbZ3hnGJlh/wMtCrlp1Hah6AzBLjGI5I2urTfNnpovpHdrL6YRuBOPnCA==",
+ "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",
- "postcss": "^8.4.36",
+ "postcss": "^8.4.38",
"rollup": "^4.13.0"
},
"bin": {
@@ -10649,26 +11731,26 @@
}
},
"node_modules/vitepress": {
- "version": "1.0.1",
- "resolved": "https://registry.npmjs.org/vitepress/-/vitepress-1.0.1.tgz",
- "integrity": "sha512-eNr5pOBppYUUjEhv8S0S2t9Tv95LQ6mMeHj6ivaGwfHxpov70Vduuwl/QQMDRznKDSaP0WKV7a82Pb4JVOaqEw==",
+ "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.0",
- "@shikijs/transformers": "^1.2.0",
- "@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.16",
+ "@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.0",
- "vite": "^5.2.2",
- "vue": "^3.4.21"
+ "shiki": "^1.3.0",
+ "vite": "^5.2.9",
+ "vue": "^3.4.23"
},
"bin": {
"vitepress": "bin/vitepress.js"
@@ -10687,25 +11769,25 @@
}
},
"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.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.25"
+ "@vue/devtools-kit": "^7.1.2"
}
},
"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.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.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.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": "*"
@@ -10740,6 +11822,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 +12208,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..53477f75a 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "rollup",
- "version": "4.13.2",
+ "version": "4.17.0",
"description": "Next-generation ES module bundler",
"main": "dist/rollup.js",
"module": "dist/es/rollup.js",
@@ -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",
@@ -38,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",
@@ -65,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",
@@ -112,15 +113,15 @@
"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",
"@codemirror/state": "^6.4.1",
- "@codemirror/view": "^6.26.0",
+ "@codemirror/view": "^6.26.3",
"@jridgewell/sourcemap-codec": "^1.4.15",
"@mermaid-js/mermaid-cli": "^10.8.0",
- "@napi-rs/cli": "^2.18.0",
+ "@napi-rs/cli": "^2.18.2",
"@rollup/plugin-alias": "^5.1.0",
"@rollup/plugin-buble": "^1.0.3",
"@rollup/plugin-commonjs": "^25.0.7",
@@ -130,13 +131,14 @@
"@rollup/plugin-terser": "^0.4.4",
"@rollup/plugin-typescript": "^11.1.6",
"@rollup/pluginutils": "^5.1.0",
- "@types/eslint": "^8.56.6",
+ "@shikijs/vitepress-twoslash": "^1.3.0",
+ "@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.4.0",
- "@typescript-eslint/parser": "^7.4.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",
@@ -147,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",
@@ -154,26 +157,26 @@
"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-vue": "^9.24.0",
+ "eslint-plugin-unicorn": "^52.0.0",
+ "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.16",
+ "inquirer": "^9.2.19",
"is-reference": "^3.0.2",
"lint-staged": "^15.2.2",
"locate-character": "^3.0.0",
- "magic-string": "^0.30.8",
- "mocha": "^10.3.0",
+ "magic-string": "^0.30.10",
+ "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.16.3",
"rollup-plugin-license": "^3.3.1",
"rollup-plugin-string": "^3.0.0",
"semver": "^7.6.0",
@@ -182,12 +185,12 @@
"source-map": "^0.7.4",
"source-map-support": "^0.5.21",
"systemjs": "^6.14.3",
- "terser": "^5.29.2",
+ "terser": "^5.30.4",
"tslib": "^2.6.2",
- "typescript": "^5.4.3",
- "vite": "^5.2.6",
- "vitepress": "^1.0.1",
- "vue": "^3.4.21",
+ "typescript": "^5.4.5",
+ "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/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/rust/Cargo.lock b/rust/Cargo.lock
index b91d88948..80600e273 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"
@@ -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",
@@ -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"
@@ -143,15 +137,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.95"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8cd6604a82acf3039f1144f54b8eb34e91ffba622051189e71b781822d5ee1f5"
+checksum = "d32a725bc159af97c3e629873bb9f88fb8cf8a4867175f76dc987815ea07c83b"
[[package]]
name = "cfg-if"
@@ -170,9 +164,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 +209,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"
@@ -259,9 +253,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,15 +278,16 @@ checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024"
[[package]]
name = "hstr"
-version = "0.2.7"
+version = "0.2.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "17fafeca18cf0927e23ea44d7a5189c10536279dfe9094e0dfa953053fbb5377"
+checksum = "96274be293b8877e61974a607105d09c84caebe9620b47774aa8a6b942042dd4"
dependencies = [
+ "hashbrown",
"new_debug_unreachable",
"once_cell",
"phf",
"rustc-hash",
- "smallvec",
+ "triomphe",
]
[[package]]
@@ -367,14 +362,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0c2a198fb6b0eada2a8df47933734e6d35d350665a33a3593d7164fa52c75c19"
dependencies = [
"cfg-if",
- "windows-targets 0.52.4",
+ "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",
@@ -414,11 +409,11 @@ dependencies = [
[[package]]
name = "napi"
-version = "2.16.1"
+version = "2.16.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c4ca998356d8ff9fba7a070dae4508a2298439c98c9f3bc9c07669538b999e8f"
+checksum = "da1edd9510299935e4f52a24d1e69ebd224157e3e962c6c847edec5c2e4f786f"
dependencies = [
- "bitflags 2.5.0",
+ "bitflags",
"ctor",
"napi-derive",
"napi-sys",
@@ -427,15 +422,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.1"
+version = "2.16.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b138cecf1141ae0ff5d62f4aa0e2f269aec339f66070f346ba6fb4279f1fc178"
+checksum = "e5a6de411b6217dbb47cd7a8c48684b162309ff48a77df9228c082400dd5b030"
dependencies = [
"cfg-if",
"convert_case",
@@ -447,9 +442,9 @@ dependencies = [
[[package]]
name = "napi-derive-backend"
-version = "1.0.63"
+version = "1.0.65"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ce5126b64f6ad9e28e30e6d15213dd378626b38f556454afebc42f7f02a90902"
+checksum = "c3e35868d43b178b0eb9c17bd018960b1b5dd1732a7d47c23debe8f5c4caf498"
dependencies = [
"convert_case",
"once_cell",
@@ -462,9 +457,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",
]
@@ -529,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",
@@ -539,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]]
@@ -629,15 +624,15 @@ 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"
-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",
]
@@ -653,9 +648,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",
]
@@ -689,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]]
@@ -787,18 +782,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",
@@ -807,9 +802,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",
@@ -850,9 +845,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 +862,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"
@@ -888,9 +889,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",
@@ -900,9 +901,9 @@ dependencies = [
[[package]]
name = "swc_atoms"
-version = "0.6.5"
+version = "0.6.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7d538eaaa6f085161d088a04cf0a3a5a52c5a7f2b3bd9b83f73f058b0ed357c0"
+checksum = "bb6567e4e67485b3e7662b486f1565bdae54bd5b9d6b16b2ba1a9babb1e42125"
dependencies = [
"hstr",
"once_cell",
@@ -912,9 +913,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 +927,9 @@ dependencies = [
[[package]]
name = "swc_common"
-version = "0.33.21"
+version = "0.33.25"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "89598a0dfe7311750e6fad8464cafcec8ee010c649c2e04531b25e32362fdec7"
+checksum = "a529796c240cd87da18d26d63f9de4c7ad3680cf0a04b95f0c37f4c4f0a0da63"
dependencies = [
"ahash",
"ast_node",
@@ -954,9 +955,9 @@ dependencies = [
[[package]]
name = "swc_compiler_base"
-version = "0.7.19"
+version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "66405c58d5241ae020b0522a08bdc284da52b13742a58e3023e09cc2e0fb9e8c"
+checksum = "10efbe9caf469304b3410e9701f529b748b7d7649409a30b5b9a1516e5d9df67"
dependencies = [
"anyhow",
"base64",
@@ -1004,11 +1005,11 @@ dependencies = [
[[package]]
name = "swc_ecma_ast"
-version = "0.112.6"
+version = "0.113.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "70656acd47c91918635f1e8589963428cb3170975b71d786c79fb7a25605f687"
+checksum = "f99fdda741656887f4cf75c1cee249a5f0374d67d30acc2b073182e902546ff2"
dependencies = [
- "bitflags 2.5.0",
+ "bitflags",
"is-macro",
"num-bigint",
"phf",
@@ -1017,14 +1018,14 @@ dependencies = [
"string_enum",
"swc_atoms",
"swc_common",
- "unicode-id",
+ "unicode-id-start",
]
[[package]]
name = "swc_ecma_codegen"
-version = "0.148.13"
+version = "0.149.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c9ae864cb69934f8753b9cbbad803a0ee1b0759f5b87c219db0a12e8d03fa86a"
+checksum = "5c21b8ae99bc3b95c6f7909915cd1e5994bec4e5b576f2e2a6879e56f2770760"
dependencies = [
"memchr",
"num-bigint",
@@ -1041,9 +1042,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",
@@ -1053,9 +1054,9 @@ dependencies = [
[[package]]
name = "swc_ecma_minifier"
-version = "0.192.19"
+version = "0.193.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e3acd953ba8fd935428003d015cc119ddb31a510537bf2ef06294c52bacffa67"
+checksum = "3b0f521603b4a32a25d9a6c9bdc9c06a053dc1708f4952faab1c41bbc717e644"
dependencies = [
"arrayvec",
"indexmap",
@@ -1086,9 +1087,9 @@ dependencies = [
[[package]]
name = "swc_ecma_parser"
-version = "0.143.11"
+version = "0.144.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "192482230498a24c2e7c9c580ba334a80dc43b3899366e54aa548f8d7b0f12cd"
+checksum = "3da9f3a58f0a64410f4006eb1fdb64d190ad3cc6cd12a7bf1f0dbb916e4ca4c7"
dependencies = [
"either",
"new_debug_unreachable",
@@ -1108,12 +1109,12 @@ dependencies = [
[[package]]
name = "swc_ecma_transforms_base"
-version = "0.137.16"
+version = "0.138.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "69e9a23d6af398b6efd17bbdad2cfa580102f6c560611f85c63b48f76ffe8f0c"
+checksum = "91771e358664649cf2cabec86a270bd9ce267f5213f299cacb255951b5edf06b"
dependencies = [
"better_scoped_tls",
- "bitflags 2.5.0",
+ "bitflags",
"indexmap",
"once_cell",
"phf",
@@ -1143,9 +1144,9 @@ dependencies = [
[[package]]
name = "swc_ecma_transforms_optimization"
-version = "0.198.17"
+version = "0.199.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "86789174146707d78c086cee25868624bdfef924bb535ea3fc42f53fa426d4c0"
+checksum = "ba0d1c320c74b97e6f79f8ff5bae05b78cc211492b29654994963e4f1fe4a01f"
dependencies = [
"dashmap",
"indexmap",
@@ -1167,9 +1168,9 @@ dependencies = [
[[package]]
name = "swc_ecma_usage_analyzer"
-version = "0.23.13"
+version = "0.24.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "21ccc0ff427471b70e48f265854a2e0843ef8429c729009898bea993f300fa77"
+checksum = "fbf2ab496ed1d5006758c27cadf3273798a6fe740fdf1b09b78f66cc252d40ae"
dependencies = [
"indexmap",
"rustc-hash",
@@ -1184,9 +1185,9 @@ dependencies = [
[[package]]
name = "swc_ecma_utils"
-version = "0.127.15"
+version = "0.128.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "68f83263f449935d33f86b8ab17c88a13bc175a87a742752ebcc94be2006ab25"
+checksum = "cd533f5751b7a8673bd843151c4e6e64a2dcf6c1f65331401e88f244c0e85de7"
dependencies = [
"indexmap",
"num_cpus",
@@ -1202,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",
@@ -1227,9 +1228,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",
@@ -1239,9 +1240,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",
@@ -1259,9 +1260,9 @@ dependencies = [
[[package]]
name = "swc_visit"
-version = "0.5.10"
+version = "0.5.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3f5b3e8d1269a7cb95358fed3412645d9c15aa0eb1f4ca003a25a38ef2f30f1b"
+checksum = "0263be55289abfe9c877ffef83d877b5bdfac036ffe2de793f48f5e47e41dbae"
dependencies = [
"either",
"swc_visit_macros",
@@ -1282,9 +1283,9 @@ dependencies = [
[[package]]
name = "syn"
-version = "2.0.55"
+version = "2.0.60"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "002a1b3dbf967edfafc32655d0f377ab0bb7b994aa1d32c8cc7e9b8bf3ebb8f0"
+checksum = "909518bc7b1c9b779f1bbf07f2929d35af9f0f37e47c6e9ef7f9dddc1e1821f3"
dependencies = [
"proc-macro2",
"quote",
@@ -1343,6 +1344,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"
@@ -1501,117 +1512,67 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
[[package]]
name = "windows-targets"
-version = "0.48.5"
+version = "0.52.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c"
+checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb"
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",
+ "windows_aarch64_gnullvm",
+ "windows_aarch64_msvc",
+ "windows_i686_gnu",
+ "windows_i686_gnullvm",
+ "windows_i686_msvc",
+ "windows_x86_64_gnu",
+ "windows_x86_64_gnullvm",
+ "windows_x86_64_msvc",
]
-[[package]]
-name = "windows-targets"
-version = "0.52.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7dd37b7e5ab9018759f893a1952c9420d060016fc19a472b4bb20d1bdd694d1b"
-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",
-]
-
-[[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.4"
+version = "0.52.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "bcf46cf4c365c6f2d1cc93ce535f2c8b244591df96ceee75d8e83deb70a9cac9"
+checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263"
[[package]]
name = "windows_aarch64_msvc"
-version = "0.48.5"
+version = "0.52.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc"
-
-[[package]]
-name = "windows_aarch64_msvc"
-version = "0.52.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "da9f259dd3bcf6990b55bffd094c4f7235817ba4ceebde8e6d11cd0c5633b675"
+checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6"
[[package]]
name = "windows_i686_gnu"
-version = "0.48.5"
+version = "0.52.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e"
+checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670"
[[package]]
-name = "windows_i686_gnu"
-version = "0.52.4"
+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"
-version = "0.48.5"
+version = "0.52.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406"
-
-[[package]]
-name = "windows_i686_msvc"
-version = "0.52.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1515e9a29e5bed743cb4415a9ecf5dfca648ce85ee42e15873c3cd8610ff8e02"
+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.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5eee091590e89cc02ad514ffe3ead9eb6b660aedca2183455434b93546371a03"
-
-[[package]]
-name = "windows_x86_64_gnullvm"
-version = "0.48.5"
+version = "0.52.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc"
+checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9"
[[package]]
name = "windows_x86_64_gnullvm"
-version = "0.52.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "77ca79f2451b49fa9e2af39f0747fe999fcda4f5e241b2898624dca97a1f2177"
-
-[[package]]
-name = "windows_x86_64_msvc"
-version = "0.48.5"
+version = "0.52.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538"
+checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596"
[[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/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"
diff --git a/rust/bindings_napi/Cargo.toml b/rust/bindings_napi/Cargo.toml
index 91aa15c46..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.1", default-features = false, features = ["napi4"] }
-napi-derive = "2.16.1"
+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/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 623e061ae..b086383ee 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"
-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"
-parking_lot = "0.12.1"
+anyhow = "1.0.82"
+swc_atoms = "0.6.7"
+swc_compiler_base = "0.8.0"
+swc_common = { version = "0.33.25", features = ["ahash", "parking_lot"] }
+swc_ecma_ast = "0.113.0"
+swc_ecma_parser = "0.144.0"
+parking_lot = "0.12.2"
diff --git a/rust/parse_ast/src/convert_ast/converter.rs b/rust/parse_ast/src/convert_ast/converter.rs
index 41415f680..739f2d823 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};
@@ -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);
}
@@ -259,14 +275,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,
+ &TYPE_FUNCTION_DECLARATION,
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"),
@@ -379,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
@@ -527,12 +547,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))
+ }
}
}
@@ -574,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),
}
@@ -995,7 +1021,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);
@@ -1006,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,
@@ -1014,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);
@@ -1028,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,
@@ -1036,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);
@@ -1050,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,
@@ -1059,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;
}
@@ -1078,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 {
@@ -1099,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;
@@ -1142,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) => {
@@ -1165,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);
@@ -1180,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;
@@ -1230,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,
@@ -1240,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 {
@@ -1283,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,
@@ -1292,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());
@@ -1322,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);
}
@@ -1362,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,
@@ -1378,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);
}
@@ -1427,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);
@@ -1472,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);
@@ -1488,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);
@@ -1534,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);
}
@@ -1546,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!(
@@ -1556,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);
@@ -1565,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(),
),
}
@@ -1582,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 {
@@ -1592,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);
@@ -1607,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() {
@@ -1633,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);
@@ -1646,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);
@@ -1665,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);
@@ -1735,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;
@@ -1750,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 {
@@ -1763,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);
@@ -1776,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);
@@ -1810,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
@@ -1820,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 {
@@ -1850,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,
@@ -1858,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
@@ -1867,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);
}
@@ -1878,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);
@@ -1891,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) {
@@ -1912,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);
@@ -1944,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);
@@ -1960,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);
}
@@ -1981,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());
@@ -2013,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);
@@ -2022,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);
@@ -2063,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);
@@ -2109,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,
@@ -2117,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,
@@ -2132,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,
@@ -2153,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;
@@ -2181,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,
@@ -2210,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;
@@ -2245,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,
@@ -2265,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
@@ -2299,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,
@@ -2307,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
@@ -2318,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,
@@ -2326,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
@@ -2337,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 {
@@ -2358,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 {
@@ -2377,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 {
@@ -2397,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
@@ -2417,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());
@@ -2464,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());
@@ -2482,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,
@@ -2523,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,
@@ -2584,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);
@@ -2597,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;
}
@@ -2618,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);
@@ -2646,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,
@@ -2670,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()
@@ -2679,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);
}
@@ -2717,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);
@@ -2763,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);
@@ -2789,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());
@@ -2853,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);
@@ -2866,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() {
@@ -2889,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;
@@ -2915,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
@@ -2942,16 +3061,37 @@ 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,
+ &TYPE_VARIABLE_DECLARATION,
+ &span,
VARIABLE_DECLARATION_RESERVED_BYTES,
- matches!(variable_declaration.kind, VarDeclKind::Const),
+ kind == &STRING_CONST,
);
// declarations
self.convert_item_list(
- &variable_declaration.decls,
+ decls,
+ end_position + VARIABLE_DECLARATION_DECLARATIONS_OFFSET,
|ast_converter, variable_declarator| {
ast_converter.convert_variable_declarator(variable_declarator);
true
@@ -2959,20 +3099,14 @@ impl<'a> AstConverter<'a> {
);
// 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) {
let end_position = self.add_type_and_start(
- &TYPE_VARIABLE_DECLARATOR_INLINED_ID,
+ &TYPE_VARIABLE_DECLARATOR,
&variable_declarator.span,
VARIABLE_DECLARATOR_RESERVED_BYTES,
false,
@@ -2990,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 {
@@ -3005,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);
@@ -3027,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
@@ -3065,6 +3200,17 @@ 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),
+}
+
enum StoredCallee<'a> {
Expression(&'a Expr),
Super(&'a Super),
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..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,153 +1,169 @@
-// 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_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/convert_ast/converter/string_constants.rs b/rust/parse_ast/src/convert_ast/converter/string_constants.rs
index 5163c0242..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,4 +1,6 @@
-// These need to correspond to the positions in convert-ast-strings.ts
+// 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
@@ -49,7 +51,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(); // &=
@@ -60,3 +62,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/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 9012c9aea..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 {
@@ -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()
});
@@ -62,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-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..1340d334b 100644
--- a/scripts/generate-buffer-parsers.js
+++ b/scripts/generate-buffer-parsers.js
@@ -1,96 +1,86 @@
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 { astNodeNamesWithFieldOrder } from './ast-types.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);
-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 +104,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 +148,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
};
}
@@ -180,14 +170,13 @@ function getFieldDefinition([fieldName, fieldType], name, offset, isInlined) {
}
}
-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';
+import { EMPTY_ARRAY } from '../utils/blank';
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')}
@@ -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++) {
@@ -253,4 +243,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..132cf0dc9 100644
--- a/scripts/generate-buffer-to-ast.js
+++ b/scripts/generate-buffer-to-ast.js
@@ -1,55 +1,50 @@
import { writeFile } from 'node:fs/promises';
-import { AST_NODES, astNodeNamesWithFieldOrder } from './ast-types.js';
-import { firstLetterLowercase, lintFile } from './helpers.js';
+import { astNodeNamesWithFieldOrder } from './ast-types.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);
-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 +54,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 +91,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 +106,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 +130,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) {
@@ -178,9 +158,7 @@ const types = astNodeNamesWithFieldOrder.map(({ name }) => {
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';
@@ -190,7 +168,8 @@ import {
convertString,
INVALID_ANNOTATION_KEY
} from './astConverterHelpers';
-import { FIXED_STRINGS } from './convert-ast-strings';
+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++) {
@@ -239,4 +219,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..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 { lintFile } 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))
@@ -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..ae74a631e 100644
--- a/scripts/generate-rust-constants.js
+++ b/scripts/generate-rust-constants.js
@@ -1,10 +1,11 @@
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 { 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
@@ -16,15 +17,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 '';
@@ -47,7 +46,7 @@ const reservedBytesAndOffsets = astNodeNamesWithFieldOrder
);
}
}
- for (const [fieldName, fieldType] of reservedFields) {
+ for (const [fieldName, fieldType] of fields) {
lines.push(
`pub const ${toScreamingSnakeCase(name)}_${toScreamingSnakeCase(
fieldName
@@ -70,13 +69,11 @@ 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}
`;
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..120c2a6c9
--- /dev/null
+++ b/scripts/generate-string-constants.js
@@ -0,0 +1,100 @@
+import { writeFile } from 'node:fs/promises';
+import { generateNotEditFilesComment, lintRustFile, lintTsFile } from './helpers.js';
+
+const notEditFilesComment = generateNotEditFilesComment(import.meta.url);
+
+const targetRustFile = new URL(
+ '../rust/parse_ast/src/convert_ast/converter/string_constants.rs',
+ import.meta.url
+);
+const targetTsFile = new URL('../src/utils/convert-ast-strings.ts', import.meta.url);
+
+const stringConstantsTemplate = [
+ ['STRING_VAR', 'var'],
+ ['STRING_LET', 'let'],
+ ['STRING_CONST', 'const'],
+ ['STRING_INIT', 'init'],
+ ['STRING_GET', 'get'],
+ ['STRING_SET', 'set'],
+ ['STRING_CONSTRUCTOR', 'constructor'],
+ ['STRING_METHOD', 'method'],
+ ['STRING_MINUS', '-'],
+ ['STRING_PLUS', '+'],
+ ['STRING_BANG', '!'],
+ ['STRING_TILDE', '~'],
+ ['STRING_TYPEOF', 'typeof'],
+ ['STRING_VOID', 'void'],
+ ['STRING_DELETE', 'delete'],
+ ['STRING_PLUSPLUS', '++'],
+ ['STRING_MINUSMINUS', '--'],
+ ['STRING_EQEQ', '=='],
+ ['STRING_NOTEQ', '!='],
+ ['STRING_EQEQEQ', '==='],
+ ['STRING_NOTEQEQ', '!=='],
+ ['STRING_LT', '<'],
+ ['STRING_LTEQ', '<='],
+ ['STRING_GT', '>'],
+ ['STRING_GTEQ', '>='],
+ ['STRING_LSHIFT', '<<'],
+ ['STRING_RSHIFT', '>>'],
+ ['STRING_ZEROFILLRSHIFT', '>>>'],
+ ['STRING_ADD', '+'],
+ ['STRING_SUB', '-'],
+ ['STRING_MUL', '*'],
+ ['STRING_DIV', '/'],
+ ['STRING_MOD', '%'],
+ ['STRING_BITOR', '|'],
+ ['STRING_BITXOR', '^'],
+ ['STRING_BITAND', '&'],
+ ['STRING_LOGICALOR', '||'],
+ ['STRING_LOGICALAND', '&&'],
+ ['STRING_IN', 'in'],
+ ['STRING_INSTANCEOF', 'instanceof'],
+ ['STRING_EXP', '**'],
+ ['STRING_NULLISHCOALESCING', '??'],
+ ['STRING_ASSIGN', '='],
+ ['STRING_ADDASSIGN', '+='],
+ ['STRING_SUBASSIGN', '-='],
+ ['STRING_MULASSIGN', '*='],
+ ['STRING_DIVASSIGN', '/='],
+ ['STRING_MODASSIGN', '%='],
+ ['STRING_LSHIFTASSIGN', '<<='],
+ ['STRING_RSHIFTASSIGN', '>>='],
+ ['STRING_ZEROFILLRSHIFTASSIGN', '>>>='],
+ ['STRING_BITORASSIGN', '|='],
+ ['STRING_BITXORASSIGN', '^='],
+ ['STRING_BITANDASSIGN', '&='],
+ ['STRING_EXPASSIGN', '**='],
+ ['STRING_ANDASSIGN', '&&='],
+ ['STRING_ORASSIGN', '||='],
+ ['STRING_NULLISHASSIGN', '??='],
+ ['STRING_PURE', 'pure'],
+ ['STRING_NOSIDEEFFECTS', 'noSideEffects'],
+ ['STRING_SOURCEMAP', 'sourcemap'],
+ ['STRING_USING', 'using'],
+ ['STRING_AWAIT_USING', 'await using']
+];
+
+const rustCode =
+ notEditFilesComment +
+ stringConstantsTemplate
+ .map(
+ ([variableName, value], index) =>
+ `pub const ${variableName}: [u8; 4] = ${index}u32.to_ne_bytes(); // ${value}`
+ )
+ .join('\n');
+
+const tsCode =
+ notEditFilesComment +
+ `export default ` +
+ JSON.stringify(
+ stringConstantsTemplate.map(([, value]) => value),
+ undefined,
+ 2
+ ) +
+ `;\n`;
+
+await Promise.all([
+ writeFile(targetTsFile, tsCode).then(() => lintTsFile(targetTsFile)),
+ writeFile(targetRustFile, rustCode).then(() => lintRustFile(targetRustFile))
+]);
diff --git a/scripts/helpers.js b/scripts/helpers.js
index 842cd5281..aa9143dbf 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 path from 'node:path';
import { fileURLToPath } from 'node:url';
import { ESLint } from 'eslint';
import { blue, bold, cyan, green, magenta, red, yellow } from './colors.js';
@@ -80,7 +81,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 +90,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}
@@ -104,3 +113,12 @@ export function firstLetterLowercase(string) {
export function toScreamingSnakeCase(string) {
return string.replace(/(?} 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';
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/Chunk.ts b/src/Chunk.ts
index c4e057b02..bfb7fc1dc 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)
);
@@ -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/src/ast/bufferParsers.ts b/src/ast/bufferParsers.ts
index f902359ca..e26719bae 100644
--- a/src/ast/bufferParsers.ts
+++ b/src/ast/bufferParsers.ts
@@ -1,11 +1,12 @@
-// This file is generated by scripts/generate-ast-converters.js.
+// This file is generated by scripts/generate-buffer-parsers.js.
// Do not edit this file directly.
import type * as estree from 'estree';
import type { AstContext } from '../Module';
import { convertAnnotations, 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 FIXED_STRINGS from '../utils/convert-ast-strings';
import type { ReadString } from '../utils/getReadStringFunction';
import getReadStringFunction from '../utils/getReadStringFunction';
import ArrayExpression from './nodes/ArrayExpression';
@@ -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/childNodeKeys.ts b/src/ast/childNodeKeys.ts
index 9ea9c6f64..c1e6e433b 100644
--- a/src/ast/childNodeKeys.ts
+++ b/src/ast/childNodeKeys.ts
@@ -1,4 +1,4 @@
-// This file is generated by scripts/generate-ast-converters.js.
+// This file is generated by scripts/generate-child-node-keys.js.
// Do not edit this file directly.
export const childNodeKeys: Record = {
diff --git a/src/ast/nodes/ArrowFunctionExpression.ts b/src/ast/nodes/ArrowFunctionExpression.ts
index fc97713d7..c46db27f5 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';
@@ -71,6 +72,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 b230e7ea5..8bc4ffcd8 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;
@@ -66,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;
}
}
@@ -92,6 +88,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 +219,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
@@ -299,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/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/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/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/FunctionBase.ts b/src/ast/nodes/shared/FunctionBase.ts
index 30c24011c..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;
@@ -215,19 +264,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/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/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/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/astConverterHelpers.ts b/src/utils/astConverterHelpers.ts
index 5772ae7ed..da5ad27f4 100644
--- a/src/utils/astConverterHelpers.ts
+++ b/src/utils/astConverterHelpers.ts
@@ -1,4 +1,5 @@
-import { FIXED_STRINGS } from './convert-ast-strings';
+import { EMPTY_ARRAY } from './blank';
+import FIXED_STRINGS from './convert-ast-strings';
import type { ReadString } from './getReadStringFunction';
export const ANNOTATION_KEY = '_rollupAnnotations';
@@ -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 04c6520e5..381b1688e 100644
--- a/src/utils/bufferToAst.ts
+++ b/src/utils/bufferToAst.ts
@@ -1,9 +1,10 @@
-// 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';
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,
@@ -11,7 +12,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';
@@ -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++) {
diff --git a/src/utils/convert-ast-strings.ts b/src/utils/convert-ast-strings.ts
index 381bb3743..ad2da5d2b 100644
--- a/src/utils/convert-ast-strings.ts
+++ b/src/utils/convert-ast-strings.ts
@@ -1,4 +1,7 @@
-export const FIXED_STRINGS = [
+// This file is generated by scripts/generate-string-constants.js.
+// Do not edit this file directly.
+
+export default [
'var',
'let',
'const',
@@ -58,5 +61,8 @@ export const FIXED_STRINGS = [
'||=',
'??=',
'pure',
- 'noSideEffects'
+ 'noSideEffects',
+ 'sourcemap',
+ 'using',
+ 'await using'
];
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[];
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/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/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/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/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")
+ })
+ });
+ }
+ }
+ ]
+};
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/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/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/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/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/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/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();
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/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';
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/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/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');
+
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/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';
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',
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;