From 9724408108cfd16dafbc9b386b1f667f4559787e Mon Sep 17 00:00:00 2001 From: Lukas Taegert-Atkinson Date: Fri, 23 Oct 2026 11:47:55 +0200 Subject: [PATCH 01/43] chore(repo): add infrastructure to test against earliest supported rollup When vitest runs with mode "earliest", both imports and requires of rollup resolve to the package-local rollup-earliest dependency so that each package can test against the earliest rollup version it declares to support. --- .config/vitest.config.mts | 18 ++++++++++---- .config/vitest.setup.earliest.mts | 39 +++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 4 deletions(-) create mode 100644 .config/vitest.setup.earliest.mts diff --git a/.config/vitest.config.mts b/.config/vitest.config.mts index 104645a1b..0b58939b6 100644 --- a/.config/vitest.config.mts +++ b/.config/vitest.config.mts @@ -1,9 +1,11 @@ import { defineConfig } from 'vitest/config'; import path from 'node:path'; +import { fileURLToPath } from 'node:url'; const isAutoInstallPackage = path.basename(process.cwd()) === 'auto-install'; +const earliestRollupPath = path.resolve(process.cwd(), 'node_modules/rollup-earliest'); -export default defineConfig({ +export default defineConfig(({ mode }) => ({ test: { // Enable global APIs for CommonJS test files. globals: true, @@ -26,10 +28,18 @@ export default defineConfig({ fileParallelism: !isAutoInstallPackage, // Keep snapshots in the same location used by Ava. resolveSnapshotPath: (testPath, snapExt) => - path.join(path.dirname(testPath), 'snapshots', path.basename(testPath) + snapExt) + path.join(path.dirname(testPath), 'snapshots', path.basename(testPath) + snapExt), + setupFiles: + mode === 'earliest' + ? [fileURLToPath(new URL('./vitest.setup.earliest.mts', import.meta.url))] + : [] }, resolve: { // Allow importing the current package under test via `~package` - alias: [{ find: /^~package$/, replacement: path.resolve(process.cwd()) }] + alias: [ + { find: /^~package$/, replacement: path.resolve(process.cwd()) }, + // In earliest mode, resolve imports of rollup to the aliased earliest supported version. + ...(mode === 'earliest' ? [{ find: /^rollup$/, replacement: earliestRollupPath }] : []) + ] } -}); +})); diff --git a/.config/vitest.setup.earliest.mts b/.config/vitest.setup.earliest.mts new file mode 100644 index 000000000..1522cbe66 --- /dev/null +++ b/.config/vitest.setup.earliest.mts @@ -0,0 +1,39 @@ +// The vite alias in vitest.config.mts redirects ESM imports of "rollup" to the aliased +// earliest supported version, but it does not affect require("rollup"). Patch the Node +// module resolution so CommonJS tests resolve the same version. +import Module from 'node:module'; +import path from 'node:path'; +import { existsSync } from 'node:fs'; + +type ResolveFilename = ( + request: string, + parent?: unknown, + isMain?: boolean, + options?: unknown +) => string; + +const earliestRollupPath = path.resolve(process.cwd(), 'node_modules/rollup-earliest'); + +// Without the aliased version installed, tests would silently run against the +// current dev version of rollup. Fail loudly instead of passing for the wrong reason. +if (!existsSync(earliestRollupPath)) { + throw new Error( + `Missing "${earliestRollupPath}". Run "pnpm install" to test against the earliest supported version.` + ); +} + +const originalResolveFilename = (Module as { _resolveFilename?: ResolveFilename }) + ._resolveFilename; + +if (originalResolveFilename && !originalResolveFilename.name.includes('earliestRollup')) { + (Module as { _resolveFilename: ResolveFilename })._resolveFilename = + function earliestRollup(this: unknown, request, parent, isMain, options) { + return originalResolveFilename.call( + this, + request === 'rollup' ? earliestRollupPath : request, + parent, + isMain, + options + ); + }; +} From b84de80ccac8e62e1afa951c16dbc19e59128c1c Mon Sep 17 00:00:00 2001 From: Lukas Taegert-Atkinson Date: Fri, 23 Oct 2026 16:13:22 +0200 Subject: [PATCH 02/43] chore(repo): redirect all declared earliest dependencies in earliest mode Test helpers such as @rollup/plugin-node-resolve can require a newer rollup than a package's own peer floor. Redirect every devDependency declared as `-earliest` instead of only rollup so packages can pin old helper versions next to rollup-earliest. The guard against missing installs now covers every declared alias. --- .config/vitest.config.mts | 16 ++++++++++++--- .config/vitest.earliest.mts | 26 +++++++++++++++++++++++ .config/vitest.setup.earliest.mts | 34 ++++++++++++++----------------- 3 files changed, 54 insertions(+), 22 deletions(-) create mode 100644 .config/vitest.earliest.mts diff --git a/.config/vitest.config.mts b/.config/vitest.config.mts index 0b58939b6..b2a0509a1 100644 --- a/.config/vitest.config.mts +++ b/.config/vitest.config.mts @@ -2,8 +2,18 @@ import { defineConfig } from 'vitest/config'; import path from 'node:path'; import { fileURLToPath } from 'node:url'; +import { getEarliestDependencies } from './vitest.earliest.mts'; + const isAutoInstallPackage = path.basename(process.cwd()) === 'auto-install'; -const earliestRollupPath = path.resolve(process.cwd(), 'node_modules/rollup-earliest'); +const escapeRegExp = (value: string) => value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); + +const getEarliestAliases = (mode: string) => + mode === 'earliest' + ? getEarliestDependencies().map(({ name, path: dependencyPath }) => ({ + find: new RegExp(`^${escapeRegExp(name)}$`), + replacement: dependencyPath + })) + : []; export default defineConfig(({ mode }) => ({ test: { @@ -38,8 +48,8 @@ export default defineConfig(({ mode }) => ({ // Allow importing the current package under test via `~package` alias: [ { find: /^~package$/, replacement: path.resolve(process.cwd()) }, - // In earliest mode, resolve imports of rollup to the aliased earliest supported version. - ...(mode === 'earliest' ? [{ find: /^rollup$/, replacement: earliestRollupPath }] : []) + // In earliest mode, resolve imports of aliased dependencies to the earliest supported versions. + ...getEarliestAliases(mode) ] } })); diff --git a/.config/vitest.earliest.mts b/.config/vitest.earliest.mts new file mode 100644 index 000000000..7f998fbdf --- /dev/null +++ b/.config/vitest.earliest.mts @@ -0,0 +1,26 @@ +import { existsSync, readFileSync } from 'node:fs'; +import { join } from 'node:path'; + +const EARLIEST_SUFFIX = '-earliest'; + +export function getEarliestDependencies() { + const packageJsonPath = join(process.cwd(), 'package.json'); + const { devDependencies = {} } = JSON.parse(readFileSync(packageJsonPath, 'utf8')); + const dependencies = Object.keys(devDependencies) + .filter((name) => name.endsWith(EARLIEST_SUFFIX)) + .map((name) => ({ + name: name.slice(0, -EARLIEST_SUFFIX.length), + path: join(process.cwd(), 'node_modules', name) + })); + if (!dependencies.some(({ name }) => name === 'rollup')) { + throw new Error(`Missing "rollup-earliest" devDependency in ${packageJsonPath}.`); + } + for (const { path } of dependencies) { + if (!existsSync(path)) { + throw new Error( + `Missing "${path}". Run "pnpm install" to test against the earliest supported versions.` + ); + } + } + return dependencies; +} diff --git a/.config/vitest.setup.earliest.mts b/.config/vitest.setup.earliest.mts index 1522cbe66..5ca63ef39 100644 --- a/.config/vitest.setup.earliest.mts +++ b/.config/vitest.setup.earliest.mts @@ -1,9 +1,9 @@ -// The vite alias in vitest.config.mts redirects ESM imports of "rollup" to the aliased -// earliest supported version, but it does not affect require("rollup"). Patch the Node -// module resolution so CommonJS tests resolve the same version. +// The vite aliases in vitest.config.mts redirect ESM imports of the aliased dependencies to +// their earliest supported versions, but they do not affect require(...). Patch the Node +// module resolution so CommonJS tests resolve the same versions. import Module from 'node:module'; -import path from 'node:path'; -import { existsSync } from 'node:fs'; + +import { getEarliestDependencies } from './vitest.earliest.mts'; type ResolveFilename = ( request: string, @@ -12,25 +12,21 @@ type ResolveFilename = ( options?: unknown ) => string; -const earliestRollupPath = path.resolve(process.cwd(), 'node_modules/rollup-earliest'); - -// Without the aliased version installed, tests would silently run against the -// current dev version of rollup. Fail loudly instead of passing for the wrong reason. -if (!existsSync(earliestRollupPath)) { - throw new Error( - `Missing "${earliestRollupPath}". Run "pnpm install" to test against the earliest supported version.` - ); -} +const earliestPaths = new Map( + getEarliestDependencies().map(({ name, path }) => [name, path] as const) +); -const originalResolveFilename = (Module as { _resolveFilename?: ResolveFilename }) - ._resolveFilename; +const originalResolveFilename = (Module as { _resolveFilename?: ResolveFilename })._resolveFilename; -if (originalResolveFilename && !originalResolveFilename.name.includes('earliestRollup')) { +if ( + originalResolveFilename && + !originalResolveFilename.name.includes('redirectEarliestDependencies') +) { (Module as { _resolveFilename: ResolveFilename })._resolveFilename = - function earliestRollup(this: unknown, request, parent, isMain, options) { + function redirectEarliestDependencies(this: unknown, request, parent, isMain, options) { return originalResolveFilename.call( this, - request === 'rollup' ? earliestRollupPath : request, + earliestPaths.get(request) ?? request, parent, isMain, options From 3ab43a2cd6c3e0372125a1eb5ed7c65f01edb6c0 Mon Sep 17 00:00:00 2001 From: Lukas Taegert-Atkinson Date: Fri, 23 Oct 2026 16:30:13 +0200 Subject: [PATCH 03/43] chore(repo): support version-specific snapshots in earliest mode When the output of a package drifts between rollup versions, a single snapshot file cannot cover both. In earliest mode, prefer a snapshot file in test/snapshots-earliest over the shared one if it exists, so packages can opt in per test file. --- .config/vitest.config.mts | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/.config/vitest.config.mts b/.config/vitest.config.mts index b2a0509a1..8a6c6cc39 100644 --- a/.config/vitest.config.mts +++ b/.config/vitest.config.mts @@ -1,5 +1,6 @@ import { defineConfig } from 'vitest/config'; import path from 'node:path'; +import { existsSync } from 'node:fs'; import { fileURLToPath } from 'node:url'; import { getEarliestDependencies } from './vitest.earliest.mts'; @@ -15,6 +16,21 @@ const getEarliestAliases = (mode: string) => })) : []; +const getSnapshotPath = (testPath: string, snapExt: string, mode: string) => { + const defaultPath = path.join( + path.dirname(testPath), + 'snapshots', + path.basename(testPath) + snapExt + ); + // Packages opt in to version-specific snapshots by adding the file to this directory. + const earliestPath = path.join( + path.dirname(testPath), + 'snapshots-earliest', + path.basename(testPath) + snapExt + ); + return mode === 'earliest' && existsSync(earliestPath) ? earliestPath : defaultPath; +}; + export default defineConfig(({ mode }) => ({ test: { // Enable global APIs for CommonJS test files. @@ -32,13 +48,13 @@ export default defineConfig(({ mode }) => ({ '**/test/recipes/**', '**/test/output/**', '**/test/snapshots/**', + '**/test/snapshots-earliest/**', '**/test/types.ts' ], // These tests switch process cwd and invoke package managers; run files serially there. fileParallelism: !isAutoInstallPackage, // Keep snapshots in the same location used by Ava. - resolveSnapshotPath: (testPath, snapExt) => - path.join(path.dirname(testPath), 'snapshots', path.basename(testPath) + snapExt), + resolveSnapshotPath: (testPath, snapExt) => getSnapshotPath(testPath, snapExt, mode), setupFiles: mode === 'earliest' ? [fileURLToPath(new URL('./vitest.setup.earliest.mts', import.meta.url))] From 19332ff43614b0ea97df411e6f529f2f4a68c777 Mon Sep 17 00:00:00 2001 From: Lukas Taegert-Atkinson Date: Tue, 27 Oct 2026 13:34:52 +0100 Subject: [PATCH 04/43] chore(repo): define catalog version of rollup To act as the "current stable" in all packages. --- pnpm-workspace.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index c1c7cb59f..2843d432a 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -6,4 +6,5 @@ packages: # "typescript": "catalog:" # and resolve to the range below. catalog: + rollup: ^4.65.1 typescript: ^5.9.3 From a210ef7e2e77ba9cddbe5515446abe5a7209d912 Mon Sep 17 00:00:00 2001 From: Lukas Taegert-Atkinson Date: Fri, 23 Oct 2026 11:47:58 +0200 Subject: [PATCH 05/43] test(alias): test against earliest supported rollup Run the test suite a second time with rollup pinned to the earliest supported version (4.0.0) and adapt the plugin warning assertion, whose message gained a prefix in rollup 4.13.0. --- packages/alias/package.json | 6 +- packages/alias/test/alias.test.ts | 13 ++-- pnpm-lock.yaml | 111 ++++++++++++++++++++++++++++++ 3 files changed, 124 insertions(+), 6 deletions(-) diff --git a/packages/alias/package.json b/packages/alias/package.json index 922347049..558430196 100755 --- a/packages/alias/package.json +++ b/packages/alias/package.json @@ -32,7 +32,8 @@ "prerelease": "pnpm build", "pretest": "pnpm build", "release": "pnpm --workspace-root package:release $(pwd)", - "test": "vitest --config ../../.config/vitest.config.mts run" + "test": "vitest --config ../../.config/vitest.config.mts run", + "test:earliest": "pnpm test -- --mode earliest" }, "files": [ "dist", @@ -58,7 +59,8 @@ "devDependencies": { "@rollup/plugin-node-resolve": "^15.0.0", "del-cli": "^5.0.0", - "rollup": "^4.0.0", + "rollup": "catalog:", + "rollup-earliest": "npm:rollup@4.0.0", "typescript": "catalog:" }, "types": "./dist/index.d.ts", diff --git a/packages/alias/test/alias.test.ts b/packages/alias/test/alias.test.ts index bc2e540e9..f1aad5255 100644 --- a/packages/alias/test/alias.test.ts +++ b/packages/alias/test/alias.test.ts @@ -3,7 +3,7 @@ import { fileURLToPath } from 'node:url'; import os from 'node:os'; import { describe, it, expect } from 'vitest'; -import { rollup } from 'rollup'; +import { rollup, VERSION } from 'rollup'; import nodeResolvePlugin from '@rollup/plugin-node-resolve'; import alias from '~package'; @@ -11,6 +11,11 @@ import alias from '~package'; const DIRNAME = fileURLToPath(new URL('.', import.meta.url)); const isWindows = os.platform() === 'win32'; +// rollup 4.13.0 added a prefix to plugin warning messages +const [rollupMajor, rollupMinor] = VERSION.split('.').map(Number); +const warningPrefix = + rollupMajor > 4 || (rollupMajor === 4 && rollupMinor >= 13) ? '[plugin alias] ' : ''; + /** * Helper function to test configuration with Rollup * @param plugins is an array of plugins for Rollup, they should include "alias" @@ -506,9 +511,9 @@ describe('plugin-alias', () => { expect(warnList).toMatchObject([ { message: - '[plugin alias] rewrote @/warn-importee.js to test/fixtures/folder/warn-importee.js but was not an absolute path and was not handled by other plugins. ' + - 'This will lead to duplicated modules for the same path. ' + - 'To avoid duplicating modules, you should resolve to an absolute path.', + `${warningPrefix}rewrote @/warn-importee.js to test/fixtures/folder/warn-importee.js but was not an absolute path and was not handled by other plugins. ` + + `This will lead to duplicated modules for the same path. ` + + `To avoid duplicating modules, you should resolve to an absolute path.`, code: 'PLUGIN_WARNING', plugin: 'alias' } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 8cbba389d..626601186 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -98,6 +98,9 @@ importers: rollup: specifier: ^4.0.0 version: 4.52.5 + rollup-earliest: + specifier: npm:rollup@4.0.0 + version: rollup@4.0.0 typescript: specifier: 'catalog:' version: 5.9.3 @@ -1854,6 +1857,11 @@ packages: rollup: optional: true + '@rollup/rollup-android-arm-eabi@4.0.0': + resolution: {integrity: sha512-rN3qt1JzOx0v7JWyK68zkb3yf1k1f1OhhHR0i7vLlGlediTtM3FKsOkestQN6HwJ9nEaP3KxPHxH5Xv7yr6f4w==} + cpu: [arm] + os: [android] + '@rollup/rollup-android-arm-eabi@4.0.0-24': resolution: {integrity: sha512-19cF3V1fHfzPzwu0cgZEdWLMdNkqSmKOhidqQv1CkUqAMcb7etA7WLx8YrX5ob31ruI0BYYrUDBunlIuMHHUrg==} cpu: [arm] @@ -1864,6 +1872,11 @@ packages: cpu: [arm] os: [android] + '@rollup/rollup-android-arm64@4.0.0': + resolution: {integrity: sha512-dcdg6Zp2bqIS/+2FHhdSS+lbcySufP2fYYoXkDa4W6uHE22L15psftdQZtFhxvvqRWPD1HsK0xIj5f07zuujkg==} + cpu: [arm64] + os: [android] + '@rollup/rollup-android-arm64@4.0.0-24': resolution: {integrity: sha512-ftTp5ByyyozDsHfmYGeErrQmBi4ZEVZItC4Siilwretkf+cMv9z0s0Ru8ncd28OZpaO0cr9b7Afm+DIRDyE8Kw==} cpu: [arm64] @@ -1874,6 +1887,11 @@ packages: cpu: [arm64] os: [android] + '@rollup/rollup-darwin-arm64@4.0.0': + resolution: {integrity: sha512-mOz75DpOOHGk4+xYbh1E23vmSOrOqskTwq9s/e2Z46eYbTZ0+s/UVoS42cLG8dUe6enF2Xh3hTtiIEzLhO9kmA==} + cpu: [arm64] + os: [darwin] + '@rollup/rollup-darwin-arm64@4.0.0-24': resolution: {integrity: sha512-wYXWdPbMLiIRHQeTF/r9ZoDcf3k1ROR0Kyd/caUtbs5VEZOBfnpZ/FHQPzXW0S1fzxTtD5W4tXULxARMHAlNdQ==} cpu: [arm64] @@ -1884,6 +1902,11 @@ packages: cpu: [arm64] os: [darwin] + '@rollup/rollup-darwin-x64@4.0.0': + resolution: {integrity: sha512-rEBuHQ2ejl9gb0//19F88gR7Z9HY2kcCX8jT5LhCHqGqAvlloETXO1FD7DKEdqGz98UtJy6pVAxxeVBN4tlWag==} + cpu: [x64] + os: [darwin] + '@rollup/rollup-darwin-x64@4.0.0-24': resolution: {integrity: sha512-8tIz6Uga/5XdeRkid7kfNtxrvru7o4lDBxAPooZezKXbyB2ap2yKAKCqTFEXyTuPhl2yxLMa5zqZ91FBEnSbPg==} cpu: [x64] @@ -1904,6 +1927,11 @@ packages: cpu: [x64] os: [freebsd] + '@rollup/rollup-linux-arm-gnueabihf@4.0.0': + resolution: {integrity: sha512-W4Elp0SGWqWOkdgoYniOp6ERrhHYRfMPikUZmnU/kAdLXQ9p0M0meF648Z6Y7ClHJr8pIQpcCdmr7E2h8Kn7Fw==} + cpu: [arm] + os: [linux] + '@rollup/rollup-linux-arm-gnueabihf@4.0.0-24': resolution: {integrity: sha512-ZCNBOaw2NV3BnpQ049VCPJSamss3wAoCunFcWYfhWgGyu9C0hiRvZAcKvhd7e/9EhuoIxsNxMLwI46NmZx9WBQ==} cpu: [arm] @@ -1919,6 +1947,11 @@ packages: cpu: [arm] os: [linux] + '@rollup/rollup-linux-arm64-gnu@4.0.0': + resolution: {integrity: sha512-/BTevM/UKprMJgFse0nm+YXQ83iDqArru+k3kZtQlvaNMWdkLcyscOP8SwWPpR0CJuLlXr8Gtpps+EgH3TUqLA==} + cpu: [arm64] + os: [linux] + '@rollup/rollup-linux-arm64-gnu@4.0.0-24': resolution: {integrity: sha512-BGnRktAZq4RI6FSicI+F6ws9paiYmjyaXUNKSukLthzgzPC91V4SXVylbFOCKvrhdWAr0lvZgcTrkgYNAmAcuQ==} cpu: [arm64] @@ -1959,6 +1992,11 @@ packages: cpu: [s390x] os: [linux] + '@rollup/rollup-linux-x64-gnu@4.0.0': + resolution: {integrity: sha512-Pz2FD/4FUZM98+rcpuGAJgatW5/dW/pXXrbanjtir38EYqqmdVc0odHwqlQ+KFY2C5P+B6PJO5vom8PmJQLdug==} + cpu: [x64] + os: [linux] + '@rollup/rollup-linux-x64-gnu@4.0.0-24': resolution: {integrity: sha512-FzhHpp+vRTjIUYXMExj9Ffj2bCQgnRAzlWlsQTdYGYvPQMVadfPMvnlcr4Li8P7Yv1iBFtDzRVfZAgL5glvIAA==} cpu: [x64] @@ -1969,6 +2007,11 @@ packages: cpu: [x64] os: [linux] + '@rollup/rollup-linux-x64-musl@4.0.0': + resolution: {integrity: sha512-Xs2tOshU5MD7nK5WnaSBUwiFdBlMtyKdXOOnBno4IRbDIyrjLtx9lnSIO47FNP0LtpGfyOcsK/lE/ZsLlnXyIg==} + cpu: [x64] + os: [linux] + '@rollup/rollup-linux-x64-musl@4.0.0-24': resolution: {integrity: sha512-0y+oXnCCT5+U5V58bY7dy65yDrWWfopFJwtC2EbFeA9SHrVjG36/TQo535ML3zdFwO+fma8r5FP1os0psbQBXQ==} cpu: [x64] @@ -1984,6 +2027,11 @@ packages: cpu: [arm64] os: [openharmony] + '@rollup/rollup-win32-arm64-msvc@4.0.0': + resolution: {integrity: sha512-h2r04SsqVMbmaIRSMN3HKQLYpKewJ7rWQx1SwEZQMeXRkecWFBBNOfoB3iMlvvUfc3VUOonR/3Dm/Op6yOD2Lg==} + cpu: [arm64] + os: [win32] + '@rollup/rollup-win32-arm64-msvc@4.0.0-24': resolution: {integrity: sha512-xT8djNMxVB84cCm1XILpQXkMcu8S+GBKjurXM4sc6eB1FQpFpcTAOsuQSg9xOhfPqm1xa7qqXA6ZpUhoUMboVQ==} cpu: [arm64] @@ -1994,6 +2042,11 @@ packages: cpu: [arm64] os: [win32] + '@rollup/rollup-win32-ia32-msvc@4.0.0': + resolution: {integrity: sha512-1pl05L51RbVLnqZTEpbgG2RxeS7VLysF7vhU8v1EOAMqbLzko64r8+S2SxsNDKODsgusFqHO8rc3w+G9VUjodw==} + cpu: [ia32] + os: [win32] + '@rollup/rollup-win32-ia32-msvc@4.0.0-24': resolution: {integrity: sha512-3gXFBlG5f18xbhVxKTM+zwciJPk097i3YswLI9cajVd4MAqMw5bGbuZkGOZOMnkzeIX0ELxovYWPbGDyUr+f5g==} cpu: [ia32] @@ -2009,6 +2062,11 @@ packages: cpu: [x64] os: [win32] + '@rollup/rollup-win32-x64-msvc@4.0.0': + resolution: {integrity: sha512-GDi4TkL95/J0ven1wt+q2cfdg1k9UEIQiF58lSC36KUdA0xtlqgLPEDlNAhu6NTXJ491eiZ71lQbLu1D7hlz9w==} + cpu: [x64] + os: [win32] + '@rollup/rollup-win32-x64-msvc@4.0.0-24': resolution: {integrity: sha512-41+QkzRaKEZwmA14Fa2DI0QKN5hkcN/orA2KOg5vJAtvwSfB1uQTUmf6T4SGZLw/8In2TEmViB9tDVlbnXmH1A==} cpu: [x64] @@ -4705,6 +4763,11 @@ packages: rollup-pluginutils@2.8.2: resolution: {integrity: sha512-EEp9NhnUkwY8aif6bxgovPHMoMoNr2FulJziTndpt5H9RdwC47GSGuII9XxpSdzVGM0GWrNPHV6ie1LTNJPaLQ==} + rollup@4.0.0: + resolution: {integrity: sha512-dtlkoIdp/g2glVlQb6FzhMAMzhMYVIJ3KLGjhWKkwz/ambEuHeVZ7Eg6GALhHZOsDRD+ZWSjnUikZXPyb22puQ==} + engines: {node: '>=18.0.0', npm: '>=8.0.0'} + hasBin: true + rollup@4.0.0-24: resolution: {integrity: sha512-Tcdk9cYyF5abnUQP68AWuSHahowglrzQH6olnHB4Lxi7VBuflwrlpavK7d046Ep2WmwDN0ey5sr+QzLShQ7Odw==} engines: {node: '>=18.0.0', npm: '>=8.0.0'} @@ -6543,24 +6606,36 @@ snapshots: optionalDependencies: rollup: 4.0.0-24 + '@rollup/rollup-android-arm-eabi@4.0.0': + optional: true + '@rollup/rollup-android-arm-eabi@4.0.0-24': optional: true '@rollup/rollup-android-arm-eabi@4.52.5': optional: true + '@rollup/rollup-android-arm64@4.0.0': + optional: true + '@rollup/rollup-android-arm64@4.0.0-24': optional: true '@rollup/rollup-android-arm64@4.52.5': optional: true + '@rollup/rollup-darwin-arm64@4.0.0': + optional: true + '@rollup/rollup-darwin-arm64@4.0.0-24': optional: true '@rollup/rollup-darwin-arm64@4.52.5': optional: true + '@rollup/rollup-darwin-x64@4.0.0': + optional: true + '@rollup/rollup-darwin-x64@4.0.0-24': optional: true @@ -6573,6 +6648,9 @@ snapshots: '@rollup/rollup-freebsd-x64@4.52.5': optional: true + '@rollup/rollup-linux-arm-gnueabihf@4.0.0': + optional: true + '@rollup/rollup-linux-arm-gnueabihf@4.0.0-24': optional: true @@ -6582,6 +6660,9 @@ snapshots: '@rollup/rollup-linux-arm-musleabihf@4.52.5': optional: true + '@rollup/rollup-linux-arm64-gnu@4.0.0': + optional: true + '@rollup/rollup-linux-arm64-gnu@4.0.0-24': optional: true @@ -6606,12 +6687,18 @@ snapshots: '@rollup/rollup-linux-s390x-gnu@4.52.5': optional: true + '@rollup/rollup-linux-x64-gnu@4.0.0': + optional: true + '@rollup/rollup-linux-x64-gnu@4.0.0-24': optional: true '@rollup/rollup-linux-x64-gnu@4.52.5': optional: true + '@rollup/rollup-linux-x64-musl@4.0.0': + optional: true + '@rollup/rollup-linux-x64-musl@4.0.0-24': optional: true @@ -6621,12 +6708,18 @@ snapshots: '@rollup/rollup-openharmony-arm64@4.52.5': optional: true + '@rollup/rollup-win32-arm64-msvc@4.0.0': + optional: true + '@rollup/rollup-win32-arm64-msvc@4.0.0-24': optional: true '@rollup/rollup-win32-arm64-msvc@4.52.5': optional: true + '@rollup/rollup-win32-ia32-msvc@4.0.0': + optional: true + '@rollup/rollup-win32-ia32-msvc@4.0.0-24': optional: true @@ -6636,6 +6729,9 @@ snapshots: '@rollup/rollup-win32-x64-gnu@4.52.5': optional: true + '@rollup/rollup-win32-x64-msvc@4.0.0': + optional: true + '@rollup/rollup-win32-x64-msvc@4.0.0-24': optional: true @@ -9562,6 +9658,21 @@ snapshots: dependencies: estree-walker: 0.6.1 + rollup@4.0.0: + optionalDependencies: + '@rollup/rollup-android-arm-eabi': 4.0.0 + '@rollup/rollup-android-arm64': 4.0.0 + '@rollup/rollup-darwin-arm64': 4.0.0 + '@rollup/rollup-darwin-x64': 4.0.0 + '@rollup/rollup-linux-arm-gnueabihf': 4.0.0 + '@rollup/rollup-linux-arm64-gnu': 4.0.0 + '@rollup/rollup-linux-x64-gnu': 4.0.0 + '@rollup/rollup-linux-x64-musl': 4.0.0 + '@rollup/rollup-win32-arm64-msvc': 4.0.0 + '@rollup/rollup-win32-ia32-msvc': 4.0.0 + '@rollup/rollup-win32-x64-msvc': 4.0.0 + fsevents: 2.3.3 + rollup@4.0.0-24: optionalDependencies: '@rollup/rollup-android-arm-eabi': 4.0.0-24 From 3813491efc281e2223ec38c953636048629b8cf4 Mon Sep 17 00:00:00 2001 From: Lukas Taegert-Atkinson Date: Fri, 23 Oct 2026 13:07:15 +0200 Subject: [PATCH 06/43] test(virtual): test against earliest supported rollup Run the test suite a second time with rollup pinned to the earliest supported version (1.20.0). As the existing tests only call the plugin hooks directly, add a test that runs an actual build so the pinned version is exercised. --- packages/virtual/package.json | 4 +- packages/virtual/test/rollup-build.test.js | 18 ++ packages/virtual/test/types.test.js | 13 +- pnpm-lock.yaml | 296 ++++++++++++++++++++- 4 files changed, 323 insertions(+), 8 deletions(-) create mode 100644 packages/virtual/test/rollup-build.test.js diff --git a/packages/virtual/package.json b/packages/virtual/package.json index 7f65ac9d0..aed226760 100755 --- a/packages/virtual/package.json +++ b/packages/virtual/package.json @@ -41,6 +41,7 @@ "pretest": "pnpm build", "release": "pnpm --workspace-root package:release $(pwd)", "test": "vitest --config ../../.config/vitest.config.mts run", + "test:earliest": "pnpm test -- --mode earliest", "test:ts": "tsc --noEmit && vitest --config ../../.config/vitest.config.mts run test/types.test.js" }, "files": [ @@ -70,7 +71,8 @@ "devDependencies": { "@rollup/plugin-node-resolve": "^15.0.0", "@rollup/plugin-typescript": "^9.0.1", - "rollup": "^4.0.0-24", + "rollup": "catalog:", + "rollup-earliest": "npm:rollup@1.20.0", "typescript": "^4.8.3" }, "types": "./types/index.d.ts" diff --git a/packages/virtual/test/rollup-build.test.js b/packages/virtual/test/rollup-build.test.js new file mode 100644 index 000000000..d01da0375 --- /dev/null +++ b/packages/virtual/test/rollup-build.test.js @@ -0,0 +1,18 @@ +const { rollup } = require('rollup'); + +const virtual = require('..'); + +test('bundles virtual modules with rollup', async () => { + const bundle = await rollup({ + input: 'entry', + plugins: [ + virtual({ + entry: "import value from './dep.js'; export default value;", + 'dep.js': 'export default "virtual-test-value";' + }) + ] + }); + const { output } = await bundle.generate({ format: 'es' }); + expect(output).toHaveLength(1); + expect(output[0].code).toContain('virtual-test-value'); +}); diff --git a/packages/virtual/test/types.test.js b/packages/virtual/test/types.test.js index c708522a8..22e89da2d 100644 --- a/packages/virtual/test/types.test.js +++ b/packages/virtual/test/types.test.js @@ -1,5 +1,7 @@ const path = require('path'); +const { existsSync } = require('fs'); + const ts = require('typescript'); const modes = [ @@ -7,13 +9,22 @@ const modes = [ ['NodeNext', ts.ModuleKind.NodeNext, ts.ModuleResolutionKind.NodeNext] ]; +// The rollup type declarations reference Symbol.asyncDispose, which requires the disposable lib. +// Only TypeScript 5.2 and later ship that lib; older versions fall back to skipping lib checks. +const disposableLib = 'lib.esnext.disposable.d.ts'; +const hasDisposableLib = existsSync( + path.join(path.dirname(require.resolve('typescript')), disposableLib) +); + function diagnostics(fixture, module, moduleResolution) { const program = ts.createProgram([path.join(__dirname, 'fixtures', 'types', fixture)], { esModuleInterop: true, module, moduleResolution, noEmit: true, - skipLibCheck: false, + ...(hasDisposableLib + ? { lib: ['lib.es2019.d.ts', disposableLib], skipLibCheck: false } + : { skipLibCheck: true }), strict: true, target: ts.ScriptTarget.ES2019, types: [] diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 626601186..c3a137eaa 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -6,6 +6,9 @@ settings: catalogs: default: + rollup: + specifier: ^4.65.1 + version: 4.65.1 typescript: specifier: ^5.9.3 version: 5.9.3 @@ -91,13 +94,13 @@ importers: devDependencies: '@rollup/plugin-node-resolve': specifier: ^15.0.0 - version: 15.0.0(rollup@4.52.5) + version: 15.0.0(rollup@4.65.1) del-cli: specifier: ^5.0.0 version: 5.0.0 rollup: - specifier: ^4.0.0 - version: 4.52.5 + specifier: 'catalog:' + version: 4.65.1 rollup-earliest: specifier: npm:rollup@4.0.0 version: rollup@4.0.0 @@ -782,6 +785,9 @@ importers: rollup: specifier: ^4.0.0-24 version: 4.0.0-24 + rollup-earliest: + specifier: npm:rollup@1.20.0 + version: rollup@1.20.0 typescript: specifier: ^4.8.3 version: 4.8.4 @@ -1725,6 +1731,12 @@ packages: '@jridgewell/trace-mapping@0.3.9': resolution: {integrity: sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==} + '@napi-rs/lzma-linux-x64-gnu@1.5.1': + resolution: {integrity: sha512-oTXEIha4SsuXdTA4Iyskj0kpdx2yVXdhd75c2v3xGrHFfVMsbhTPZU/nMPL4sWKo4pBHm3aucLaqGlF696dTyQ==} + engines: {node: ^22.20 || ^24.12 || >=25} + cpu: [x64] + os: [linux] + '@nodelib/fs.scandir@2.1.5': resolution: {integrity: sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==} engines: {node: '>= 8'} @@ -1872,6 +1884,11 @@ packages: cpu: [arm] os: [android] + '@rollup/rollup-android-arm-eabi@4.65.1': + resolution: {integrity: sha512-5coxNSjqOI2J3NkVhlp3u+zGcyjnowQFsU9sg7MMz4UPXY4Dv63kFGLt7ConXz9CNq2i0yuOJZAF/2RMrgI2OA==} + cpu: [arm] + os: [android] + '@rollup/rollup-android-arm64@4.0.0': resolution: {integrity: sha512-dcdg6Zp2bqIS/+2FHhdSS+lbcySufP2fYYoXkDa4W6uHE22L15psftdQZtFhxvvqRWPD1HsK0xIj5f07zuujkg==} cpu: [arm64] @@ -1887,6 +1904,11 @@ packages: cpu: [arm64] os: [android] + '@rollup/rollup-android-arm64@4.65.1': + resolution: {integrity: sha512-K0HFf6XMB3IYs+jDZ1/RRhZaVOwxNXrl0n4MDEyGDjuK7+B6K/nDJp8DCBitO3S1sK/fzNxAf9QZAny4AIUPtg==} + cpu: [arm64] + os: [android] + '@rollup/rollup-darwin-arm64@4.0.0': resolution: {integrity: sha512-mOz75DpOOHGk4+xYbh1E23vmSOrOqskTwq9s/e2Z46eYbTZ0+s/UVoS42cLG8dUe6enF2Xh3hTtiIEzLhO9kmA==} cpu: [arm64] @@ -1902,6 +1924,11 @@ packages: cpu: [arm64] os: [darwin] + '@rollup/rollup-darwin-arm64@4.65.1': + resolution: {integrity: sha512-zkZrXYwNlIcSUmcwY2DpsaDHr0XjVUeQHCuSunG3eQD7/5Wn/DvI7OMUE8NRRweK87yG8ebJ1xGOzmwpMsbZQA==} + cpu: [arm64] + os: [darwin] + '@rollup/rollup-darwin-x64@4.0.0': resolution: {integrity: sha512-rEBuHQ2ejl9gb0//19F88gR7Z9HY2kcCX8jT5LhCHqGqAvlloETXO1FD7DKEdqGz98UtJy6pVAxxeVBN4tlWag==} cpu: [x64] @@ -1917,16 +1944,31 @@ packages: cpu: [x64] os: [darwin] + '@rollup/rollup-darwin-x64@4.65.1': + resolution: {integrity: sha512-Zaed+R3cpkkA3aiNd7NO0GV5KFh/LVf8j6bGcoRdpoXkSm/mWH8M0oX2/3u/nyGcx/bHEovD9CzX+w9/gcpI4A==} + cpu: [x64] + os: [darwin] + '@rollup/rollup-freebsd-arm64@4.52.5': resolution: {integrity: sha512-QofO7i7JycsYOWxe0GFqhLmF6l1TqBswJMvICnRUjqCx8b47MTo46W8AoeQwiokAx3zVryVnxtBMcGcnX12LvA==} cpu: [arm64] os: [freebsd] + '@rollup/rollup-freebsd-arm64@4.65.1': + resolution: {integrity: sha512-h12p3WJWhyJ9kir0zqAPr0rKNmBzOWIjoaOMT9OULs9KZQZCeOMKd+mGSvERjd9VxJYShd3zIxtrVxkYz6BEVA==} + cpu: [arm64] + os: [freebsd] + '@rollup/rollup-freebsd-x64@4.52.5': resolution: {integrity: sha512-jr21b/99ew8ujZubPo9skbrItHEIE50WdV86cdSoRkKtmWa+DDr6fu2c/xyRT0F/WazZpam6kk7IHBerSL7LDQ==} cpu: [x64] os: [freebsd] + '@rollup/rollup-freebsd-x64@4.65.1': + resolution: {integrity: sha512-yRBwh/5imKY4DydDulVtrjy8Jf7h7NQJUqZbgmZ3zFsCD9QqlnWvZ7RtEF+ecO1b+IukKjXlu5Bb9fehV3tIbg==} + cpu: [x64] + os: [freebsd] + '@rollup/rollup-linux-arm-gnueabihf@4.0.0': resolution: {integrity: sha512-W4Elp0SGWqWOkdgoYniOp6ERrhHYRfMPikUZmnU/kAdLXQ9p0M0meF648Z6Y7ClHJr8pIQpcCdmr7E2h8Kn7Fw==} cpu: [arm] @@ -1942,11 +1984,21 @@ packages: cpu: [arm] os: [linux] + '@rollup/rollup-linux-arm-gnueabihf@4.65.1': + resolution: {integrity: sha512-1XuPiWYYaLE1UDOqhbKVOfsqxvfmFS/lYPSk92U1hEX1qRfSYH0hNeAlbxFIgjp4d6+YQmL95EPRgdvjbZEddA==} + cpu: [arm] + os: [linux] + '@rollup/rollup-linux-arm-musleabihf@4.52.5': resolution: {integrity: sha512-Fw4tysRutyQc/wwkmcyoqFtJhh0u31K+Q6jYjeicsGJJ7bbEq8LwPWV/w0cnzOqR2m694/Af6hpFayLJZkG2VQ==} cpu: [arm] os: [linux] + '@rollup/rollup-linux-arm-musleabihf@4.65.1': + resolution: {integrity: sha512-Y3C5e55Yrf6p2r5rBcc4P9hFWVNi6oqWy/53I/AyCJJGlp3KRSpTP8eoUmVntchTbEnhgBgAgLO9flj9AvOdUw==} + cpu: [arm] + os: [linux] + '@rollup/rollup-linux-arm64-gnu@4.0.0': resolution: {integrity: sha512-/BTevM/UKprMJgFse0nm+YXQ83iDqArru+k3kZtQlvaNMWdkLcyscOP8SwWPpR0CJuLlXr8Gtpps+EgH3TUqLA==} cpu: [arm64] @@ -1962,36 +2014,81 @@ packages: cpu: [arm64] os: [linux] + '@rollup/rollup-linux-arm64-gnu@4.65.1': + resolution: {integrity: sha512-Itj6coSswkYPIcVLczObXmwdplHNQQxyfnK1ppBg4czDaX8RiEzLKqU7EMc64BiBuiDZEUS+M93ktM18rv5llw==} + cpu: [arm64] + os: [linux] + '@rollup/rollup-linux-arm64-musl@4.52.5': resolution: {integrity: sha512-AvttBOMwO9Pcuuf7m9PkC1PUIKsfaAJ4AYhy944qeTJgQOqJYJ9oVl2nYgY7Rk0mkbsuOpCAYSs6wLYB2Xiw0Q==} cpu: [arm64] os: [linux] + '@rollup/rollup-linux-arm64-musl@4.65.1': + resolution: {integrity: sha512-KeO8jTEqdrnhvcahufbimyMoI44vedRUp1bVz2QUnRX2vDm/hxzCPt5F8fERVD5fsHyTW/vXmCElT054VOSVOA==} + cpu: [arm64] + os: [linux] + '@rollup/rollup-linux-loong64-gnu@4.52.5': resolution: {integrity: sha512-DkDk8pmXQV2wVrF6oq5tONK6UHLz/XcEVow4JTTerdeV1uqPeHxwcg7aFsfnSm9L+OO8WJsWotKM2JJPMWrQtA==} cpu: [loong64] os: [linux] + '@rollup/rollup-linux-loong64-gnu@4.65.1': + resolution: {integrity: sha512-dDOz5VZZ+ZGnglpmET6VJefamWXFsgaVtuhSClf2/URZBp048jprD6z1hddsIMN6n1w+oUzGZEBp9u6Mlszsfg==} + cpu: [loong64] + os: [linux] + + '@rollup/rollup-linux-loong64-musl@4.65.1': + resolution: {integrity: sha512-JbfRKz8nJCuo8gn1Dqx8lQWEHw4qhZ3uRaHphw5vrSjnSptJTKTRC/bLKHh8QQMsEnhL4uq+bdg3tkiXbJ2q/A==} + cpu: [loong64] + os: [linux] + '@rollup/rollup-linux-ppc64-gnu@4.52.5': resolution: {integrity: sha512-W/b9ZN/U9+hPQVvlGwjzi+Wy4xdoH2I8EjaCkMvzpI7wJUs8sWJ03Rq96jRnHkSrcHTpQe8h5Tg3ZzUPGauvAw==} cpu: [ppc64] os: [linux] + '@rollup/rollup-linux-ppc64-gnu@4.65.1': + resolution: {integrity: sha512-3oQpe1q0emSeCAssVHMQdOz5fz3PBH5my/Fr0ZekV2UMNL4ZiRa1ciikYlGQXyDkeqseYYv1InwOY8YPqY7RIQ==} + cpu: [ppc64] + os: [linux] + + '@rollup/rollup-linux-ppc64-musl@4.65.1': + resolution: {integrity: sha512-nNV3HHi23o1LtpGGwH+Bav4hqnc4+klQtC96tSvCfvql8bLlNFTnTFiGl/jai2nve3eEr/vT2ocuyf+h+eMnYQ==} + cpu: [ppc64] + os: [linux] + '@rollup/rollup-linux-riscv64-gnu@4.52.5': resolution: {integrity: sha512-sjQLr9BW7R/ZiXnQiWPkErNfLMkkWIoCz7YMn27HldKsADEKa5WYdobaa1hmN6slu9oWQbB6/jFpJ+P2IkVrmw==} cpu: [riscv64] os: [linux] + '@rollup/rollup-linux-riscv64-gnu@4.65.1': + resolution: {integrity: sha512-b5zab0FryBxuocuDeqOsYGAg2EzjKw4mKA6LjQXCyewXjGv/BXqACBsY2cO45xM4hV2weYtdjGThP2VB2ByAYg==} + cpu: [riscv64] + os: [linux] + '@rollup/rollup-linux-riscv64-musl@4.52.5': resolution: {integrity: sha512-hq3jU/kGyjXWTvAh2awn8oHroCbrPm8JqM7RUpKjalIRWWXE01CQOf/tUNWNHjmbMHg/hmNCwc/Pz3k1T/j/Lg==} cpu: [riscv64] os: [linux] + '@rollup/rollup-linux-riscv64-musl@4.65.1': + resolution: {integrity: sha512-Rh08xZakiUxKNgI3hbgH9mivlx478lSqckS9s+Oc3/TX1VrAH3W8z/5wpJXR/v5VjqcJ/jJNVBg64PU1+iQsTQ==} + cpu: [riscv64] + os: [linux] + '@rollup/rollup-linux-s390x-gnu@4.52.5': resolution: {integrity: sha512-gn8kHOrku8D4NGHMK1Y7NA7INQTRdVOntt1OCYypZPRt6skGbddska44K8iocdpxHTMMNui5oH4elPH4QOLrFQ==} cpu: [s390x] os: [linux] + '@rollup/rollup-linux-s390x-gnu@4.65.1': + resolution: {integrity: sha512-qDgtS6juN3/k97y4kcD6XLFpXEo4f6CnG8lTOGYwlhrUYTrMyhN0WHdZCPAW5rqS0MqQG7qI7dxnjugt6QB39Q==} + cpu: [s390x] + os: [linux] + '@rollup/rollup-linux-x64-gnu@4.0.0': resolution: {integrity: sha512-Pz2FD/4FUZM98+rcpuGAJgatW5/dW/pXXrbanjtir38EYqqmdVc0odHwqlQ+KFY2C5P+B6PJO5vom8PmJQLdug==} cpu: [x64] @@ -2007,6 +2104,11 @@ packages: cpu: [x64] os: [linux] + '@rollup/rollup-linux-x64-gnu@4.65.1': + resolution: {integrity: sha512-44IKzBPqXXVm0kt1O+F5eW4juR5FyIxGNlFkpP8qwIDzucBsjM1HCbdYUQrQw8rU/g6HRl/tfBm0+Qq4H4Ro3w==} + cpu: [x64] + os: [linux] + '@rollup/rollup-linux-x64-musl@4.0.0': resolution: {integrity: sha512-Xs2tOshU5MD7nK5WnaSBUwiFdBlMtyKdXOOnBno4IRbDIyrjLtx9lnSIO47FNP0LtpGfyOcsK/lE/ZsLlnXyIg==} cpu: [x64] @@ -2022,11 +2124,26 @@ packages: cpu: [x64] os: [linux] + '@rollup/rollup-linux-x64-musl@4.65.1': + resolution: {integrity: sha512-tvYWZ/h2PCHs558Xu7B6LptuRCV8lXV2xI75ONMcldII1m2zlFwuI4BJZi9M6rSMkYqcPLLtPUPrjyqfbzLOdg==} + cpu: [x64] + os: [linux] + + '@rollup/rollup-openbsd-x64@4.65.1': + resolution: {integrity: sha512-gdyeucgZCnei3pXwadKVTEAOgRx0B+c847DUPR/PdOMmp3olhfkYo6r0J4PzRFZB5ZICZQTxntyvgmWH5xT7rg==} + cpu: [x64] + os: [openbsd] + '@rollup/rollup-openharmony-arm64@4.52.5': resolution: {integrity: sha512-QoFqB6+/9Rly/RiPjaomPLmR/13cgkIGfA40LHly9zcH1S0bN2HVFYk3a1eAyHQyjs3ZJYlXvIGtcCs5tko9Cw==} cpu: [arm64] os: [openharmony] + '@rollup/rollup-openharmony-arm64@4.65.1': + resolution: {integrity: sha512-Wf/NEKdn2SAL4Nvt8HyDtdkseWTwiLbZEOoNYnEaHkbso0B9eHO42vKnZh+OYsn+IMhAMcWcuIwPlBOgOXsUzg==} + cpu: [arm64] + os: [openharmony] + '@rollup/rollup-win32-arm64-msvc@4.0.0': resolution: {integrity: sha512-h2r04SsqVMbmaIRSMN3HKQLYpKewJ7rWQx1SwEZQMeXRkecWFBBNOfoB3iMlvvUfc3VUOonR/3Dm/Op6yOD2Lg==} cpu: [arm64] @@ -2042,6 +2159,11 @@ packages: cpu: [arm64] os: [win32] + '@rollup/rollup-win32-arm64-msvc@4.65.1': + resolution: {integrity: sha512-x9VSsDmsMsEWy4cr/mFeaEsXnVJ6Kc4NCAU/lCnwml3s7LQbZoa9+/qwc9etWHbuuDT5mYxdyyKUwo76njtjZw==} + cpu: [arm64] + os: [win32] + '@rollup/rollup-win32-ia32-msvc@4.0.0': resolution: {integrity: sha512-1pl05L51RbVLnqZTEpbgG2RxeS7VLysF7vhU8v1EOAMqbLzko64r8+S2SxsNDKODsgusFqHO8rc3w+G9VUjodw==} cpu: [ia32] @@ -2057,11 +2179,21 @@ packages: cpu: [ia32] os: [win32] + '@rollup/rollup-win32-ia32-msvc@4.65.1': + resolution: {integrity: sha512-RIDbiVvvLkN45mOFpbo6eYMgnuiBEB62BGR/0s4QJgGg2AvVxucDDNn67kpAcUoYyfmY8iX8/RifMcmxmmnejA==} + cpu: [ia32] + os: [win32] + '@rollup/rollup-win32-x64-gnu@4.52.5': resolution: {integrity: sha512-UGBUGPFp1vkj6p8wCRraqNhqwX/4kNQPS57BCFc8wYh0g94iVIW33wJtQAx3G7vrjjNtRaxiMUylM0ktp/TRSQ==} cpu: [x64] os: [win32] + '@rollup/rollup-win32-x64-gnu@4.65.1': + resolution: {integrity: sha512-+KN8HIr88vN59JNxlrM2fMimzY43Y0lQB7+0xdVsFbvFCAA74CLKCdfzIHzzvndJryBc94Pm+MvwtukKjaS2ug==} + cpu: [x64] + os: [win32] + '@rollup/rollup-win32-x64-msvc@4.0.0': resolution: {integrity: sha512-GDi4TkL95/J0ven1wt+q2cfdg1k9UEIQiF58lSC36KUdA0xtlqgLPEDlNAhu6NTXJ491eiZ71lQbLu1D7hlz9w==} cpu: [x64] @@ -2077,6 +2209,11 @@ packages: cpu: [x64] os: [win32] + '@rollup/rollup-win32-x64-msvc@4.65.1': + resolution: {integrity: sha512-+Y1Sd49cSDq60UOl8/U2HI0ebUvnSl/hDhMHQn+ouw17yb8fYwMWIazzJ4JFpSkjPE7sj5NTNSX9IoyEqcFfyQ==} + cpu: [x64] + os: [win32] + '@sindresorhus/is@4.6.0': resolution: {integrity: sha512-t09vSN3MdfsyCHoFcTRCH/iUtG7OJ0CsjzB8cjAmKc/va/kIgeDI/TxsigdncE/4be734m0cvIYwNaV4i2XqAw==} engines: {node: '>=10'} @@ -2215,12 +2352,18 @@ packages: '@types/eslint@8.56.12': resolution: {integrity: sha512-03ruubjWyOHlmljCVoxSuNDdmfZDzsrrz0P2LeJsOXr+ZwFQ+0yQIwNCwt/GYhV7Z31fgtXJTAEs+FYlEL851g==} + '@types/estree@0.0.39': + resolution: {integrity: sha512-EYNwp3bU+98cpU4lAWYYL7Zz+2gryWH1qbdDTidVd6hkiR6weksdbMadyXKXNPEkQFhXM+hVO9ZygomHXp+AIw==} + '@types/estree@1.0.0': resolution: {integrity: sha512-WulqXMDUTYAXCjZnk6JtIHPigp55cVtDgDrO2gHRwhyJto21+1zbVCtOYB2L1F9w4qCQ0rOGWBnBe0FNTiEJIQ==} '@types/estree@1.0.8': resolution: {integrity: sha512-dWHzHa2WqEXI/O1E9OjrocMTKJl2mSrEolh1Iomrv6U+JuNwaHXsXx9bLu5gG7BUWFIN0skIQJQ/L1rIex4X6w==} + '@types/estree@1.0.9': + resolution: {integrity: sha512-GhdPgy1el4/ImP05X05Uw4cw2/M93BCUmnEvWZNStlCzEKME4Fkk+YpoA5OiHNQmoS7Cafb8Xa3Pya8m1Qrzeg==} + '@types/http-cache-semantics@4.0.1': resolution: {integrity: sha512-SZs7ekbP8CN0txVG2xVRH6EgKmEm31BOxA07vkFaETzZz1xh+cbt8BcI0slpymvwhx5dlFnQG2rTlPVQn+iRPQ==} @@ -2236,6 +2379,9 @@ packages: '@types/minimist@1.2.2': resolution: {integrity: sha512-jhuKLIRrhvCPLqwPcx6INqmKeiA5EWrsCOPhrlFSrbrmU4ZMPjj5Ul/oLCMDO98XRUIwVm78xICz4EPCektzeQ==} + '@types/node@12.20.55': + resolution: {integrity: sha512-J8xLz7q2OFulZ2cyGTLE1TbbZcjpno7FaN6zdJNrgAdrJ+DZzh/uFR6YrTb4C+nXakvud8Q4+rbhoIWlYQbUFQ==} + '@types/node@14.18.30': resolution: {integrity: sha512-8OEyg4oc/CqN5+LbInKNLA8MfbGzbC+k8lVPePXazuwEVrVeQ9gwMDX00HJwWbC7syc1FWRU6Mow0Lm+mibHAQ==} @@ -2447,6 +2593,11 @@ packages: engines: {node: '>=0.4.0'} hasBin: true + acorn@7.4.1: + resolution: {integrity: sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A==} + engines: {node: '>=0.4.0'} + hasBin: true + acorn@8.14.0: resolution: {integrity: sha512-cl669nCJTZBsL97OF4kUQm5g5hC2uihk0NxY3WENAC0TYdILVkAyHymAntgxGkl7K+t0cXIrH5siy5S4XkFycA==} engines: {node: '>=0.4.0'} @@ -4763,6 +4914,10 @@ packages: rollup-pluginutils@2.8.2: resolution: {integrity: sha512-EEp9NhnUkwY8aif6bxgovPHMoMoNr2FulJziTndpt5H9RdwC47GSGuII9XxpSdzVGM0GWrNPHV6ie1LTNJPaLQ==} + rollup@1.20.0: + resolution: {integrity: sha512-zW80j9RSJ0VV0VOxP1i7cF279+IlAaD49Ihwqb87PDR0555Fvk10HKmh2yUtXCdBb37bELuhHWZTJc4uoCo8Vw==} + hasBin: true + rollup@4.0.0: resolution: {integrity: sha512-dtlkoIdp/g2glVlQb6FzhMAMzhMYVIJ3KLGjhWKkwz/ambEuHeVZ7Eg6GALhHZOsDRD+ZWSjnUikZXPyb22puQ==} engines: {node: '>=18.0.0', npm: '>=8.0.0'} @@ -4778,6 +4933,11 @@ packages: engines: {node: '>=18.0.0', npm: '>=8.0.0'} hasBin: true + rollup@4.65.1: + resolution: {integrity: sha512-HzD4IdphaPMvuAacnL/vtoq5B8FwqewKvxTtqYibWvP6VDyZ+UsTtlw5F8HIOIIpLQAkN2NOP/0sM3puo9xN/A==} + engines: {node: '>=18.0.0', npm: '>=8.0.0'} + hasBin: true + run-parallel@1.2.0: resolution: {integrity: sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==} @@ -6474,6 +6634,9 @@ snapshots: '@jridgewell/resolve-uri': 3.1.0 '@jridgewell/sourcemap-codec': 1.5.5 + '@napi-rs/lzma-linux-x64-gnu@1.5.1': + optional: true + '@nodelib/fs.scandir@2.1.5': dependencies: '@nodelib/fs.stat': 2.0.5 @@ -6537,7 +6700,7 @@ snapshots: optionalDependencies: rollup: 4.0.0-24 - '@rollup/plugin-node-resolve@15.0.0(rollup@4.52.5)': + '@rollup/plugin-node-resolve@15.0.0(rollup@4.65.1)': dependencies: '@rollup/pluginutils': 4.2.1 '@types/resolve': 1.20.2 @@ -6546,7 +6709,7 @@ snapshots: is-module: 1.0.0 resolve: 1.22.1 optionalDependencies: - rollup: 4.52.5 + rollup: 4.65.1 '@rollup/plugin-typescript@9.0.1(rollup@4.0.0-24)(tslib@2.4.0)(typescript@4.8.4)': dependencies: @@ -6615,6 +6778,9 @@ snapshots: '@rollup/rollup-android-arm-eabi@4.52.5': optional: true + '@rollup/rollup-android-arm-eabi@4.65.1': + optional: true + '@rollup/rollup-android-arm64@4.0.0': optional: true @@ -6624,6 +6790,9 @@ snapshots: '@rollup/rollup-android-arm64@4.52.5': optional: true + '@rollup/rollup-android-arm64@4.65.1': + optional: true + '@rollup/rollup-darwin-arm64@4.0.0': optional: true @@ -6633,6 +6802,9 @@ snapshots: '@rollup/rollup-darwin-arm64@4.52.5': optional: true + '@rollup/rollup-darwin-arm64@4.65.1': + optional: true + '@rollup/rollup-darwin-x64@4.0.0': optional: true @@ -6642,12 +6814,21 @@ snapshots: '@rollup/rollup-darwin-x64@4.52.5': optional: true + '@rollup/rollup-darwin-x64@4.65.1': + optional: true + '@rollup/rollup-freebsd-arm64@4.52.5': optional: true + '@rollup/rollup-freebsd-arm64@4.65.1': + optional: true + '@rollup/rollup-freebsd-x64@4.52.5': optional: true + '@rollup/rollup-freebsd-x64@4.65.1': + optional: true + '@rollup/rollup-linux-arm-gnueabihf@4.0.0': optional: true @@ -6657,9 +6838,15 @@ snapshots: '@rollup/rollup-linux-arm-gnueabihf@4.52.5': optional: true + '@rollup/rollup-linux-arm-gnueabihf@4.65.1': + optional: true + '@rollup/rollup-linux-arm-musleabihf@4.52.5': optional: true + '@rollup/rollup-linux-arm-musleabihf@4.65.1': + optional: true + '@rollup/rollup-linux-arm64-gnu@4.0.0': optional: true @@ -6669,24 +6856,51 @@ snapshots: '@rollup/rollup-linux-arm64-gnu@4.52.5': optional: true + '@rollup/rollup-linux-arm64-gnu@4.65.1': + optional: true + '@rollup/rollup-linux-arm64-musl@4.52.5': optional: true + '@rollup/rollup-linux-arm64-musl@4.65.1': + optional: true + '@rollup/rollup-linux-loong64-gnu@4.52.5': optional: true + '@rollup/rollup-linux-loong64-gnu@4.65.1': + optional: true + + '@rollup/rollup-linux-loong64-musl@4.65.1': + optional: true + '@rollup/rollup-linux-ppc64-gnu@4.52.5': optional: true + '@rollup/rollup-linux-ppc64-gnu@4.65.1': + optional: true + + '@rollup/rollup-linux-ppc64-musl@4.65.1': + optional: true + '@rollup/rollup-linux-riscv64-gnu@4.52.5': optional: true + '@rollup/rollup-linux-riscv64-gnu@4.65.1': + optional: true + '@rollup/rollup-linux-riscv64-musl@4.52.5': optional: true + '@rollup/rollup-linux-riscv64-musl@4.65.1': + optional: true + '@rollup/rollup-linux-s390x-gnu@4.52.5': optional: true + '@rollup/rollup-linux-s390x-gnu@4.65.1': + optional: true + '@rollup/rollup-linux-x64-gnu@4.0.0': optional: true @@ -6696,6 +6910,9 @@ snapshots: '@rollup/rollup-linux-x64-gnu@4.52.5': optional: true + '@rollup/rollup-linux-x64-gnu@4.65.1': + optional: true + '@rollup/rollup-linux-x64-musl@4.0.0': optional: true @@ -6705,9 +6922,18 @@ snapshots: '@rollup/rollup-linux-x64-musl@4.52.5': optional: true + '@rollup/rollup-linux-x64-musl@4.65.1': + optional: true + + '@rollup/rollup-openbsd-x64@4.65.1': + optional: true + '@rollup/rollup-openharmony-arm64@4.52.5': optional: true + '@rollup/rollup-openharmony-arm64@4.65.1': + optional: true + '@rollup/rollup-win32-arm64-msvc@4.0.0': optional: true @@ -6717,6 +6943,9 @@ snapshots: '@rollup/rollup-win32-arm64-msvc@4.52.5': optional: true + '@rollup/rollup-win32-arm64-msvc@4.65.1': + optional: true + '@rollup/rollup-win32-ia32-msvc@4.0.0': optional: true @@ -6726,9 +6955,15 @@ snapshots: '@rollup/rollup-win32-ia32-msvc@4.52.5': optional: true + '@rollup/rollup-win32-ia32-msvc@4.65.1': + optional: true + '@rollup/rollup-win32-x64-gnu@4.52.5': optional: true + '@rollup/rollup-win32-x64-gnu@4.65.1': + optional: true + '@rollup/rollup-win32-x64-msvc@4.0.0': optional: true @@ -6738,6 +6973,9 @@ snapshots: '@rollup/rollup-win32-x64-msvc@4.52.5': optional: true + '@rollup/rollup-win32-x64-msvc@4.65.1': + optional: true + '@sindresorhus/is@4.6.0': {} '@sinonjs/commons@1.8.3': @@ -6861,10 +7099,14 @@ snapshots: '@types/estree': 1.0.8 '@types/json-schema': 7.0.15 + '@types/estree@0.0.39': {} + '@types/estree@1.0.0': {} '@types/estree@1.0.8': {} + '@types/estree@1.0.9': {} + '@types/http-cache-semantics@4.0.1': {} '@types/json-schema@7.0.15': {} @@ -6877,6 +7119,8 @@ snapshots: '@types/minimist@1.2.2': {} + '@types/node@12.20.55': {} + '@types/node@14.18.30': {} '@types/node@14.18.31': {} @@ -7151,6 +7395,8 @@ snapshots: acorn@6.4.2: {} + acorn@7.4.1: {} + acorn@8.14.0: {} acorn@8.15.0: {} @@ -8193,7 +8439,7 @@ snapshots: estree-walker@3.0.3: dependencies: - '@types/estree': 1.0.0 + '@types/estree': 1.0.8 esutils@2.0.3: {} @@ -9658,6 +9904,12 @@ snapshots: dependencies: estree-walker: 0.6.1 + rollup@1.20.0: + dependencies: + '@types/estree': 0.0.39 + '@types/node': 12.20.55 + acorn: 7.4.1 + rollup@4.0.0: optionalDependencies: '@rollup/rollup-android-arm-eabi': 4.0.0 @@ -9716,6 +9968,38 @@ snapshots: '@rollup/rollup-win32-x64-msvc': 4.52.5 fsevents: 2.3.3 + rollup@4.65.1: + dependencies: + '@types/estree': 1.0.9 + optionalDependencies: + '@napi-rs/lzma-linux-x64-gnu': 1.5.1 + '@rollup/rollup-android-arm-eabi': 4.65.1 + '@rollup/rollup-android-arm64': 4.65.1 + '@rollup/rollup-darwin-arm64': 4.65.1 + '@rollup/rollup-darwin-x64': 4.65.1 + '@rollup/rollup-freebsd-arm64': 4.65.1 + '@rollup/rollup-freebsd-x64': 4.65.1 + '@rollup/rollup-linux-arm-gnueabihf': 4.65.1 + '@rollup/rollup-linux-arm-musleabihf': 4.65.1 + '@rollup/rollup-linux-arm64-gnu': 4.65.1 + '@rollup/rollup-linux-arm64-musl': 4.65.1 + '@rollup/rollup-linux-loong64-gnu': 4.65.1 + '@rollup/rollup-linux-loong64-musl': 4.65.1 + '@rollup/rollup-linux-ppc64-gnu': 4.65.1 + '@rollup/rollup-linux-ppc64-musl': 4.65.1 + '@rollup/rollup-linux-riscv64-gnu': 4.65.1 + '@rollup/rollup-linux-riscv64-musl': 4.65.1 + '@rollup/rollup-linux-s390x-gnu': 4.65.1 + '@rollup/rollup-linux-x64-gnu': 4.65.1 + '@rollup/rollup-linux-x64-musl': 4.65.1 + '@rollup/rollup-openbsd-x64': 4.65.1 + '@rollup/rollup-openharmony-arm64': 4.65.1 + '@rollup/rollup-win32-arm64-msvc': 4.65.1 + '@rollup/rollup-win32-ia32-msvc': 4.65.1 + '@rollup/rollup-win32-x64-gnu': 4.65.1 + '@rollup/rollup-win32-x64-msvc': 4.65.1 + fsevents: 2.3.3 + run-parallel@1.2.0: dependencies: queue-microtask: 1.2.3 From 7de81f35cd72722fdcec9f65466528a0234b55f5 Mon Sep 17 00:00:00 2001 From: Lukas Taegert-Atkinson Date: Fri, 23 Oct 2026 14:21:12 +0200 Subject: [PATCH 07/43] test(dsv): test against earliest supported rollup Run the test suite a second time with rollup pinned to the earliest supported version (2.78.0). The root @rollup/plugin-typescript now links the added rollup as its optional peer. --- packages/dsv/package.json | 6 +- pnpm-lock.yaml | 249 +++++--------------------------------- 2 files changed, 35 insertions(+), 220 deletions(-) diff --git a/packages/dsv/package.json b/packages/dsv/package.json index 4617e7152..8a4ee0ae3 100755 --- a/packages/dsv/package.json +++ b/packages/dsv/package.json @@ -31,7 +31,8 @@ "prerelease": "pnpm build", "pretest": "pnpm build", "release": "pnpm --workspace-root package:release $(pwd)", - "test": "vitest --config ../../.config/vitest.config.mts run" + "test": "vitest --config ../../.config/vitest.config.mts run", + "test:earliest": "pnpm test -- --mode earliest" }, "files": [ "dist", @@ -60,7 +61,8 @@ }, "devDependencies": { "del-cli": "^5.0.0", - "rollup": "^4.0.0-24" + "rollup": "catalog:", + "rollup-earliest": "npm:rollup@2.78.0" }, "types": "./types/index.d.ts" } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c3a137eaa..18442d908 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -22,7 +22,7 @@ importers: version: 0.4.3 '@rollup/plugin-typescript': specifier: ^9.0.1 - version: 9.0.1(tslib@2.4.0)(typescript@5.9.3) + version: 9.0.1(rollup@2.78.0)(tslib@2.4.0)(typescript@5.9.3) '@types/node': specifier: ^20.19.0 version: 20.19.23 @@ -301,6 +301,9 @@ importers: rollup: specifier: ^4.0.0-24 version: 4.0.0-24 + rollup-earliest: + specifier: npm:rollup@2.78.0 + version: rollup@2.78.0 packages/dynamic-import-vars: dependencies: @@ -778,13 +781,13 @@ importers: devDependencies: '@rollup/plugin-node-resolve': specifier: ^15.0.0 - version: 15.0.0(rollup@4.0.0-24) + version: 15.0.0(rollup@4.65.1) '@rollup/plugin-typescript': specifier: ^9.0.1 - version: 9.0.1(rollup@4.0.0-24)(tslib@2.4.0)(typescript@4.8.4) + version: 9.0.1(rollup@4.65.1)(tslib@2.4.0)(typescript@4.8.4) rollup: - specifier: ^4.0.0-24 - version: 4.0.0-24 + specifier: 'catalog:' + version: 4.65.1 rollup-earliest: specifier: npm:rollup@1.20.0 version: rollup@1.20.0 @@ -1879,11 +1882,6 @@ packages: cpu: [arm] os: [android] - '@rollup/rollup-android-arm-eabi@4.52.5': - resolution: {integrity: sha512-8c1vW4ocv3UOMp9K+gToY5zL2XiiVw3k7f1ksf4yO1FlDFQ1C2u72iACFnSOceJFsWskc2WZNqeRhFRPzv+wtQ==} - cpu: [arm] - os: [android] - '@rollup/rollup-android-arm-eabi@4.65.1': resolution: {integrity: sha512-5coxNSjqOI2J3NkVhlp3u+zGcyjnowQFsU9sg7MMz4UPXY4Dv63kFGLt7ConXz9CNq2i0yuOJZAF/2RMrgI2OA==} cpu: [arm] @@ -1899,11 +1897,6 @@ packages: cpu: [arm64] os: [android] - '@rollup/rollup-android-arm64@4.52.5': - resolution: {integrity: sha512-mQGfsIEFcu21mvqkEKKu2dYmtuSZOBMmAl5CFlPGLY94Vlcm+zWApK7F/eocsNzp8tKmbeBP8yXyAbx0XHsFNA==} - cpu: [arm64] - os: [android] - '@rollup/rollup-android-arm64@4.65.1': resolution: {integrity: sha512-K0HFf6XMB3IYs+jDZ1/RRhZaVOwxNXrl0n4MDEyGDjuK7+B6K/nDJp8DCBitO3S1sK/fzNxAf9QZAny4AIUPtg==} cpu: [arm64] @@ -1919,11 +1912,6 @@ packages: cpu: [arm64] os: [darwin] - '@rollup/rollup-darwin-arm64@4.52.5': - resolution: {integrity: sha512-takF3CR71mCAGA+v794QUZ0b6ZSrgJkArC+gUiG6LB6TQty9T0Mqh3m2ImRBOxS2IeYBo4lKWIieSvnEk2OQWA==} - cpu: [arm64] - os: [darwin] - '@rollup/rollup-darwin-arm64@4.65.1': resolution: {integrity: sha512-zkZrXYwNlIcSUmcwY2DpsaDHr0XjVUeQHCuSunG3eQD7/5Wn/DvI7OMUE8NRRweK87yG8ebJ1xGOzmwpMsbZQA==} cpu: [arm64] @@ -1939,31 +1927,16 @@ packages: cpu: [x64] os: [darwin] - '@rollup/rollup-darwin-x64@4.52.5': - resolution: {integrity: sha512-W901Pla8Ya95WpxDn//VF9K9u2JbocwV/v75TE0YIHNTbhqUTv9w4VuQ9MaWlNOkkEfFwkdNhXgcLqPSmHy0fA==} - cpu: [x64] - os: [darwin] - '@rollup/rollup-darwin-x64@4.65.1': resolution: {integrity: sha512-Zaed+R3cpkkA3aiNd7NO0GV5KFh/LVf8j6bGcoRdpoXkSm/mWH8M0oX2/3u/nyGcx/bHEovD9CzX+w9/gcpI4A==} cpu: [x64] os: [darwin] - '@rollup/rollup-freebsd-arm64@4.52.5': - resolution: {integrity: sha512-QofO7i7JycsYOWxe0GFqhLmF6l1TqBswJMvICnRUjqCx8b47MTo46W8AoeQwiokAx3zVryVnxtBMcGcnX12LvA==} - cpu: [arm64] - os: [freebsd] - '@rollup/rollup-freebsd-arm64@4.65.1': resolution: {integrity: sha512-h12p3WJWhyJ9kir0zqAPr0rKNmBzOWIjoaOMT9OULs9KZQZCeOMKd+mGSvERjd9VxJYShd3zIxtrVxkYz6BEVA==} cpu: [arm64] os: [freebsd] - '@rollup/rollup-freebsd-x64@4.52.5': - resolution: {integrity: sha512-jr21b/99ew8ujZubPo9skbrItHEIE50WdV86cdSoRkKtmWa+DDr6fu2c/xyRT0F/WazZpam6kk7IHBerSL7LDQ==} - cpu: [x64] - os: [freebsd] - '@rollup/rollup-freebsd-x64@4.65.1': resolution: {integrity: sha512-yRBwh/5imKY4DydDulVtrjy8Jf7h7NQJUqZbgmZ3zFsCD9QqlnWvZ7RtEF+ecO1b+IukKjXlu5Bb9fehV3tIbg==} cpu: [x64] @@ -1979,21 +1952,11 @@ packages: cpu: [arm] os: [linux] - '@rollup/rollup-linux-arm-gnueabihf@4.52.5': - resolution: {integrity: sha512-PsNAbcyv9CcecAUagQefwX8fQn9LQ4nZkpDboBOttmyffnInRy8R8dSg6hxxl2Re5QhHBf6FYIDhIj5v982ATQ==} - cpu: [arm] - os: [linux] - '@rollup/rollup-linux-arm-gnueabihf@4.65.1': resolution: {integrity: sha512-1XuPiWYYaLE1UDOqhbKVOfsqxvfmFS/lYPSk92U1hEX1qRfSYH0hNeAlbxFIgjp4d6+YQmL95EPRgdvjbZEddA==} cpu: [arm] os: [linux] - '@rollup/rollup-linux-arm-musleabihf@4.52.5': - resolution: {integrity: sha512-Fw4tysRutyQc/wwkmcyoqFtJhh0u31K+Q6jYjeicsGJJ7bbEq8LwPWV/w0cnzOqR2m694/Af6hpFayLJZkG2VQ==} - cpu: [arm] - os: [linux] - '@rollup/rollup-linux-arm-musleabihf@4.65.1': resolution: {integrity: sha512-Y3C5e55Yrf6p2r5rBcc4P9hFWVNi6oqWy/53I/AyCJJGlp3KRSpTP8eoUmVntchTbEnhgBgAgLO9flj9AvOdUw==} cpu: [arm] @@ -2009,31 +1972,16 @@ packages: cpu: [arm64] os: [linux] - '@rollup/rollup-linux-arm64-gnu@4.52.5': - resolution: {integrity: sha512-a+3wVnAYdQClOTlyapKmyI6BLPAFYs0JM8HRpgYZQO02rMR09ZcV9LbQB+NL6sljzG38869YqThrRnfPMCDtZg==} - cpu: [arm64] - os: [linux] - '@rollup/rollup-linux-arm64-gnu@4.65.1': resolution: {integrity: sha512-Itj6coSswkYPIcVLczObXmwdplHNQQxyfnK1ppBg4czDaX8RiEzLKqU7EMc64BiBuiDZEUS+M93ktM18rv5llw==} cpu: [arm64] os: [linux] - '@rollup/rollup-linux-arm64-musl@4.52.5': - resolution: {integrity: sha512-AvttBOMwO9Pcuuf7m9PkC1PUIKsfaAJ4AYhy944qeTJgQOqJYJ9oVl2nYgY7Rk0mkbsuOpCAYSs6wLYB2Xiw0Q==} - cpu: [arm64] - os: [linux] - '@rollup/rollup-linux-arm64-musl@4.65.1': resolution: {integrity: sha512-KeO8jTEqdrnhvcahufbimyMoI44vedRUp1bVz2QUnRX2vDm/hxzCPt5F8fERVD5fsHyTW/vXmCElT054VOSVOA==} cpu: [arm64] os: [linux] - '@rollup/rollup-linux-loong64-gnu@4.52.5': - resolution: {integrity: sha512-DkDk8pmXQV2wVrF6oq5tONK6UHLz/XcEVow4JTTerdeV1uqPeHxwcg7aFsfnSm9L+OO8WJsWotKM2JJPMWrQtA==} - cpu: [loong64] - os: [linux] - '@rollup/rollup-linux-loong64-gnu@4.65.1': resolution: {integrity: sha512-dDOz5VZZ+ZGnglpmET6VJefamWXFsgaVtuhSClf2/URZBp048jprD6z1hddsIMN6n1w+oUzGZEBp9u6Mlszsfg==} cpu: [loong64] @@ -2044,11 +1992,6 @@ packages: cpu: [loong64] os: [linux] - '@rollup/rollup-linux-ppc64-gnu@4.52.5': - resolution: {integrity: sha512-W/b9ZN/U9+hPQVvlGwjzi+Wy4xdoH2I8EjaCkMvzpI7wJUs8sWJ03Rq96jRnHkSrcHTpQe8h5Tg3ZzUPGauvAw==} - cpu: [ppc64] - os: [linux] - '@rollup/rollup-linux-ppc64-gnu@4.65.1': resolution: {integrity: sha512-3oQpe1q0emSeCAssVHMQdOz5fz3PBH5my/Fr0ZekV2UMNL4ZiRa1ciikYlGQXyDkeqseYYv1InwOY8YPqY7RIQ==} cpu: [ppc64] @@ -2059,31 +2002,16 @@ packages: cpu: [ppc64] os: [linux] - '@rollup/rollup-linux-riscv64-gnu@4.52.5': - resolution: {integrity: sha512-sjQLr9BW7R/ZiXnQiWPkErNfLMkkWIoCz7YMn27HldKsADEKa5WYdobaa1hmN6slu9oWQbB6/jFpJ+P2IkVrmw==} - cpu: [riscv64] - os: [linux] - '@rollup/rollup-linux-riscv64-gnu@4.65.1': resolution: {integrity: sha512-b5zab0FryBxuocuDeqOsYGAg2EzjKw4mKA6LjQXCyewXjGv/BXqACBsY2cO45xM4hV2weYtdjGThP2VB2ByAYg==} cpu: [riscv64] os: [linux] - '@rollup/rollup-linux-riscv64-musl@4.52.5': - resolution: {integrity: sha512-hq3jU/kGyjXWTvAh2awn8oHroCbrPm8JqM7RUpKjalIRWWXE01CQOf/tUNWNHjmbMHg/hmNCwc/Pz3k1T/j/Lg==} - cpu: [riscv64] - os: [linux] - '@rollup/rollup-linux-riscv64-musl@4.65.1': resolution: {integrity: sha512-Rh08xZakiUxKNgI3hbgH9mivlx478lSqckS9s+Oc3/TX1VrAH3W8z/5wpJXR/v5VjqcJ/jJNVBg64PU1+iQsTQ==} cpu: [riscv64] os: [linux] - '@rollup/rollup-linux-s390x-gnu@4.52.5': - resolution: {integrity: sha512-gn8kHOrku8D4NGHMK1Y7NA7INQTRdVOntt1OCYypZPRt6skGbddska44K8iocdpxHTMMNui5oH4elPH4QOLrFQ==} - cpu: [s390x] - os: [linux] - '@rollup/rollup-linux-s390x-gnu@4.65.1': resolution: {integrity: sha512-qDgtS6juN3/k97y4kcD6XLFpXEo4f6CnG8lTOGYwlhrUYTrMyhN0WHdZCPAW5rqS0MqQG7qI7dxnjugt6QB39Q==} cpu: [s390x] @@ -2099,11 +2027,6 @@ packages: cpu: [x64] os: [linux] - '@rollup/rollup-linux-x64-gnu@4.52.5': - resolution: {integrity: sha512-hXGLYpdhiNElzN770+H2nlx+jRog8TyynpTVzdlc6bndktjKWyZyiCsuDAlpd+j+W+WNqfcyAWz9HxxIGfZm1Q==} - cpu: [x64] - os: [linux] - '@rollup/rollup-linux-x64-gnu@4.65.1': resolution: {integrity: sha512-44IKzBPqXXVm0kt1O+F5eW4juR5FyIxGNlFkpP8qwIDzucBsjM1HCbdYUQrQw8rU/g6HRl/tfBm0+Qq4H4Ro3w==} cpu: [x64] @@ -2119,11 +2042,6 @@ packages: cpu: [x64] os: [linux] - '@rollup/rollup-linux-x64-musl@4.52.5': - resolution: {integrity: sha512-arCGIcuNKjBoKAXD+y7XomR9gY6Mw7HnFBv5Rw7wQRvwYLR7gBAgV7Mb2QTyjXfTveBNFAtPt46/36vV9STLNg==} - cpu: [x64] - os: [linux] - '@rollup/rollup-linux-x64-musl@4.65.1': resolution: {integrity: sha512-tvYWZ/h2PCHs558Xu7B6LptuRCV8lXV2xI75ONMcldII1m2zlFwuI4BJZi9M6rSMkYqcPLLtPUPrjyqfbzLOdg==} cpu: [x64] @@ -2134,11 +2052,6 @@ packages: cpu: [x64] os: [openbsd] - '@rollup/rollup-openharmony-arm64@4.52.5': - resolution: {integrity: sha512-QoFqB6+/9Rly/RiPjaomPLmR/13cgkIGfA40LHly9zcH1S0bN2HVFYk3a1eAyHQyjs3ZJYlXvIGtcCs5tko9Cw==} - cpu: [arm64] - os: [openharmony] - '@rollup/rollup-openharmony-arm64@4.65.1': resolution: {integrity: sha512-Wf/NEKdn2SAL4Nvt8HyDtdkseWTwiLbZEOoNYnEaHkbso0B9eHO42vKnZh+OYsn+IMhAMcWcuIwPlBOgOXsUzg==} cpu: [arm64] @@ -2154,11 +2067,6 @@ packages: cpu: [arm64] os: [win32] - '@rollup/rollup-win32-arm64-msvc@4.52.5': - resolution: {integrity: sha512-w0cDWVR6MlTstla1cIfOGyl8+qb93FlAVutcor14Gf5Md5ap5ySfQ7R9S/NjNaMLSFdUnKGEasmVnu3lCMqB7w==} - cpu: [arm64] - os: [win32] - '@rollup/rollup-win32-arm64-msvc@4.65.1': resolution: {integrity: sha512-x9VSsDmsMsEWy4cr/mFeaEsXnVJ6Kc4NCAU/lCnwml3s7LQbZoa9+/qwc9etWHbuuDT5mYxdyyKUwo76njtjZw==} cpu: [arm64] @@ -2174,21 +2082,11 @@ packages: cpu: [ia32] os: [win32] - '@rollup/rollup-win32-ia32-msvc@4.52.5': - resolution: {integrity: sha512-Aufdpzp7DpOTULJCuvzqcItSGDH73pF3ko/f+ckJhxQyHtp67rHw3HMNxoIdDMUITJESNE6a8uh4Lo4SLouOUg==} - cpu: [ia32] - os: [win32] - '@rollup/rollup-win32-ia32-msvc@4.65.1': resolution: {integrity: sha512-RIDbiVvvLkN45mOFpbo6eYMgnuiBEB62BGR/0s4QJgGg2AvVxucDDNn67kpAcUoYyfmY8iX8/RifMcmxmmnejA==} cpu: [ia32] os: [win32] - '@rollup/rollup-win32-x64-gnu@4.52.5': - resolution: {integrity: sha512-UGBUGPFp1vkj6p8wCRraqNhqwX/4kNQPS57BCFc8wYh0g94iVIW33wJtQAx3G7vrjjNtRaxiMUylM0ktp/TRSQ==} - cpu: [x64] - os: [win32] - '@rollup/rollup-win32-x64-gnu@4.65.1': resolution: {integrity: sha512-+KN8HIr88vN59JNxlrM2fMimzY43Y0lQB7+0xdVsFbvFCAA74CLKCdfzIHzzvndJryBc94Pm+MvwtukKjaS2ug==} cpu: [x64] @@ -2204,11 +2102,6 @@ packages: cpu: [x64] os: [win32] - '@rollup/rollup-win32-x64-msvc@4.52.5': - resolution: {integrity: sha512-TAcgQh2sSkykPRWLrdyy2AiceMckNf5loITqXxFI5VuQjS5tSuw3WlwdN8qv8vzjLAUTvYaH/mVjSFpbkFbpTg==} - cpu: [x64] - os: [win32] - '@rollup/rollup-win32-x64-msvc@4.65.1': resolution: {integrity: sha512-+Y1Sd49cSDq60UOl8/U2HI0ebUvnSl/hDhMHQn+ouw17yb8fYwMWIazzJ4JFpSkjPE7sj5NTNSX9IoyEqcFfyQ==} cpu: [x64] @@ -4918,6 +4811,11 @@ packages: resolution: {integrity: sha512-zW80j9RSJ0VV0VOxP1i7cF279+IlAaD49Ihwqb87PDR0555Fvk10HKmh2yUtXCdBb37bELuhHWZTJc4uoCo8Vw==} hasBin: true + rollup@2.78.0: + resolution: {integrity: sha512-4+YfbQC9QEVvKTanHhIAFVUFSRsezvQF8vFOJwtGfb9Bb+r014S+qryr9PSmw8x6sMnPkmFBGAvIFVQxvJxjtg==} + engines: {node: '>=10.0.0'} + hasBin: true + rollup@4.0.0: resolution: {integrity: sha512-dtlkoIdp/g2glVlQb6FzhMAMzhMYVIJ3KLGjhWKkwz/ambEuHeVZ7Eg6GALhHZOsDRD+ZWSjnUikZXPyb22puQ==} engines: {node: '>=18.0.0', npm: '>=8.0.0'} @@ -4928,11 +4826,6 @@ packages: engines: {node: '>=18.0.0', npm: '>=8.0.0'} hasBin: true - rollup@4.52.5: - resolution: {integrity: sha512-3GuObel8h7Kqdjt0gxkEzaifHTqLVW56Y/bjN7PSQtkKr0w3V/QYSdt6QWYtd7A1xUtYQigtdUfgj1RvWVtorw==} - engines: {node: '>=18.0.0', npm: '>=8.0.0'} - hasBin: true - rollup@4.65.1: resolution: {integrity: sha512-HzD4IdphaPMvuAacnL/vtoq5B8FwqewKvxTtqYibWvP6VDyZ+UsTtlw5F8HIOIIpLQAkN2NOP/0sM3puo9xN/A==} engines: {node: '>=18.0.0', npm: '>=8.0.0'} @@ -6711,6 +6604,15 @@ snapshots: optionalDependencies: rollup: 4.65.1 + '@rollup/plugin-typescript@9.0.1(rollup@2.78.0)(tslib@2.4.0)(typescript@5.9.3)': + dependencies: + '@rollup/pluginutils': 4.2.1 + resolve: 1.22.1 + typescript: 5.9.3 + optionalDependencies: + rollup: 2.78.0 + tslib: 2.4.0 + '@rollup/plugin-typescript@9.0.1(rollup@4.0.0-24)(tslib@2.4.0)(typescript@4.8.4)': dependencies: '@rollup/pluginutils': 4.2.1 @@ -6720,12 +6622,13 @@ snapshots: rollup: 4.0.0-24 tslib: 2.4.0 - '@rollup/plugin-typescript@9.0.1(tslib@2.4.0)(typescript@5.9.3)': + '@rollup/plugin-typescript@9.0.1(rollup@4.65.1)(tslib@2.4.0)(typescript@4.8.4)': dependencies: '@rollup/pluginutils': 4.2.1 resolve: 1.22.1 - typescript: 5.9.3 + typescript: 4.8.4 optionalDependencies: + rollup: 4.65.1 tslib: 2.4.0 '@rollup/plugin-virtual@3.0.0(rollup@4.0.0-24)': @@ -6775,9 +6678,6 @@ snapshots: '@rollup/rollup-android-arm-eabi@4.0.0-24': optional: true - '@rollup/rollup-android-arm-eabi@4.52.5': - optional: true - '@rollup/rollup-android-arm-eabi@4.65.1': optional: true @@ -6787,9 +6687,6 @@ snapshots: '@rollup/rollup-android-arm64@4.0.0-24': optional: true - '@rollup/rollup-android-arm64@4.52.5': - optional: true - '@rollup/rollup-android-arm64@4.65.1': optional: true @@ -6799,9 +6696,6 @@ snapshots: '@rollup/rollup-darwin-arm64@4.0.0-24': optional: true - '@rollup/rollup-darwin-arm64@4.52.5': - optional: true - '@rollup/rollup-darwin-arm64@4.65.1': optional: true @@ -6811,21 +6705,12 @@ snapshots: '@rollup/rollup-darwin-x64@4.0.0-24': optional: true - '@rollup/rollup-darwin-x64@4.52.5': - optional: true - '@rollup/rollup-darwin-x64@4.65.1': optional: true - '@rollup/rollup-freebsd-arm64@4.52.5': - optional: true - '@rollup/rollup-freebsd-arm64@4.65.1': optional: true - '@rollup/rollup-freebsd-x64@4.52.5': - optional: true - '@rollup/rollup-freebsd-x64@4.65.1': optional: true @@ -6835,15 +6720,9 @@ snapshots: '@rollup/rollup-linux-arm-gnueabihf@4.0.0-24': optional: true - '@rollup/rollup-linux-arm-gnueabihf@4.52.5': - optional: true - '@rollup/rollup-linux-arm-gnueabihf@4.65.1': optional: true - '@rollup/rollup-linux-arm-musleabihf@4.52.5': - optional: true - '@rollup/rollup-linux-arm-musleabihf@4.65.1': optional: true @@ -6853,51 +6732,30 @@ snapshots: '@rollup/rollup-linux-arm64-gnu@4.0.0-24': optional: true - '@rollup/rollup-linux-arm64-gnu@4.52.5': - optional: true - '@rollup/rollup-linux-arm64-gnu@4.65.1': optional: true - '@rollup/rollup-linux-arm64-musl@4.52.5': - optional: true - '@rollup/rollup-linux-arm64-musl@4.65.1': optional: true - '@rollup/rollup-linux-loong64-gnu@4.52.5': - optional: true - '@rollup/rollup-linux-loong64-gnu@4.65.1': optional: true '@rollup/rollup-linux-loong64-musl@4.65.1': optional: true - '@rollup/rollup-linux-ppc64-gnu@4.52.5': - optional: true - '@rollup/rollup-linux-ppc64-gnu@4.65.1': optional: true '@rollup/rollup-linux-ppc64-musl@4.65.1': optional: true - '@rollup/rollup-linux-riscv64-gnu@4.52.5': - optional: true - '@rollup/rollup-linux-riscv64-gnu@4.65.1': optional: true - '@rollup/rollup-linux-riscv64-musl@4.52.5': - optional: true - '@rollup/rollup-linux-riscv64-musl@4.65.1': optional: true - '@rollup/rollup-linux-s390x-gnu@4.52.5': - optional: true - '@rollup/rollup-linux-s390x-gnu@4.65.1': optional: true @@ -6907,9 +6765,6 @@ snapshots: '@rollup/rollup-linux-x64-gnu@4.0.0-24': optional: true - '@rollup/rollup-linux-x64-gnu@4.52.5': - optional: true - '@rollup/rollup-linux-x64-gnu@4.65.1': optional: true @@ -6919,18 +6774,12 @@ snapshots: '@rollup/rollup-linux-x64-musl@4.0.0-24': optional: true - '@rollup/rollup-linux-x64-musl@4.52.5': - optional: true - '@rollup/rollup-linux-x64-musl@4.65.1': optional: true '@rollup/rollup-openbsd-x64@4.65.1': optional: true - '@rollup/rollup-openharmony-arm64@4.52.5': - optional: true - '@rollup/rollup-openharmony-arm64@4.65.1': optional: true @@ -6940,9 +6789,6 @@ snapshots: '@rollup/rollup-win32-arm64-msvc@4.0.0-24': optional: true - '@rollup/rollup-win32-arm64-msvc@4.52.5': - optional: true - '@rollup/rollup-win32-arm64-msvc@4.65.1': optional: true @@ -6952,15 +6798,9 @@ snapshots: '@rollup/rollup-win32-ia32-msvc@4.0.0-24': optional: true - '@rollup/rollup-win32-ia32-msvc@4.52.5': - optional: true - '@rollup/rollup-win32-ia32-msvc@4.65.1': optional: true - '@rollup/rollup-win32-x64-gnu@4.52.5': - optional: true - '@rollup/rollup-win32-x64-gnu@4.65.1': optional: true @@ -6970,9 +6810,6 @@ snapshots: '@rollup/rollup-win32-x64-msvc@4.0.0-24': optional: true - '@rollup/rollup-win32-x64-msvc@4.52.5': - optional: true - '@rollup/rollup-win32-x64-msvc@4.65.1': optional: true @@ -8439,7 +8276,7 @@ snapshots: estree-walker@3.0.3: dependencies: - '@types/estree': 1.0.8 + '@types/estree': 1.0.9 esutils@2.0.3: {} @@ -9910,6 +9747,10 @@ snapshots: '@types/node': 12.20.55 acorn: 7.4.1 + rollup@2.78.0: + optionalDependencies: + fsevents: 2.3.3 + rollup@4.0.0: optionalDependencies: '@rollup/rollup-android-arm-eabi': 4.0.0 @@ -9940,34 +9781,6 @@ snapshots: '@rollup/rollup-win32-x64-msvc': 4.0.0-24 fsevents: 2.3.3 - rollup@4.52.5: - dependencies: - '@types/estree': 1.0.8 - optionalDependencies: - '@rollup/rollup-android-arm-eabi': 4.52.5 - '@rollup/rollup-android-arm64': 4.52.5 - '@rollup/rollup-darwin-arm64': 4.52.5 - '@rollup/rollup-darwin-x64': 4.52.5 - '@rollup/rollup-freebsd-arm64': 4.52.5 - '@rollup/rollup-freebsd-x64': 4.52.5 - '@rollup/rollup-linux-arm-gnueabihf': 4.52.5 - '@rollup/rollup-linux-arm-musleabihf': 4.52.5 - '@rollup/rollup-linux-arm64-gnu': 4.52.5 - '@rollup/rollup-linux-arm64-musl': 4.52.5 - '@rollup/rollup-linux-loong64-gnu': 4.52.5 - '@rollup/rollup-linux-ppc64-gnu': 4.52.5 - '@rollup/rollup-linux-riscv64-gnu': 4.52.5 - '@rollup/rollup-linux-riscv64-musl': 4.52.5 - '@rollup/rollup-linux-s390x-gnu': 4.52.5 - '@rollup/rollup-linux-x64-gnu': 4.52.5 - '@rollup/rollup-linux-x64-musl': 4.52.5 - '@rollup/rollup-openharmony-arm64': 4.52.5 - '@rollup/rollup-win32-arm64-msvc': 4.52.5 - '@rollup/rollup-win32-ia32-msvc': 4.52.5 - '@rollup/rollup-win32-x64-gnu': 4.52.5 - '@rollup/rollup-win32-x64-msvc': 4.52.5 - fsevents: 2.3.3 - rollup@4.65.1: dependencies: '@types/estree': 1.0.9 @@ -10478,7 +10291,7 @@ snapshots: fdir: 6.5.0(picomatch@4.0.3) picomatch: 4.0.3 postcss: 8.5.6 - rollup: 4.52.5 + rollup: 4.65.1 tinyglobby: 0.2.15 optionalDependencies: '@types/node': 20.19.23 From f54efc292f1529590173c35533039dd8e9c2e30d Mon Sep 17 00:00:00 2001 From: Lukas Taegert-Atkinson Date: Fri, 23 Oct 2026 14:21:22 +0200 Subject: [PATCH 08/43] test(image): test against earliest supported rollup Run the test suite a second time with rollup pinned to the earliest supported version (1.20.0). --- packages/image/package.json | 6 ++++-- pnpm-lock.yaml | 17 ++++++++++++++--- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/packages/image/package.json b/packages/image/package.json index d2fba283d..87e3a65bc 100644 --- a/packages/image/package.json +++ b/packages/image/package.json @@ -34,7 +34,8 @@ "prerelease": "pnpm build", "pretest": "pnpm build", "release": "pnpm --workspace-root package:release $(pwd)", - "test": "vitest --config ../../.config/vitest.config.mts run" + "test": "vitest --config ../../.config/vitest.config.mts run", + "test:earliest": "pnpm test -- --mode earliest" }, "files": [ "dist", @@ -64,7 +65,8 @@ }, "devDependencies": { "@rollup/plugin-buble": "^1.0.0", - "rollup": "^4.0.0-24" + "rollup": "catalog:", + "rollup-earliest": "npm:rollup@1.20.0" }, "types": "./types/index.d.ts" } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 18442d908..4f6120350 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -281,7 +281,7 @@ importers: dependencies: '@rollup/pluginutils': specifier: ^5.0.1 - version: 5.0.1(rollup@4.0.0-24) + version: 5.0.1(rollup@4.65.1) '@types/d3-dsv': specifier: ^3.0.0 version: 3.0.0 @@ -299,8 +299,8 @@ importers: specifier: ^5.0.0 version: 5.0.0 rollup: - specifier: ^4.0.0-24 - version: 4.0.0-24 + specifier: 'catalog:' + version: 4.65.1 rollup-earliest: specifier: npm:rollup@2.78.0 version: rollup@2.78.0 @@ -432,6 +432,9 @@ importers: rollup: specifier: ^4.0.0-24 version: 4.0.0-24 + rollup-earliest: + specifier: npm:rollup@1.20.0 + version: rollup@1.20.0 packages/inject: dependencies: @@ -6648,6 +6651,14 @@ snapshots: optionalDependencies: rollup: 4.0.0-24 + '@rollup/pluginutils@5.0.1(rollup@4.65.1)': + dependencies: + '@types/estree': 1.0.0 + estree-walker: 2.0.2 + picomatch: 2.3.1 + optionalDependencies: + rollup: 4.65.1 + '@rollup/pluginutils@5.0.4(rollup@4.0.0-24)': dependencies: '@types/estree': 1.0.0 From 8cbce645c216472b69121996c8a55790e31c366e Mon Sep 17 00:00:00 2001 From: Lukas Taegert-Atkinson Date: Fri, 23 Oct 2026 14:21:24 +0200 Subject: [PATCH 09/43] test(data-uri): test against earliest supported rollup Run the test suite a second time with rollup pinned to the earliest supported version (1.20.0). --- packages/data-uri/package.json | 4 +++- pnpm-lock.yaml | 19 +++++++++++++++---- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/packages/data-uri/package.json b/packages/data-uri/package.json index d82c61233..97dea417a 100644 --- a/packages/data-uri/package.json +++ b/packages/data-uri/package.json @@ -35,6 +35,7 @@ "pretest": "pnpm build --sourcemap", "release": "pnpm --workspace-root package:release $(pwd)", "test": "vitest --config ../../.config/vitest.config.mts run", + "test:earliest": "pnpm test -- --mode earliest", "test:ts": "tsc --noEmit" }, "files": [ @@ -67,7 +68,8 @@ }, "devDependencies": { "@rollup/plugin-typescript": "^9.0.1", - "rollup": "^4.0.0-24", + "rollup": "catalog:", + "rollup-earliest": "npm:rollup@1.20.0", "typescript": "^4.8.3" }, "types": "./types/index.d.ts" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 4f6120350..4f013f443 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -273,6 +273,9 @@ importers: rollup: specifier: ^4.0.0-24 version: 4.0.0-24 + rollup-earliest: + specifier: npm:rollup@1.20.0 + version: rollup@1.20.0 typescript: specifier: ^4.8.3 version: 4.8.4 @@ -421,17 +424,17 @@ importers: dependencies: '@rollup/pluginutils': specifier: ^5.0.1 - version: 5.0.1(rollup@4.0.0-24) + version: 5.0.1(rollup@4.65.1) mini-svg-data-uri: specifier: ^1.4.4 version: 1.4.4 devDependencies: '@rollup/plugin-buble': specifier: ^1.0.0 - version: 1.0.0(rollup@4.0.0-24) + version: 1.0.0(rollup@4.65.1) rollup: - specifier: ^4.0.0-24 - version: 4.0.0-24 + specifier: 'catalog:' + version: 4.65.1 rollup-earliest: specifier: npm:rollup@1.20.0 version: rollup@1.20.0 @@ -6568,6 +6571,14 @@ snapshots: optionalDependencies: rollup: 4.0.0-24 + '@rollup/plugin-buble@1.0.0(rollup@4.65.1)': + dependencies: + '@rollup/pluginutils': 4.2.1 + '@types/buble': 0.19.2 + buble: 0.20.0 + optionalDependencies: + rollup: 4.65.1 + '@rollup/plugin-commonjs@23.0.0(rollup@4.0.0-24)': dependencies: '@rollup/pluginutils': 4.2.1 From 77f44875bd587610cc5f168feb397eefb52426d7 Mon Sep 17 00:00:00 2001 From: Lukas Taegert-Atkinson Date: Fri, 23 Oct 2026 14:38:28 +0200 Subject: [PATCH 10/43] test(graphql): test against earliest supported rollup Run the test suite a second time with rollup pinned to the earliest supported version (2.78.0). --- packages/graphql/package.json | 4 +++- pnpm-lock.yaml | 11 +++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/packages/graphql/package.json b/packages/graphql/package.json index c55e45977..da8983446 100644 --- a/packages/graphql/package.json +++ b/packages/graphql/package.json @@ -36,6 +36,7 @@ "pretest": "pnpm build", "release": "pnpm --workspace-root package:release $(pwd)", "test": "vitest --config ../../.config/vitest.config.mts run", + "test:earliest": "pnpm test -- --mode earliest", "test:ts": "tsc types/index.d.ts test/types.ts --noEmit" }, "files": [ @@ -70,7 +71,8 @@ "devDependencies": { "@rollup/plugin-buble": "^1.0.0", "graphql": "^16.6.0", - "rollup": "^4.0.0-24" + "rollup": "catalog:", + "rollup-earliest": "npm:rollup@2.78.0" }, "types": "./types/index.d.ts" } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 4f013f443..49294b616 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -265,14 +265,14 @@ importers: dependencies: '@rollup/pluginutils': specifier: ^5.0.1 - version: 5.0.1(rollup@4.0.0-24) + version: 5.0.1(rollup@4.65.1) devDependencies: '@rollup/plugin-typescript': specifier: ^9.0.1 - version: 9.0.1(rollup@4.0.0-24)(tslib@2.4.0)(typescript@4.8.4) + version: 9.0.1(rollup@4.65.1)(tslib@2.4.0)(typescript@4.8.4) rollup: - specifier: ^4.0.0-24 - version: 4.0.0-24 + specifier: 'catalog:' + version: 4.65.1 rollup-earliest: specifier: npm:rollup@1.20.0 version: rollup@1.20.0 @@ -401,6 +401,9 @@ importers: rollup: specifier: ^4.0.0-24 version: 4.0.0-24 + rollup-earliest: + specifier: npm:rollup@2.78.0 + version: rollup@2.78.0 packages/html: devDependencies: From 42180e3fb8c313fd3217961ac0ae07517ee1256e Mon Sep 17 00:00:00 2001 From: Lukas Taegert-Atkinson Date: Fri, 23 Oct 2026 14:38:52 +0200 Subject: [PATCH 11/43] test(buble): test against earliest supported rollup Run the test suite a second time with rollup pinned to the earliest supported version (1.20.0). Accept the `export default` rendering of the default export by rollup 1.x. --- packages/buble/package.json | 4 +++- packages/buble/test/test.js | 6 +++++- pnpm-lock.yaml | 11 +++++++---- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/packages/buble/package.json b/packages/buble/package.json index 9d26e8bc9..8ba5e2357 100644 --- a/packages/buble/package.json +++ b/packages/buble/package.json @@ -35,6 +35,7 @@ "pretest": "pnpm build", "release": "pnpm --workspace-root package:release $(pwd)", "test": "vitest --config ../../.config/vitest.config.mts run", + "test:earliest": "pnpm test -- --mode earliest", "test:ts": "tsc types/index.d.ts test/types.ts --noEmit" }, "files": [ @@ -69,7 +70,8 @@ "devDependencies": { "@rollup/plugin-typescript": "^9.0.1", "del-cli": "^5.0.0", - "rollup": "^4.0.0-24", + "rollup": "catalog:", + "rollup-earliest": "npm:rollup@1.20.0", "source-map": "^0.7.4", "typescript": "^4.8.3" }, diff --git a/packages/buble/test/test.js b/packages/buble/test/test.js index 8c452222c..b542e34a4 100644 --- a/packages/buble/test/test.js +++ b/packages/buble/test/test.js @@ -2,6 +2,8 @@ const rollup = require('rollup'); const buble = require('..'); +const [rollupMajor] = rollup.VERSION.split('.').map(Number); + process.chdir(__dirname); const getChunksFromGenerated = (generated) => { @@ -29,6 +31,8 @@ test('transforms files', async () => { const generated = await getChunksFromBundle(bundle); expect(generated.length).toBe(1); expect(generated[0].code).toBe( - 'function main () { return 42; }\n\nexport { main as default };\n' + `function main () { return 42; }\n\n${ + rollupMajor < 2 ? 'export default main;\n' : 'export { main as default };\n' + }` ); }); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 49294b616..e07f1ce28 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -205,6 +205,9 @@ importers: rollup: specifier: ^4.0.0-24 version: 4.0.0-24 + rollup-earliest: + specifier: npm:rollup@1.20.0 + version: rollup@1.20.0 source-map: specifier: ^0.7.4 version: 0.7.4 @@ -387,20 +390,20 @@ importers: dependencies: '@rollup/pluginutils': specifier: ^5.0.1 - version: 5.0.1(rollup@4.0.0-24) + version: 5.0.1(rollup@4.65.1) graphql-tag: specifier: ^2.12.6 version: 2.12.6(graphql@16.6.0) devDependencies: '@rollup/plugin-buble': specifier: ^1.0.0 - version: 1.0.0(rollup@4.0.0-24) + version: 1.0.0(rollup@4.65.1) graphql: specifier: ^16.6.0 version: 16.6.0 rollup: - specifier: ^4.0.0-24 - version: 4.0.0-24 + specifier: 'catalog:' + version: 4.65.1 rollup-earliest: specifier: npm:rollup@2.78.0 version: rollup@2.78.0 From 45b4a5eceff3ffe8c9e2476bc1b8227a48c5024c Mon Sep 17 00:00:00 2001 From: Lukas Taegert-Atkinson Date: Fri, 23 Oct 2026 14:38:58 +0200 Subject: [PATCH 12/43] test(legacy): test against earliest supported rollup Run the test suite a second time with rollup pinned to the earliest supported version (1.20.0). --- packages/legacy/package.json | 6 ++++-- pnpm-lock.yaml | 11 +++++++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/packages/legacy/package.json b/packages/legacy/package.json index 4c398892a..a3c9184dd 100644 --- a/packages/legacy/package.json +++ b/packages/legacy/package.json @@ -34,7 +34,8 @@ "prerelease": "pnpm build", "pretest": "pnpm build", "release": "pnpm --workspace-root package:release $(pwd)", - "test": "vitest --config ../../.config/vitest.config.mts run" + "test": "vitest --config ../../.config/vitest.config.mts run", + "test:earliest": "pnpm test -- --mode earliest" }, "files": [ "dist", @@ -62,7 +63,8 @@ "devDependencies": { "@rollup/plugin-buble": "^1.0.0", "del-cli": "^5.0.0", - "rollup": "^4.0.0-24" + "rollup": "catalog:", + "rollup-earliest": "npm:rollup@1.20.0" }, "types": "./types/index.d.ts" } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index e07f1ce28..74cb6f965 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -188,7 +188,7 @@ importers: dependencies: '@rollup/pluginutils': specifier: ^5.0.1 - version: 5.0.1(rollup@4.0.0-24) + version: 5.0.1(rollup@4.65.1) '@types/buble': specifier: ^0.19.2 version: 0.19.2 @@ -198,13 +198,13 @@ importers: devDependencies: '@rollup/plugin-typescript': specifier: ^9.0.1 - version: 9.0.1(rollup@4.0.0-24)(tslib@2.4.0)(typescript@4.8.4) + version: 9.0.1(rollup@4.65.1)(tslib@2.4.0)(typescript@4.8.4) del-cli: specifier: ^5.0.0 version: 5.0.0 rollup: - specifier: ^4.0.0-24 - version: 4.0.0-24 + specifier: 'catalog:' + version: 4.65.1 rollup-earliest: specifier: npm:rollup@1.20.0 version: rollup@1.20.0 @@ -510,6 +510,9 @@ importers: rollup: specifier: ^4.0.0-24 version: 4.0.0-24 + rollup-earliest: + specifier: npm:rollup@1.20.0 + version: rollup@1.20.0 packages/multi-entry: dependencies: From bbc17a0306523db1ab52e53ff2abcc4289f0c50b Mon Sep 17 00:00:00 2001 From: Lukas Taegert-Atkinson Date: Fri, 23 Oct 2026 14:39:06 +0200 Subject: [PATCH 13/43] test(yaml): test against earliest supported rollup Run the test suite a second time with rollup pinned to the earliest supported version (2.78.0). --- packages/yaml/package.json | 6 ++++-- pnpm-lock.yaml | 23 +++++++++++++---------- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/packages/yaml/package.json b/packages/yaml/package.json index b7be7851e..e4f77b531 100755 --- a/packages/yaml/package.json +++ b/packages/yaml/package.json @@ -34,7 +34,8 @@ "prerelease": "pnpm build", "pretest": "pnpm build", "release": "pnpm --workspace-root package:release $(pwd)", - "test": "vitest --config ../../.config/vitest.config.mts run" + "test": "vitest --config ../../.config/vitest.config.mts run", + "test:earliest": "pnpm test -- --mode earliest" }, "files": [ "dist", @@ -65,7 +66,8 @@ "devDependencies": { "@rollup/plugin-node-resolve": "^15.0.0", "del-cli": "^5.0.0", - "rollup": "^4.0.0-24", + "rollup": "catalog:", + "rollup-earliest": "npm:rollup@2.78.0", "source-map-support": "^0.5.21" }, "types": "./types/index.d.ts" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 74cb6f965..e3d0e6855 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -499,17 +499,17 @@ importers: dependencies: '@rollup/pluginutils': specifier: ^5.0.1 - version: 5.0.1(rollup@4.0.0-24) + version: 5.0.1(rollup@4.65.1) devDependencies: '@rollup/plugin-buble': specifier: ^1.0.0 - version: 1.0.0(rollup@4.0.0-24) + version: 1.0.0(rollup@4.65.1) del-cli: specifier: ^5.0.0 version: 5.0.0 rollup: - specifier: ^4.0.0-24 - version: 4.0.0-24 + specifier: 'catalog:' + version: 4.65.1 rollup-earliest: specifier: npm:rollup@1.20.0 version: rollup@1.20.0 @@ -836,7 +836,7 @@ importers: dependencies: '@rollup/pluginutils': specifier: ^5.3.0 - version: 5.3.0(rollup@4.0.0-24) + version: 5.3.0(rollup@4.65.1) js-yaml: specifier: ^4.1.0 version: 4.1.0 @@ -846,13 +846,16 @@ importers: devDependencies: '@rollup/plugin-node-resolve': specifier: ^15.0.0 - version: 15.0.0(rollup@4.0.0-24) + version: 15.0.0(rollup@4.65.1) del-cli: specifier: ^5.0.0 version: 5.0.0 rollup: - specifier: ^4.0.0-24 - version: 4.0.0-24 + specifier: 'catalog:' + version: 4.65.1 + rollup-earliest: + specifier: npm:rollup@2.78.0 + version: rollup@2.78.0 source-map-support: specifier: ^0.5.21 version: 0.5.21 @@ -6695,13 +6698,13 @@ snapshots: optionalDependencies: rollup: 4.0.0-24 - '@rollup/pluginutils@5.3.0(rollup@4.0.0-24)': + '@rollup/pluginutils@5.3.0(rollup@4.65.1)': dependencies: '@types/estree': 1.0.8 estree-walker: 2.0.2 picomatch: 4.0.3 optionalDependencies: - rollup: 4.0.0-24 + rollup: 4.65.1 '@rollup/rollup-android-arm-eabi@4.0.0': optional: true From 2c2326ea9f8bdde3bdd30d140af37d62985cce0a Mon Sep 17 00:00:00 2001 From: Lukas Taegert-Atkinson Date: Fri, 23 Oct 2026 14:45:22 +0200 Subject: [PATCH 14/43] test(pluginutils): test against earliest supported rollup Run the test suite a second time with rollup pinned to the earliest supported version (1.20.0). --- packages/pluginutils/package.json | 4 +++- pnpm-lock.yaml | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/pluginutils/package.json b/packages/pluginutils/package.json index 3a5c6b216..9ee457160 100644 --- a/packages/pluginutils/package.json +++ b/packages/pluginutils/package.json @@ -38,6 +38,7 @@ "pretest": "pnpm build --sourcemap", "release": "pnpm --workspace-root package:release $(pwd)", "test": "vitest --config ../../.config/vitest.config.mts run", + "test:earliest": "pnpm test -- --mode earliest", "test:ts": "tsc --noEmit" }, "files": [ @@ -72,7 +73,8 @@ "@types/node": "^14.18.30", "@types/picomatch": "^2.3.0", "acorn": "^8.8.0", - "rollup": "^4.0.0-24", + "rollup": "catalog:", + "rollup-earliest": "npm:rollup@1.20.0", "typescript": "^4.8.3" }, "types": "./types/index.d.ts", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index e3d0e6855..3e89d222d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -606,6 +606,9 @@ importers: rollup: specifier: ^4.0.0-24 version: 4.0.0-24 + rollup-earliest: + specifier: npm:rollup@1.20.0 + version: rollup@1.20.0 typescript: specifier: ^4.8.3 version: 4.8.4 From 96d20aea8ad7989ba38069d068438a184b54deaf Mon Sep 17 00:00:00 2001 From: Lukas Taegert-Atkinson Date: Fri, 23 Oct 2026 14:45:26 +0200 Subject: [PATCH 15/43] test(strip): test against earliest supported rollup Run the test suite a second time with rollup pinned to the earliest supported version (1.20.0). As the existing tests only call the plugin hooks directly, add a test that runs an actual build so the pinned version is exercised. --- packages/strip/package.json | 6 ++-- packages/strip/test/rollup-build.test.js | 35 ++++++++++++++++++++++++ pnpm-lock.yaml | 24 ++++++++++++---- 3 files changed, 58 insertions(+), 7 deletions(-) create mode 100644 packages/strip/test/rollup-build.test.js diff --git a/packages/strip/package.json b/packages/strip/package.json index e9d975aca..1d7db80da 100644 --- a/packages/strip/package.json +++ b/packages/strip/package.json @@ -33,7 +33,8 @@ "prerelease": "pnpm build", "pretest": "pnpm build", "release": "pnpm --workspace-root package:release $(pwd)", - "test": "vitest --config ../../.config/vitest.config.mts run" + "test": "vitest --config ../../.config/vitest.config.mts run", + "test:earliest": "pnpm test -- --mode earliest" }, "files": [ "dist", @@ -62,7 +63,8 @@ }, "devDependencies": { "acorn": "^8.8.0", - "rollup": "^4.0.0-24" + "rollup": "catalog:", + "rollup-earliest": "npm:rollup@1.20.0" }, "types": "./types/index.d.ts" } diff --git a/packages/strip/test/rollup-build.test.js b/packages/strip/test/rollup-build.test.js new file mode 100644 index 000000000..4bc8208db --- /dev/null +++ b/packages/strip/test/rollup-build.test.js @@ -0,0 +1,35 @@ +const { rollup } = require('rollup'); + +const strip = require('..'); + +const ENTRY_ID = 'entry.js'; +const ENTRY_CODE = [ + 'debugger;', + "console.log('stripped-sentinel');", + "export default 'kept-sentinel';" +].join('\n'); + +const entryPlugin = { + name: 'entry', + resolveId(id) { + if (id === ENTRY_ID) return ENTRY_ID; + return null; + }, + load(id) { + if (id === ENTRY_ID) return ENTRY_CODE; + return null; + } +}; + +test('strips debugger and console calls in a real build', async () => { + const bundle = await rollup({ + input: ENTRY_ID, + plugins: [entryPlugin, strip()] + }); + const { output } = await bundle.generate({ format: 'es' }); + expect(output).toHaveLength(1); + const [{ code }] = output; + expect(code).toContain('kept-sentinel'); + expect(code).not.toContain('stripped-sentinel'); + expect(code).not.toContain('debugger'); +}); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 3e89d222d..a49de3570 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -587,13 +587,13 @@ importers: devDependencies: '@rollup/plugin-commonjs': specifier: ^23.0.0 - version: 23.0.0(rollup@4.0.0-24) + version: 23.0.0(rollup@4.65.1) '@rollup/plugin-node-resolve': specifier: ^15.0.0 - version: 15.0.0(rollup@4.0.0-24) + version: 15.0.0(rollup@4.65.1) '@rollup/plugin-typescript': specifier: ^9.0.1 - version: 9.0.1(rollup@4.0.0-24)(tslib@2.4.0)(typescript@4.8.4) + version: 9.0.1(rollup@4.65.1)(tslib@2.4.0)(typescript@4.8.4) '@types/node': specifier: ^14.18.30 version: 14.18.31 @@ -604,8 +604,8 @@ importers: specifier: ^8.8.0 version: 8.8.0 rollup: - specifier: ^4.0.0-24 - version: 4.0.0-24 + specifier: 'catalog:' + version: 4.65.1 rollup-earliest: specifier: npm:rollup@1.20.0 version: rollup@1.20.0 @@ -681,6 +681,9 @@ importers: rollup: specifier: ^4.0.0-24 version: 4.0.0-24 + rollup-earliest: + specifier: npm:rollup@1.20.0 + version: rollup@1.20.0 packages/sucrase: dependencies: @@ -6605,6 +6608,17 @@ snapshots: optionalDependencies: rollup: 4.0.0-24 + '@rollup/plugin-commonjs@23.0.0(rollup@4.65.1)': + dependencies: + '@rollup/pluginutils': 4.2.1 + commondir: 1.0.1 + estree-walker: 2.0.2 + glob: 8.1.0 + is-reference: 1.2.1 + magic-string: 0.26.7 + optionalDependencies: + rollup: 4.65.1 + '@rollup/plugin-json@5.0.0(rollup@4.0.0-24)': dependencies: '@rollup/pluginutils': 4.2.1 From 57d4b3c3e95b74412bf7fe17c7ec7c6d927f7f2c Mon Sep 17 00:00:00 2001 From: Lukas Taegert-Atkinson Date: Fri, 23 Oct 2026 14:45:28 +0200 Subject: [PATCH 16/43] test(inject): test against earliest supported rollup Run the test suite a second time with rollup pinned to the earliest supported version (1.20.0). As the existing tests only call the plugin hooks directly, add a test that runs an actual build so the pinned version is exercised. --- packages/inject/package.json | 4 +++- packages/inject/test/rollup-build.test.js | 24 +++++++++++++++++++++++ pnpm-lock.yaml | 9 ++++++--- 3 files changed, 33 insertions(+), 4 deletions(-) create mode 100644 packages/inject/test/rollup-build.test.js diff --git a/packages/inject/package.json b/packages/inject/package.json index 07bdf4825..d2426a0e8 100644 --- a/packages/inject/package.json +++ b/packages/inject/package.json @@ -35,6 +35,7 @@ "pretest": "pnpm build", "release": "pnpm --workspace-root package:release $(pwd)", "test": "vitest --config ../../.config/vitest.config.mts run", + "test:earliest": "pnpm test -- --mode earliest", "test:ts": "tsc types/index.d.ts test/types.ts --noEmit" }, "files": [ @@ -70,7 +71,8 @@ "@rollup/plugin-buble": "^1.0.0", "del-cli": "^5.0.0", "locate-character": "^2.0.5", - "rollup": "^4.0.0-24", + "rollup": "catalog:", + "rollup-earliest": "npm:rollup@1.20.0", "source-map": "^0.7.4", "typescript": "^4.8.3" }, diff --git a/packages/inject/test/rollup-build.test.js b/packages/inject/test/rollup-build.test.js new file mode 100644 index 000000000..34379e623 --- /dev/null +++ b/packages/inject/test/rollup-build.test.js @@ -0,0 +1,24 @@ +const { rollup } = require('rollup'); + +const inject = require('..'); + +const modules = { + 'entry.js': 'export default $;', + 'injected.js': "export default 'inject-sentinel-value';" +}; + +const modulesPlugin = { + name: 'modules', + resolveId: (id) => (id in modules ? id : null), + load: (id) => (id in modules ? modules[id] : null) +}; + +test('injects imports in a real build', async () => { + const bundle = await rollup({ + input: 'entry.js', + plugins: [modulesPlugin, inject({ $: 'injected.js' })] + }); + const { output } = await bundle.generate({ format: 'es' }); + expect(output).toHaveLength(1); + expect(output[0].code).toContain('inject-sentinel-value'); +}); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a49de3570..774d07d5d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -469,6 +469,9 @@ importers: rollup: specifier: ^4.0.0-24 version: 4.0.0-24 + rollup-earliest: + specifier: npm:rollup@1.20.0 + version: rollup@1.20.0 source-map: specifier: ^0.7.4 version: 0.7.4 @@ -667,7 +670,7 @@ importers: dependencies: '@rollup/pluginutils': specifier: ^5.0.1 - version: 5.0.1(rollup@4.0.0-24) + version: 5.0.1(rollup@4.65.1) estree-walker: specifier: ^2.0.2 version: 2.0.2 @@ -679,8 +682,8 @@ importers: specifier: ^8.8.0 version: 8.8.0 rollup: - specifier: ^4.0.0-24 - version: 4.0.0-24 + specifier: 'catalog:' + version: 4.65.1 rollup-earliest: specifier: npm:rollup@1.20.0 version: rollup@1.20.0 From 4dab47189a7755cc03afce17e14a185fff600034 Mon Sep 17 00:00:00 2001 From: Lukas Taegert-Atkinson Date: Fri, 23 Oct 2026 14:55:24 +0200 Subject: [PATCH 17/43] test(run): test against earliest supported rollup Run the test suite a second time with rollup pinned to the earliest supported version (2.0.0). --- packages/run/package.json | 6 ++++-- packages/run/test/test.js | 14 +++++++++++--- pnpm-lock.yaml | 28 ++++++++++++++++++++++++---- 3 files changed, 39 insertions(+), 9 deletions(-) diff --git a/packages/run/package.json b/packages/run/package.json index b804b5af6..0f4decac1 100644 --- a/packages/run/package.json +++ b/packages/run/package.json @@ -34,7 +34,8 @@ "prerelease": "pnpm build", "pretest": "pnpm build", "release": "pnpm --workspace-root package:release $(pwd)", - "test": "vitest --config ../../.config/vitest.config.mts run" + "test": "vitest --config ../../.config/vitest.config.mts run", + "test:earliest": "pnpm test -- --mode earliest" }, "files": [ "dist", @@ -63,7 +64,8 @@ "devDependencies": { "@rollup/plugin-typescript": "^9.0.1", "del": "^6.1.1", - "rollup": "^4.0.0-24", + "rollup": "catalog:", + "rollup-earliest": "npm:rollup@2.0.0", "sinon": "^14.0.0", "typescript": "^4.8.3" }, diff --git a/packages/run/test/test.js b/packages/run/test/test.js index ae53e16c4..b5f563b31 100644 --- a/packages/run/test/test.js +++ b/packages/run/test/test.js @@ -8,11 +8,13 @@ const childProcess = require('child_process'); const writeFile = require('util').promisify(fs.writeFile); const del = require('del'); -const { rollup } = require('rollup'); +const { rollup, VERSION } = require('rollup'); const sinon = require('sinon'); const run = require('../'); +const [rollupMajor, rollupMinor] = VERSION.split('.').map(Number); + const cwd = join(__dirname, 'fixtures/'); const outputDir = join(cwd, 'output'); const file = join(outputDir, 'bundle.js'); @@ -91,7 +93,9 @@ test('throws an error when bundle is not written to disk', async () => { expect(error).toBeInstanceOf(Error); expect(error.message).toBe( - '@rollup/plugin-run currently only works with bundles that are written to disk' + rollupMajor > 4 || (rollupMajor === 4 && rollupMinor >= 13) + ? '[plugin run] @rollup/plugin-run currently only works with bundles that are written to disk' + : '@rollup/plugin-run currently only works with bundles that are written to disk' ); }); @@ -105,7 +109,11 @@ test('throws an error when input option is invalid', async () => { const error = await bundle.write(outputDirOptions).catch((caught) => caught); expect(error).toBeInstanceOf(Error); - expect(error.message).toBe('@rollup/plugin-run could not find output chunk'); + expect(error.message).toBe( + rollupMajor > 4 || (rollupMajor === 4 && rollupMinor >= 13) + ? '[plugin run] @rollup/plugin-run could not find output chunk' + : '@rollup/plugin-run could not find output chunk' + ); }); test('throws an error when there are multiple entry points', async () => { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 774d07d5d..5dd18668e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -449,7 +449,7 @@ importers: dependencies: '@rollup/pluginutils': specifier: ^5.0.1 - version: 5.0.1(rollup@4.0.0-24) + version: 5.0.1(rollup@4.65.1) estree-walker: specifier: ^2.0.2 version: 2.0.2 @@ -459,7 +459,7 @@ importers: devDependencies: '@rollup/plugin-buble': specifier: ^1.0.0 - version: 1.0.0(rollup@4.0.0-24) + version: 1.0.0(rollup@4.65.1) del-cli: specifier: ^5.0.0 version: 5.0.0 @@ -467,8 +467,8 @@ importers: specifier: ^2.0.5 version: 2.0.5 rollup: - specifier: ^4.0.0-24 - version: 4.0.0-24 + specifier: 'catalog:' + version: 4.65.1 rollup-earliest: specifier: npm:rollup@1.20.0 version: rollup@1.20.0 @@ -659,6 +659,9 @@ importers: rollup: specifier: ^4.0.0-24 version: 4.0.0-24 + rollup-earliest: + specifier: npm:rollup@2.0.0 + version: rollup@2.0.0 sinon: specifier: ^14.0.0 version: 14.0.1 @@ -3452,6 +3455,11 @@ packages: fs.realpath@1.0.0: resolution: {integrity: sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==} + fsevents@2.1.3: + resolution: {integrity: sha512-Auw9a4AxqWpa9GUfj370BMPzzyncfBABW8Mab7BGWBYDj4Isgq+cDKtx0i6u9jcX9pQDnswsaaOTgTmA5pEjuQ==} + engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0} + os: [darwin] + fsevents@2.3.3: resolution: {integrity: sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==} engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0} @@ -4838,6 +4846,11 @@ packages: resolution: {integrity: sha512-zW80j9RSJ0VV0VOxP1i7cF279+IlAaD49Ihwqb87PDR0555Fvk10HKmh2yUtXCdBb37bELuhHWZTJc4uoCo8Vw==} hasBin: true + rollup@2.0.0: + resolution: {integrity: sha512-tbvWownITR+0ebaX6iRr7IcLkziTCJacRpmWz03NIj3CZDmGlergYSwdG8wPx68LT0ms1YzqmbjUQHb6ut8pdw==} + engines: {node: '>=10.0.0'} + hasBin: true + rollup@2.78.0: resolution: {integrity: sha512-4+YfbQC9QEVvKTanHhIAFVUFSRsezvQF8vFOJwtGfb9Bb+r014S+qryr9PSmw8x6sMnPkmFBGAvIFVQxvJxjtg==} engines: {node: '>=10.0.0'} @@ -8447,6 +8460,9 @@ snapshots: fs.realpath@1.0.0: {} + fsevents@2.1.3: + optional: true + fsevents@2.3.3: optional: true @@ -9801,6 +9817,10 @@ snapshots: '@types/node': 12.20.55 acorn: 7.4.1 + rollup@2.0.0: + optionalDependencies: + fsevents: 2.1.3 + rollup@2.78.0: optionalDependencies: fsevents: 2.3.3 From 1ec2d718add6f7c7713482b34c458c45c00cff8d Mon Sep 17 00:00:00 2001 From: Lukas Taegert-Atkinson Date: Fri, 23 Oct 2026 14:55:28 +0200 Subject: [PATCH 18/43] test(swc): test against earliest supported rollup Run the test suite a second time with rollup pinned to the earliest supported version (3.0.0). The root @rollup/plugin-typescript now links the added rollup as its optional peer. --- packages/swc/package.json | 4 +++- pnpm-lock.yaml | 24 ++++++++++++++++++------ 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/packages/swc/package.json b/packages/swc/package.json index 7539ab965..2c6925a8e 100644 --- a/packages/swc/package.json +++ b/packages/swc/package.json @@ -35,6 +35,7 @@ "pretest": "pnpm build", "release": "pnpm --workspace-root package:release $(pwd)", "test": "vitest --config ../../.config/vitest.config.mts run", + "test:earliest": "pnpm test -- --mode earliest", "test:ts": "tsc types/index.d.ts test/types.ts --noEmit" }, "files": [ @@ -68,7 +69,8 @@ }, "devDependencies": { "@swc/core": "^1.3.78", - "rollup": "^4.0.0-24", + "rollup": "catalog:", + "rollup-earliest": "npm:rollup@3.0.0", "typescript": "^4.8.3" }, "types": "./types/index.d.ts" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 5dd18668e..b85cb9280 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -22,7 +22,7 @@ importers: version: 0.4.3 '@rollup/plugin-typescript': specifier: ^9.0.1 - version: 9.0.1(rollup@2.78.0)(tslib@2.4.0)(typescript@5.9.3) + version: 9.0.1(rollup@3.0.0)(tslib@2.4.0)(typescript@5.9.3) '@types/node': specifier: ^20.19.0 version: 20.19.23 @@ -652,13 +652,13 @@ importers: devDependencies: '@rollup/plugin-typescript': specifier: ^9.0.1 - version: 9.0.1(rollup@4.0.0-24)(tslib@2.4.0)(typescript@4.8.4) + version: 9.0.1(rollup@4.65.1)(tslib@2.4.0)(typescript@4.8.4) del: specifier: ^6.1.1 version: 6.1.1 rollup: - specifier: ^4.0.0-24 - version: 4.0.0-24 + specifier: 'catalog:' + version: 4.65.1 rollup-earliest: specifier: npm:rollup@2.0.0 version: rollup@2.0.0 @@ -722,6 +722,9 @@ importers: rollup: specifier: ^4.0.0-24 version: 4.0.0-24 + rollup-earliest: + specifier: npm:rollup@3.0.0 + version: rollup@3.0.0 typescript: specifier: ^4.8.3 version: 4.8.4 @@ -4856,6 +4859,11 @@ packages: engines: {node: '>=10.0.0'} hasBin: true + rollup@3.0.0: + resolution: {integrity: sha512-iVomS2lySi4BM2QJb7lGZBjSndUEs6Ip+VDl25jcbM99VI5vWeEitvUSiNQkQkwqEiI4515m5shjyuwPcXS5Dg==} + engines: {node: '>=14.18.0', npm: '>=8.0.0'} + hasBin: true + rollup@4.0.0: resolution: {integrity: sha512-dtlkoIdp/g2glVlQb6FzhMAMzhMYVIJ3KLGjhWKkwz/ambEuHeVZ7Eg6GALhHZOsDRD+ZWSjnUikZXPyb22puQ==} engines: {node: '>=18.0.0', npm: '>=8.0.0'} @@ -6663,13 +6671,13 @@ snapshots: optionalDependencies: rollup: 4.65.1 - '@rollup/plugin-typescript@9.0.1(rollup@2.78.0)(tslib@2.4.0)(typescript@5.9.3)': + '@rollup/plugin-typescript@9.0.1(rollup@3.0.0)(tslib@2.4.0)(typescript@5.9.3)': dependencies: '@rollup/pluginutils': 4.2.1 resolve: 1.22.1 typescript: 5.9.3 optionalDependencies: - rollup: 2.78.0 + rollup: 3.0.0 tslib: 2.4.0 '@rollup/plugin-typescript@9.0.1(rollup@4.0.0-24)(tslib@2.4.0)(typescript@4.8.4)': @@ -9825,6 +9833,10 @@ snapshots: optionalDependencies: fsevents: 2.3.3 + rollup@3.0.0: + optionalDependencies: + fsevents: 2.3.3 + rollup@4.0.0: optionalDependencies: '@rollup/rollup-android-arm-eabi': 4.0.0 From ca6262fa44ff14314d292c20038740e0b7067192 Mon Sep 17 00:00:00 2001 From: Lukas Taegert-Atkinson Date: Fri, 23 Oct 2026 14:58:05 +0200 Subject: [PATCH 19/43] test(multi-entry): test against earliest supported rollup Run the test suite a second time with rollup pinned to the earliest supported version (1.20.0). The preserveModules tests are skipped below rollup 3 as they rely on output.preserveModules, which does not exist at the floor. --- packages/multi-entry/package.json | 6 ++-- packages/multi-entry/test/test.mjs | 55 ++++++++++++++++-------------- pnpm-lock.yaml | 9 +++-- 3 files changed, 40 insertions(+), 30 deletions(-) diff --git a/packages/multi-entry/package.json b/packages/multi-entry/package.json index f13fc4580..577e056ec 100755 --- a/packages/multi-entry/package.json +++ b/packages/multi-entry/package.json @@ -34,7 +34,8 @@ "prerelease": "pnpm build", "pretest": "pnpm build", "release": "pnpm --workspace-root package:release $(pwd)", - "test": "vitest --config ../../.config/vitest.config.mts run" + "test": "vitest --config ../../.config/vitest.config.mts run", + "test:earliest": "pnpm test -- --mode earliest" }, "files": [ "dist", @@ -65,7 +66,8 @@ "tinyglobby": "^0.2.14" }, "devDependencies": { - "rollup": "^4.0.0-24" + "rollup": "catalog:", + "rollup-earliest": "npm:rollup@1.20.0" }, "types": "./types/index.d.ts" } diff --git a/packages/multi-entry/test/test.mjs b/packages/multi-entry/test/test.mjs index 89db55c57..f783498ba 100755 --- a/packages/multi-entry/test/test.mjs +++ b/packages/multi-entry/test/test.mjs @@ -3,12 +3,14 @@ import { createRequire } from 'module'; import { test, expect } from 'vitest'; -import { rollup } from 'rollup'; +import { rollup, VERSION } from 'rollup'; import multiEntry from 'current-package'; import { getCode } from '../../../util/test.js'; +const [rollupMajor] = VERSION.split('.').map(Number); + test('takes a single file as input', async () => { const bundle = await rollup({ input: 'test/fixtures/0.js', plugins: [multiEntry()] }); const code = await getCode(bundle); @@ -92,7 +94,7 @@ test('works as CJS plugin', async () => { expect(code.includes('exports.zero = zero;')).toBeTruthy(); }); -test('maintains filename when preserveModules = true', async () => { +test.skipIf(rollupMajor < 3)('maintains filename when preserveModules = true', async () => { const bundle = await rollup({ input: 'test/fixtures/{0,1}.js', plugins: [multiEntry({ preserveModules: true, entryFileName: 'testing.js' })] @@ -108,29 +110,32 @@ test('maintains filename when preserveModules = true', async () => { expect(nonVirtualFiles.find(({ fileName }) => fileName === '1.js')).toBeTruthy(); }); -test('makes a bundle with entryFileName as the output.entryFileName when preserveModules = true and entryName is not set', async () => { - const bundle = await rollup({ - input: 'test/fixtures/{0,1}.js', - plugins: [multiEntry({ preserveModules: true })] - }); - - const files = await getCode( - bundle, - { - format: 'cjs', - preserveModules: true, - entryFileNames: (c) => `entry-${c.name}.js` - }, - true - ); - - const nonVirtualFiles = files.filter(({ fileName }) => !fileName.includes('_virtual/')); - - expect(nonVirtualFiles.length).toBe(2); - - expect(nonVirtualFiles.find(({ fileName }) => fileName === 'entry-0.js')).toBeTruthy(); - expect(nonVirtualFiles.find(({ fileName }) => fileName === 'entry-1.js')).toBeTruthy(); -}); +test.skipIf(rollupMajor < 3)( + 'makes a bundle with entryFileName as the output.entryFileName when preserveModules = true and entryName is not set', + async () => { + const bundle = await rollup({ + input: 'test/fixtures/{0,1}.js', + plugins: [multiEntry({ preserveModules: true })] + }); + + const files = await getCode( + bundle, + { + format: 'cjs', + preserveModules: true, + entryFileNames: (c) => `entry-${c.name}.js` + }, + true + ); + + const nonVirtualFiles = files.filter(({ fileName }) => !fileName.includes('_virtual/')); + + expect(nonVirtualFiles.length).toBe(2); + + expect(nonVirtualFiles.find(({ fileName }) => fileName === 'entry-0.js')).toBeTruthy(); + expect(nonVirtualFiles.find(({ fileName }) => fileName === 'entry-1.js')).toBeTruthy(); + } +); test('deterministic output, regardless of input order', async () => { const bundle1 = await rollup({ diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b85cb9280..32fcb08e0 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -529,6 +529,9 @@ importers: rollup: specifier: ^4.0.0-24 version: 4.0.0-24 + rollup-earliest: + specifier: npm:rollup@1.20.0 + version: rollup@1.20.0 packages/node-resolve: dependencies: @@ -711,7 +714,7 @@ importers: dependencies: '@rollup/pluginutils': specifier: ^5.0.1 - version: 5.0.1(rollup@4.0.0-24) + version: 5.0.1(rollup@4.65.1) smob: specifier: ^1.4.0 version: 1.4.0 @@ -720,8 +723,8 @@ importers: specifier: ^1.3.78 version: 1.3.78 rollup: - specifier: ^4.0.0-24 - version: 4.0.0-24 + specifier: 'catalog:' + version: 4.65.1 rollup-earliest: specifier: npm:rollup@3.0.0 version: rollup@3.0.0 From 08faa64eb4da4198bf44a569ccba45f4eaf4d864 Mon Sep 17 00:00:00 2001 From: Lukas Taegert-Atkinson Date: Fri, 23 Oct 2026 15:16:20 +0200 Subject: [PATCH 20/43] test(terser): test against earliest supported rollup Run the test suite a second time with rollup pinned to the earliest supported version (2.0.0). Accept that rollup 2 does not emit sourcemaps as separate assets. --- packages/terser/package.json | 4 +++- packages/terser/test/test.js | 6 ++++-- pnpm-lock.yaml | 13 ++++++++----- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/packages/terser/package.json b/packages/terser/package.json index 0e0fa9f6b..104cb42c5 100644 --- a/packages/terser/package.json +++ b/packages/terser/package.json @@ -35,6 +35,7 @@ "pretest": "pnpm build", "release": "pnpm --workspace-root package:release $(pwd)", "test": "vitest --config ../../.config/vitest.config.mts run", + "test:earliest": "pnpm test -- --mode earliest", "test:ts": "tsc types/index.d.ts test/types.ts --noEmit" }, "files": [ @@ -68,7 +69,8 @@ }, "devDependencies": { "@types/serialize-javascript": "^5.0.4", - "rollup": "^4.0.0-24", + "rollup": "catalog:", + "rollup-earliest": "npm:rollup@2.0.0", "typescript": "catalog:" }, "types": "./types/index.d.ts" diff --git a/packages/terser/test/test.js b/packages/terser/test/test.js index 447ac9c16..c69dbee2e 100644 --- a/packages/terser/test/test.js +++ b/packages/terser/test/test.js @@ -1,7 +1,9 @@ -const { rollup } = require('rollup'); +const { rollup, VERSION } = require('rollup'); const terser = require('../'); +const [rollupMajor] = VERSION.split('.').map(Number); + test.sequential('minify', async () => { const bundle = await rollup({ input: 'test/fixtures/unminified.js', @@ -24,7 +26,7 @@ test.sequential('minify with source map', async () => { format: 'cjs', sourcemap: true }); - expect(result.output.length).toBe(2); + expect(result.output.length).toBe(rollupMajor < 3 ? 1 : 2); const [output] = result.output; expect(output.map).toBeTruthy(); expect(output.map.version).toBe(3); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 32fcb08e0..86fda1a2e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -521,14 +521,14 @@ importers: dependencies: '@rollup/plugin-virtual': specifier: ^3.0.0 - version: 3.0.0(rollup@4.0.0-24) + version: 3.0.0(rollup@4.65.1) tinyglobby: specifier: ^0.2.14 version: 0.2.14 devDependencies: rollup: - specifier: ^4.0.0-24 - version: 4.0.0-24 + specifier: 'catalog:' + version: 4.65.1 rollup-earliest: specifier: npm:rollup@1.20.0 version: rollup@1.20.0 @@ -750,6 +750,9 @@ importers: rollup: specifier: ^4.0.0-24 version: 4.0.0-24 + rollup-earliest: + specifier: npm:rollup@2.0.0 + version: rollup@2.0.0 typescript: specifier: 'catalog:' version: 5.9.3 @@ -6701,9 +6704,9 @@ snapshots: rollup: 4.65.1 tslib: 2.4.0 - '@rollup/plugin-virtual@3.0.0(rollup@4.0.0-24)': + '@rollup/plugin-virtual@3.0.0(rollup@4.65.1)': optionalDependencies: - rollup: 4.0.0-24 + rollup: 4.65.1 '@rollup/pluginutils@4.2.1': dependencies: From 007ec07350c43994235f228d5eed599188753a0f Mon Sep 17 00:00:00 2001 From: Lukas Taegert-Atkinson Date: Fri, 23 Oct 2026 15:16:37 +0200 Subject: [PATCH 21/43] test(sucrase): test against earliest supported rollup Run the test suite a second time with rollup pinned to the earliest supported version (2.53.1). --- packages/sucrase/package.json | 4 +++- pnpm-lock.yaml | 16 ++++++++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/packages/sucrase/package.json b/packages/sucrase/package.json index b173b9bcf..05fb4a750 100644 --- a/packages/sucrase/package.json +++ b/packages/sucrase/package.json @@ -36,6 +36,7 @@ "pretest": "pnpm build", "release": "pnpm --workspace-root package:release $(pwd)", "test": "vitest --config ../../.config/vitest.config.mts run", + "test:earliest": "pnpm test -- --mode earliest", "test:ts": "tsc types/index.d.ts test/types.ts --noEmit" }, "files": [ @@ -68,7 +69,8 @@ }, "devDependencies": { "@rollup/plugin-alias": "^4.0.0", - "rollup": "^4.0.0-24" + "rollup": "catalog:", + "rollup-earliest": "npm:rollup@2.53.1" }, "types": "./types/index.d.ts" } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 86fda1a2e..793835814 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -709,6 +709,9 @@ importers: rollup: specifier: ^4.0.0-24 version: 4.0.0-24 + rollup-earliest: + specifier: npm:rollup@2.53.1 + version: rollup@2.53.1 packages/swc: dependencies: @@ -748,8 +751,8 @@ importers: specifier: ^5.0.4 version: 5.0.4 rollup: - specifier: ^4.0.0-24 - version: 4.0.0-24 + specifier: 'catalog:' + version: 4.65.1 rollup-earliest: specifier: npm:rollup@2.0.0 version: rollup@2.0.0 @@ -4860,6 +4863,11 @@ packages: engines: {node: '>=10.0.0'} hasBin: true + rollup@2.53.1: + resolution: {integrity: sha512-yiTCvcYXZEulNWNlEONOQVlhXA/hgxjelFSjNcrwAAIfYx/xqjSHwqg/cCaWOyFRKr+IQBaXwt723m8tCaIUiw==} + engines: {node: '>=10.0.0'} + hasBin: true + rollup@2.78.0: resolution: {integrity: sha512-4+YfbQC9QEVvKTanHhIAFVUFSRsezvQF8vFOJwtGfb9Bb+r014S+qryr9PSmw8x6sMnPkmFBGAvIFVQxvJxjtg==} engines: {node: '>=10.0.0'} @@ -9835,6 +9843,10 @@ snapshots: optionalDependencies: fsevents: 2.1.3 + rollup@2.53.1: + optionalDependencies: + fsevents: 2.3.3 + rollup@2.78.0: optionalDependencies: fsevents: 2.3.3 From e8912f86b07fe70bad3dc721e480d65a2b968e27 Mon Sep 17 00:00:00 2001 From: Lukas Taegert-Atkinson Date: Fri, 23 Oct 2026 15:16:44 +0200 Subject: [PATCH 22/43] test(esm-shim): test against earliest supported rollup Run the test suite a second time with rollup pinned to the earliest supported version (2.0.0). Use output options that render identically across rollup versions and accept that rollup 2 does not emit sourcemaps as separate assets. --- packages/esm-shim/package.json | 4 +++- packages/esm-shim/test/snapshots/test.js.snap | 1 - packages/esm-shim/test/test.js | 15 ++++++++++----- pnpm-lock.yaml | 15 +++++++++------ 4 files changed, 22 insertions(+), 13 deletions(-) diff --git a/packages/esm-shim/package.json b/packages/esm-shim/package.json index c5ca37a8d..e82a6a16b 100644 --- a/packages/esm-shim/package.json +++ b/packages/esm-shim/package.json @@ -35,6 +35,7 @@ "pretest": "pnpm build", "release": "pnpm --workspace-root package:release $(pwd)", "test": "vitest --config ../../.config/vitest.config.mts run", + "test:earliest": "pnpm test -- --mode earliest", "test:ts": "tsc types/index.d.ts test/types.ts --noEmit" }, "files": [ @@ -65,7 +66,8 @@ "mlly": "^1.7.4" }, "devDependencies": { - "rollup": "^4.0.0-24", + "rollup": "catalog:", + "rollup-earliest": "npm:rollup@2.0.0", "typescript": "^4.8.3" }, "types": "./types/index.d.ts" diff --git a/packages/esm-shim/test/snapshots/test.js.snap b/packages/esm-shim/test/snapshots/test.js.snap index 0c457ad6f..fa385f023 100644 --- a/packages/esm-shim/test/snapshots/test.js.snap +++ b/packages/esm-shim/test/snapshots/test.js.snap @@ -67,7 +67,6 @@ const require = cjsModule.createRequire(import.meta.url); const child = require('child'); export { child }; -//# sourceMappingURL=cjs.js.map " `; diff --git a/packages/esm-shim/test/test.js b/packages/esm-shim/test/test.js index afc987959..6dfe0fa5b 100644 --- a/packages/esm-shim/test/test.js +++ b/packages/esm-shim/test/test.js @@ -1,7 +1,9 @@ -const { rollup } = require('rollup'); +const { rollup, VERSION } = require('rollup'); const esmShim = require('../'); +const [rollupMajor] = VERSION.split('.').map(Number); + test.sequential('inject cjs shim for esm output', async () => { const bundle = await rollup({ input: 'test/fixtures/cjs.js', @@ -22,15 +24,17 @@ test.sequential('inject cjs shim for esm output with sourcemap', async () => { }); const result = await bundle.generate({ format: 'es', - sourcemap: true + sourcemap: 'hidden' }); - expect(result.output.length).toBe(2); + expect(result.output.length).toBe(rollupMajor < 3 ? 1 : 2); const [output, map] = result.output; expect(output.code).toMatchSnapshot(); expect(output.map).toBeTruthy(); expect(output.map.file).toBe('cjs.js'); expect(output.map.sources).toEqual(['test/fixtures/cjs.js']); - expect(map.fileName).toBe('cjs.js.map'); + if (rollupMajor >= 3) { + expect(map.fileName).toBe('cjs.js.map'); + } }); test.sequential('not inject cjs shim for cjs output', async () => { const bundle = await rollup({ @@ -38,7 +42,8 @@ test.sequential('not inject cjs shim for cjs output', async () => { plugins: [esmShim()] }); const result = await bundle.generate({ - format: 'cjs' + format: 'cjs', + esModule: false }); expect(result.output.length).toBe(1); const [output] = result.output; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 793835814..00bc2c502 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -382,6 +382,9 @@ importers: rollup: specifier: ^4.0.0-24 version: 4.0.0-24 + rollup-earliest: + specifier: npm:rollup@2.0.0 + version: rollup@2.0.0 typescript: specifier: ^4.8.3 version: 4.8.4 @@ -698,17 +701,17 @@ importers: dependencies: '@rollup/pluginutils': specifier: ^5.0.1 - version: 5.0.1(rollup@4.0.0-24) + version: 5.0.1(rollup@4.65.1) sucrase: specifier: ^3.27.0 version: 3.28.0 devDependencies: '@rollup/plugin-alias': specifier: ^4.0.0 - version: 4.0.0(rollup@4.0.0-24) + version: 4.0.0(rollup@4.65.1) rollup: - specifier: ^4.0.0-24 - version: 4.0.0-24 + specifier: 'catalog:' + version: 4.65.1 rollup-earliest: specifier: npm:rollup@2.53.1 version: rollup@2.53.1 @@ -6604,11 +6607,11 @@ snapshots: '@nodelib/fs.scandir': 2.1.5 fastq: 1.13.0 - '@rollup/plugin-alias@4.0.0(rollup@4.0.0-24)': + '@rollup/plugin-alias@4.0.0(rollup@4.65.1)': dependencies: slash: 4.0.0 optionalDependencies: - rollup: 4.0.0-24 + rollup: 4.65.1 '@rollup/plugin-babel@6.0.0(@babel/core@7.19.3)(@types/babel__core@7.1.19)(rollup@4.0.0-24)': dependencies: From 2be6960526b3bc0261b74cbcd991dc9545e34ddd Mon Sep 17 00:00:00 2001 From: Lukas Taegert-Atkinson Date: Fri, 23 Oct 2026 15:26:08 +0200 Subject: [PATCH 23/43] test(wasm): test against earliest supported rollup Run the test suite a second time with rollup pinned to the earliest supported version (1.20.0). --- packages/wasm/package.json | 4 +++- packages/wasm/test/test.mjs | 19 ++++++++++++++++--- pnpm-lock.yaml | 7 +++++-- 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/packages/wasm/package.json b/packages/wasm/package.json index 1e8d7df03..4c8247361 100644 --- a/packages/wasm/package.json +++ b/packages/wasm/package.json @@ -35,6 +35,7 @@ "pretest": "pnpm build", "release": "pnpm --workspace-root package:release $(pwd)", "test": "vitest --config ../../.config/vitest.config.mts run", + "test:earliest": "pnpm test -- --mode earliest", "test:ts": "tsc --noEmit" }, "files": [ @@ -69,7 +70,8 @@ "devDependencies": { "@rollup/plugin-typescript": "^9.0.1", "del-cli": "^5.0.0", - "rollup": "^4.0.0-24", + "rollup": "catalog:", + "rollup-earliest": "npm:rollup@1.20.0", "source-map": "^0.7.4", "typescript": "^4.8.3" }, diff --git a/packages/wasm/test/test.mjs b/packages/wasm/test/test.mjs index 80b1f21a5..855ade93b 100755 --- a/packages/wasm/test/test.mjs +++ b/packages/wasm/test/test.mjs @@ -27,6 +27,19 @@ const testBundle = async (t, bundle) => { const func = new AsyncFunction('t', `let result;\n\n${code}\n\nreturn result;`); return func(t); }; +// From rollup 4.16.0 on, function parameter tracking removes the file-loading branch of the +// helper from the bundle when the wasm module is inlined. Asserting on a build where the +// file-loading variant is used keeps all helper branches in the bundle for every rollup version. +const getFileVariantCode = (targetEnv) => + rollup({ + input: 'fixtures/async.js', + plugins: [ + wasmPlugin({ + targetEnv, + maxFileSize: 0 + }) + ] + }).then(getCode); test('async compiling', async () => { expect.assertions(2); const bundle = await rollup({ @@ -150,8 +163,8 @@ test('target environment auto', async () => { }) ] }); - const code = await getCode(bundle); await testBundle(avaAssertions, bundle); + const code = await getFileVariantCode('auto'); expect(code.includes(`require("fs")`)).toBe(true); expect(code.includes(`require("path")`)).toBe(true); expect(code.includes(`fetch`)).toBe(true); @@ -183,8 +196,8 @@ test('target environment browser', async () => { }) ] }); - const code = await getCode(bundle); await testBundle(avaAssertions, bundle); + const code = await getFileVariantCode('browser'); expect(!code.includes(`require("`)).toBe(true); expect(code.includes(`fetch`)).toBe(true); }); @@ -198,8 +211,8 @@ test('target environment node', async () => { }) ] }); - const code = await getCode(bundle); await testBundle(avaAssertions, bundle); + const code = await getFileVariantCode('node'); expect(code.includes(`require("`)).toBe(true); expect(!code.includes(`fetch`)).toBe(true); }); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 00bc2c502..15155d672 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -380,8 +380,8 @@ importers: version: 1.7.4 devDependencies: rollup: - specifier: ^4.0.0-24 - version: 4.0.0-24 + specifier: 'catalog:' + version: 4.65.1 rollup-earliest: specifier: npm:rollup@2.0.0 version: rollup@2.0.0 @@ -852,6 +852,9 @@ importers: rollup: specifier: ^4.0.0-24 version: 4.0.0-24 + rollup-earliest: + specifier: npm:rollup@1.20.0 + version: rollup@1.20.0 source-map: specifier: ^0.7.4 version: 0.7.4 From 3b6b9f5033c97c2dc5eb1052e80bfcf57c53478f Mon Sep 17 00:00:00 2001 From: Lukas Taegert-Atkinson Date: Fri, 23 Oct 2026 15:26:12 +0200 Subject: [PATCH 24/43] test(replace): test against earliest supported rollup Run the test suite a second time with rollup pinned to the earliest supported version (1.20.0). Skip the output plugin test below rollup 3 as output plugins do not exist at the floor and rollup 2 does not add the sourcemap comment on generate. Accept the quoted plugin name in rollup 1 sourcemap warnings and only snapshot stable warning properties, as rollup 1 adds an enumerable toString. --- packages/replace/package.json | 4 +++- packages/replace/test/misc.js | 8 +++++--- .../replace/test/snapshots-earliest/misc.js.snap | 15 +++++++++++++++ packages/replace/test/snapshots/misc.js.snap | 2 +- packages/replace/test/sourcemaps.js | 16 +++++++++++++--- pnpm-lock.yaml | 15 +++++++++------ 6 files changed, 46 insertions(+), 14 deletions(-) create mode 100644 packages/replace/test/snapshots-earliest/misc.js.snap diff --git a/packages/replace/package.json b/packages/replace/package.json index 84fd2b5de..4de192262 100644 --- a/packages/replace/package.json +++ b/packages/replace/package.json @@ -35,6 +35,7 @@ "pretest": "pnpm build", "release": "pnpm --workspace-root package:release $(pwd)", "test": "vitest --config ../../.config/vitest.config.mts run", + "test:earliest": "pnpm test -- --mode earliest", "test:ts": "tsc types/index.d.ts test/types.ts --noEmit" }, "files": [ @@ -69,7 +70,8 @@ "@rollup/plugin-buble": "^1.0.0", "del-cli": "^5.0.0", "locate-character": "^2.0.5", - "rollup": "^4.0.0-24", + "rollup": "catalog:", + "rollup-earliest": "npm:rollup@1.20.0", "source-map": "^0.7.4", "typescript": "^4.8.3" }, diff --git a/packages/replace/test/misc.js b/packages/replace/test/misc.js index a844467af..100fc5c38 100644 --- a/packages/replace/test/misc.js +++ b/packages/replace/test/misc.js @@ -2,12 +2,14 @@ const { join } = require('path'); -const { rollup } = require('rollup'); +const { rollup, VERSION } = require('rollup'); const replace = require('..'); const { getOutputFromGenerated } = require('./helpers/util'); +const [rollupMajor] = VERSION.split('.').map(Number); + test('does not mutate the values map properties', async () => { const valuesMap = { ANSWER: '42' @@ -40,7 +42,7 @@ test('does not mutate the values map properties', async () => { ANSWER: '42' }); }); -test('can be configured with output plugins', async () => { +test.skipIf(rollupMajor < 3)('can be configured with output plugins', async () => { const bundle = await rollup({ input: 'main.js', plugins: [ @@ -79,7 +81,7 @@ test.sequential('no explicit setting of preventAssignment', async () => { const warnings = []; await rollup({ input: 'input.js', - onwarn: (warning) => warnings.push(warning), + onwarn: ({ code, message, plugin }) => warnings.push({ code, message, plugin }), plugins: [ replace({ preventAssignment: value diff --git a/packages/replace/test/snapshots-earliest/misc.js.snap b/packages/replace/test/snapshots-earliest/misc.js.snap new file mode 100644 index 000000000..7eb1ce21d --- /dev/null +++ b/packages/replace/test/snapshots-earliest/misc.js.snap @@ -0,0 +1,15 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`no explicit setting of preventAssignment 1`] = ` +[ + { + "code": "PLUGIN_WARNING", + "message": "@rollup/plugin-replace: 'preventAssignment' currently defaults to false. It is recommended to set this option to \`true\`, as the next major version will default this option to \`true\`.", + "plugin": "replace", + }, +] +`; + +exports[`no explicit setting of preventAssignment 2`] = `[]`; + +exports[`no explicit setting of preventAssignment 3`] = `[]`; diff --git a/packages/replace/test/snapshots/misc.js.snap b/packages/replace/test/snapshots/misc.js.snap index 7eb1ce21d..28af20bcd 100644 --- a/packages/replace/test/snapshots/misc.js.snap +++ b/packages/replace/test/snapshots/misc.js.snap @@ -4,7 +4,7 @@ exports[`no explicit setting of preventAssignment 1`] = ` [ { "code": "PLUGIN_WARNING", - "message": "@rollup/plugin-replace: 'preventAssignment' currently defaults to false. It is recommended to set this option to \`true\`, as the next major version will default this option to \`true\`.", + "message": "[plugin replace] @rollup/plugin-replace: 'preventAssignment' currently defaults to false. It is recommended to set this option to \`true\`, as the next major version will default this option to \`true\`.", "plugin": "replace", }, ] diff --git a/packages/replace/test/sourcemaps.js b/packages/replace/test/sourcemaps.js index be365c326..19909715e 100644 --- a/packages/replace/test/sourcemaps.js +++ b/packages/replace/test/sourcemaps.js @@ -1,6 +1,6 @@ /* eslint-disable consistent-return */ -const { rollup } = require('rollup'); +const { rollup, VERSION } = require('rollup'); const { getLocator } = require('locate-character'); // source-map uses the presence of fetch to detect browser environments which // breaks in Node 18 @@ -13,6 +13,8 @@ const replace = require('..'); const { getOutputFromGenerated } = require('./helpers/util'); +const [rollupMajor, rollupMinor] = VERSION.split('.').map(Number); + function verifySourcemap(code, map) { return SourceMapConsumer.with(map, null, async (smc) => { const locator = getLocator(code, { @@ -121,7 +123,11 @@ test('does not generate sourcemaps if disabled in plugin', async () => { input: 'main.js', onwarn(warning) { expect(warning.message).toBe( - "Sourcemap is likely to be incorrect: a plugin (replace) was used to transform files, but didn't generate a sourcemap for the transformation. Consult the plugin documentation for help" + rollupMajor > 4 || (rollupMajor === 4 && rollupMinor >= 13) + ? "[plugin replace] Sourcemap is likely to be incorrect: a plugin (replace) was used to transform files, but didn't generate a sourcemap for the transformation. Consult the plugin documentation for help" + : rollupMajor < 2 + ? "Sourcemap is likely to be incorrect: a plugin ('replace') was used to transform files, but didn't generate a sourcemap for the transformation. Consult the plugin documentation for help" + : "Sourcemap is likely to be incorrect: a plugin (replace) was used to transform files, but didn't generate a sourcemap for the transformation. Consult the plugin documentation for help" ); warned = true; }, @@ -149,7 +155,11 @@ test('does not generate sourcemaps if disabled in plugin (camelcase)', async () input: 'main.js', onwarn(warning) { expect(warning.message).toBe( - "Sourcemap is likely to be incorrect: a plugin (replace) was used to transform files, but didn't generate a sourcemap for the transformation. Consult the plugin documentation for help" + rollupMajor > 4 || (rollupMajor === 4 && rollupMinor >= 13) + ? "[plugin replace] Sourcemap is likely to be incorrect: a plugin (replace) was used to transform files, but didn't generate a sourcemap for the transformation. Consult the plugin documentation for help" + : rollupMajor < 2 + ? "Sourcemap is likely to be incorrect: a plugin ('replace') was used to transform files, but didn't generate a sourcemap for the transformation. Consult the plugin documentation for help" + : "Sourcemap is likely to be incorrect: a plugin (replace) was used to transform files, but didn't generate a sourcemap for the transformation. Consult the plugin documentation for help" ); warned = true; }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 15155d672..d7aa3745c 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -643,6 +643,9 @@ importers: rollup: specifier: ^4.0.0-24 version: 4.0.0-24 + rollup-earliest: + specifier: npm:rollup@1.20.0 + version: rollup@1.20.0 source-map: specifier: ^0.7.4 version: 0.7.4 @@ -841,17 +844,17 @@ importers: dependencies: '@rollup/pluginutils': specifier: ^5.0.2 - version: 5.0.4(rollup@4.0.0-24) + version: 5.0.4(rollup@4.65.1) devDependencies: '@rollup/plugin-typescript': specifier: ^9.0.1 - version: 9.0.1(rollup@4.0.0-24)(tslib@2.4.0)(typescript@4.8.4) + version: 9.0.1(rollup@4.65.1)(tslib@2.4.0)(typescript@4.8.4) del-cli: specifier: ^5.0.0 version: 5.0.0 rollup: - specifier: ^4.0.0-24 - version: 4.0.0-24 + specifier: 'catalog:' + version: 4.65.1 rollup-earliest: specifier: npm:rollup@1.20.0 version: rollup@1.20.0 @@ -6743,13 +6746,13 @@ snapshots: optionalDependencies: rollup: 4.65.1 - '@rollup/pluginutils@5.0.4(rollup@4.0.0-24)': + '@rollup/pluginutils@5.0.4(rollup@4.65.1)': dependencies: '@types/estree': 1.0.0 estree-walker: 2.0.2 picomatch: 2.3.1 optionalDependencies: - rollup: 4.0.0-24 + rollup: 4.65.1 '@rollup/pluginutils@5.1.0(rollup@4.0.0-24)': dependencies: From f246e0a9679b48ae6985a88210561f989e20293d Mon Sep 17 00:00:00 2001 From: Lukas Taegert-Atkinson Date: Fri, 23 Oct 2026 16:13:44 +0200 Subject: [PATCH 25/43] test(json): test against earliest supported rollup Run the test suite a second time with rollup pinned to the earliest supported version (1.20.0). @rollup/plugin-node-resolve is pinned to 11.2.1, the last version supporting rollup 1. The arbitrary export names test is skipped below rollup 3.9 as string export names are not supported there, and below rollup 3 errors are named "Error" instead of "RollupError". --- packages/json/package.json | 5 +++- packages/json/test/test.js | 47 +++++++++++++++++++------------- pnpm-lock.yaml | 55 +++++++++++++++++++++++++++++++++++--- 3 files changed, 83 insertions(+), 24 deletions(-) diff --git a/packages/json/package.json b/packages/json/package.json index 41576afcf..97e9218b4 100755 --- a/packages/json/package.json +++ b/packages/json/package.json @@ -35,6 +35,7 @@ "pretest": "pnpm build", "release": "pnpm --workspace-root package:release $(pwd)", "test": "vitest --config ../../.config/vitest.config.mts run", + "test:earliest": "pnpm test -- --mode earliest", "test:ts": "tsc types/index.d.ts test/types.ts --noEmit" }, "files": [ @@ -67,7 +68,9 @@ "devDependencies": { "@rollup/plugin-buble": "^1.0.0", "@rollup/plugin-node-resolve": "^15.0.0", - "rollup": "^4.0.0-24", + "@rollup/plugin-node-resolve-earliest": "npm:@rollup/plugin-node-resolve@11.2.1", + "rollup": "catalog:", + "rollup-earliest": "npm:rollup@1.20.0", "source-map-support": "^0.5.21" }, "types": "./types/index.d.ts" diff --git a/packages/json/test/test.js b/packages/json/test/test.js index 3dfa8b039..9801f6372 100755 --- a/packages/json/test/test.js +++ b/packages/json/test/test.js @@ -1,11 +1,13 @@ const { readFileSync } = require('fs'); -const { rollup } = require('rollup'); +const { rollup, VERSION } = require('rollup'); const { nodeResolve } = require('@rollup/plugin-node-resolve'); const { testBundle } = require('../../../util/test'); const json = require('..'); + // eslint-disable-line import/no-unresolved +const [rollupMajor, rollupMinor] = VERSION.split('.').map(Number); const avaAssertions = { is(actual, expected) { expect(actual).toBe(expected); @@ -56,22 +58,25 @@ test('generates named exports', async () => { expect(result.version).toBe('1.33.7'); expect(code.indexOf('this-should-be-excluded')).toBe(-1); }); -test('generates named exports including arbitrary names', async () => { - const bundle = await rollup({ - input: 'fixtures/arbitrary/main.js', - plugins: [ - json({ - includeArbitraryNames: true - }) - ] - }); - const { result } = await testBundle(avaAssertions, bundle, { - inject: { - exports: {} - } - }); - expect(result.bar).toBe('baz'); -}); +test.skipIf(rollupMajor < 3 || (rollupMajor === 3 && rollupMinor < 9))( + 'generates named exports including arbitrary names', + async () => { + const bundle = await rollup({ + input: 'fixtures/arbitrary/main.js', + plugins: [ + json({ + includeArbitraryNames: true + }) + ] + }); + const { result } = await testBundle(avaAssertions, bundle, { + inject: { + exports: {} + } + }); + expect(result.bar).toBe('baz'); + } +); test('resolves extensionless imports in conjunction with the node-resolve plugin', async () => { const bundle = await rollup({ input: 'fixtures/extensionless/main.js', @@ -100,8 +105,12 @@ test('handles garbage', async () => { }).catch((error) => error); expect(err.code).toBe('PLUGIN_ERROR'); expect(err.plugin).toBe('json'); - expect(err.message).toBe('Could not parse JSON file'); - expect(err.name).toBe('RollupError'); + expect(err.message).toBe( + rollupMajor > 4 || (rollupMajor === 4 && rollupMinor >= 13) + ? '[plugin json] fixtures/garbage/bad.json: Could not parse JSON file' + : 'Could not parse JSON file' + ); + expect(err.name).toBe(rollupMajor >= 3 ? 'RollupError' : 'Error'); expect(err.cause.name).toBe('SyntaxError'); expect(err.id).toMatch(/(.*)bad.json$/); }); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d7aa3745c..36e8575f7 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -494,9 +494,15 @@ importers: '@rollup/plugin-node-resolve': specifier: ^15.0.0 version: 15.0.0(rollup@4.0.0-24) + '@rollup/plugin-node-resolve-earliest': + specifier: npm:@rollup/plugin-node-resolve@11.2.1 + version: '@rollup/plugin-node-resolve@11.2.1(rollup@4.0.0-24)' rollup: specifier: ^4.0.0-24 version: 4.0.0-24 + rollup-earliest: + specifier: npm:rollup@1.20.0 + version: rollup@1.20.0 source-map-support: specifier: ^0.5.21 version: 0.5.21 @@ -626,14 +632,14 @@ importers: dependencies: '@rollup/pluginutils': specifier: ^5.0.1 - version: 5.0.1(rollup@4.0.0-24) + version: 5.0.1(rollup@4.65.1) magic-string: specifier: ^0.30.3 version: 0.30.3 devDependencies: '@rollup/plugin-buble': specifier: ^1.0.0 - version: 1.0.0(rollup@4.0.0-24) + version: 1.0.0(rollup@4.65.1) del-cli: specifier: ^5.0.0 version: 5.0.0 @@ -641,8 +647,8 @@ importers: specifier: ^2.0.5 version: 2.0.5 rollup: - specifier: ^4.0.0-24 - version: 4.0.0-24 + specifier: 'catalog:' + version: 4.65.1 rollup-earliest: specifier: npm:rollup@1.20.0 version: rollup@1.20.0 @@ -1852,6 +1858,12 @@ packages: rollup: optional: true + '@rollup/plugin-node-resolve@11.2.1': + resolution: {integrity: sha512-yc2n43jcqVyGE2sqV5/YCmocy9ArjVAP/BeXyTtADTBBX6V0e5UMqwO8CdQ0kzjb6zu5P1qMzsScCMRvE9OlVg==} + engines: {node: '>= 10.0.0'} + peerDependencies: + rollup: ^1.20.0||^2.0.0 + '@rollup/plugin-node-resolve@15.0.0': resolution: {integrity: sha512-iwJbzfTzlzDDQcGmkS7EkCKwe2kSkdBrjX87Fy/KrNjr6UNnLpod0t6X66e502LRe5JJCA4FFqrEscWPnZAkig==} engines: {node: '>=14.0.0'} @@ -1883,6 +1895,12 @@ packages: rollup: optional: true + '@rollup/pluginutils@3.1.0': + resolution: {integrity: sha512-GksZ6pr6TpIjHm8h9lSQ8pi8BE9VeubNT0OMJ3B5uZJ8pz73NPiqOtCog/x2/QzM1ENChPKxMDhiQuRHsqc+lg==} + engines: {node: '>= 8.0.0'} + peerDependencies: + rollup: ^1.20.0||^2.0.0 + '@rollup/pluginutils@4.2.1': resolution: {integrity: sha512-iKnFXr7NkdZAIHiIWE+BX5ULi/ucVFYWD6TbAV+rZctiRTY2PL6tsIKhoIOaoskiWAkgu+VsbXgUVDNLHf+InQ==} engines: {node: '>= 8.0.0'} @@ -2344,6 +2362,9 @@ packages: '@types/picomatch@2.3.0': resolution: {integrity: sha512-O397rnSS9iQI4OirieAtsDqvCj4+3eY1J+EPdNTKuHuRWIfUoGyzX294o8C4KJYaLqgSrd2o60c5EqCU8Zv02g==} + '@types/resolve@1.17.1': + resolution: {integrity: sha512-yy7HuzQhj0dhGpD8RLXSZWEkLsV9ibvxvi6EiJ3bkqLAO1RGo0WbkWQiwpRlSFymTJRz0d3k5LM3kkx8ArDbLw==} + '@types/resolve@1.20.2': resolution: {integrity: sha512-60BCwRFOZCQhDncwQdxxeOEEkbc5dIMccYLwbxsS4TUNeVECQ/pBJ0j09mrHOl/JJvpRPGwO9SvE4nR2Nb/a4Q==} @@ -3352,6 +3373,9 @@ packages: estree-walker@0.6.1: resolution: {integrity: sha512-SqmZANLWS0mnatqbSfRP5g8OXZC12Fgg1IwNtLsyHDzJizORW4khDfjPqJZsemPWBB2uqykUah5YpQ6epsqC/w==} + estree-walker@1.0.1: + resolution: {integrity: sha512-1fMXF3YP4pZZVozF8j/ZLfvnR8NSIljt56UhbZ5PeeDmmGHpgpdwQt7ITlGvYaQukCvuBRMLEiKiYC+oeIg4cg==} + estree-walker@2.0.2: resolution: {integrity: sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==} @@ -6672,6 +6696,16 @@ snapshots: optionalDependencies: rollup: 4.0.0-24 + '@rollup/plugin-node-resolve@11.2.1(rollup@4.0.0-24)': + dependencies: + '@rollup/pluginutils': 3.1.0(rollup@4.0.0-24) + '@types/resolve': 1.17.1 + builtin-modules: 3.3.0 + deepmerge: 4.2.2 + is-module: 1.0.0 + resolve: 1.22.1 + rollup: 4.0.0-24 + '@rollup/plugin-node-resolve@15.0.0(rollup@4.0.0-24)': dependencies: '@rollup/pluginutils': 4.2.1 @@ -6725,6 +6759,13 @@ snapshots: optionalDependencies: rollup: 4.65.1 + '@rollup/pluginutils@3.1.0(rollup@4.0.0-24)': + dependencies: + '@types/estree': 0.0.39 + estree-walker: 1.0.1 + picomatch: 2.3.1 + rollup: 4.0.0-24 + '@rollup/pluginutils@4.2.1': dependencies: estree-walker: 2.0.2 @@ -7070,6 +7111,10 @@ snapshots: '@types/picomatch@2.3.0': {} + '@types/resolve@1.17.1': + dependencies: + '@types/node': 14.18.30 + '@types/resolve@1.20.2': {} '@types/responselike@1.0.0': @@ -8370,6 +8415,8 @@ snapshots: estree-walker@0.6.1: {} + estree-walker@1.0.1: {} + estree-walker@2.0.2: {} estree-walker@3.0.3: From 48ae3e003e6e4d9558e301b8eafeef9f8c7b4758 Mon Sep 17 00:00:00 2001 From: Lukas Taegert-Atkinson Date: Fri, 23 Oct 2026 16:14:05 +0200 Subject: [PATCH 26/43] test(eslint): test against earliest supported rollup Run the test suite a second time with rollup pinned to the earliest supported version (1.20.0). @rollup/plugin-node-resolve is pinned to 11.2.1, the last version supporting rollup 1. --- packages/eslint/package.json | 5 ++++- pnpm-lock.yaml | 43 +++++++++++++++++++++++++++++++----- 2 files changed, 41 insertions(+), 7 deletions(-) diff --git a/packages/eslint/package.json b/packages/eslint/package.json index 00e2fa1c2..a53166326 100755 --- a/packages/eslint/package.json +++ b/packages/eslint/package.json @@ -35,6 +35,7 @@ "pretest": "pnpm build", "release": "pnpm --workspace-root package:release $(pwd)", "test": "vitest --config ../../.config/vitest.config.mts run", + "test:earliest": "pnpm test -- --mode earliest", "test:ts": "tsc types/index.d.ts test/types.ts --noEmit" }, "files": [ @@ -67,12 +68,14 @@ }, "devDependencies": { "@rollup/plugin-node-resolve": "^15.0.0", + "@rollup/plugin-node-resolve-earliest": "npm:@rollup/plugin-node-resolve@11.2.1", "@rollup/plugin-typescript": "^9.0.1", "@types/eslint": "^8.56.12", "eslint": "^8.57.1", "eslint9": "npm:eslint@^9.37.0", "esmock": "^2.7.3", - "rollup": "^4.0.0-24", + "rollup": "catalog:", + "rollup-earliest": "npm:rollup@1.20.0", "typescript": "^4.8.3" }, "types": "./types/index.d.ts", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 36e8575f7..14d05bc43 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -348,6 +348,9 @@ importers: '@rollup/plugin-node-resolve': specifier: ^15.0.0 version: 15.0.0(rollup@4.0.0-24) + '@rollup/plugin-node-resolve-earliest': + specifier: npm:@rollup/plugin-node-resolve@11.2.1 + version: '@rollup/plugin-node-resolve@11.2.1(rollup@4.0.0-24)' '@rollup/plugin-typescript': specifier: ^9.0.1 version: 9.0.1(rollup@4.0.0-24)(tslib@2.4.0)(typescript@4.8.4) @@ -366,6 +369,9 @@ importers: rollup: specifier: ^4.0.0-24 version: 4.0.0-24 + rollup-earliest: + specifier: npm:rollup@1.20.0 + version: rollup@1.20.0 typescript: specifier: ^4.8.3 version: 4.8.4 @@ -486,20 +492,20 @@ importers: dependencies: '@rollup/pluginutils': specifier: ^5.1.0 - version: 5.1.0(rollup@4.0.0-24) + version: 5.1.0(rollup@4.65.1) devDependencies: '@rollup/plugin-buble': specifier: ^1.0.0 - version: 1.0.0(rollup@4.0.0-24) + version: 1.0.0(rollup@4.65.1) '@rollup/plugin-node-resolve': specifier: ^15.0.0 - version: 15.0.0(rollup@4.0.0-24) + version: 15.0.0(rollup@4.65.1) '@rollup/plugin-node-resolve-earliest': specifier: npm:@rollup/plugin-node-resolve@11.2.1 - version: '@rollup/plugin-node-resolve@11.2.1(rollup@4.0.0-24)' + version: '@rollup/plugin-node-resolve@11.2.1(rollup@4.65.1)' rollup: - specifier: ^4.0.0-24 - version: 4.0.0-24 + specifier: 'catalog:' + version: 4.65.1 rollup-earliest: specifier: npm:rollup@1.20.0 version: rollup@1.20.0 @@ -6706,6 +6712,16 @@ snapshots: resolve: 1.22.1 rollup: 4.0.0-24 + '@rollup/plugin-node-resolve@11.2.1(rollup@4.65.1)': + dependencies: + '@rollup/pluginutils': 3.1.0(rollup@4.65.1) + '@types/resolve': 1.17.1 + builtin-modules: 3.3.0 + deepmerge: 4.2.2 + is-module: 1.0.0 + resolve: 1.22.1 + rollup: 4.65.1 + '@rollup/plugin-node-resolve@15.0.0(rollup@4.0.0-24)': dependencies: '@rollup/pluginutils': 4.2.1 @@ -6766,6 +6782,13 @@ snapshots: picomatch: 2.3.1 rollup: 4.0.0-24 + '@rollup/pluginutils@3.1.0(rollup@4.65.1)': + dependencies: + '@types/estree': 0.0.39 + estree-walker: 1.0.1 + picomatch: 2.3.1 + rollup: 4.65.1 + '@rollup/pluginutils@4.2.1': dependencies: estree-walker: 2.0.2 @@ -6803,6 +6826,14 @@ snapshots: optionalDependencies: rollup: 4.0.0-24 + '@rollup/pluginutils@5.1.0(rollup@4.65.1)': + dependencies: + '@types/estree': 1.0.0 + estree-walker: 2.0.2 + picomatch: 2.3.1 + optionalDependencies: + rollup: 4.65.1 + '@rollup/pluginutils@5.3.0(rollup@4.65.1)': dependencies: '@types/estree': 1.0.8 From a86ec545160a8706ab01ac4872504c8eb4268d5b Mon Sep 17 00:00:00 2001 From: Lukas Taegert-Atkinson Date: Fri, 23 Oct 2026 16:20:10 +0200 Subject: [PATCH 27/43] test(babel): test against earliest supported rollup Run the test suite a second time with rollup pinned to 2.78.0. As the plugin uses object-form hooks, which rollup only supports from 2.78.0, this deviates from the declared peer floor of 2.0.0. Accept the different unresolved-import warning format and chunk hash of rollup 2 and pin the interop option in the transform-runtime test so that rollup 2 renders the same output. --- packages/babel/package.json | 4 ++- packages/babel/test/as-input-plugin.mjs | 31 ++++++++++++++++++----- packages/babel/test/as-output-plugin.mjs | 18 ++++++++++--- pnpm-lock.yaml | 32 +++++++----------------- 4 files changed, 52 insertions(+), 33 deletions(-) diff --git a/packages/babel/package.json b/packages/babel/package.json index 30fc774d9..58aac0514 100644 --- a/packages/babel/package.json +++ b/packages/babel/package.json @@ -35,6 +35,7 @@ "pretest": "pnpm build", "release": "pnpm --workspace-root package:release $(pwd)", "test": "vitest --config ../../.config/vitest.config.mts run", + "test:earliest": "pnpm test -- --mode earliest", "test:ts": "tsc types/index.d.ts test/types.ts --noEmit" }, "files": [ @@ -80,7 +81,8 @@ "@rollup/plugin-json": "^5.0.0", "@rollup/plugin-node-resolve": "^15.0.0", "@types/babel__core": "^7.1.9", - "rollup": "^4.0.0-24", + "rollup": "catalog:", + "rollup-earliest": "npm:rollup@2.78.0", "source-map": "^0.7.4" }, "types": "./types/index.d.ts", diff --git a/packages/babel/test/as-input-plugin.mjs b/packages/babel/test/as-input-plugin.mjs index c388a5b2e..6771b927b 100644 --- a/packages/babel/test/as-input-plugin.mjs +++ b/packages/babel/test/as-input-plugin.mjs @@ -4,7 +4,7 @@ import * as fs from 'node:fs'; import { fileURLToPath } from 'url'; import { test, expect } from 'vitest'; -import { rollup } from 'rollup'; +import { rollup, VERSION } from 'rollup'; import jsonPlugin from '@rollup/plugin-json'; import nodeResolvePlugin from '@rollup/plugin-node-resolve'; import { createFilter } from '@rollup/pluginutils'; @@ -13,8 +13,13 @@ import babelPlugin, { getBabelOutputPlugin, createBabelInputPluginFactory } from import { getCode } from '../../../util/test.js'; +const [rollupMajor] = VERSION.split('.').map(Number); const DIRNAME = fileURLToPath(new URL('.', import.meta.url)); const FIXTURES = `${DIRNAME}/fixtures/`; +const getUnresolvedImportWarning = (source, importer) => + rollupMajor < 3 + ? `'${source}' is imported by ${importer}, but could not be resolved – treating it as an external dependency` + : `"${source}" is imported by "${importer}", but could not be resolved – treating it as an external dependency.`; function getLocation(source, charIndex) { const lines = source.split('\n'); const len = lines.length; @@ -250,7 +255,9 @@ test('allows transform-runtime to be used instead of bundled helpers', async () { babelHelpers: 'runtime' }, - {}, + { + interop: 'default' + }, { onwarn(warning) { warnings.push(warning.message); @@ -258,8 +265,14 @@ test('allows transform-runtime to be used instead of bundled helpers', async () } ); expect(warnings).toEqual([ - `"@babel/runtime/helpers/createClass" is imported by "test/fixtures/runtime-helpers/main.js", but could not be resolved – treating it as an external dependency.`, - `"@babel/runtime/helpers/classCallCheck" is imported by "test/fixtures/runtime-helpers/main.js", but could not be resolved – treating it as an external dependency.` + getUnresolvedImportWarning( + '@babel/runtime/helpers/createClass', + 'test/fixtures/runtime-helpers/main.js' + ), + getUnresolvedImportWarning( + '@babel/runtime/helpers/classCallCheck', + 'test/fixtures/runtime-helpers/main.js' + ) ]); expect(code).toBe(`'use strict'; @@ -290,8 +303,14 @@ test('allows transform-runtime to inject esm version of helpers', async () => { } ); expect(warnings).toEqual([ - `"@babel/runtime/helpers/esm/createClass" is imported by "test/fixtures/runtime-helpers-esm/main.js", but could not be resolved – treating it as an external dependency.`, - `"@babel/runtime/helpers/esm/classCallCheck" is imported by "test/fixtures/runtime-helpers-esm/main.js", but could not be resolved – treating it as an external dependency.` + getUnresolvedImportWarning( + '@babel/runtime/helpers/esm/createClass', + 'test/fixtures/runtime-helpers-esm/main.js' + ), + getUnresolvedImportWarning( + '@babel/runtime/helpers/esm/classCallCheck', + 'test/fixtures/runtime-helpers-esm/main.js' + ) ]); expect(code).toBe(`import _createClass from '@babel/runtime/helpers/esm/createClass'; import _classCallCheck from '@babel/runtime/helpers/esm/classCallCheck'; diff --git a/packages/babel/test/as-output-plugin.mjs b/packages/babel/test/as-output-plugin.mjs index e33e33bd1..00590ad88 100644 --- a/packages/babel/test/as-output-plugin.mjs +++ b/packages/babel/test/as-output-plugin.mjs @@ -2,12 +2,15 @@ import * as nodePath from 'path'; import { fileURLToPath } from 'url'; import { test, expect } from 'vitest'; -import { rollup } from 'rollup'; +import { rollup, VERSION } from 'rollup'; import { getBabelOutputPlugin, createBabelOutputPluginFactory } from 'current-package'; import { getCode } from '../../../util/test.js'; +const [rollupMajor, rollupMinor] = VERSION.split('.').map(Number); +// rollup 4.13.0 augments plugin warnings and errors with a "[plugin ]" message prefix +const hasAugmentedPluginLogs = rollupMajor > 4 || (rollupMajor === 4 && rollupMinor >= 13); const DIRNAME = fileURLToPath(new URL('.', import.meta.url)); const FIXTURES = `${DIRNAME}/fixtures/`; function getLocation(source, charIndex) { @@ -192,7 +195,9 @@ test('warns when using the "include" option', async () => { } ); expect(warnings).toEqual([ - 'The "include", "exclude" and "extensions" options are ignored when transforming the output.' + `${ + hasAugmentedPluginLogs ? '[plugin babel] ' : '' + }The "include", "exclude" and "extensions" options are ignored when transforming the output.` ]); }); test('transforms all chunks in a code-splitting setup', async () => { @@ -212,8 +217,15 @@ test('transforms all chunks in a code-splitting setup', async () => { }, true ); + // the content hash algorithm changed in rollup 4.10.0 + const depFileName = + rollupMajor < 3 + ? 'dep-805038a5.js' + : rollupMajor > 4 || (rollupMajor === 4 && rollupMinor >= 10) + ? 'dep-D_rFPbwT.js' + : 'dep--s88I99N.js'; expect(output.map(({ code }) => code)).toEqual([ - `import('./dep--s88I99N.js').then(function (result) { + `import('./${depFileName}').then(function (result) { return console.log(result); }); `, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 14d05bc43..c8866b28a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -171,6 +171,9 @@ importers: rollup: specifier: ^4.0.0-24 version: 4.0.0-24 + rollup-earliest: + specifier: npm:rollup@2.78.0 + version: rollup@2.78.0 source-map: specifier: ^0.7.4 version: 0.7.4 @@ -343,17 +346,17 @@ importers: dependencies: '@rollup/pluginutils': specifier: ^5.0.1 - version: 5.1.0(rollup@4.0.0-24) + version: 5.1.0(rollup@4.65.1) devDependencies: '@rollup/plugin-node-resolve': specifier: ^15.0.0 - version: 15.0.0(rollup@4.0.0-24) + version: 15.0.0(rollup@4.65.1) '@rollup/plugin-node-resolve-earliest': specifier: npm:@rollup/plugin-node-resolve@11.2.1 - version: '@rollup/plugin-node-resolve@11.2.1(rollup@4.0.0-24)' + version: '@rollup/plugin-node-resolve@11.2.1(rollup@4.65.1)' '@rollup/plugin-typescript': specifier: ^9.0.1 - version: 9.0.1(rollup@4.0.0-24)(tslib@2.4.0)(typescript@4.8.4) + version: 9.0.1(rollup@4.65.1)(tslib@2.4.0)(typescript@4.8.4) '@types/eslint': specifier: ^8.56.12 version: 8.56.12 @@ -367,8 +370,8 @@ importers: specifier: ^2.7.3 version: 2.7.3 rollup: - specifier: ^4.0.0-24 - version: 4.0.0-24 + specifier: 'catalog:' + version: 4.65.1 rollup-earliest: specifier: npm:rollup@1.20.0 version: rollup@1.20.0 @@ -6702,16 +6705,6 @@ snapshots: optionalDependencies: rollup: 4.0.0-24 - '@rollup/plugin-node-resolve@11.2.1(rollup@4.0.0-24)': - dependencies: - '@rollup/pluginutils': 3.1.0(rollup@4.0.0-24) - '@types/resolve': 1.17.1 - builtin-modules: 3.3.0 - deepmerge: 4.2.2 - is-module: 1.0.0 - resolve: 1.22.1 - rollup: 4.0.0-24 - '@rollup/plugin-node-resolve@11.2.1(rollup@4.65.1)': dependencies: '@rollup/pluginutils': 3.1.0(rollup@4.65.1) @@ -6775,13 +6768,6 @@ snapshots: optionalDependencies: rollup: 4.65.1 - '@rollup/pluginutils@3.1.0(rollup@4.0.0-24)': - dependencies: - '@types/estree': 0.0.39 - estree-walker: 1.0.1 - picomatch: 2.3.1 - rollup: 4.0.0-24 - '@rollup/pluginutils@3.1.0(rollup@4.65.1)': dependencies: '@types/estree': 0.0.39 From fda135c0ca1f2b4a8a41df85c1512e2174ba7ad6 Mon Sep 17 00:00:00 2001 From: Lukas Taegert-Atkinson Date: Fri, 23 Oct 2026 16:30:15 +0200 Subject: [PATCH 28/43] test(auto-install): test against earliest supported rollup Run the test suite a second time with rollup pinned to the earliest supported version (1.20.0). @rollup/plugin-node-resolve is pinned to 11.2.1, the last version supporting rollup 1. --- packages/auto-install/package.json | 5 +++- pnpm-lock.yaml | 39 ++++++++++++++++++++++++++---- 2 files changed, 38 insertions(+), 6 deletions(-) diff --git a/packages/auto-install/package.json b/packages/auto-install/package.json index 26672ca30..e6848e09f 100755 --- a/packages/auto-install/package.json +++ b/packages/auto-install/package.json @@ -35,6 +35,7 @@ "pretest": "pnpm build", "release": "pnpm --workspace-root package:release $(pwd)", "test": "vitest --config ../../.config/vitest.config.mts run", + "test:earliest": "pnpm test -- --mode earliest", "test:ts": "tsc --noEmit" }, "files": [ @@ -63,10 +64,12 @@ }, "devDependencies": { "@rollup/plugin-node-resolve": "^15.0.0", + "@rollup/plugin-node-resolve-earliest": "npm:@rollup/plugin-node-resolve@11.2.1", "@rollup/plugin-typescript": "^9.0.1", "del": "^6.1.1", "node-noop": "^1.0.0", - "rollup": "^4.0.0-24", + "rollup": "catalog:", + "rollup-earliest": "npm:rollup@1.20.0", "typescript": "^4.8.3" }, "types": "./types/index.d.ts" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c8866b28a..30569e7b8 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -113,6 +113,9 @@ importers: '@rollup/plugin-node-resolve': specifier: ^15.0.0 version: 15.0.0(rollup@4.0.0-24) + '@rollup/plugin-node-resolve-earliest': + specifier: npm:@rollup/plugin-node-resolve@11.2.1 + version: '@rollup/plugin-node-resolve@11.2.1(rollup@4.0.0-24)' '@rollup/plugin-typescript': specifier: ^9.0.1 version: 9.0.1(rollup@4.0.0-24)(tslib@2.4.0)(typescript@4.8.4) @@ -125,6 +128,9 @@ importers: rollup: specifier: ^4.0.0-24 version: 4.0.0-24 + rollup-earliest: + specifier: npm:rollup@1.20.0 + version: rollup@1.20.0 typescript: specifier: ^4.8.3 version: 4.8.4 @@ -136,7 +142,7 @@ importers: version: 7.18.6 '@rollup/pluginutils': specifier: ^5.0.1 - version: 5.0.1(rollup@4.0.0-24) + version: 5.0.1(rollup@4.65.1) workerpool: specifier: ^9.0.0 version: 9.3.4 @@ -161,16 +167,16 @@ importers: version: 7.19.4(@babel/core@7.19.3) '@rollup/plugin-json': specifier: ^5.0.0 - version: 5.0.0(rollup@4.0.0-24) + version: 5.0.0(rollup@4.65.1) '@rollup/plugin-node-resolve': specifier: ^15.0.0 - version: 15.0.0(rollup@4.0.0-24) + version: 15.0.0(rollup@4.65.1) '@types/babel__core': specifier: ^7.1.9 version: 7.1.19 rollup: - specifier: ^4.0.0-24 - version: 4.0.0-24 + specifier: 'catalog:' + version: 4.65.1 rollup-earliest: specifier: npm:rollup@2.78.0 version: rollup@2.78.0 @@ -6705,6 +6711,22 @@ snapshots: optionalDependencies: rollup: 4.0.0-24 + '@rollup/plugin-json@5.0.0(rollup@4.65.1)': + dependencies: + '@rollup/pluginutils': 4.2.1 + optionalDependencies: + rollup: 4.65.1 + + '@rollup/plugin-node-resolve@11.2.1(rollup@4.0.0-24)': + dependencies: + '@rollup/pluginutils': 3.1.0(rollup@4.0.0-24) + '@types/resolve': 1.17.1 + builtin-modules: 3.3.0 + deepmerge: 4.2.2 + is-module: 1.0.0 + resolve: 1.22.1 + rollup: 4.0.0-24 + '@rollup/plugin-node-resolve@11.2.1(rollup@4.65.1)': dependencies: '@rollup/pluginutils': 3.1.0(rollup@4.65.1) @@ -6768,6 +6790,13 @@ snapshots: optionalDependencies: rollup: 4.65.1 + '@rollup/pluginutils@3.1.0(rollup@4.0.0-24)': + dependencies: + '@types/estree': 0.0.39 + estree-walker: 1.0.1 + picomatch: 2.3.1 + rollup: 4.0.0-24 + '@rollup/pluginutils@3.1.0(rollup@4.65.1)': dependencies: '@types/estree': 0.0.39 From 405550985407a6c87211d78cd3ccad56e635934f Mon Sep 17 00:00:00 2001 From: Lukas Taegert-Atkinson Date: Fri, 23 Oct 2026 17:55:30 +0200 Subject: [PATCH 29/43] test(commonjs): test against earliest supported rollup Run the test suite a second time with rollup pinned to the earliest supported version (2.68.0). @rollup/plugin-node-resolve is pinned to 13.3.0, the last version supporting rollup 2.68. Branch expectations on the rollup version where interop helpers, parse error frames, resolveId options and warning properties differ, and fork the snapshots whose rendered output differs in rollup 2. Let three fixture resolveId hooks skip themselves explicitly, as rollup 2 does not do so by default and recurses infinitely. Pass the active rollup to the worker of the caching test, which does not inherit the earliest redirection. Skip the shebang test as rollup 2 cannot parse hashbangs; the plugin itself fails on shebang modules at that version. --- packages/commonjs/package.json | 5 +- .../function/custom-options/_config.js | 19 +- .../function/esm-externals-true/main.js | 6 +- .../main.js | 6 +- .../main.js | 6 +- .../main.js | 6 +- .../main.js | 6 +- .../main.js | 6 +- .../module-meta-properties/_config.js | 2 +- .../_config.js | 2 +- .../module-side-effects-late-entry/_config.js | 10 +- .../_config.js | 2 +- .../strict-requires-debug-none/_config.js | 13 +- .../transpiled-esm-namespace-named/main.js | 8 +- .../unresolved-dependencies/_config.js | 6 +- .../_config.js | 10 +- .../fixtures/samples/caching/rollupWorker.js | 4 +- packages/commonjs/test/helpers/util.js | 8 +- .../test/snapshots-earliest/function.js.snap | 11040 ++++++++++++++++ .../test/snapshots-earliest/test.js.snap | 490 + .../commonjs/test/snapshots/function.js.snap | 124 +- packages/commonjs/test/test.js | 35 +- pnpm-lock.yaml | 45 +- 23 files changed, 11766 insertions(+), 93 deletions(-) create mode 100644 packages/commonjs/test/snapshots-earliest/function.js.snap create mode 100644 packages/commonjs/test/snapshots-earliest/test.js.snap diff --git a/packages/commonjs/package.json b/packages/commonjs/package.json index 89616d3b8..f689e8ec8 100644 --- a/packages/commonjs/package.json +++ b/packages/commonjs/package.json @@ -36,6 +36,7 @@ "pretest": "pnpm build", "release": "pnpm --workspace-root package:release $(pwd)", "test": "vitest --config ../../.config/vitest.config.mts run", + "test:earliest": "pnpm test -- --mode earliest", "test:ts": "tsc types/index.d.ts test/types.ts --noEmit" }, "files": [ @@ -74,9 +75,11 @@ "devDependencies": { "@rollup/plugin-json": "^5.0.0", "@rollup/plugin-node-resolve": "^15.0.0", + "@rollup/plugin-node-resolve-earliest": "npm:@rollup/plugin-node-resolve@13.3.0", "locate-character": "^2.0.5", "require-relative": "^0.8.7", - "rollup": "^4.0.0-24", + "rollup": "catalog:", + "rollup-earliest": "npm:rollup@2.68.0", "source-map": "^0.7.4", "source-map-support": "^0.5.21", "typescript": "^4.8.3" diff --git a/packages/commonjs/test/fixtures/function/custom-options/_config.js b/packages/commonjs/test/fixtures/function/custom-options/_config.js index 8fe741c1b..8de7745b8 100644 --- a/packages/commonjs/test/fixtures/function/custom-options/_config.js +++ b/packages/commonjs/test/fixtures/function/custom-options/_config.js @@ -1,6 +1,10 @@ const path = require('path'); const assert = require('assert'); +const { VERSION } = require('rollup'); + +const [rollupMajor, rollupMinor] = VERSION.split('.').map(Number); + const ID_MAIN = path.join(__dirname, 'main.js'); const getLastPathFragment = (pathString) => pathString && pathString.split(/[\\/]/).slice(-1)[0]; @@ -20,9 +24,20 @@ module.exports = { }); }, buildEnd() { + const resolveIdOptions = (custom) => { + const options = { custom, isEntry: true }; + if (rollupMajor < 4) { + return options; + } + // rollup 4.57.0 adds "importerAttributes" as an own property to resolveId options + return rollupMajor > 4 || (rollupMajor === 4 && rollupMinor >= 57) + ? { attributes: {}, importerAttributes: undefined, ...options } + : { attributes: {}, ...options }; + }; + assert.deepStrictEqual(resolveIdArgs, [ - ['other.js', 'main.js', { attributes: {}, custom: { test: 42 }, isEntry: true }], - ['main.js', void 0, { attributes: {}, custom: {}, isEntry: true }] + ['other.js', 'main.js', resolveIdOptions({ test: 42 })], + ['main.js', void 0, resolveIdOptions({})] ]); }, resolveId(source, importer, options) { diff --git a/packages/commonjs/test/fixtures/function/esm-externals-true/main.js b/packages/commonjs/test/fixtures/function/esm-externals-true/main.js index 6468e66ca..3929b7a08 100644 --- a/packages/commonjs/test/fixtures/function/esm-externals-true/main.js +++ b/packages/commonjs/test/fixtures/function/esm-externals-true/main.js @@ -2,6 +2,10 @@ const externalNamed = require('external-esm-named'); const externalMixed = require('external-esm-mixed'); const externalDefault = require('external-esm-default'); -t.deepEqual(externalNamed, { foo: 'foo', default: { foo: 'foo' } }, 'external named'); +t.deepEqual( + externalNamed, + rollupMajor < 3 ? { foo: 'foo' } : { foo: 'foo', default: { foo: 'foo' } }, + 'external named' +); t.deepEqual(externalMixed, { default: 'bar', foo: 'foo' }, 'external mixed'); t.deepEqual(externalDefault, { default: 'bar' }, 'external default'); diff --git a/packages/commonjs/test/fixtures/function/import-esm-require-returns-default-auto/main.js b/packages/commonjs/test/fixtures/function/import-esm-require-returns-default-auto/main.js index 3833a330d..4e7718392 100644 --- a/packages/commonjs/test/fixtures/function/import-esm-require-returns-default-auto/main.js +++ b/packages/commonjs/test/fixtures/function/import-esm-require-returns-default-auto/main.js @@ -11,6 +11,10 @@ t.deepEqual(namedExports, { foo: 'foo' }, 'named exports'); t.deepEqual(mixedExports, { foo: 'foo', default: 'bar' }, 'mixed exports'); t.deepEqual(defaultExport, 'bar', 'default export'); t.deepEqual(noExports, {}, 'no exports'); -t.deepEqual(externalNamed, { foo: 'foo', default: { foo: 'foo' } }, 'external named'); +t.deepEqual( + externalNamed, + rollupMajor < 3 ? { foo: 'foo' } : { foo: 'foo', default: { foo: 'foo' } }, + 'external named' +); t.deepEqual(externalMixed, { foo: 'foo', default: 'bar' }, 'external mixed'); t.deepEqual(externalDefault, 'bar', 'external default'); diff --git a/packages/commonjs/test/fixtures/function/import-esm-require-returns-default-false/main.js b/packages/commonjs/test/fixtures/function/import-esm-require-returns-default-false/main.js index 88098f14c..7771b2fe0 100644 --- a/packages/commonjs/test/fixtures/function/import-esm-require-returns-default-false/main.js +++ b/packages/commonjs/test/fixtures/function/import-esm-require-returns-default-false/main.js @@ -11,7 +11,11 @@ t.deepEqual(namedExports, { foo: 'foo' }, 'named exports'); t.deepEqual(mixedExports, { foo: 'foo', default: 'bar' }, 'mixed exports'); t.deepEqual(defaultExport, { default: 'bar' }, 'default export'); t.deepEqual(noExports, {}, 'no exports'); -t.deepEqual(externalNamed, { foo: 'foo', default: { foo: 'foo' } }, 'external named'); +t.deepEqual( + externalNamed, + rollupMajor < 3 ? { foo: 'foo' } : { foo: 'foo', default: { foo: 'foo' } }, + 'external named' +); t.deepEqual(externalMixed, { foo: 'foo', default: 'bar' }, 'external mixed'); t.deepEqual(externalDefault, { default: 'bar' }, 'external default'); diff --git a/packages/commonjs/test/fixtures/function/import-esm-require-returns-default-function-external/main.js b/packages/commonjs/test/fixtures/function/import-esm-require-returns-default-function-external/main.js index 2be40f769..624eeb451 100644 --- a/packages/commonjs/test/fixtures/function/import-esm-require-returns-default-function-external/main.js +++ b/packages/commonjs/test/fixtures/function/import-esm-require-returns-default-function-external/main.js @@ -2,6 +2,10 @@ const externalNamed = require('external-esm-named'); const externalMixed = require('external-esm-mixed'); const externalDefault = require('external-esm-default'); -t.deepEqual(externalNamed, { foo: 'foo', default: { foo: 'foo' } }, 'named'); +t.deepEqual( + externalNamed, + rollupMajor < 3 ? { foo: 'foo' } : { foo: 'foo', default: { foo: 'foo' } }, + 'named' +); t.deepEqual(externalMixed, 'bar', 'mixed'); t.deepEqual(externalDefault, { default: 'bar' }, 'default'); diff --git a/packages/commonjs/test/fixtures/function/import-esm-require-returns-default-namespace/main.js b/packages/commonjs/test/fixtures/function/import-esm-require-returns-default-namespace/main.js index d3442fafb..17e362d3d 100644 --- a/packages/commonjs/test/fixtures/function/import-esm-require-returns-default-namespace/main.js +++ b/packages/commonjs/test/fixtures/function/import-esm-require-returns-default-namespace/main.js @@ -11,6 +11,10 @@ t.deepEqual(namedExports, { foo: 'foo' }, 'named exports'); t.deepEqual(mixedExports, { foo: 'foo', default: 'bar' }, 'mixed exports'); t.deepEqual(defaultExport, { default: 'bar' }, 'default export'); t.deepEqual(noExports, {}, 'no exports'); -t.deepEqual(externalNamed, { foo: 'foo', default: { foo: 'foo' } }, 'external named'); +t.deepEqual( + externalNamed, + rollupMajor < 3 ? { foo: 'foo' } : { foo: 'foo', default: { foo: 'foo' } }, + 'external named' +); t.deepEqual(externalMixed, { foo: 'foo', default: 'bar' }, 'external mixed'); t.deepEqual(externalDefault, { default: 'bar' }, 'external default'); diff --git a/packages/commonjs/test/fixtures/function/import-esm-require-returns-default-undefined/main.js b/packages/commonjs/test/fixtures/function/import-esm-require-returns-default-undefined/main.js index d3442fafb..17e362d3d 100644 --- a/packages/commonjs/test/fixtures/function/import-esm-require-returns-default-undefined/main.js +++ b/packages/commonjs/test/fixtures/function/import-esm-require-returns-default-undefined/main.js @@ -11,6 +11,10 @@ t.deepEqual(namedExports, { foo: 'foo' }, 'named exports'); t.deepEqual(mixedExports, { foo: 'foo', default: 'bar' }, 'mixed exports'); t.deepEqual(defaultExport, { default: 'bar' }, 'default export'); t.deepEqual(noExports, {}, 'no exports'); -t.deepEqual(externalNamed, { foo: 'foo', default: { foo: 'foo' } }, 'external named'); +t.deepEqual( + externalNamed, + rollupMajor < 3 ? { foo: 'foo' } : { foo: 'foo', default: { foo: 'foo' } }, + 'external named' +); t.deepEqual(externalMixed, { foo: 'foo', default: 'bar' }, 'external mixed'); t.deepEqual(externalDefault, { default: 'bar' }, 'external default'); diff --git a/packages/commonjs/test/fixtures/function/module-meta-properties/_config.js b/packages/commonjs/test/fixtures/function/module-meta-properties/_config.js index 1e924b4bf..27d03238c 100644 --- a/packages/commonjs/test/fixtures/function/module-meta-properties/_config.js +++ b/packages/commonjs/test/fixtures/function/module-meta-properties/_config.js @@ -6,7 +6,7 @@ module.exports = { async resolveId(source, importer, options) { if (source.endsWith('dep.js')) { return { - ...(await this.resolve(source, importer, options)), + ...(await this.resolve(source, importer, { ...options, skipSelf: true })), meta: { test: 'provided' } }; } diff --git a/packages/commonjs/test/fixtures/function/module-side-effects-import-wrapped/_config.js b/packages/commonjs/test/fixtures/function/module-side-effects-import-wrapped/_config.js index dbd6590af..d39012065 100644 --- a/packages/commonjs/test/fixtures/function/module-side-effects-import-wrapped/_config.js +++ b/packages/commonjs/test/fixtures/function/module-side-effects-import-wrapped/_config.js @@ -6,7 +6,7 @@ module.exports = { name: 'test', async resolveId(source, importer, options) { if (source.endsWith('./foo.js')) { - const resolved = await this.resolve(source, importer, options); + const resolved = await this.resolve(source, importer, { ...options, skipSelf: true }); return { ...resolved, moduleSideEffects: false }; } return null; diff --git a/packages/commonjs/test/fixtures/function/module-side-effects-late-entry/_config.js b/packages/commonjs/test/fixtures/function/module-side-effects-late-entry/_config.js index 09d728ee6..2bc7ffacb 100644 --- a/packages/commonjs/test/fixtures/function/module-side-effects-late-entry/_config.js +++ b/packages/commonjs/test/fixtures/function/module-side-effects-late-entry/_config.js @@ -1,8 +1,16 @@ const path = require('path'); const assert = require('assert'); +const { VERSION } = require('rollup'); + +const [rollupMajor, rollupMinor] = VERSION.split('.').map(Number); + let referenceId; -const testEntry = 'generated-foo2.js'; +// rollup 4.61.0 sorts entry modules, flipping which same-named chunk a reference points to +const testEntry = + rollupMajor > 4 || (rollupMajor === 4 && rollupMinor >= 61) + ? 'generated-foo.js' + : 'generated-foo2.js'; module.exports = { description: diff --git a/packages/commonjs/test/fixtures/function/module-side-effects-require-wrapped/_config.js b/packages/commonjs/test/fixtures/function/module-side-effects-require-wrapped/_config.js index f4526f347..b993532bd 100644 --- a/packages/commonjs/test/fixtures/function/module-side-effects-require-wrapped/_config.js +++ b/packages/commonjs/test/fixtures/function/module-side-effects-require-wrapped/_config.js @@ -6,7 +6,7 @@ module.exports = { name: 'test', async resolveId(source, importer, options) { if (source.endsWith('./foo.js')) { - const resolved = await this.resolve(source, importer, options); + const resolved = await this.resolve(source, importer, { ...options, skipSelf: true }); return { ...resolved, moduleSideEffects: false }; } return null; diff --git a/packages/commonjs/test/fixtures/function/strict-requires-debug-none/_config.js b/packages/commonjs/test/fixtures/function/strict-requires-debug-none/_config.js index d570e0882..d37a4842c 100644 --- a/packages/commonjs/test/fixtures/function/strict-requires-debug-none/_config.js +++ b/packages/commonjs/test/fixtures/function/strict-requires-debug-none/_config.js @@ -1,5 +1,13 @@ const assert = require('assert'); +const { VERSION } = require('rollup'); + +const [rollupMajor, rollupMinor] = VERSION.split('.').map(Number); + +// rollup 4.13.0 augments plugin warnings with a "[plugin commonjs] " prefix +const messagePrefix = + rollupMajor > 4 || (rollupMajor === 4 && rollupMinor >= 13) ? '[plugin commonjs] ' : ''; + const warnings = []; module.exports = { @@ -18,6 +26,9 @@ module.exports = { exports() { assert.strictEqual(warnings.length, 1); assert.deepStrictEqual(warnings[0].ids, []); - assert.strictEqual(warnings[0].message, 'The commonjs plugin did not wrap any files.'); + assert.strictEqual( + warnings[0].message, + `${messagePrefix}The commonjs plugin did not wrap any files.` + ); } }; diff --git a/packages/commonjs/test/fixtures/function/transpiled-esm-namespace-named/main.js b/packages/commonjs/test/fixtures/function/transpiled-esm-namespace-named/main.js index 1dd35e434..e13164628 100644 --- a/packages/commonjs/test/fixtures/function/transpiled-esm-namespace-named/main.js +++ b/packages/commonjs/test/fixtures/function/transpiled-esm-namespace-named/main.js @@ -9,7 +9,7 @@ t.deepEqual(dep, { named: 'named' }); -t.deepEqual(external, { - foo: 'foo', - default: { foo: 'foo' } -}); +t.deepEqual( + external, + rollupMajor < 3 ? { foo: 'foo' } : { foo: 'foo', default: { foo: 'foo' } } +); diff --git a/packages/commonjs/test/fixtures/function/unresolved-dependencies/_config.js b/packages/commonjs/test/fixtures/function/unresolved-dependencies/_config.js index 186e07ce1..bf2991ef5 100644 --- a/packages/commonjs/test/fixtures/function/unresolved-dependencies/_config.js +++ b/packages/commonjs/test/fixtures/function/unresolved-dependencies/_config.js @@ -1,5 +1,9 @@ const assert = require('assert'); +const { VERSION } = require('rollup'); + +const [rollupMajor] = VERSION.split('.').map(Number); + const warnings = []; module.exports = { @@ -15,7 +19,7 @@ module.exports = { warnings.map(({ code, exporter, ...rest }) => { return { code, exporter }; }), - [{ code: 'UNRESOLVED_IMPORT', exporter: 'path' }] + [{ code: 'UNRESOLVED_IMPORT', exporter: rollupMajor >= 3 ? 'path' : undefined }] ); } } diff --git a/packages/commonjs/test/fixtures/function/warn-this-resolve-without-options/_config.js b/packages/commonjs/test/fixtures/function/warn-this-resolve-without-options/_config.js index a79b74cb8..795ae4e95 100644 --- a/packages/commonjs/test/fixtures/function/warn-this-resolve-without-options/_config.js +++ b/packages/commonjs/test/fixtures/function/warn-this-resolve-without-options/_config.js @@ -1,5 +1,13 @@ const assert = require('assert'); +const { VERSION } = require('rollup'); + +const [rollupMajor, rollupMinor] = VERSION.split('.').map(Number); + +// rollup 4.13.0 augments plugin warnings with the name of the emitting plugin +const messagePrefix = + rollupMajor > 4 || (rollupMajor === 4 && rollupMinor >= 13) ? '[plugin commonjs--resolver] ' : ''; + const warnings = []; module.exports = { @@ -18,7 +26,7 @@ module.exports = { assert.strictEqual(warnings.length, 1); assert.strictEqual( warnings[0].message, - 'It appears a plugin has implemented a "resolveId" hook that uses "this.resolve" without forwarding the third "options" parameter of "resolveId". This is problematic as it can lead to wrong module resolutions especially for the node-resolve plugin and in certain cases cause early exit errors for the commonjs plugin.\nIn rare cases, this warning can appear if the same file is both imported and required from the same mixed ES/CommonJS module, in which case it can be ignored.' + `${messagePrefix}It appears a plugin has implemented a "resolveId" hook that uses "this.resolve" without forwarding the third "options" parameter of "resolveId". This is problematic as it can lead to wrong module resolutions especially for the node-resolve plugin and in certain cases cause early exit errors for the commonjs plugin.\nIn rare cases, this warning can appear if the same file is both imported and required from the same mixed ES/CommonJS module, in which case it can be ignored.` ); assert.strictEqual(warnings[0].pluginCode, 'THIS_RESOLVE_WITHOUT_OPTIONS'); assert.strictEqual(warnings[0].url, 'https://rollupjs.org/guide/en/#resolveid'); diff --git a/packages/commonjs/test/fixtures/samples/caching/rollupWorker.js b/packages/commonjs/test/fixtures/samples/caching/rollupWorker.js index eb7e39ea6..9b4eb28d7 100644 --- a/packages/commonjs/test/fixtures/samples/caching/rollupWorker.js +++ b/packages/commonjs/test/fixtures/samples/caching/rollupWorker.js @@ -1,11 +1,11 @@ const { workerData, parentPort } = require('worker_threads'); -const { rollup } = require('rollup'); +const { rollup } = require(workerData.rollupPath); const commonjs = require('../../../..'); const { getCodeFromBundle } = require('../../../helpers/util'); -generateCode(workerData); +generateCode(workerData.cache); async function generateCode(cache) { const code = await getCodeFromBundle( diff --git a/packages/commonjs/test/helpers/util.js b/packages/commonjs/test/helpers/util.js index 4d8bb2fda..8fbc7fcaf 100644 --- a/packages/commonjs/test/helpers/util.js +++ b/packages/commonjs/test/helpers/util.js @@ -1,7 +1,11 @@ const path = require('path'); +const { VERSION } = require('rollup'); + const commonjsPlugin = require('../..'); +const [rollupMajor] = VERSION.split('.').map(Number); + function commonjs(options) { delete require.cache[require.resolve('../..')]; return commonjsPlugin(options); @@ -50,7 +54,7 @@ function runCodeSplitTest(codeMap, t, entryName = 'main.js', configContext = {}) ); } const global = {}; - const context = { t, global, globalThis: global, ...configContext }; + const context = { t, global, globalThis: global, rollupMajor, ...configContext }; let exports; try { exports = requireWithContext(codeMap[entryName], { @@ -65,7 +69,7 @@ function runCodeSplitTest(codeMap, t, entryName = 'main.js', configContext = {}) async function getCodeMapFromBundle(bundle, options = {}) { const generated = await bundle.generate({ - interop: 'compat', + interop: rollupMajor >= 3 ? 'compat' : undefined, exports: 'auto', format: 'cjs', ...options diff --git a/packages/commonjs/test/snapshots-earliest/function.js.snap b/packages/commonjs/test/snapshots-earliest/function.js.snap new file mode 100644 index 000000000..80ad37f3c --- /dev/null +++ b/packages/commonjs/test/snapshots-earliest/function.js.snap @@ -0,0 +1,11040 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`assign-properties-to-default-export 1`] = ` +{ + "main.js": "'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var foo$1 = {exports: {}}; + +var hasRequiredFoo; + +function requireFoo () { + if (hasRequiredFoo) return foo$1.exports; + hasRequiredFoo = 1; + const foo = {}; + + foo$1.exports = foo; + foo$1.exports.bar = 1; + return foo$1.exports; +} + +var fooExports = requireFoo(); +var foo = /*@__PURE__*/getDefaultExportFromCjs(fooExports); + +t.is(foo.bar, 1); +", +} +`; + +exports[`assumed-globals 1`] = ` +{ + "main.js": "'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var document$2 = {exports: {}}; + +/* eslint-disable */ + +var hasRequiredDocument; + +function requireDocument () { + if (hasRequiredDocument) return document$2.exports; + hasRequiredDocument = 1; + if (typeof document !== 'undefined') { + document$2.exports = document; + } else { + document$2.exports = { fake: true }; + } + return document$2.exports; +} + +var documentExports = requireDocument(); +var document$1 = /*@__PURE__*/getDefaultExportFromCjs(documentExports); + +t.deepEqual(document$1, { real: true }); +", +} +`; + +exports[`bare-import 1`] = ` +{ + "main.js": "'use strict'; + +var foo = {}; + +var bar = {}; + +var hasRequiredBar; + +function requireBar () { + if (hasRequiredBar) return bar; + hasRequiredBar = 1; + Math.bar = 42; + return bar; +} + +var hasRequiredFoo; + +function requireFoo () { + if (hasRequiredFoo) return foo; + hasRequiredFoo = 1; + requireBar(); + return foo; +} + +requireFoo(); + +t.is(Math.bar, 42); +", +} +`; + +exports[`bare-import-comment 1`] = ` +{ + "main.js": "'use strict'; + +var foo = {}; + +var bar = {}; + +var hasRequiredBar; + +function requireBar () { + if (hasRequiredBar) return bar; + hasRequiredBar = 1; + // Great module + Math.bar = 42; + return bar; +} + +var hasRequiredFoo; + +function requireFoo () { + if (hasRequiredFoo) return foo; + hasRequiredFoo = 1; + requireBar(); + return foo; +} + +requireFoo(); + +t.is(Math.bar, 42); +", +} +`; + +exports[`basic 1`] = ` +{ + "main.js": "'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var foo; +var hasRequiredFoo; + +function requireFoo () { + if (hasRequiredFoo) return foo; + hasRequiredFoo = 1; + foo = 21; + return foo; +} + +var main$1; +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + const foo = requireFoo(); + + main$1 = foo * 2; + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +", +} +`; + +exports[`call-non-local-function-semantics 1`] = ` +{ + "main.js": "'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var main$1 = {}; + +var platform = {}; + +var hasRequiredPlatform; + +function requirePlatform () { + if (hasRequiredPlatform) return platform; + hasRequiredPlatform = 1; + platform.use = (platform$1) => (platform.platform = platform$1); + return platform; +} + +var browser; +var hasRequiredBrowser; + +function requireBrowser () { + if (hasRequiredBrowser) return browser; + hasRequiredBrowser = 1; + browser = 'browser'; + return browser; +} + +var proxy = {}; + +var hasRequiredProxy; + +function requireProxy () { + if (hasRequiredProxy) return proxy; + hasRequiredProxy = 1; + const { platform } = requirePlatform(); + + t.is(platform, 'browser'); + return proxy; +} + +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + // simplified from dd-trace + const platform = requirePlatform(); + const browser = requireBrowser(); + + platform.use(browser); + + requireProxy(); + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +", +} +`; + +exports[`circular-dependencies 1`] = ` +{ + "main.js": "'use strict'; + +Object.defineProperty(exports, '__esModule', { value: true }); + +var main$1 = {}; + +var dep$1 = {}; + +const main = main$1; + +dep$1.getMain = () => main; + +const dep = dep$1; + +var foo = main$1.foo = 'foo'; +t.is(dep.getMain().foo, 'foo'); + +exports["default"] = main$1; +exports.foo = foo; +", +} +`; + +exports[`circular-dependencies-wrapped 1`] = ` +{ + "main.js": "'use strict'; + +Object.defineProperty(exports, '__esModule', { value: true }); + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var main$1 = {}; + +var dep = {}; + +(function (exports) { + const main = main$1; + + addExports(exports); + + function addExports(exported) { + // eslint-disable-next-line no-param-reassign + exported.getMain = () => main; + } +} (dep)); + +(function (exports) { + const dep$1 = dep; + + addExports(); + t.is(dep$1.getMain().foo, 'foo'); + + function addExports(exported) { + // eslint-disable-next-line no-param-reassign + exports.foo = 'foo'; + } +} (main$1)); + +var main = /*@__PURE__*/getDefaultExportFromCjs(main$1); + +exports["default"] = main; +", +} +`; + +exports[`cjs-extension 1`] = ` +{ + "main.js": "'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var main$1 = {}; + +var _export; +var hasRequired_export; + +function require_export () { + if (hasRequired_export) return _export; + hasRequired_export = 1; + _export = { + test: 42 + }; + return _export; +} + +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + const { test } = require_export(); + + t.is(test, 42); + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +", +} +`; + +exports[`class-body-property-keys-are-special-keywords 1`] = ` +{ + "main.js": "'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var main$1 = {}; + +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + class Rollup { + define; + require; + global; + } + + main$1.Rollup = Rollup; + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +", +} +`; + +exports[`compiled-esm-default-is-module-exports-false 1`] = ` +{ + "main.js": "'use strict'; + +var dep$1 = {}; + +var hasRequiredDep; + +function requireDep () { + if (hasRequiredDep) return dep$1; + hasRequiredDep = 1; + dep$1.default = 'default'; + dep$1.named = 'named'; + return dep$1; +} + +var depExports = requireDep(); +var dep = depExports.default; + +t.is(dep, 'default'); +", +} +`; + +exports[`conditional-require-chain 1`] = ` +{ + "main.js": "'use strict'; + +var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var main$1 = {}; + +var dep = {}; + +var throws = {}; + +var hasRequiredThrows; + +function requireThrows () { + if (hasRequiredThrows) return throws; + hasRequiredThrows = 1; + throw new Error('This should not be executed'); +} + +var hasRequiredDep; + +function requireDep () { + if (hasRequiredDep) return dep; + hasRequiredDep = 1; + requireThrows(); + return dep; +} + +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + commonjsGlobal.false = false; + + if (commonjsGlobal.false) { + // eslint-disable-next-line global-require + requireDep(); + } + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +", +} +`; + +exports[`conditional-require-non-strict 1`] = ` +{ + "main.js": "'use strict'; + +var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; + +var main = {}; + +commonjsGlobal.foo = true; + +commonjsGlobal.bar = true; + +commonjsGlobal.main = true; + +t.is(commonjsGlobal.foo, true, 'foo'); +t.is(commonjsGlobal.main, true, 'main'); + +module.exports = main; +", +} +`; + +exports[`custom-options 1`] = ` +{ + "main.js": "'use strict'; + +t.is('main', 'main'); +", +} +`; + +exports[`dash-name 1`] = ` +{ + "main.js": "'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var dashName; +var hasRequiredDashName; + +function requireDashName () { + if (hasRequiredDashName) return dashName; + hasRequiredDashName = 1; + dashName = true; + return dashName; +} + +var dashNameExports = requireDashName(); +var value = /*@__PURE__*/getDefaultExportFromCjs(dashNameExports); + +t.truthy(value); +", +} +`; + +exports[`deconflict-export-and-local 1`] = ` +{ + "main.js": "'use strict'; + +var deconflictExportAndLocal = {}; + +var someValue = {}; + +var hasRequiredSomeValue; + +function requireSomeValue () { + if (hasRequiredSomeValue) return someValue; + hasRequiredSomeValue = 1; + someValue.someValue = 10; + return someValue; +} + +var hasRequiredDeconflictExportAndLocal; + +function requireDeconflictExportAndLocal () { + if (hasRequiredDeconflictExportAndLocal) return deconflictExportAndLocal; + hasRequiredDeconflictExportAndLocal = 1; + const someValueModule = requireSomeValue(); + + deconflictExportAndLocal.someValue = someValueModule.someValue; + return deconflictExportAndLocal; +} + +var deconflictExportAndLocalExports = requireDeconflictExportAndLocal(); + +t.is(deconflictExportAndLocalExports.someValue, 10); +", +} +`; + +exports[`dot 1`] = ` +{ + "main.js": "'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var main$1 = {}; + +var foo_bar; +var hasRequiredFoo_bar; + +function requireFoo_bar () { + if (hasRequiredFoo_bar) return foo_bar; + hasRequiredFoo_bar = 1; + foo_bar = 'fubar'; + return foo_bar; +} + +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + const status = requireFoo_bar(); + + t.is(status, 'fubar'); + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +", +} +`; + +exports[`double-exports-assignment 1`] = ` +{ + "main.js": "'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var dep$1 = {}; + +var hasRequiredDep; + +function requireDep () { + if (hasRequiredDep) return dep$1; + hasRequiredDep = 1; + dep$1.foo = 'first'; + dep$1.foo = 'second'; + return dep$1; +} + +var depExports = requireDep(); +var dep = /*@__PURE__*/getDefaultExportFromCjs(depExports); + +t.is(dep.foo, 'second'); +", +} +`; + +exports[`double-exports-assignment-named 1`] = ` +{ + "main.js": "'use strict'; + +var dep = {}; + +var hasRequiredDep; + +function requireDep () { + if (hasRequiredDep) return dep; + hasRequiredDep = 1; + dep.foo = 'first'; + dep.foo = 'second'; + return dep; +} + +var depExports = requireDep(); + +t.is(depExports.foo, 'second'); +", +} +`; + +exports[`double-module-exports-assignment 1`] = ` +{ + "main.js": "'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var dep$1; +var hasRequiredDep; + +function requireDep () { + if (hasRequiredDep) return dep$1; + hasRequiredDep = 1; + dep$1 = 'first'; + dep$1 = 'second'; + return dep$1; +} + +var depExports = requireDep(); +var dep = /*@__PURE__*/getDefaultExportFromCjs(depExports); + +t.is(dep, 'second'); +", +} +`; + +exports[`duplicate-default-exports 1`] = ` +{ + "main.js": "'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var x$1 = {exports: {}}; + +var hasRequiredX; + +function requireX () { + if (hasRequiredX) return x$1.exports; + hasRequiredX = 1; + const x = {}; + + x$1.exports = x; + x$1.exports.default = x; + return x$1.exports; +} + +var xExports = requireX(); +var x = /*@__PURE__*/getDefaultExportFromCjs(xExports); + +t.is(x.default, x); +", +} +`; + +exports[`duplicate-default-exports-b 1`] = ` +{ + "main.js": "'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var x$1 = {exports: {}}; + +var hasRequiredX; + +function requireX () { + if (hasRequiredX) return x$1.exports; + hasRequiredX = 1; + const x = {}; + + x$1.exports = x; + x$1.exports.default = 42; + return x$1.exports; +} + +var xExports = requireX(); +var x = /*@__PURE__*/getDefaultExportFromCjs(xExports); + +t.deepEqual(x, { default: 42 }); +", +} +`; + +exports[`duplicate-default-exports-c 1`] = ` +{ + "main.js": "'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var exports$1 = {}; + +var hasRequiredExports; + +function requireExports () { + if (hasRequiredExports) return exports$1; + hasRequiredExports = 1; + exports$1.Foo = 1; + exports$1.var = 'VAR'; + exports$1.default = { + Foo: 2, + default: 3 + }; + return exports$1; +} + +var exportsExports = requireExports(); +var E = /*@__PURE__*/getDefaultExportFromCjs(exportsExports); + +/* eslint-disable */ + +t.is(E.Foo, 1); +t.is(E.var, 'VAR'); +t.deepEqual(E.default, { Foo: 2, default: 3 }); +t.is(E.default.Foo, 2); +t.is(E.default.default, 3); +t.is(exportsExports.Foo, 1); +t.is(exportsExports["var"], 'VAR'); +", +} +`; + +exports[`dynamic-module-require 1`] = ` +{ + "main.js": "'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var submodule; +var hasRequiredSubmodule; + +function requireSubmodule () { + if (hasRequiredSubmodule) return submodule; + hasRequiredSubmodule = 1; + submodule = function () { + return 'Hello there'; + }; + return submodule; +} + +var dynamicModules; + +function getDynamicModules() { + return dynamicModules || (dynamicModules = { + "/fixtures/function/dynamic-module-require/submodule.js": requireSubmodule + }); +} + +function createCommonjsRequire(originalModuleDir) { + function handleRequire(path) { + var resolvedPath = commonjsResolve(path, originalModuleDir); + if (resolvedPath !== null) { + return getDynamicModules()[resolvedPath](); + } + throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.'); + } + handleRequire.resolve = function (path) { + var resolvedPath = commonjsResolve(path, originalModuleDir); + if (resolvedPath !== null) { + return resolvedPath; + } + return require.resolve(path); + }; + return handleRequire; +} + +function commonjsResolve (path, originalModuleDir) { + var shouldTryNodeModules = isPossibleNodeModulesPath(path); + path = normalize(path); + var relPath; + if (path[0] === '/') { + originalModuleDir = ''; + } + var modules = getDynamicModules(); + var checkedExtensions = ['', '.js', '.json']; + while (true) { + if (!shouldTryNodeModules) { + relPath = normalize(originalModuleDir + '/' + path); + } else { + relPath = normalize(originalModuleDir + '/node_modules/' + path); + } + + if (relPath.endsWith('/..')) { + break; // Travelled too far up, avoid infinite loop + } + + for (var extensionIndex = 0; extensionIndex < checkedExtensions.length; extensionIndex++) { + var resolvedPath = relPath + checkedExtensions[extensionIndex]; + if (modules[resolvedPath]) { + return resolvedPath; + } + } + if (!shouldTryNodeModules) break; + var nextDir = normalize(originalModuleDir + '/..'); + if (nextDir === originalModuleDir) break; + originalModuleDir = nextDir; + } + return null; +} + +function isPossibleNodeModulesPath (modulePath) { + var c0 = modulePath[0]; + if (c0 === '/' || c0 === '\\\\') return false; + var c1 = modulePath[1], c2 = modulePath[2]; + if ((c0 === '.' && (!c1 || c1 === '/' || c1 === '\\\\')) || + (c0 === '.' && c1 === '.' && (!c2 || c2 === '/' || c2 === '\\\\'))) return false; + if (c1 === ':' && (c2 === '/' || c2 === '\\\\')) return false; + return true; +} + +function normalize (path) { + path = path.replace(/\\\\/g, '/'); + var parts = path.split('/'); + var slashed = parts[0] === ''; + for (var i = 1; i < parts.length; i++) { + if (parts[i] === '.' || parts[i] === '') { + parts.splice(i--, 1); + } + } + for (var i = 1; i < parts.length; i++) { + if (parts[i] !== '..') continue; + if (i > 0 && parts[i - 1] !== '..' && parts[i - 1] !== '.') { + parts.splice(--i, 2); + i--; + } + } + path = parts.join('/'); + if (slashed && path[0] !== '/') path = '/' + path; + else if (path.length === 0) path = '.'; + return path; +} + +var main$1 = {}; + +/* eslint-disable import/no-dynamic-require, global-require */ + +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + let message; + + function takeModule(withName) { + return createCommonjsRequire("/fixtures/function/dynamic-module-require")(\`./\${withName}\`); + } + + try { + const submodule = takeModule('submodule'); + message = submodule(); + } catch (err) { + ({ message } = err); + } + + t.is(message, 'Hello there'); + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +", +} +`; + +exports[`dynamic-require 1`] = ` +{ + "main.js": "'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var submodule; +var hasRequiredSubmodule; + +function requireSubmodule () { + if (hasRequiredSubmodule) return submodule; + hasRequiredSubmodule = 1; + submodule = function () { + return 'Hello there'; + }; + return submodule; +} + +var dynamicModules; + +function getDynamicModules() { + return dynamicModules || (dynamicModules = { + "/fixtures/function/dynamic-require/submodule.js": requireSubmodule + }); +} + +function createCommonjsRequire(originalModuleDir) { + function handleRequire(path) { + var resolvedPath = commonjsResolve(path, originalModuleDir); + if (resolvedPath !== null) { + return getDynamicModules()[resolvedPath](); + } + throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.'); + } + handleRequire.resolve = function (path) { + var resolvedPath = commonjsResolve(path, originalModuleDir); + if (resolvedPath !== null) { + return resolvedPath; + } + return require.resolve(path); + }; + return handleRequire; +} + +function commonjsResolve (path, originalModuleDir) { + var shouldTryNodeModules = isPossibleNodeModulesPath(path); + path = normalize(path); + var relPath; + if (path[0] === '/') { + originalModuleDir = ''; + } + var modules = getDynamicModules(); + var checkedExtensions = ['', '.js', '.json']; + while (true) { + if (!shouldTryNodeModules) { + relPath = normalize(originalModuleDir + '/' + path); + } else { + relPath = normalize(originalModuleDir + '/node_modules/' + path); + } + + if (relPath.endsWith('/..')) { + break; // Travelled too far up, avoid infinite loop + } + + for (var extensionIndex = 0; extensionIndex < checkedExtensions.length; extensionIndex++) { + var resolvedPath = relPath + checkedExtensions[extensionIndex]; + if (modules[resolvedPath]) { + return resolvedPath; + } + } + if (!shouldTryNodeModules) break; + var nextDir = normalize(originalModuleDir + '/..'); + if (nextDir === originalModuleDir) break; + originalModuleDir = nextDir; + } + return null; +} + +function isPossibleNodeModulesPath (modulePath) { + var c0 = modulePath[0]; + if (c0 === '/' || c0 === '\\\\') return false; + var c1 = modulePath[1], c2 = modulePath[2]; + if ((c0 === '.' && (!c1 || c1 === '/' || c1 === '\\\\')) || + (c0 === '.' && c1 === '.' && (!c2 || c2 === '/' || c2 === '\\\\'))) return false; + if (c1 === ':' && (c2 === '/' || c2 === '\\\\')) return false; + return true; +} + +function normalize (path) { + path = path.replace(/\\\\/g, '/'); + var parts = path.split('/'); + var slashed = parts[0] === ''; + for (var i = 1; i < parts.length; i++) { + if (parts[i] === '.' || parts[i] === '') { + parts.splice(i--, 1); + } + } + for (var i = 1; i < parts.length; i++) { + if (parts[i] !== '..') continue; + if (i > 0 && parts[i - 1] !== '..' && parts[i - 1] !== '.') { + parts.splice(--i, 2); + i--; + } + } + path = parts.join('/'); + if (slashed && path[0] !== '/') path = '/' + path; + else if (path.length === 0) path = '.'; + return path; +} + +var main$1 = {}; + +/* eslint-disable import/no-dynamic-require, global-require */ + +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + let message; + + function takeModule(withName) { + return createCommonjsRequire("/fixtures/function/dynamic-require")(\`./\${withName}\`); + } + + try { + const submodule = takeModule('submodule'); + message = submodule(); + } catch (err) { + ({ message } = err); + } + + t.is(message, 'Hello there'); + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +", +} +`; + +exports[`dynamic-require-absolute-import 1`] = ` +{ + "main.js": "'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var main$1 = {}; + +var direct; +var hasRequiredDirect; + +function requireDirect () { + if (hasRequiredDirect) return direct; + hasRequiredDirect = 1; + direct = 'direct'; + return direct; +} + +var nested; +var hasRequiredNested; + +function requireNested () { + if (hasRequiredNested) return nested; + hasRequiredNested = 1; + nested = 'nested'; + return nested; +} + +var parent; +var hasRequiredParent; + +function requireParent () { + if (hasRequiredParent) return parent; + hasRequiredParent = 1; + parent = 'parent'; + return parent; +} + +var dynamicModules; + +function getDynamicModules() { + return dynamicModules || (dynamicModules = { + "/fixtures/function/dynamic-require-absolute-import/sub/node_modules/module/direct.js": requireDirect, + "/fixtures/function/dynamic-require-absolute-import/sub/node_modules/module/nested/nested.js": requireNested, + "/fixtures/function/dynamic-require-absolute-import/node_modules/parent-module/parent.js": requireParent + }); +} + +function createCommonjsRequire(originalModuleDir) { + function handleRequire(path) { + var resolvedPath = commonjsResolve(path, originalModuleDir); + if (resolvedPath !== null) { + return getDynamicModules()[resolvedPath](); + } + throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.'); + } + handleRequire.resolve = function (path) { + var resolvedPath = commonjsResolve(path, originalModuleDir); + if (resolvedPath !== null) { + return resolvedPath; + } + return require.resolve(path); + }; + return handleRequire; +} + +function commonjsResolve (path, originalModuleDir) { + var shouldTryNodeModules = isPossibleNodeModulesPath(path); + path = normalize(path); + var relPath; + if (path[0] === '/') { + originalModuleDir = ''; + } + var modules = getDynamicModules(); + var checkedExtensions = ['', '.js', '.json']; + while (true) { + if (!shouldTryNodeModules) { + relPath = normalize(originalModuleDir + '/' + path); + } else { + relPath = normalize(originalModuleDir + '/node_modules/' + path); + } + + if (relPath.endsWith('/..')) { + break; // Travelled too far up, avoid infinite loop + } + + for (var extensionIndex = 0; extensionIndex < checkedExtensions.length; extensionIndex++) { + var resolvedPath = relPath + checkedExtensions[extensionIndex]; + if (modules[resolvedPath]) { + return resolvedPath; + } + } + if (!shouldTryNodeModules) break; + var nextDir = normalize(originalModuleDir + '/..'); + if (nextDir === originalModuleDir) break; + originalModuleDir = nextDir; + } + return null; +} + +function isPossibleNodeModulesPath (modulePath) { + var c0 = modulePath[0]; + if (c0 === '/' || c0 === '\\\\') return false; + var c1 = modulePath[1], c2 = modulePath[2]; + if ((c0 === '.' && (!c1 || c1 === '/' || c1 === '\\\\')) || + (c0 === '.' && c1 === '.' && (!c2 || c2 === '/' || c2 === '\\\\'))) return false; + if (c1 === ':' && (c2 === '/' || c2 === '\\\\')) return false; + return true; +} + +function normalize (path) { + path = path.replace(/\\\\/g, '/'); + var parts = path.split('/'); + var slashed = parts[0] === ''; + for (var i = 1; i < parts.length; i++) { + if (parts[i] === '.' || parts[i] === '') { + parts.splice(i--, 1); + } + } + for (var i = 1; i < parts.length; i++) { + if (parts[i] !== '..') continue; + if (i > 0 && parts[i - 1] !== '..' && parts[i - 1] !== '.') { + parts.splice(--i, 2); + i--; + } + } + path = parts.join('/'); + if (slashed && path[0] !== '/') path = '/' + path; + else if (path.length === 0) path = '.'; + return path; +} + +var submodule = {}; + +/* eslint-disable import/no-dynamic-require, global-require */ + +var hasRequiredSubmodule; + +function requireSubmodule () { + if (hasRequiredSubmodule) return submodule; + hasRequiredSubmodule = 1; + function takeModule(name) { + return createCommonjsRequire("/fixtures/function/dynamic-require-absolute-import/sub")(name); + } + + submodule.moduleDirect = takeModule('module/direct'); + submodule.moduleNested = takeModule('module/nested/nested'); + submodule.parentModule = takeModule('parent-module/parent'); + return submodule; +} + +/* eslint-disable import/no-dynamic-require, global-require */ + +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + t.deepEqual(requireSubmodule(), { + moduleDirect: 'direct', + moduleNested: 'nested', + parentModule: 'parent' + }); + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +", +} +`; + +exports[`dynamic-require-alias-hack 1`] = ` +{ + "main.js": "'use strict'; + +var require$$0 = require('buffer'); + +function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } + +var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0); + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var stub; +var hasRequiredStub; + +function requireStub () { + if (hasRequiredStub) return stub; + hasRequiredStub = 1; + stub = function () { + return 'Hello there'; + }; + return stub; +} + +var dynamicModules; + +function getDynamicModules() { + return dynamicModules || (dynamicModules = { + "/fixtures/function/dynamic-require-alias-hack/stub.js": requireStub + }); +} + +function createCommonjsRequire(originalModuleDir) { + function handleRequire(path) { + var resolvedPath = commonjsResolve(path, originalModuleDir); + if (resolvedPath !== null) { + return getDynamicModules()[resolvedPath](); + } + return require(path); + } + handleRequire.resolve = function (path) { + var resolvedPath = commonjsResolve(path, originalModuleDir); + if (resolvedPath !== null) { + return resolvedPath; + } + return require.resolve(path); + }; + return handleRequire; +} + +function commonjsResolve (path, originalModuleDir) { + var shouldTryNodeModules = isPossibleNodeModulesPath(path); + path = normalize(path); + var relPath; + if (path[0] === '/') { + originalModuleDir = ''; + } + var modules = getDynamicModules(); + var checkedExtensions = ['', '.js', '.json']; + while (true) { + if (!shouldTryNodeModules) { + relPath = normalize(originalModuleDir + '/' + path); + } else { + relPath = normalize(originalModuleDir + '/node_modules/' + path); + } + + if (relPath.endsWith('/..')) { + break; // Travelled too far up, avoid infinite loop + } + + for (var extensionIndex = 0; extensionIndex < checkedExtensions.length; extensionIndex++) { + var resolvedPath = relPath + checkedExtensions[extensionIndex]; + if (modules[resolvedPath]) { + return resolvedPath; + } + } + if (!shouldTryNodeModules) break; + var nextDir = normalize(originalModuleDir + '/..'); + if (nextDir === originalModuleDir) break; + originalModuleDir = nextDir; + } + return null; +} + +function isPossibleNodeModulesPath (modulePath) { + var c0 = modulePath[0]; + if (c0 === '/' || c0 === '\\\\') return false; + var c1 = modulePath[1], c2 = modulePath[2]; + if ((c0 === '.' && (!c1 || c1 === '/' || c1 === '\\\\')) || + (c0 === '.' && c1 === '.' && (!c2 || c2 === '/' || c2 === '\\\\'))) return false; + if (c1 === ':' && (c2 === '/' || c2 === '\\\\')) return false; + return true; +} + +function normalize (path) { + path = path.replace(/\\\\/g, '/'); + var parts = path.split('/'); + var slashed = parts[0] === ''; + for (var i = 1; i < parts.length; i++) { + if (parts[i] === '.' || parts[i] === '') { + parts.splice(i--, 1); + } + } + for (var i = 1; i < parts.length; i++) { + if (parts[i] !== '..') continue; + if (i > 0 && parts[i - 1] !== '..' && parts[i - 1] !== '.') { + parts.splice(--i, 2); + i--; + } + } + path = parts.join('/'); + if (slashed && path[0] !== '/') path = '/' + path; + else if (path.length === 0) path = '.'; + return path; +} + +var main$1 = {}; + +/* eslint-disable global-require */ + +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + // noinspection UnnecessaryLocalVariableJS + + // A hack used in many old libraries, saying "workaround to exclude package from browserify list." + // Will bypass rollup-commonjs finding out that this is a require that should not go through the plugin, and will do an infinite search. + const _require = createCommonjsRequire("/fixtures/function/dynamic-require-alias-hack"); + const buffer = _require('buffer'); + + t.is(buffer, require$$0__default["default"]); + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +", +} +`; + +exports[`dynamic-require-code-splitting 1`] = ` +{ + "generated-lib2.js": "'use strict'; + +var target1; +var hasRequiredTarget1; + +function requireTarget1 () { + if (hasRequiredTarget1) return target1; + hasRequiredTarget1 = 1; + target1 = '1'; + return target1; +} + +var target2; +var hasRequiredTarget2; + +function requireTarget2 () { + if (hasRequiredTarget2) return target2; + hasRequiredTarget2 = 1; + target2 = '2'; + return target2; +} + +var dynamicModules; + +function getDynamicModules() { + return dynamicModules || (dynamicModules = { + "/fixtures/function/dynamic-require-code-splitting/target1.js": requireTarget1, + "/fixtures/function/dynamic-require-code-splitting/target2.js": requireTarget2 + }); +} + +function createCommonjsRequire(originalModuleDir) { + function handleRequire(path) { + var resolvedPath = commonjsResolve(path, originalModuleDir); + if (resolvedPath !== null) { + return getDynamicModules()[resolvedPath](); + } + throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.'); + } + handleRequire.resolve = function (path) { + var resolvedPath = commonjsResolve(path, originalModuleDir); + if (resolvedPath !== null) { + return resolvedPath; + } + return require.resolve(path); + }; + return handleRequire; +} + +function commonjsResolve (path, originalModuleDir) { + var shouldTryNodeModules = isPossibleNodeModulesPath(path); + path = normalize(path); + var relPath; + if (path[0] === '/') { + originalModuleDir = ''; + } + var modules = getDynamicModules(); + var checkedExtensions = ['', '.js', '.json']; + while (true) { + if (!shouldTryNodeModules) { + relPath = normalize(originalModuleDir + '/' + path); + } else { + relPath = normalize(originalModuleDir + '/node_modules/' + path); + } + + if (relPath.endsWith('/..')) { + break; // Travelled too far up, avoid infinite loop + } + + for (var extensionIndex = 0; extensionIndex < checkedExtensions.length; extensionIndex++) { + var resolvedPath = relPath + checkedExtensions[extensionIndex]; + if (modules[resolvedPath]) { + return resolvedPath; + } + } + if (!shouldTryNodeModules) break; + var nextDir = normalize(originalModuleDir + '/..'); + if (nextDir === originalModuleDir) break; + originalModuleDir = nextDir; + } + return null; +} + +function isPossibleNodeModulesPath (modulePath) { + var c0 = modulePath[0]; + if (c0 === '/' || c0 === '\\\\') return false; + var c1 = modulePath[1], c2 = modulePath[2]; + if ((c0 === '.' && (!c1 || c1 === '/' || c1 === '\\\\')) || + (c0 === '.' && c1 === '.' && (!c2 || c2 === '/' || c2 === '\\\\'))) return false; + if (c1 === ':' && (c2 === '/' || c2 === '\\\\')) return false; + return true; +} + +function normalize (path) { + path = path.replace(/\\\\/g, '/'); + var parts = path.split('/'); + var slashed = parts[0] === ''; + for (var i = 1; i < parts.length; i++) { + if (parts[i] === '.' || parts[i] === '') { + parts.splice(i--, 1); + } + } + for (var i = 1; i < parts.length; i++) { + if (parts[i] !== '..') continue; + if (i > 0 && parts[i - 1] !== '..' && parts[i - 1] !== '.') { + parts.splice(--i, 2); + i--; + } + } + path = parts.join('/'); + if (slashed && path[0] !== '/') path = '/' + path; + else if (path.length === 0) path = '.'; + return path; +} + +var lib2 = {}; + +/* eslint-disable import/no-dynamic-require, global-require */ + +var hasRequiredLib2; + +function requireLib2 () { + if (hasRequiredLib2) return lib2; + hasRequiredLib2 = 1; + let message; + + for (const index of [1, 2]) { + try { + message = createCommonjsRequire("/fixtures/function/dynamic-require-code-splitting")(\`./target\${index}.js\`); + } catch (err) { + ({ message } = err); + } + t.is(message, index.toString()); + } + return lib2; +} + +requireLib2(); + +exports.createCommonjsRequire = createCommonjsRequire; +", + "main.js": "'use strict'; + +var lib2 = require('./generated-lib2.js'); + +var lib1 = {}; + +/* eslint-disable import/no-dynamic-require, global-require */ + +var hasRequiredLib1; + +function requireLib1 () { + if (hasRequiredLib1) return lib1; + hasRequiredLib1 = 1; + let message; + + for (const index of [1, 2]) { + try { + message = lib2.createCommonjsRequire("/fixtures/function/dynamic-require-code-splitting")(\`./target\${index}.js\`); + } catch (err) { + ({ message } = err); + } + t.is(message, index.toString()); + } + return lib1; +} + +requireLib1(); +", + "main2.js": "'use strict'; + +require('./generated-lib2.js'); + +", +} +`; + +exports[`dynamic-require-different-loader 1`] = ` +{ + "main.js": "'use strict'; + +var submodule2; +var hasRequiredSubmodule2; + +function requireSubmodule2 () { + if (hasRequiredSubmodule2) return submodule2; + hasRequiredSubmodule2 = 1; + submodule2 = function () { + return 'Hello there'; + }; + return submodule2; +} + +const fn = requireSubmodule2(); + +var main = fn(); + +module.exports = main; +", +} +`; + +exports[`dynamic-require-empty 1`] = ` +{ + "main.js": "'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var submodule = {}; + +var hasRequiredSubmodule; + +function requireSubmodule () { + if (hasRequiredSubmodule) return submodule; + hasRequiredSubmodule = 1; + + return submodule; +} + +var dynamicModules; + +function getDynamicModules() { + return dynamicModules || (dynamicModules = { + "/fixtures/function/dynamic-require-empty/submodule.js": requireSubmodule + }); +} + +function createCommonjsRequire(originalModuleDir) { + function handleRequire(path) { + var resolvedPath = commonjsResolve(path, originalModuleDir); + if (resolvedPath !== null) { + return getDynamicModules()[resolvedPath](); + } + throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.'); + } + handleRequire.resolve = function (path) { + var resolvedPath = commonjsResolve(path, originalModuleDir); + if (resolvedPath !== null) { + return resolvedPath; + } + return require.resolve(path); + }; + return handleRequire; +} + +function commonjsResolve (path, originalModuleDir) { + var shouldTryNodeModules = isPossibleNodeModulesPath(path); + path = normalize(path); + var relPath; + if (path[0] === '/') { + originalModuleDir = ''; + } + var modules = getDynamicModules(); + var checkedExtensions = ['', '.js', '.json']; + while (true) { + if (!shouldTryNodeModules) { + relPath = normalize(originalModuleDir + '/' + path); + } else { + relPath = normalize(originalModuleDir + '/node_modules/' + path); + } + + if (relPath.endsWith('/..')) { + break; // Travelled too far up, avoid infinite loop + } + + for (var extensionIndex = 0; extensionIndex < checkedExtensions.length; extensionIndex++) { + var resolvedPath = relPath + checkedExtensions[extensionIndex]; + if (modules[resolvedPath]) { + return resolvedPath; + } + } + if (!shouldTryNodeModules) break; + var nextDir = normalize(originalModuleDir + '/..'); + if (nextDir === originalModuleDir) break; + originalModuleDir = nextDir; + } + return null; +} + +function isPossibleNodeModulesPath (modulePath) { + var c0 = modulePath[0]; + if (c0 === '/' || c0 === '\\\\') return false; + var c1 = modulePath[1], c2 = modulePath[2]; + if ((c0 === '.' && (!c1 || c1 === '/' || c1 === '\\\\')) || + (c0 === '.' && c1 === '.' && (!c2 || c2 === '/' || c2 === '\\\\'))) return false; + if (c1 === ':' && (c2 === '/' || c2 === '\\\\')) return false; + return true; +} + +function normalize (path) { + path = path.replace(/\\\\/g, '/'); + var parts = path.split('/'); + var slashed = parts[0] === ''; + for (var i = 1; i < parts.length; i++) { + if (parts[i] === '.' || parts[i] === '') { + parts.splice(i--, 1); + } + } + for (var i = 1; i < parts.length; i++) { + if (parts[i] !== '..') continue; + if (i > 0 && parts[i - 1] !== '..' && parts[i - 1] !== '.') { + parts.splice(--i, 2); + i--; + } + } + path = parts.join('/'); + if (slashed && path[0] !== '/') path = '/' + path; + else if (path.length === 0) path = '.'; + return path; +} + +var main$1 = {}; + +/* eslint-disable import/no-dynamic-require, global-require */ + +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + function takeModule(withName) { + return createCommonjsRequire("/fixtures/function/dynamic-require-empty")(\`./\${withName}\`); + } + + t.deepEqual(takeModule('submodule'), {}); + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +", +} +`; + +exports[`dynamic-require-es-entry 1`] = ` +{ + "main.js": "'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var submodule; +var hasRequiredSubmodule; + +function requireSubmodule () { + if (hasRequiredSubmodule) return submodule; + hasRequiredSubmodule = 1; + submodule = 'submodule'; + return submodule; +} + +var dynamicModules; + +function getDynamicModules() { + return dynamicModules || (dynamicModules = { + "/fixtures/function/dynamic-require-es-entry/submodule.js": requireSubmodule + }); +} + +function createCommonjsRequire(originalModuleDir) { + function handleRequire(path) { + var resolvedPath = commonjsResolve(path, originalModuleDir); + if (resolvedPath !== null) { + return getDynamicModules()[resolvedPath](); + } + throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.'); + } + handleRequire.resolve = function (path) { + var resolvedPath = commonjsResolve(path, originalModuleDir); + if (resolvedPath !== null) { + return resolvedPath; + } + return require.resolve(path); + }; + return handleRequire; +} + +function commonjsResolve (path, originalModuleDir) { + var shouldTryNodeModules = isPossibleNodeModulesPath(path); + path = normalize(path); + var relPath; + if (path[0] === '/') { + originalModuleDir = ''; + } + var modules = getDynamicModules(); + var checkedExtensions = ['', '.js', '.json']; + while (true) { + if (!shouldTryNodeModules) { + relPath = normalize(originalModuleDir + '/' + path); + } else { + relPath = normalize(originalModuleDir + '/node_modules/' + path); + } + + if (relPath.endsWith('/..')) { + break; // Travelled too far up, avoid infinite loop + } + + for (var extensionIndex = 0; extensionIndex < checkedExtensions.length; extensionIndex++) { + var resolvedPath = relPath + checkedExtensions[extensionIndex]; + if (modules[resolvedPath]) { + return resolvedPath; + } + } + if (!shouldTryNodeModules) break; + var nextDir = normalize(originalModuleDir + '/..'); + if (nextDir === originalModuleDir) break; + originalModuleDir = nextDir; + } + return null; +} + +function isPossibleNodeModulesPath (modulePath) { + var c0 = modulePath[0]; + if (c0 === '/' || c0 === '\\\\') return false; + var c1 = modulePath[1], c2 = modulePath[2]; + if ((c0 === '.' && (!c1 || c1 === '/' || c1 === '\\\\')) || + (c0 === '.' && c1 === '.' && (!c2 || c2 === '/' || c2 === '\\\\'))) return false; + if (c1 === ':' && (c2 === '/' || c2 === '\\\\')) return false; + return true; +} + +function normalize (path) { + path = path.replace(/\\\\/g, '/'); + var parts = path.split('/'); + var slashed = parts[0] === ''; + for (var i = 1; i < parts.length; i++) { + if (parts[i] === '.' || parts[i] === '') { + parts.splice(i--, 1); + } + } + for (var i = 1; i < parts.length; i++) { + if (parts[i] !== '..') continue; + if (i > 0 && parts[i - 1] !== '..' && parts[i - 1] !== '.') { + parts.splice(--i, 2); + i--; + } + } + path = parts.join('/'); + if (slashed && path[0] !== '/') path = '/' + path; + else if (path.length === 0) path = '.'; + return path; +} + +/* eslint-disable import/no-dynamic-require, global-require */ + +var importer; +var hasRequiredImporter; + +function requireImporter () { + if (hasRequiredImporter) return importer; + hasRequiredImporter = 1; + function takeModule(withName) { + return createCommonjsRequire("/fixtures/function/dynamic-require-es-entry")(\`./\${withName}\`); + } + + importer = takeModule('submodule.js'); + return importer; +} + +var importerExports = requireImporter(); +var result = /*@__PURE__*/getDefaultExportFromCjs(importerExports); + +/* eslint-disable import/no-dynamic-require, global-require */ + +t.is(result, 'submodule'); +", +} +`; + +exports[`dynamic-require-es-mixed-helpers 1`] = ` +{ + "main.js": "'use strict'; + +var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; + +var submodule; +var hasRequiredSubmodule; + +function requireSubmodule () { + if (hasRequiredSubmodule) return submodule; + hasRequiredSubmodule = 1; + commonjsGlobal.hasSubmoduleRun = true; + submodule = 'submodule'; + return submodule; +} + +t.is(global.hasSubmoduleRun, undefined, 'before require'); + +// eslint-disable-next-line global-require +var result = requireSubmodule(); + +t.is(global.hasSubmoduleRun, true, 'after require'); +delete global.hasSubmoduleRun; + +t.is(result, 'submodule'); +", +} +`; + +exports[`dynamic-require-extensions 1`] = ` +{ + "main.js": "'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var submodule; +var hasRequiredSubmodule; + +function requireSubmodule () { + if (hasRequiredSubmodule) return submodule; + hasRequiredSubmodule = 1; + submodule = { name: 'submodule', value: null }; + return submodule; +} + +var dynamicModules; + +function getDynamicModules() { + return dynamicModules || (dynamicModules = { + "/fixtures/function/dynamic-require-extensions/submodule.js": requireSubmodule + }); +} + +function createCommonjsRequire(originalModuleDir) { + function handleRequire(path) { + var resolvedPath = commonjsResolve(path, originalModuleDir); + if (resolvedPath !== null) { + return getDynamicModules()[resolvedPath](); + } + throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.'); + } + handleRequire.resolve = function (path) { + var resolvedPath = commonjsResolve(path, originalModuleDir); + if (resolvedPath !== null) { + return resolvedPath; + } + return require.resolve(path); + }; + return handleRequire; +} + +function commonjsResolve (path, originalModuleDir) { + var shouldTryNodeModules = isPossibleNodeModulesPath(path); + path = normalize(path); + var relPath; + if (path[0] === '/') { + originalModuleDir = ''; + } + var modules = getDynamicModules(); + var checkedExtensions = ['', '.js', '.json']; + while (true) { + if (!shouldTryNodeModules) { + relPath = normalize(originalModuleDir + '/' + path); + } else { + relPath = normalize(originalModuleDir + '/node_modules/' + path); + } + + if (relPath.endsWith('/..')) { + break; // Travelled too far up, avoid infinite loop + } + + for (var extensionIndex = 0; extensionIndex < checkedExtensions.length; extensionIndex++) { + var resolvedPath = relPath + checkedExtensions[extensionIndex]; + if (modules[resolvedPath]) { + return resolvedPath; + } + } + if (!shouldTryNodeModules) break; + var nextDir = normalize(originalModuleDir + '/..'); + if (nextDir === originalModuleDir) break; + originalModuleDir = nextDir; + } + return null; +} + +function isPossibleNodeModulesPath (modulePath) { + var c0 = modulePath[0]; + if (c0 === '/' || c0 === '\\\\') return false; + var c1 = modulePath[1], c2 = modulePath[2]; + if ((c0 === '.' && (!c1 || c1 === '/' || c1 === '\\\\')) || + (c0 === '.' && c1 === '.' && (!c2 || c2 === '/' || c2 === '\\\\'))) return false; + if (c1 === ':' && (c2 === '/' || c2 === '\\\\')) return false; + return true; +} + +function normalize (path) { + path = path.replace(/\\\\/g, '/'); + var parts = path.split('/'); + var slashed = parts[0] === ''; + for (var i = 1; i < parts.length; i++) { + if (parts[i] === '.' || parts[i] === '') { + parts.splice(i--, 1); + } + } + for (var i = 1; i < parts.length; i++) { + if (parts[i] !== '..') continue; + if (i > 0 && parts[i - 1] !== '..' && parts[i - 1] !== '.') { + parts.splice(--i, 2); + i--; + } + } + path = parts.join('/'); + if (slashed && path[0] !== '/') path = '/' + path; + else if (path.length === 0) path = '.'; + return path; +} + +var main$1 = {}; + +/* eslint-disable import/no-dynamic-require, global-require */ + +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + function takeModule(withName) { + return createCommonjsRequire("/fixtures/function/dynamic-require-extensions")(\`./\${withName}\`); + } + + const withExtension = takeModule('submodule.js'); + const withoutExtension = takeModule('submodule'); + + t.is(withExtension.name, 'submodule'); + t.is(withoutExtension.name, 'submodule'); + + withExtension.value = 'mutated'; + + t.is(withoutExtension.value, 'mutated'); + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +", +} +`; + +exports[`dynamic-require-fallback 1`] = ` +{ + "main.js": "'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var main$1 = {}; + +/* eslint-disable import/no-dynamic-require, global-require */ + +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + function takeModule(withName) { + return require(withName); + } + + // The bundled code will run from test/helpers/util.js + t.is(takeModule('../fixtures/function/dynamic-require-fallback/dep.js'), 'dep'); + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +", +} +`; + +exports[`dynamic-require-from-es-import 1`] = ` +{ + "main.js": "'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var submodule$1; +var hasRequiredSubmodule; + +function requireSubmodule () { + if (hasRequiredSubmodule) return submodule$1; + hasRequiredSubmodule = 1; + submodule$1 = 'submodule'; + return submodule$1; +} + +var submoduleExports = requireSubmodule(); +var submodule = /*@__PURE__*/getDefaultExportFromCjs(submoduleExports); + +t.is(submodule, 'submodule'); +", +} +`; + +exports[`dynamic-require-globs 1`] = ` +{ + "main.js": "'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var submodule1; +var hasRequiredSubmodule1; + +function requireSubmodule1 () { + if (hasRequiredSubmodule1) return submodule1; + hasRequiredSubmodule1 = 1; + submodule1 = 'submodule1'; + return submodule1; +} + +var submodule2; +var hasRequiredSubmodule2; + +function requireSubmodule2 () { + if (hasRequiredSubmodule2) return submodule2; + hasRequiredSubmodule2 = 1; + submodule2 = 'submodule2'; + return submodule2; +} + +var extramodule1; +var hasRequiredExtramodule1; + +function requireExtramodule1 () { + if (hasRequiredExtramodule1) return extramodule1; + hasRequiredExtramodule1 = 1; + extramodule1 = 'extramodule1'; + return extramodule1; +} + +var dynamicModules; + +function getDynamicModules() { + return dynamicModules || (dynamicModules = { + "/fixtures/function/dynamic-require-globs/submodule1.js": requireSubmodule1, + "/fixtures/function/dynamic-require-globs/submodule2.js": requireSubmodule2, + "/fixtures/function/dynamic-require-globs/extramodule1.js": requireExtramodule1 + }); +} + +function createCommonjsRequire(originalModuleDir) { + function handleRequire(path) { + var resolvedPath = commonjsResolve(path, originalModuleDir); + if (resolvedPath !== null) { + return getDynamicModules()[resolvedPath](); + } + throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.'); + } + handleRequire.resolve = function (path) { + var resolvedPath = commonjsResolve(path, originalModuleDir); + if (resolvedPath !== null) { + return resolvedPath; + } + return require.resolve(path); + }; + return handleRequire; +} + +function commonjsResolve (path, originalModuleDir) { + var shouldTryNodeModules = isPossibleNodeModulesPath(path); + path = normalize(path); + var relPath; + if (path[0] === '/') { + originalModuleDir = ''; + } + var modules = getDynamicModules(); + var checkedExtensions = ['', '.js', '.json']; + while (true) { + if (!shouldTryNodeModules) { + relPath = normalize(originalModuleDir + '/' + path); + } else { + relPath = normalize(originalModuleDir + '/node_modules/' + path); + } + + if (relPath.endsWith('/..')) { + break; // Travelled too far up, avoid infinite loop + } + + for (var extensionIndex = 0; extensionIndex < checkedExtensions.length; extensionIndex++) { + var resolvedPath = relPath + checkedExtensions[extensionIndex]; + if (modules[resolvedPath]) { + return resolvedPath; + } + } + if (!shouldTryNodeModules) break; + var nextDir = normalize(originalModuleDir + '/..'); + if (nextDir === originalModuleDir) break; + originalModuleDir = nextDir; + } + return null; +} + +function isPossibleNodeModulesPath (modulePath) { + var c0 = modulePath[0]; + if (c0 === '/' || c0 === '\\\\') return false; + var c1 = modulePath[1], c2 = modulePath[2]; + if ((c0 === '.' && (!c1 || c1 === '/' || c1 === '\\\\')) || + (c0 === '.' && c1 === '.' && (!c2 || c2 === '/' || c2 === '\\\\'))) return false; + if (c1 === ':' && (c2 === '/' || c2 === '\\\\')) return false; + return true; +} + +function normalize (path) { + path = path.replace(/\\\\/g, '/'); + var parts = path.split('/'); + var slashed = parts[0] === ''; + for (var i = 1; i < parts.length; i++) { + if (parts[i] === '.' || parts[i] === '') { + parts.splice(i--, 1); + } + } + for (var i = 1; i < parts.length; i++) { + if (parts[i] !== '..') continue; + if (i > 0 && parts[i - 1] !== '..' && parts[i - 1] !== '.') { + parts.splice(--i, 2); + i--; + } + } + path = parts.join('/'); + if (slashed && path[0] !== '/') path = '/' + path; + else if (path.length === 0) path = '.'; + return path; +} + +var main$1 = {}; + +/* eslint-disable import/no-dynamic-require, global-require */ + +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + function takeModule(withName) { + return createCommonjsRequire("/fixtures/function/dynamic-require-globs")(\`./\${withName}\`); + } + + t.is(takeModule('submodule1.js'), 'submodule1'); + t.is(takeModule('submodule2.js'), 'submodule2'); + t.is(takeModule('extramodule1.js'), 'extramodule1'); + t.throws(() => takeModule('extramodule2.js'), { + message: + 'Could not dynamically require "./extramodule2.js". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.' + }); + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +", +} +`; + +exports[`dynamic-require-instances 1`] = ` +{ + "main.js": "'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var direct; +var hasRequiredDirect; + +function requireDirect () { + if (hasRequiredDirect) return direct; + hasRequiredDirect = 1; + direct = { name: 'direct', value: null }; + return direct; +} + +var main$2; +var hasRequiredMain$1; + +function requireMain$1 () { + if (hasRequiredMain$1) return main$2; + hasRequiredMain$1 = 1; + main$2 = { name: 'package', value: null }; + return main$2; +} + +var dynamicModules; + +function getDynamicModules() { + return dynamicModules || (dynamicModules = { + "/fixtures/function/dynamic-require-instances/direct": requireDirect, + "/fixtures/function/dynamic-require-instances/direct/index.js": requireDirect, + "/fixtures/function/dynamic-require-instances/package": requireMain$1, + "/fixtures/function/dynamic-require-instances/package/main.js": requireMain$1 + }); +} + +function createCommonjsRequire(originalModuleDir) { + function handleRequire(path) { + var resolvedPath = commonjsResolve(path, originalModuleDir); + if (resolvedPath !== null) { + return getDynamicModules()[resolvedPath](); + } + throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.'); + } + handleRequire.resolve = function (path) { + var resolvedPath = commonjsResolve(path, originalModuleDir); + if (resolvedPath !== null) { + return resolvedPath; + } + return require.resolve(path); + }; + return handleRequire; +} + +function commonjsResolve (path, originalModuleDir) { + var shouldTryNodeModules = isPossibleNodeModulesPath(path); + path = normalize(path); + var relPath; + if (path[0] === '/') { + originalModuleDir = ''; + } + var modules = getDynamicModules(); + var checkedExtensions = ['', '.js', '.json']; + while (true) { + if (!shouldTryNodeModules) { + relPath = normalize(originalModuleDir + '/' + path); + } else { + relPath = normalize(originalModuleDir + '/node_modules/' + path); + } + + if (relPath.endsWith('/..')) { + break; // Travelled too far up, avoid infinite loop + } + + for (var extensionIndex = 0; extensionIndex < checkedExtensions.length; extensionIndex++) { + var resolvedPath = relPath + checkedExtensions[extensionIndex]; + if (modules[resolvedPath]) { + return resolvedPath; + } + } + if (!shouldTryNodeModules) break; + var nextDir = normalize(originalModuleDir + '/..'); + if (nextDir === originalModuleDir) break; + originalModuleDir = nextDir; + } + return null; +} + +function isPossibleNodeModulesPath (modulePath) { + var c0 = modulePath[0]; + if (c0 === '/' || c0 === '\\\\') return false; + var c1 = modulePath[1], c2 = modulePath[2]; + if ((c0 === '.' && (!c1 || c1 === '/' || c1 === '\\\\')) || + (c0 === '.' && c1 === '.' && (!c2 || c2 === '/' || c2 === '\\\\'))) return false; + if (c1 === ':' && (c2 === '/' || c2 === '\\\\')) return false; + return true; +} + +function normalize (path) { + path = path.replace(/\\\\/g, '/'); + var parts = path.split('/'); + var slashed = parts[0] === ''; + for (var i = 1; i < parts.length; i++) { + if (parts[i] === '.' || parts[i] === '') { + parts.splice(i--, 1); + } + } + for (var i = 1; i < parts.length; i++) { + if (parts[i] !== '..') continue; + if (i > 0 && parts[i - 1] !== '..' && parts[i - 1] !== '.') { + parts.splice(--i, 2); + i--; + } + } + path = parts.join('/'); + if (slashed && path[0] !== '/') path = '/' + path; + else if (path.length === 0) path = '.'; + return path; +} + +var main$1 = {}; + +/* eslint-disable import/no-dynamic-require, global-require */ + +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + function takeModule(withName) { + return createCommonjsRequire("/fixtures/function/dynamic-require-instances")(withName); + } + + takeModule('./direct').value = 'direct-instance'; + t.is(takeModule('./direct/index.js').value, 'direct-instance'); + t.is(requireDirect().value, 'direct-instance'); + + takeModule('./package').value = 'package-instance'; + t.is(takeModule('./package/main.js').value, 'package-instance'); + t.is(requireMain$1().value, 'package-instance'); + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +", +} +`; + +exports[`dynamic-require-json 1`] = ` +{ + "main.js": "'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var value = "present"; +var json0 = { + value: value +}; + +var dynamicModules; + +function getDynamicModules() { + return dynamicModules || (dynamicModules = { + "/fixtures/function/dynamic-require-json/dynamic.json": function () { return json0; } + }); +} + +function createCommonjsRequire(originalModuleDir) { + function handleRequire(path) { + var resolvedPath = commonjsResolve(path, originalModuleDir); + if (resolvedPath !== null) { + return getDynamicModules()[resolvedPath](); + } + throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.'); + } + handleRequire.resolve = function (path) { + var resolvedPath = commonjsResolve(path, originalModuleDir); + if (resolvedPath !== null) { + return resolvedPath; + } + return require.resolve(path); + }; + return handleRequire; +} + +function commonjsResolve (path, originalModuleDir) { + var shouldTryNodeModules = isPossibleNodeModulesPath(path); + path = normalize(path); + var relPath; + if (path[0] === '/') { + originalModuleDir = ''; + } + var modules = getDynamicModules(); + var checkedExtensions = ['', '.js', '.json']; + while (true) { + if (!shouldTryNodeModules) { + relPath = normalize(originalModuleDir + '/' + path); + } else { + relPath = normalize(originalModuleDir + '/node_modules/' + path); + } + + if (relPath.endsWith('/..')) { + break; // Travelled too far up, avoid infinite loop + } + + for (var extensionIndex = 0; extensionIndex < checkedExtensions.length; extensionIndex++) { + var resolvedPath = relPath + checkedExtensions[extensionIndex]; + if (modules[resolvedPath]) { + return resolvedPath; + } + } + if (!shouldTryNodeModules) break; + var nextDir = normalize(originalModuleDir + '/..'); + if (nextDir === originalModuleDir) break; + originalModuleDir = nextDir; + } + return null; +} + +function isPossibleNodeModulesPath (modulePath) { + var c0 = modulePath[0]; + if (c0 === '/' || c0 === '\\\\') return false; + var c1 = modulePath[1], c2 = modulePath[2]; + if ((c0 === '.' && (!c1 || c1 === '/' || c1 === '\\\\')) || + (c0 === '.' && c1 === '.' && (!c2 || c2 === '/' || c2 === '\\\\'))) return false; + if (c1 === ':' && (c2 === '/' || c2 === '\\\\')) return false; + return true; +} + +function normalize (path) { + path = path.replace(/\\\\/g, '/'); + var parts = path.split('/'); + var slashed = parts[0] === ''; + for (var i = 1; i < parts.length; i++) { + if (parts[i] === '.' || parts[i] === '') { + parts.splice(i--, 1); + } + } + for (var i = 1; i < parts.length; i++) { + if (parts[i] !== '..') continue; + if (i > 0 && parts[i - 1] !== '..' && parts[i - 1] !== '.') { + parts.splice(--i, 2); + i--; + } + } + path = parts.join('/'); + if (slashed && path[0] !== '/') path = '/' + path; + else if (path.length === 0) path = '.'; + return path; +} + +var main$1 = {}; + +/* eslint-disable import/no-dynamic-require, global-require */ + +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + function takeModule(withName) { + return createCommonjsRequire("/fixtures/function/dynamic-require-json")(\`./\${withName}\`); + } + + t.deepEqual(takeModule('dynamic.json'), { value: 'present' }); + t.deepEqual(takeModule('dynamic'), { value: 'present' }); + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +", +} +`; + +exports[`dynamic-require-no-fallback 1`] = ` +{ + "main.js": "'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +function commonjsRequire(path) { + throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.'); +} + +var main$1 = {}; + +/* eslint-disable import/no-dynamic-require, global-require */ + +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + function takeModule(withName) { + return commonjsRequire(withName); + } + + t.throws(() => takeModule('./dep.js'), { + message: + 'Could not dynamically require "./dep.js". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.' + }); + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +", +} +`; + +exports[`dynamic-require-package 1`] = ` +{ + "main.js": "'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var entry$2; +var hasRequiredEntry$2; + +function requireEntry$2 () { + if (hasRequiredEntry$2) return entry$2; + hasRequiredEntry$2 = 1; + entry$2 = 'same-directory'; + return entry$2; +} + +var entry$1; +var hasRequiredEntry$1; + +function requireEntry$1 () { + if (hasRequiredEntry$1) return entry$1; + hasRequiredEntry$1 = 1; + entry$1 = 'sub'; + return entry$1; +} + +var entry; +var hasRequiredEntry; + +function requireEntry () { + if (hasRequiredEntry) return entry; + hasRequiredEntry = 1; + entry = 'custom-module'; + return entry; +} + +var dynamicModules; + +function getDynamicModules() { + return dynamicModules || (dynamicModules = { + "/fixtures/function/dynamic-require-package": requireEntry$2, + "/fixtures/function/dynamic-require-package/entry.js": requireEntry$2, + "/fixtures/function/dynamic-require-package/sub": requireEntry$1, + "/fixtures/function/dynamic-require-package/sub/entry.js": requireEntry$1, + "/fixtures/function/dynamic-require-package/node_modules/custom-module": requireEntry, + "/fixtures/function/dynamic-require-package/node_modules/custom-module/entry.js": requireEntry + }); +} + +function createCommonjsRequire(originalModuleDir) { + function handleRequire(path) { + var resolvedPath = commonjsResolve(path, originalModuleDir); + if (resolvedPath !== null) { + return getDynamicModules()[resolvedPath](); + } + throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.'); + } + handleRequire.resolve = function (path) { + var resolvedPath = commonjsResolve(path, originalModuleDir); + if (resolvedPath !== null) { + return resolvedPath; + } + return require.resolve(path); + }; + return handleRequire; +} + +function commonjsResolve (path, originalModuleDir) { + var shouldTryNodeModules = isPossibleNodeModulesPath(path); + path = normalize(path); + var relPath; + if (path[0] === '/') { + originalModuleDir = ''; + } + var modules = getDynamicModules(); + var checkedExtensions = ['', '.js', '.json']; + while (true) { + if (!shouldTryNodeModules) { + relPath = normalize(originalModuleDir + '/' + path); + } else { + relPath = normalize(originalModuleDir + '/node_modules/' + path); + } + + if (relPath.endsWith('/..')) { + break; // Travelled too far up, avoid infinite loop + } + + for (var extensionIndex = 0; extensionIndex < checkedExtensions.length; extensionIndex++) { + var resolvedPath = relPath + checkedExtensions[extensionIndex]; + if (modules[resolvedPath]) { + return resolvedPath; + } + } + if (!shouldTryNodeModules) break; + var nextDir = normalize(originalModuleDir + '/..'); + if (nextDir === originalModuleDir) break; + originalModuleDir = nextDir; + } + return null; +} + +function isPossibleNodeModulesPath (modulePath) { + var c0 = modulePath[0]; + if (c0 === '/' || c0 === '\\\\') return false; + var c1 = modulePath[1], c2 = modulePath[2]; + if ((c0 === '.' && (!c1 || c1 === '/' || c1 === '\\\\')) || + (c0 === '.' && c1 === '.' && (!c2 || c2 === '/' || c2 === '\\\\'))) return false; + if (c1 === ':' && (c2 === '/' || c2 === '\\\\')) return false; + return true; +} + +function normalize (path) { + path = path.replace(/\\\\/g, '/'); + var parts = path.split('/'); + var slashed = parts[0] === ''; + for (var i = 1; i < parts.length; i++) { + if (parts[i] === '.' || parts[i] === '') { + parts.splice(i--, 1); + } + } + for (var i = 1; i < parts.length; i++) { + if (parts[i] !== '..') continue; + if (i > 0 && parts[i - 1] !== '..' && parts[i - 1] !== '.') { + parts.splice(--i, 2); + i--; + } + } + path = parts.join('/'); + if (slashed && path[0] !== '/') path = '/' + path; + else if (path.length === 0) path = '.'; + return path; +} + +var main$1 = {}; + +/* eslint-disable import/no-dynamic-require, global-require */ + +var sub; +var hasRequiredSub; + +function requireSub () { + if (hasRequiredSub) return sub; + hasRequiredSub = 1; + function takeModule(name) { + return createCommonjsRequire("/fixtures/function/dynamic-require-package/sub")(name); + } + + sub = { + parent: takeModule('..'), + customModule: takeModule('custom-module') + }; + return sub; +} + +/* eslint-disable import/no-dynamic-require, global-require */ + +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + function takeModule(name) { + return createCommonjsRequire("/fixtures/function/dynamic-require-package")(name); + } + + t.is(takeModule('.'), 'same-directory'); + t.is(takeModule('./'), 'same-directory'); + t.is(takeModule('.//'), 'same-directory'); + + t.is(takeModule('./sub'), 'sub'); + + t.is(takeModule('custom-module'), 'custom-module'); + t.deepEqual(requireSub(), { parent: 'same-directory', customModule: 'custom-module' }); + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +", +} +`; + +exports[`dynamic-require-package-sub 1`] = ` +{ + "main.js": "'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var main$1 = {}; + +var entry; +var hasRequiredEntry; + +function requireEntry () { + if (hasRequiredEntry) return entry; + hasRequiredEntry = 1; + entry = 'custom-module'; + return entry; +} + +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + t.is(requireEntry(), 'custom-module'); + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +", +} +`; + +exports[`dynamic-require-relative-paths 1`] = ` +{ + "main.js": "'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var submodule; +var hasRequiredSubmodule; + +function requireSubmodule () { + if (hasRequiredSubmodule) return submodule; + hasRequiredSubmodule = 1; + submodule = 'submodule'; + return submodule; +} + +var subsubmodule; +var hasRequiredSubsubmodule; + +function requireSubsubmodule () { + if (hasRequiredSubsubmodule) return subsubmodule; + hasRequiredSubsubmodule = 1; + subsubmodule = 'subsubmodule'; + return subsubmodule; +} + +var dynamicModules; + +function getDynamicModules() { + return dynamicModules || (dynamicModules = { + "/fixtures/function/dynamic-require-relative-paths/sub/submodule.js": requireSubmodule, + "/fixtures/function/dynamic-require-relative-paths/sub/subsub/subsubmodule.js": requireSubsubmodule + }); +} + +function createCommonjsRequire(originalModuleDir) { + function handleRequire(path) { + var resolvedPath = commonjsResolve(path, originalModuleDir); + if (resolvedPath !== null) { + return getDynamicModules()[resolvedPath](); + } + throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.'); + } + handleRequire.resolve = function (path) { + var resolvedPath = commonjsResolve(path, originalModuleDir); + if (resolvedPath !== null) { + return resolvedPath; + } + return require.resolve(path); + }; + return handleRequire; +} + +function commonjsResolve (path, originalModuleDir) { + var shouldTryNodeModules = isPossibleNodeModulesPath(path); + path = normalize(path); + var relPath; + if (path[0] === '/') { + originalModuleDir = ''; + } + var modules = getDynamicModules(); + var checkedExtensions = ['', '.js', '.json']; + while (true) { + if (!shouldTryNodeModules) { + relPath = normalize(originalModuleDir + '/' + path); + } else { + relPath = normalize(originalModuleDir + '/node_modules/' + path); + } + + if (relPath.endsWith('/..')) { + break; // Travelled too far up, avoid infinite loop + } + + for (var extensionIndex = 0; extensionIndex < checkedExtensions.length; extensionIndex++) { + var resolvedPath = relPath + checkedExtensions[extensionIndex]; + if (modules[resolvedPath]) { + return resolvedPath; + } + } + if (!shouldTryNodeModules) break; + var nextDir = normalize(originalModuleDir + '/..'); + if (nextDir === originalModuleDir) break; + originalModuleDir = nextDir; + } + return null; +} + +function isPossibleNodeModulesPath (modulePath) { + var c0 = modulePath[0]; + if (c0 === '/' || c0 === '\\\\') return false; + var c1 = modulePath[1], c2 = modulePath[2]; + if ((c0 === '.' && (!c1 || c1 === '/' || c1 === '\\\\')) || + (c0 === '.' && c1 === '.' && (!c2 || c2 === '/' || c2 === '\\\\'))) return false; + if (c1 === ':' && (c2 === '/' || c2 === '\\\\')) return false; + return true; +} + +function normalize (path) { + path = path.replace(/\\\\/g, '/'); + var parts = path.split('/'); + var slashed = parts[0] === ''; + for (var i = 1; i < parts.length; i++) { + if (parts[i] === '.' || parts[i] === '') { + parts.splice(i--, 1); + } + } + for (var i = 1; i < parts.length; i++) { + if (parts[i] !== '..') continue; + if (i > 0 && parts[i - 1] !== '..' && parts[i - 1] !== '.') { + parts.splice(--i, 2); + i--; + } + } + path = parts.join('/'); + if (slashed && path[0] !== '/') path = '/' + path; + else if (path.length === 0) path = '.'; + return path; +} + +var main$1 = {}; + +/* eslint-disable import/no-dynamic-require, global-require */ + +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + function takeModuleWithDelimiter(name, delimiter) { + return createCommonjsRequire("/fixtures/function/dynamic-require-relative-paths")(\`.\${delimiter}\${name.replace(/=/g, delimiter)}\`); + } + + t.is(takeModuleWithDelimiter('sub=submodule.js', '/'), 'submodule'); + t.is(takeModuleWithDelimiter('sub=subsub=subsubmodule.js', '/'), 'subsubmodule'); + t.is(takeModuleWithDelimiter('sub=submodule.js', '\\\\'), 'submodule'); + t.is(takeModuleWithDelimiter('sub=subsub=subsubmodule.js', '\\\\'), 'subsubmodule'); + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +", +} +`; + +exports[`dynamic-require-resolve-index 1`] = ` +{ + "main.js": "'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var dynamicRequireResolveIndex; +var hasRequiredDynamicRequireResolveIndex; + +function requireDynamicRequireResolveIndex () { + if (hasRequiredDynamicRequireResolveIndex) return dynamicRequireResolveIndex; + hasRequiredDynamicRequireResolveIndex = 1; + dynamicRequireResolveIndex = 'same-directory'; + return dynamicRequireResolveIndex; +} + +var sub$1; +var hasRequiredSub$1; + +function requireSub$1 () { + if (hasRequiredSub$1) return sub$1; + hasRequiredSub$1 = 1; + sub$1 = 'sub'; + return sub$1; +} + +var customModule; +var hasRequiredCustomModule; + +function requireCustomModule () { + if (hasRequiredCustomModule) return customModule; + hasRequiredCustomModule = 1; + customModule = 'custom-module'; + return customModule; +} + +var dynamicModules; + +function getDynamicModules() { + return dynamicModules || (dynamicModules = { + "/fixtures/function/dynamic-require-resolve-index": requireDynamicRequireResolveIndex, + "/fixtures/function/dynamic-require-resolve-index/index.js": requireDynamicRequireResolveIndex, + "/fixtures/function/dynamic-require-resolve-index/sub": requireSub$1, + "/fixtures/function/dynamic-require-resolve-index/sub/index.js": requireSub$1, + "/fixtures/function/dynamic-require-resolve-index/node_modules/custom-module": requireCustomModule, + "/fixtures/function/dynamic-require-resolve-index/node_modules/custom-module/index.js": requireCustomModule + }); +} + +function createCommonjsRequire(originalModuleDir) { + function handleRequire(path) { + var resolvedPath = commonjsResolve(path, originalModuleDir); + if (resolvedPath !== null) { + return getDynamicModules()[resolvedPath](); + } + throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.'); + } + handleRequire.resolve = function (path) { + var resolvedPath = commonjsResolve(path, originalModuleDir); + if (resolvedPath !== null) { + return resolvedPath; + } + return require.resolve(path); + }; + return handleRequire; +} + +function commonjsResolve (path, originalModuleDir) { + var shouldTryNodeModules = isPossibleNodeModulesPath(path); + path = normalize(path); + var relPath; + if (path[0] === '/') { + originalModuleDir = ''; + } + var modules = getDynamicModules(); + var checkedExtensions = ['', '.js', '.json']; + while (true) { + if (!shouldTryNodeModules) { + relPath = normalize(originalModuleDir + '/' + path); + } else { + relPath = normalize(originalModuleDir + '/node_modules/' + path); + } + + if (relPath.endsWith('/..')) { + break; // Travelled too far up, avoid infinite loop + } + + for (var extensionIndex = 0; extensionIndex < checkedExtensions.length; extensionIndex++) { + var resolvedPath = relPath + checkedExtensions[extensionIndex]; + if (modules[resolvedPath]) { + return resolvedPath; + } + } + if (!shouldTryNodeModules) break; + var nextDir = normalize(originalModuleDir + '/..'); + if (nextDir === originalModuleDir) break; + originalModuleDir = nextDir; + } + return null; +} + +function isPossibleNodeModulesPath (modulePath) { + var c0 = modulePath[0]; + if (c0 === '/' || c0 === '\\\\') return false; + var c1 = modulePath[1], c2 = modulePath[2]; + if ((c0 === '.' && (!c1 || c1 === '/' || c1 === '\\\\')) || + (c0 === '.' && c1 === '.' && (!c2 || c2 === '/' || c2 === '\\\\'))) return false; + if (c1 === ':' && (c2 === '/' || c2 === '\\\\')) return false; + return true; +} + +function normalize (path) { + path = path.replace(/\\\\/g, '/'); + var parts = path.split('/'); + var slashed = parts[0] === ''; + for (var i = 1; i < parts.length; i++) { + if (parts[i] === '.' || parts[i] === '') { + parts.splice(i--, 1); + } + } + for (var i = 1; i < parts.length; i++) { + if (parts[i] !== '..') continue; + if (i > 0 && parts[i - 1] !== '..' && parts[i - 1] !== '.') { + parts.splice(--i, 2); + i--; + } + } + path = parts.join('/'); + if (slashed && path[0] !== '/') path = '/' + path; + else if (path.length === 0) path = '.'; + return path; +} + +var main$1 = {}; + +/* eslint-disable import/no-dynamic-require, global-require */ + +var sub; +var hasRequiredSub; + +function requireSub () { + if (hasRequiredSub) return sub; + hasRequiredSub = 1; + function takeModule(name) { + return createCommonjsRequire("/fixtures/function/dynamic-require-resolve-index/sub")(name); + } + + sub = { + parent: takeModule('..'), + customModule: takeModule('custom-module') + }; + return sub; +} + +/* eslint-disable import/no-dynamic-require, global-require */ + +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + function takeModule(name) { + return createCommonjsRequire("/fixtures/function/dynamic-require-resolve-index")(name); + } + + t.is(takeModule('.'), 'same-directory'); + t.is(takeModule('./'), 'same-directory'); + t.is(takeModule('.//'), 'same-directory'); + + t.is(takeModule('./sub'), 'sub'); + + t.is(takeModule('custom-module'), 'custom-module'); + t.deepEqual(requireSub(), { parent: 'same-directory', customModule: 'custom-module' }); + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +", +} +`; + +exports[`dynamic-require-resolve-reference 1`] = ` +{ + "main.js": "'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var main$1 = {}; + +var customModule2; +var hasRequiredCustomModule2; + +function requireCustomModule2 () { + if (hasRequiredCustomModule2) return customModule2; + hasRequiredCustomModule2 = 1; + customModule2 = () => createCommonjsRequire("/fixtures/function/dynamic-require-resolve-reference/node_modules/custom-module2").resolve('custom-module'); + return customModule2; +} + +var dynamicModules; + +function getDynamicModules() { + return dynamicModules || (dynamicModules = { + "/fixtures/function/dynamic-require-resolve-reference/node_modules/custom-module": requireCustomModule, + "/fixtures/function/dynamic-require-resolve-reference/node_modules/custom-module/index.js": requireCustomModule, + "/fixtures/function/dynamic-require-resolve-reference/node_modules/custom-module2": requireCustomModule2, + "/fixtures/function/dynamic-require-resolve-reference/node_modules/custom-module2/index.js": requireCustomModule2 + }); +} + +function createCommonjsRequire(originalModuleDir) { + function handleRequire(path) { + var resolvedPath = commonjsResolve(path, originalModuleDir); + if (resolvedPath !== null) { + return getDynamicModules()[resolvedPath](); + } + throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.'); + } + handleRequire.resolve = function (path) { + var resolvedPath = commonjsResolve(path, originalModuleDir); + if (resolvedPath !== null) { + return resolvedPath; + } + return require.resolve(path); + }; + return handleRequire; +} + +function commonjsResolve (path, originalModuleDir) { + var shouldTryNodeModules = isPossibleNodeModulesPath(path); + path = normalize(path); + var relPath; + if (path[0] === '/') { + originalModuleDir = ''; + } + var modules = getDynamicModules(); + var checkedExtensions = ['', '.js', '.json']; + while (true) { + if (!shouldTryNodeModules) { + relPath = normalize(originalModuleDir + '/' + path); + } else { + relPath = normalize(originalModuleDir + '/node_modules/' + path); + } + + if (relPath.endsWith('/..')) { + break; // Travelled too far up, avoid infinite loop + } + + for (var extensionIndex = 0; extensionIndex < checkedExtensions.length; extensionIndex++) { + var resolvedPath = relPath + checkedExtensions[extensionIndex]; + if (modules[resolvedPath]) { + return resolvedPath; + } + } + if (!shouldTryNodeModules) break; + var nextDir = normalize(originalModuleDir + '/..'); + if (nextDir === originalModuleDir) break; + originalModuleDir = nextDir; + } + return null; +} + +function isPossibleNodeModulesPath (modulePath) { + var c0 = modulePath[0]; + if (c0 === '/' || c0 === '\\\\') return false; + var c1 = modulePath[1], c2 = modulePath[2]; + if ((c0 === '.' && (!c1 || c1 === '/' || c1 === '\\\\')) || + (c0 === '.' && c1 === '.' && (!c2 || c2 === '/' || c2 === '\\\\'))) return false; + if (c1 === ':' && (c2 === '/' || c2 === '\\\\')) return false; + return true; +} + +function normalize (path) { + path = path.replace(/\\\\/g, '/'); + var parts = path.split('/'); + var slashed = parts[0] === ''; + for (var i = 1; i < parts.length; i++) { + if (parts[i] === '.' || parts[i] === '') { + parts.splice(i--, 1); + } + } + for (var i = 1; i < parts.length; i++) { + if (parts[i] !== '..') continue; + if (i > 0 && parts[i - 1] !== '..' && parts[i - 1] !== '.') { + parts.splice(--i, 2); + i--; + } + } + path = parts.join('/'); + if (slashed && path[0] !== '/') path = '/' + path; + else if (path.length === 0) path = '.'; + return path; +} + +var customModule; +var hasRequiredCustomModule; + +function requireCustomModule () { + if (hasRequiredCustomModule) return customModule; + hasRequiredCustomModule = 1; + customModule = () => createCommonjsRequire("/fixtures/function/dynamic-require-resolve-reference/node_modules/custom-module").resolve('custom-module2'); + return customModule; +} + +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + t.is( + requireCustomModule()(), + '/fixtures/function/dynamic-require-resolve-reference/node_modules/custom-module2' + ); + t.is( + requireCustomModule2()(), + '/fixtures/function/dynamic-require-resolve-reference/node_modules/custom-module' + ); + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +", +} +`; + +exports[`dynamic-require-root 1`] = ` +{ + "main.js": "'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var submodule; +var hasRequiredSubmodule; + +function requireSubmodule () { + if (hasRequiredSubmodule) return submodule; + hasRequiredSubmodule = 1; + submodule = function () { + return 'Hello there'; + }; + return submodule; +} + +var dynamicModules; + +function getDynamicModules() { + return dynamicModules || (dynamicModules = { + "/submodule.js": requireSubmodule + }); +} + +function createCommonjsRequire(originalModuleDir) { + function handleRequire(path) { + var resolvedPath = commonjsResolve(path, originalModuleDir); + if (resolvedPath !== null) { + return getDynamicModules()[resolvedPath](); + } + throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.'); + } + handleRequire.resolve = function (path) { + var resolvedPath = commonjsResolve(path, originalModuleDir); + if (resolvedPath !== null) { + return resolvedPath; + } + return require.resolve(path); + }; + return handleRequire; +} + +function commonjsResolve (path, originalModuleDir) { + var shouldTryNodeModules = isPossibleNodeModulesPath(path); + path = normalize(path); + var relPath; + if (path[0] === '/') { + originalModuleDir = ''; + } + var modules = getDynamicModules(); + var checkedExtensions = ['', '.js', '.json']; + while (true) { + if (!shouldTryNodeModules) { + relPath = normalize(originalModuleDir + '/' + path); + } else { + relPath = normalize(originalModuleDir + '/node_modules/' + path); + } + + if (relPath.endsWith('/..')) { + break; // Travelled too far up, avoid infinite loop + } + + for (var extensionIndex = 0; extensionIndex < checkedExtensions.length; extensionIndex++) { + var resolvedPath = relPath + checkedExtensions[extensionIndex]; + if (modules[resolvedPath]) { + return resolvedPath; + } + } + if (!shouldTryNodeModules) break; + var nextDir = normalize(originalModuleDir + '/..'); + if (nextDir === originalModuleDir) break; + originalModuleDir = nextDir; + } + return null; +} + +function isPossibleNodeModulesPath (modulePath) { + var c0 = modulePath[0]; + if (c0 === '/' || c0 === '\\\\') return false; + var c1 = modulePath[1], c2 = modulePath[2]; + if ((c0 === '.' && (!c1 || c1 === '/' || c1 === '\\\\')) || + (c0 === '.' && c1 === '.' && (!c2 || c2 === '/' || c2 === '\\\\'))) return false; + if (c1 === ':' && (c2 === '/' || c2 === '\\\\')) return false; + return true; +} + +function normalize (path) { + path = path.replace(/\\\\/g, '/'); + var parts = path.split('/'); + var slashed = parts[0] === ''; + for (var i = 1; i < parts.length; i++) { + if (parts[i] === '.' || parts[i] === '') { + parts.splice(i--, 1); + } + } + for (var i = 1; i < parts.length; i++) { + if (parts[i] !== '..') continue; + if (i > 0 && parts[i - 1] !== '..' && parts[i - 1] !== '.') { + parts.splice(--i, 2); + i--; + } + } + path = parts.join('/'); + if (slashed && path[0] !== '/') path = '/' + path; + else if (path.length === 0) path = '.'; + return path; +} + +var main$1 = {}; + +/* eslint-disable import/no-dynamic-require, global-require */ + +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + let message; + + function takeModule(withName) { + return createCommonjsRequire("/")(\`./\${withName}\`); + } + + try { + const submodule = takeModule('submodule'); + message = submodule(); + } catch (err) { + ({ message } = err); + } + + t.is(message, 'Hello there'); + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +", +} +`; + +exports[`dynamic-require-root-circular 1`] = ` +{ + "main.js": "'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var main$1 = {}; + +var customModule = {exports: {}}; + +var circular = {}; + +var hasRequiredCircular; + +function requireCircular () { + if (hasRequiredCircular) return circular; + hasRequiredCircular = 1; + const lib = requireCustomModule(); + + circular.extend1 = function (exports) { + exports.get2 = function () { + return 'indirect ref'; + }; + }; + + circular.extend2 = function (exports) { + exports.get3 = lib.get1; + }; + return circular; +} + +customModule.exports; + +var hasRequiredCustomModule; + +function requireCustomModule () { + if (hasRequiredCustomModule) return customModule.exports; + hasRequiredCustomModule = 1; + (function (module) { + const circular = requireCircular(); + + circular.extend1(module.exports); + + module.exports.get1 = function () { + return 'all good'; + }; + + circular.extend2(module.exports); + } (customModule)); + return customModule.exports; +} + +/* eslint-disable import/no-dynamic-require, global-require */ + +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + const custom = requireCustomModule(); + + t.is(custom.get1(), 'all good'); + t.is(custom.get2(), 'indirect ref'); + t.is(custom.get3(), custom.get1()); + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +", +} +`; + +exports[`dynamic-require-slash-access 1`] = ` +{ + "main.js": "'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var dynamicRequireSlashAccess; +var hasRequiredDynamicRequireSlashAccess; + +function requireDynamicRequireSlashAccess () { + if (hasRequiredDynamicRequireSlashAccess) return dynamicRequireSlashAccess; + hasRequiredDynamicRequireSlashAccess = 1; + dynamicRequireSlashAccess = 'same-directory'; + return dynamicRequireSlashAccess; +} + +var sub$2; +var hasRequiredSub$2; + +function requireSub$2 () { + if (hasRequiredSub$2) return sub$2; + hasRequiredSub$2 = 1; + sub$2 = 'sub'; + return sub$2; +} + +var sub$1; +var hasRequiredSub$1; + +function requireSub$1 () { + if (hasRequiredSub$1) return sub$1; + hasRequiredSub$1 = 1; + sub$1 = 'sub'; + return sub$1; +} + +var customModule; +var hasRequiredCustomModule; + +function requireCustomModule () { + if (hasRequiredCustomModule) return customModule; + hasRequiredCustomModule = 1; + customModule = 'custom-module' + ' + ' + requireSub$1(); + return customModule; +} + +var dynamicModules; + +function getDynamicModules() { + return dynamicModules || (dynamicModules = { + "/fixtures/function/dynamic-require-slash-access": requireDynamicRequireSlashAccess, + "/fixtures/function/dynamic-require-slash-access/index.js": requireDynamicRequireSlashAccess, + "/fixtures/function/dynamic-require-slash-access/sub": requireSub$2, + "/fixtures/function/dynamic-require-slash-access/sub/index.js": requireSub$2, + "/fixtures/function/dynamic-require-slash-access/node_modules/custom-module": requireCustomModule, + "/fixtures/function/dynamic-require-slash-access/node_modules/custom-module/index.js": requireCustomModule, + "/fixtures/function/dynamic-require-slash-access/node_modules/custom-module2/sub.js": requireSub$1 + }); +} + +function createCommonjsRequire(originalModuleDir) { + function handleRequire(path) { + var resolvedPath = commonjsResolve(path, originalModuleDir); + if (resolvedPath !== null) { + return getDynamicModules()[resolvedPath](); + } + throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.'); + } + handleRequire.resolve = function (path) { + var resolvedPath = commonjsResolve(path, originalModuleDir); + if (resolvedPath !== null) { + return resolvedPath; + } + return require.resolve(path); + }; + return handleRequire; +} + +function commonjsResolve (path, originalModuleDir) { + var shouldTryNodeModules = isPossibleNodeModulesPath(path); + path = normalize(path); + var relPath; + if (path[0] === '/') { + originalModuleDir = ''; + } + var modules = getDynamicModules(); + var checkedExtensions = ['', '.js', '.json']; + while (true) { + if (!shouldTryNodeModules) { + relPath = normalize(originalModuleDir + '/' + path); + } else { + relPath = normalize(originalModuleDir + '/node_modules/' + path); + } + + if (relPath.endsWith('/..')) { + break; // Travelled too far up, avoid infinite loop + } + + for (var extensionIndex = 0; extensionIndex < checkedExtensions.length; extensionIndex++) { + var resolvedPath = relPath + checkedExtensions[extensionIndex]; + if (modules[resolvedPath]) { + return resolvedPath; + } + } + if (!shouldTryNodeModules) break; + var nextDir = normalize(originalModuleDir + '/..'); + if (nextDir === originalModuleDir) break; + originalModuleDir = nextDir; + } + return null; +} + +function isPossibleNodeModulesPath (modulePath) { + var c0 = modulePath[0]; + if (c0 === '/' || c0 === '\\\\') return false; + var c1 = modulePath[1], c2 = modulePath[2]; + if ((c0 === '.' && (!c1 || c1 === '/' || c1 === '\\\\')) || + (c0 === '.' && c1 === '.' && (!c2 || c2 === '/' || c2 === '\\\\'))) return false; + if (c1 === ':' && (c2 === '/' || c2 === '\\\\')) return false; + return true; +} + +function normalize (path) { + path = path.replace(/\\\\/g, '/'); + var parts = path.split('/'); + var slashed = parts[0] === ''; + for (var i = 1; i < parts.length; i++) { + if (parts[i] === '.' || parts[i] === '') { + parts.splice(i--, 1); + } + } + for (var i = 1; i < parts.length; i++) { + if (parts[i] !== '..') continue; + if (i > 0 && parts[i - 1] !== '..' && parts[i - 1] !== '.') { + parts.splice(--i, 2); + i--; + } + } + path = parts.join('/'); + if (slashed && path[0] !== '/') path = '/' + path; + else if (path.length === 0) path = '.'; + return path; +} + +var main$1 = {}; + +/* eslint-disable import/no-dynamic-require, global-require */ + +var sub; +var hasRequiredSub; + +function requireSub () { + if (hasRequiredSub) return sub; + hasRequiredSub = 1; + function takeModule(name) { + return createCommonjsRequire("/fixtures/function/dynamic-require-slash-access/sub")(name); + } + + sub = { + parent: takeModule('..'), + customModule: takeModule('custom-module') + }; + return sub; +} + +/* eslint-disable import/no-dynamic-require, global-require */ + +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + function takeModule(name) { + return createCommonjsRequire("/fixtures/function/dynamic-require-slash-access")(name); + } + + t.is(takeModule('.'), 'same-directory', '.'); + t.is(takeModule('./'), 'same-directory', './'); + t.is(takeModule('.//'), 'same-directory', './/'); + + t.is(takeModule('./sub'), 'sub', './sub'); + + t.is(takeModule('custom-module'), 'custom-module + sub', 'custom-module'); + t.deepEqual(requireSub(), { + parent: 'same-directory', + customModule: 'custom-module + sub' + }); + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +", +} +`; + +exports[`dynamic-require-targets-fallback 1`] = ` +{ + "main.js": "'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var dep1; +var hasRequiredDep1; + +function requireDep1 () { + if (hasRequiredDep1) return dep1; + hasRequiredDep1 = 1; + dep1 = 'dep'; + return dep1; +} + +var dynamicModules; + +function getDynamicModules() { + return dynamicModules || (dynamicModules = { + "/fixtures/function/dynamic-require-targets-fallback/dep1.js": requireDep1 + }); +} + +function createCommonjsRequire(originalModuleDir) { + function handleRequire(path) { + var resolvedPath = commonjsResolve(path, originalModuleDir); + if (resolvedPath !== null) { + return getDynamicModules()[resolvedPath](); + } + return require(path); + } + handleRequire.resolve = function (path) { + var resolvedPath = commonjsResolve(path, originalModuleDir); + if (resolvedPath !== null) { + return resolvedPath; + } + return require.resolve(path); + }; + return handleRequire; +} + +function commonjsResolve (path, originalModuleDir) { + var shouldTryNodeModules = isPossibleNodeModulesPath(path); + path = normalize(path); + var relPath; + if (path[0] === '/') { + originalModuleDir = ''; + } + var modules = getDynamicModules(); + var checkedExtensions = ['', '.js', '.json']; + while (true) { + if (!shouldTryNodeModules) { + relPath = normalize(originalModuleDir + '/' + path); + } else { + relPath = normalize(originalModuleDir + '/node_modules/' + path); + } + + if (relPath.endsWith('/..')) { + break; // Travelled too far up, avoid infinite loop + } + + for (var extensionIndex = 0; extensionIndex < checkedExtensions.length; extensionIndex++) { + var resolvedPath = relPath + checkedExtensions[extensionIndex]; + if (modules[resolvedPath]) { + return resolvedPath; + } + } + if (!shouldTryNodeModules) break; + var nextDir = normalize(originalModuleDir + '/..'); + if (nextDir === originalModuleDir) break; + originalModuleDir = nextDir; + } + return null; +} + +function isPossibleNodeModulesPath (modulePath) { + var c0 = modulePath[0]; + if (c0 === '/' || c0 === '\\\\') return false; + var c1 = modulePath[1], c2 = modulePath[2]; + if ((c0 === '.' && (!c1 || c1 === '/' || c1 === '\\\\')) || + (c0 === '.' && c1 === '.' && (!c2 || c2 === '/' || c2 === '\\\\'))) return false; + if (c1 === ':' && (c2 === '/' || c2 === '\\\\')) return false; + return true; +} + +function normalize (path) { + path = path.replace(/\\\\/g, '/'); + var parts = path.split('/'); + var slashed = parts[0] === ''; + for (var i = 1; i < parts.length; i++) { + if (parts[i] === '.' || parts[i] === '') { + parts.splice(i--, 1); + } + } + for (var i = 1; i < parts.length; i++) { + if (parts[i] !== '..') continue; + if (i > 0 && parts[i - 1] !== '..' && parts[i - 1] !== '.') { + parts.splice(--i, 2); + i--; + } + } + path = parts.join('/'); + if (slashed && path[0] !== '/') path = '/' + path; + else if (path.length === 0) path = '.'; + return path; +} + +var main$1 = {}; + +/* eslint-disable import/no-dynamic-require, global-require */ + +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + function takeModule(withName) { + return createCommonjsRequire("/fixtures/function/dynamic-require-targets-fallback")(withName); + } + + t.is(takeModule('./dep1.js'), 'dep'); + // The bundled code will run from test/helpers/util.js + t.is(takeModule('../fixtures/function/dynamic-require-targets-fallback/dep2.js'), 'dep'); + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +", +} +`; + +exports[`dynamic-require-targets-no-fallback 1`] = ` +{ + "main.js": "'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var dep1; +var hasRequiredDep1; + +function requireDep1 () { + if (hasRequiredDep1) return dep1; + hasRequiredDep1 = 1; + dep1 = 'dep'; + return dep1; +} + +var dynamicModules; + +function getDynamicModules() { + return dynamicModules || (dynamicModules = { + "/fixtures/function/dynamic-require-targets-no-fallback/dep1.js": requireDep1 + }); +} + +function createCommonjsRequire(originalModuleDir) { + function handleRequire(path) { + var resolvedPath = commonjsResolve(path, originalModuleDir); + if (resolvedPath !== null) { + return getDynamicModules()[resolvedPath](); + } + throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.'); + } + handleRequire.resolve = function (path) { + var resolvedPath = commonjsResolve(path, originalModuleDir); + if (resolvedPath !== null) { + return resolvedPath; + } + return require.resolve(path); + }; + return handleRequire; +} + +function commonjsResolve (path, originalModuleDir) { + var shouldTryNodeModules = isPossibleNodeModulesPath(path); + path = normalize(path); + var relPath; + if (path[0] === '/') { + originalModuleDir = ''; + } + var modules = getDynamicModules(); + var checkedExtensions = ['', '.js', '.json']; + while (true) { + if (!shouldTryNodeModules) { + relPath = normalize(originalModuleDir + '/' + path); + } else { + relPath = normalize(originalModuleDir + '/node_modules/' + path); + } + + if (relPath.endsWith('/..')) { + break; // Travelled too far up, avoid infinite loop + } + + for (var extensionIndex = 0; extensionIndex < checkedExtensions.length; extensionIndex++) { + var resolvedPath = relPath + checkedExtensions[extensionIndex]; + if (modules[resolvedPath]) { + return resolvedPath; + } + } + if (!shouldTryNodeModules) break; + var nextDir = normalize(originalModuleDir + '/..'); + if (nextDir === originalModuleDir) break; + originalModuleDir = nextDir; + } + return null; +} + +function isPossibleNodeModulesPath (modulePath) { + var c0 = modulePath[0]; + if (c0 === '/' || c0 === '\\\\') return false; + var c1 = modulePath[1], c2 = modulePath[2]; + if ((c0 === '.' && (!c1 || c1 === '/' || c1 === '\\\\')) || + (c0 === '.' && c1 === '.' && (!c2 || c2 === '/' || c2 === '\\\\'))) return false; + if (c1 === ':' && (c2 === '/' || c2 === '\\\\')) return false; + return true; +} + +function normalize (path) { + path = path.replace(/\\\\/g, '/'); + var parts = path.split('/'); + var slashed = parts[0] === ''; + for (var i = 1; i < parts.length; i++) { + if (parts[i] === '.' || parts[i] === '') { + parts.splice(i--, 1); + } + } + for (var i = 1; i < parts.length; i++) { + if (parts[i] !== '..') continue; + if (i > 0 && parts[i - 1] !== '..' && parts[i - 1] !== '.') { + parts.splice(--i, 2); + i--; + } + } + path = parts.join('/'); + if (slashed && path[0] !== '/') path = '/' + path; + else if (path.length === 0) path = '.'; + return path; +} + +var main$1 = {}; + +/* eslint-disable import/no-dynamic-require, global-require */ + +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + function takeModule(withName) { + return createCommonjsRequire("/fixtures/function/dynamic-require-targets-no-fallback")(withName); + } + + t.is(takeModule('./dep1.js'), 'dep'); + t.throws(() => takeModule('./dep2.js'), { + message: + 'Could not dynamically require "./dep2.js". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.' + }); + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +", +} +`; + +exports[`es6-export-with-global-sniffing 1`] = ` +{ + "main.js": "'use strict'; + +let root; + +if (typeof self !== 'undefined') { + root = self; +} else if (typeof window !== 'undefined') { + root = window; +} else if (typeof global !== 'undefined') { + root = global; +} else if (typeof module !== 'undefined') { + root = module; +} else { + root = Function('return this')(); // eslint-disable-line no-new-func +} + +root.pollution = 'foo'; + +const getGlobalPollution = () => 'foo'; + +// this test makes sure that "submodule" is not wrapped in commonjs + +t.is(getGlobalPollution(), global.pollution); +", +} +`; + +exports[`esm-externals-false 1`] = ` +{ + "main.js": "'use strict'; + +var require$$0 = require('external-cjs-exports'); +var require$$1 = require('external-cjs-module-exports'); +var require$$2 = require('external-esm-named'); +var require$$3 = require('external-esm-mixed'); +var require$$4 = require('external-esm-default'); + +function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } + +var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0); +var require$$1__default = /*#__PURE__*/_interopDefaultLegacy(require$$1); +var require$$2__default = /*#__PURE__*/_interopDefaultLegacy(require$$2); +var require$$3__default = /*#__PURE__*/_interopDefaultLegacy(require$$3); +var require$$4__default = /*#__PURE__*/_interopDefaultLegacy(require$$4); + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var main$1 = {}; + +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + const externalExports = require$$0__default["default"]; + const externalModuleExports = require$$1__default["default"]; + const externalNamed = require$$2__default["default"]; + const externalMixed = require$$3__default["default"]; + const externalDefault = require$$4__default["default"]; + + t.deepEqual(externalExports, { foo: 'foo' }, 'external exports'); + t.deepEqual(externalModuleExports, 'bar', 'external module exports'); + t.deepEqual(externalNamed, { foo: 'foo' }, 'external named'); + t.deepEqual(externalMixed, 'bar', 'external mixed'); + t.deepEqual(externalDefault, 'bar', 'external default'); + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +", +} +`; + +exports[`esm-externals-function 1`] = ` +{ + "main.js": "'use strict'; + +var require$$0 = require('external-cjs-exports'); +var require$$1 = require('external-cjs-module-exports'); +var require$$2 = require('external-esm-named'); +var require$$3 = require('external-esm-mixed'); +var externalEsmDefault = require('external-esm-default'); + +function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } + +function _interopNamespace(e) { + if (e && e.__esModule) return e; + var n = Object.create(null); + if (e) { + Object.keys(e).forEach(function (k) { + if (k !== 'default') { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + } + n["default"] = e; + return Object.freeze(n); +} + +var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0); +var require$$1__default = /*#__PURE__*/_interopDefaultLegacy(require$$1); +var require$$2__default = /*#__PURE__*/_interopDefaultLegacy(require$$2); +var require$$3__default = /*#__PURE__*/_interopDefaultLegacy(require$$3); +var externalEsmDefault__namespace = /*#__PURE__*/_interopNamespace(externalEsmDefault); + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +function getAugmentedNamespace(n) { + if (Object.prototype.hasOwnProperty.call(n, '__esModule')) return n; + var f = n.default; + if (typeof f == "function") { + var a = function a () { + var isInstance = false; + try { + isInstance = this instanceof a; + } catch (e) {} + if (isInstance) { + return Reflect.construct(f, arguments, this.constructor); + } + return f.apply(this, arguments); + }; + a.prototype = f.prototype; + } else a = {}; + Object.defineProperty(a, '__esModule', {value: true}); + Object.keys(n).forEach(function (k) { + var d = Object.getOwnPropertyDescriptor(n, k); + Object.defineProperty(a, k, d.get ? d : { + enumerable: true, + get: function () { + return n[k]; + } + }); + }); + return a; +} + +var main$1 = {}; + +var require$$4 = /*@__PURE__*/getAugmentedNamespace(externalEsmDefault__namespace); + +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + const externalExports = require$$0__default["default"]; + const externalModuleExports = require$$1__default["default"]; + const externalNamed = require$$2__default["default"]; + const externalMixed = require$$3__default["default"]; + const externalDefault = require$$4; + + t.deepEqual(externalExports, { foo: 'foo' }, 'external exports'); + t.deepEqual(externalModuleExports, 'bar', 'external module exports'); + t.deepEqual(externalNamed, { foo: 'foo' }, 'external named'); + t.deepEqual(externalMixed, 'bar', 'external mixed'); + t.deepEqual(externalDefault, { default: 'bar' }, 'external default'); + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +", +} +`; + +exports[`esm-externals-list 1`] = ` +{ + "main.js": "'use strict'; + +var require$$0 = require('external-cjs-exports'); +var require$$1 = require('external-cjs-module-exports'); +var require$$2 = require('external-esm-named'); +var require$$3 = require('external-esm-mixed'); +var externalEsmDefault = require('external-esm-default'); + +function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } + +function _interopNamespace(e) { + if (e && e.__esModule) return e; + var n = Object.create(null); + if (e) { + Object.keys(e).forEach(function (k) { + if (k !== 'default') { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + } + n["default"] = e; + return Object.freeze(n); +} + +var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0); +var require$$1__default = /*#__PURE__*/_interopDefaultLegacy(require$$1); +var require$$2__default = /*#__PURE__*/_interopDefaultLegacy(require$$2); +var require$$3__default = /*#__PURE__*/_interopDefaultLegacy(require$$3); +var externalEsmDefault__namespace = /*#__PURE__*/_interopNamespace(externalEsmDefault); + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +function getAugmentedNamespace(n) { + if (Object.prototype.hasOwnProperty.call(n, '__esModule')) return n; + var f = n.default; + if (typeof f == "function") { + var a = function a () { + var isInstance = false; + try { + isInstance = this instanceof a; + } catch (e) {} + if (isInstance) { + return Reflect.construct(f, arguments, this.constructor); + } + return f.apply(this, arguments); + }; + a.prototype = f.prototype; + } else a = {}; + Object.defineProperty(a, '__esModule', {value: true}); + Object.keys(n).forEach(function (k) { + var d = Object.getOwnPropertyDescriptor(n, k); + Object.defineProperty(a, k, d.get ? d : { + enumerable: true, + get: function () { + return n[k]; + } + }); + }); + return a; +} + +var main$1 = {}; + +var require$$4 = /*@__PURE__*/getAugmentedNamespace(externalEsmDefault__namespace); + +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + const externalExports = require$$0__default["default"]; + const externalModuleExports = require$$1__default["default"]; + const externalNamed = require$$2__default["default"]; + const externalMixed = require$$3__default["default"]; + const externalDefault = require$$4; + + t.deepEqual(externalExports, { foo: 'foo' }, 'external exports'); + t.deepEqual(externalModuleExports, 'bar', 'external module exports'); + t.deepEqual(externalNamed, { foo: 'foo' }, 'external named'); + t.deepEqual(externalMixed, 'bar', 'external mixed'); + t.deepEqual(externalDefault, { default: 'bar' }, 'external default'); + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +", +} +`; + +exports[`esm-externals-true 1`] = ` +{ + "main.js": "'use strict'; + +var externalEsmNamed = require('external-esm-named'); +var externalEsmMixed = require('external-esm-mixed'); +var externalEsmDefault = require('external-esm-default'); + +function _interopNamespace(e) { + if (e && e.__esModule) return e; + var n = Object.create(null); + if (e) { + Object.keys(e).forEach(function (k) { + if (k !== 'default') { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + } + n["default"] = e; + return Object.freeze(n); +} + +var externalEsmNamed__namespace = /*#__PURE__*/_interopNamespace(externalEsmNamed); +var externalEsmMixed__namespace = /*#__PURE__*/_interopNamespace(externalEsmMixed); +var externalEsmDefault__namespace = /*#__PURE__*/_interopNamespace(externalEsmDefault); + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +function getAugmentedNamespace(n) { + if (Object.prototype.hasOwnProperty.call(n, '__esModule')) return n; + var f = n.default; + if (typeof f == "function") { + var a = function a () { + var isInstance = false; + try { + isInstance = this instanceof a; + } catch (e) {} + if (isInstance) { + return Reflect.construct(f, arguments, this.constructor); + } + return f.apply(this, arguments); + }; + a.prototype = f.prototype; + } else a = {}; + Object.defineProperty(a, '__esModule', {value: true}); + Object.keys(n).forEach(function (k) { + var d = Object.getOwnPropertyDescriptor(n, k); + Object.defineProperty(a, k, d.get ? d : { + enumerable: true, + get: function () { + return n[k]; + } + }); + }); + return a; +} + +var main$1 = {}; + +var require$$0 = /*@__PURE__*/getAugmentedNamespace(externalEsmNamed__namespace); + +var require$$1 = /*@__PURE__*/getAugmentedNamespace(externalEsmMixed__namespace); + +var require$$2 = /*@__PURE__*/getAugmentedNamespace(externalEsmDefault__namespace); + +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + const externalNamed = require$$0; + const externalMixed = require$$1; + const externalDefault = require$$2; + + t.deepEqual( + externalNamed, + rollupMajor < 3 ? { foo: 'foo' } : { foo: 'foo', default: { foo: 'foo' } }, + 'external named' + ); + t.deepEqual(externalMixed, { default: 'bar', foo: 'foo' }, 'external mixed'); + t.deepEqual(externalDefault, { default: 'bar' }, 'external default'); + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +", +} +`; + +exports[`esm-externals-undefined 1`] = ` +{ + "main.js": "'use strict'; + +var require$$0 = require('external-cjs-exports'); +var require$$1 = require('external-cjs-module-exports'); +var require$$2 = require('external-esm-named'); +var require$$3 = require('external-esm-mixed'); +var require$$4 = require('external-esm-default'); + +function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } + +var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0); +var require$$1__default = /*#__PURE__*/_interopDefaultLegacy(require$$1); +var require$$2__default = /*#__PURE__*/_interopDefaultLegacy(require$$2); +var require$$3__default = /*#__PURE__*/_interopDefaultLegacy(require$$3); +var require$$4__default = /*#__PURE__*/_interopDefaultLegacy(require$$4); + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var main$1 = {}; + +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + const externalExports = require$$0__default["default"]; + const externalModuleExports = require$$1__default["default"]; + const externalNamed = require$$2__default["default"]; + const externalMixed = require$$3__default["default"]; + const externalDefault = require$$4__default["default"]; + + t.deepEqual(externalExports, { foo: 'foo' }, 'external exports'); + t.deepEqual(externalModuleExports, 'bar', 'external module exports'); + t.deepEqual(externalNamed, { foo: 'foo' }, 'external named'); + t.deepEqual(externalMixed, 'bar', 'external mixed'); + t.deepEqual(externalDefault, 'bar', 'external default'); + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +", +} +`; + +exports[`esm-import-cjs-circular-dependency 1`] = ` +{ + "main.js": "'use strict'; + +var cjs = require('cjs-circular'); + +function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } + +var cjs__default = /*#__PURE__*/_interopDefaultLegacy(cjs); + +t.is(cjs__default["default"], 'foo'); +", +} +`; + +exports[`esm-mixed-exports-function-default 1`] = ` +{ + "main.js": "'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +function getAugmentedNamespace(n) { + if (Object.prototype.hasOwnProperty.call(n, '__esModule')) return n; + var f = n.default; + if (typeof f == "function") { + var a = function a () { + var isInstance = false; + try { + isInstance = this instanceof a; + } catch (e) {} + if (isInstance) { + return Reflect.construct(f, arguments, this.constructor); + } + return f.apply(this, arguments); + }; + a.prototype = f.prototype; + } else a = {}; + Object.defineProperty(a, '__esModule', {value: true}); + Object.keys(n).forEach(function (k) { + var d = Object.getOwnPropertyDescriptor(n, k); + Object.defineProperty(a, k, d.get ? d : { + enumerable: true, + get: function () { + return n[k]; + } + }); + }); + return a; +} + +var main$1 = {}; + +function foo(...args) { + return args; +} + +const bar$1 = 'bar'; + +var esmFunction = /*#__PURE__*/Object.freeze({ + __proto__: null, + 'default': foo, + bar: bar$1 +}); + +var require$$0 = /*@__PURE__*/getAugmentedNamespace(esmFunction); + +function Foo(...args) { + this.foo = args; +} + +Foo.prototype.update = function () { + this.foo = 'updated'; +}; + +const bar = 'bar'; + +var esmConstructor = /*#__PURE__*/Object.freeze({ + __proto__: null, + 'default': Foo, + bar: bar +}); + +var require$$1 = /*@__PURE__*/getAugmentedNamespace(esmConstructor); + +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + const foo = require$$0; + const Foo = require$$1; + + t.is(foo.bar, 'bar'); + t.deepEqual(foo.default('first'), ['first']); + t.deepEqual(foo('second'), ['second']); + + t.is(Foo.bar, 'bar'); + + // eslint-disable-next-line new-cap + const newDefault = new Foo.default('third'); + t.deepEqual(newDefault.foo, ['third']); + newDefault.update(); + t.is(newDefault.foo, 'updated'); + + const newFoo = new Foo('fourth'); + t.deepEqual(newFoo.foo, ['fourth']); + newFoo.update(); + t.is(newFoo.foo, 'updated'); + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +", +} +`; + +exports[`esm-with-esmodule 1`] = ` +{ + "main.js": "'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +function getAugmentedNamespace(n) { + if (Object.prototype.hasOwnProperty.call(n, '__esModule')) return n; + var f = n.default; + if (typeof f == "function") { + var a = function a () { + var isInstance = false; + try { + isInstance = this instanceof a; + } catch (e) {} + if (isInstance) { + return Reflect.construct(f, arguments, this.constructor); + } + return f.apply(this, arguments); + }; + a.prototype = f.prototype; + } else a = {}; + Object.defineProperty(a, '__esModule', {value: true}); + Object.keys(n).forEach(function (k) { + var d = Object.getOwnPropertyDescriptor(n, k); + Object.defineProperty(a, k, d.get ? d : { + enumerable: true, + get: function () { + return n[k]; + } + }); + }); + return a; +} + +var main$1 = {}; + +const foo = 'foo'; + +const __esModule = true; + +var esm = /*#__PURE__*/Object.freeze({ + __proto__: null, + foo: foo, + __esModule: __esModule +}); + +var require$$0 = /*@__PURE__*/getAugmentedNamespace(esm); + +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + const esm = require$$0; + + t.is(esm.foo, 'foo'); + t.is(esm.__esModule, true); + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +", +} +`; + +exports[`esm-with-falsy-esmodule 1`] = ` +{ + "main.js": "'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +function getAugmentedNamespace(n) { + if (Object.prototype.hasOwnProperty.call(n, '__esModule')) return n; + var f = n.default; + if (typeof f == "function") { + var a = function a () { + var isInstance = false; + try { + isInstance = this instanceof a; + } catch (e) {} + if (isInstance) { + return Reflect.construct(f, arguments, this.constructor); + } + return f.apply(this, arguments); + }; + a.prototype = f.prototype; + } else a = {}; + Object.defineProperty(a, '__esModule', {value: true}); + Object.keys(n).forEach(function (k) { + var d = Object.getOwnPropertyDescriptor(n, k); + Object.defineProperty(a, k, d.get ? d : { + enumerable: true, + get: function () { + return n[k]; + } + }); + }); + return a; +} + +var main$1 = {}; + +const foo = 'foo'; + +let __esModule; + +var esm = /*#__PURE__*/Object.freeze({ + __proto__: null, + foo: foo, + __esModule: __esModule +}); + +var require$$0 = /*@__PURE__*/getAugmentedNamespace(esm); + +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + const esm = require$$0; + + t.is(esm.foo, 'foo'); + t.is(esm.__esModule, undefined); + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +", +} +`; + +exports[`export-default-from 1`] = ` +{ + "main.js": "'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var main$1 = {}; + +var require$$0 = 'default export'; + +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + t.is(require$$0, 'default export'); + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +", +} +`; + +exports[`exports 1`] = ` +{ + "main.js": "'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var foo = {}; + +var hasRequiredFoo; + +function requireFoo () { + if (hasRequiredFoo) return foo; + hasRequiredFoo = 1; + foo.bar = 'BAR'; + foo.baz = 'BAZ'; + return foo; +} + +var main$1; +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + const { bar } = requireFoo(); + const { baz } = requireFoo(); + + main$1 = bar + baz; + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +", +} +`; + +exports[`exports-with-reassigned-module-exports 1`] = ` +{ + "main.js": "'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var main$1 = {}; + +var dep = {exports: {}}; + +dep.exports; + +var hasRequiredDep; + +function requireDep () { + if (hasRequiredDep) return dep.exports; + hasRequiredDep = 1; + (function (module, exports) { + exports.foo = 'foo'; + module.exports = { replaced: true }; + exports.bar = 'bar'; + } (dep, dep.exports)); + return dep.exports; +} + +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + const dep = requireDep(); + + t.deepEqual(dep, { replaced: true }); + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +", +} +`; + +exports[`expose-file-type-detection 1`] = ` +{ + "main.js": "'use strict'; + +var other = require('./other-355d70ce.js'); + +var otherExports = other.requireOther(); +var foo = /*@__PURE__*/other.getDefaultExportFromCjs(otherExports); + +t.is(foo, 'foo'); +", + "other-355d70ce.js": "'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var other; +var hasRequiredOther; + +function requireOther () { + if (hasRequiredOther) return other; + hasRequiredOther = 1; + other = 'foo'; + return other; +} + +exports.getDefaultExportFromCjs = getDefaultExportFromCjs; +exports.requireOther = requireOther; +", + "other.js": "'use strict'; + +var other$1 = require('./other-355d70ce.js'); + +var otherExports = other$1.requireOther(); +var other = /*@__PURE__*/other$1.getDefaultExportFromCjs(otherExports); + +module.exports = other; +", +} +`; + +exports[`external-imports 1`] = ` +{ + "main.js": "'use strict'; + +var require$$0 = require('foo'); + +function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } + +var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0); + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var main$1; +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + const foo = require$$0__default["default"]; + + main$1 = foo; + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +", +} +`; + +exports[`fallback-no-default 1`] = ` +{ + "main.js": "'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +function getAugmentedNamespace(n) { + if (Object.prototype.hasOwnProperty.call(n, '__esModule')) return n; + var f = n.default; + if (typeof f == "function") { + var a = function a () { + var isInstance = false; + try { + isInstance = this instanceof a; + } catch (e) {} + if (isInstance) { + return Reflect.construct(f, arguments, this.constructor); + } + return f.apply(this, arguments); + }; + a.prototype = f.prototype; + } else a = {}; + Object.defineProperty(a, '__esModule', {value: true}); + Object.keys(n).forEach(function (k) { + var d = Object.getOwnPropertyDescriptor(n, k); + Object.defineProperty(a, k, d.get ? d : { + enumerable: true, + get: function () { + return n[k]; + } + }); + }); + return a; +} + +var main$1 = {}; + +/* eslint-disable */ +var one = 1; + +var two = 2; + +var foo = /*#__PURE__*/Object.freeze({ + __proto__: null, + one: one, + two: two +}); + +var require$$0 = /*@__PURE__*/getAugmentedNamespace(foo); + +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + const foo = require$$0; + + t.is(foo.one, 1); + t.is(foo.two, 2); + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +", +} +`; + +exports[`global-not-overwritten 1`] = ` +{ + "main.js": "'use strict'; + +Object.defineProperty(exports, '__esModule', { value: true }); + +var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; + +var encode = {}; + +var hasRequiredEncode; + +function requireEncode () { + if (hasRequiredEncode) return encode; + hasRequiredEncode = 1; + (function (exports) { + exports.encodeURIComponent = function () { + return encodeURIComponent(this.str); + }; + + // to ensure module is wrapped + commonjsGlobal.foo = exports; + } (encode)); + return encode; +} + +var encodeExports = requireEncode(); + +/* eslint-disable */ + +const foo = { + str: 'test string', + encodeURIComponent: encodeExports.encodeURIComponent +}; + +var encoded = foo.encodeURIComponent(); + +exports.encoded = encoded; +", +} +`; + +exports[`global-var 1`] = ` +{ + "main.js": "'use strict'; + +var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +/* eslint-disable */ + +var main$1; +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + function foo() { + const global = {}; + global.modified = true; + return global; + } + + const notGlobal = foo(); + t.truthy(notGlobal.modified); + t.truthy(!commonjsGlobal.modified); + + main$1 = {}; + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +", +} +`; + +exports[`import-esm-require-returns-default-auto 1`] = ` +{ + "main.js": "'use strict'; + +var externalEsmNamed = require('external-esm-named'); +var externalEsmMixed = require('external-esm-mixed'); +var externalEsmDefault = require('external-esm-default'); + +function _interopNamespace(e) { + if (e && e.__esModule) return e; + var n = Object.create(null); + if (e) { + Object.keys(e).forEach(function (k) { + if (k !== 'default') { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + } + n["default"] = e; + return Object.freeze(n); +} + +var externalEsmNamed__namespace = /*#__PURE__*/_interopNamespace(externalEsmNamed); +var externalEsmMixed__namespace = /*#__PURE__*/_interopNamespace(externalEsmMixed); +var externalEsmDefault__namespace = /*#__PURE__*/_interopNamespace(externalEsmDefault); + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +function getDefaultExportFromNamespaceIfNotNamed (n) { + return n && Object.prototype.hasOwnProperty.call(n, 'default') && Object.keys(n).length === 1 ? n['default'] : n; +} + +var main$1 = {}; + +var require$$0 = /*@__PURE__*/getDefaultExportFromNamespaceIfNotNamed(externalEsmNamed__namespace); + +var require$$1 = /*@__PURE__*/getDefaultExportFromNamespaceIfNotNamed(externalEsmMixed__namespace); + +var require$$2 = /*@__PURE__*/getDefaultExportFromNamespaceIfNotNamed(externalEsmDefault__namespace); + +const foo$1 = 'foo'; + +var named = /*#__PURE__*/Object.freeze({ + __proto__: null, + foo: foo$1 +}); + +const foo = 'foo'; +var mixed = 'bar'; + +var mixed$1 = /*#__PURE__*/Object.freeze({ + __proto__: null, + foo: foo, + 'default': mixed +}); + +var require$$5 = 'bar'; + +var none = {}; + +var hasRequiredNone; + +function requireNone () { + if (hasRequiredNone) return none; + hasRequiredNone = 1; + + return none; +} + +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + const externalNamed = require$$0; + const externalMixed = require$$1; + const externalDefault = require$$2; + + const namedExports = named; + const mixedExports = mixed$1; + const defaultExport = require$$5; + const noExports = requireNone(); + + t.deepEqual(namedExports, { foo: 'foo' }, 'named exports'); + t.deepEqual(mixedExports, { foo: 'foo', default: 'bar' }, 'mixed exports'); + t.deepEqual(defaultExport, 'bar', 'default export'); + t.deepEqual(noExports, {}, 'no exports'); + t.deepEqual( + externalNamed, + rollupMajor < 3 ? { foo: 'foo' } : { foo: 'foo', default: { foo: 'foo' } }, + 'external named' + ); + t.deepEqual(externalMixed, { foo: 'foo', default: 'bar' }, 'external mixed'); + t.deepEqual(externalDefault, 'bar', 'external default'); + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +", +} +`; + +exports[`import-esm-require-returns-default-false 1`] = ` +{ + "main.js": "'use strict'; + +var externalEsmNamed = require('external-esm-named'); +var externalEsmMixed = require('external-esm-mixed'); +var externalEsmDefault = require('external-esm-default'); + +function _interopNamespace(e) { + if (e && e.__esModule) return e; + var n = Object.create(null); + if (e) { + Object.keys(e).forEach(function (k) { + if (k !== 'default') { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + } + n["default"] = e; + return Object.freeze(n); +} + +var externalEsmNamed__namespace = /*#__PURE__*/_interopNamespace(externalEsmNamed); +var externalEsmMixed__namespace = /*#__PURE__*/_interopNamespace(externalEsmMixed); +var externalEsmDefault__namespace = /*#__PURE__*/_interopNamespace(externalEsmDefault); + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +function getAugmentedNamespace(n) { + if (Object.prototype.hasOwnProperty.call(n, '__esModule')) return n; + var f = n.default; + if (typeof f == "function") { + var a = function a () { + var isInstance = false; + try { + isInstance = this instanceof a; + } catch (e) {} + if (isInstance) { + return Reflect.construct(f, arguments, this.constructor); + } + return f.apply(this, arguments); + }; + a.prototype = f.prototype; + } else a = {}; + Object.defineProperty(a, '__esModule', {value: true}); + Object.keys(n).forEach(function (k) { + var d = Object.getOwnPropertyDescriptor(n, k); + Object.defineProperty(a, k, d.get ? d : { + enumerable: true, + get: function () { + return n[k]; + } + }); + }); + return a; +} + +var main$1 = {}; + +var require$$0 = /*@__PURE__*/getAugmentedNamespace(externalEsmNamed__namespace); + +var require$$1 = /*@__PURE__*/getAugmentedNamespace(externalEsmMixed__namespace); + +var require$$2 = /*@__PURE__*/getAugmentedNamespace(externalEsmDefault__namespace); + +const foo$1 = 'foo'; + +var named = /*#__PURE__*/Object.freeze({ + __proto__: null, + foo: foo$1 +}); + +var require$$3 = /*@__PURE__*/getAugmentedNamespace(named); + +const foo = 'foo'; +var mixed = 'bar'; + +var mixed$1 = /*#__PURE__*/Object.freeze({ + __proto__: null, + foo: foo, + 'default': mixed +}); + +var require$$4 = /*@__PURE__*/getAugmentedNamespace(mixed$1); + +var _default = 'bar'; + +var _default$1 = /*#__PURE__*/Object.freeze({ + __proto__: null, + 'default': _default +}); + +var require$$5 = /*@__PURE__*/getAugmentedNamespace(_default$1); + +var none = {}; + +var hasRequiredNone; + +function requireNone () { + if (hasRequiredNone) return none; + hasRequiredNone = 1; + + return none; +} + +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + const externalNamed = require$$0; + const externalMixed = require$$1; + const externalDefault = require$$2; + + const namedExports = require$$3; + const mixedExports = require$$4; + const defaultExport = require$$5; + const noExports = requireNone(); + + t.deepEqual(namedExports, { foo: 'foo' }, 'named exports'); + t.deepEqual(mixedExports, { foo: 'foo', default: 'bar' }, 'mixed exports'); + t.deepEqual(defaultExport, { default: 'bar' }, 'default export'); + t.deepEqual(noExports, {}, 'no exports'); + t.deepEqual( + externalNamed, + rollupMajor < 3 ? { foo: 'foo' } : { foo: 'foo', default: { foo: 'foo' } }, + 'external named' + ); + t.deepEqual(externalMixed, { foo: 'foo', default: 'bar' }, 'external mixed'); + t.deepEqual(externalDefault, { default: 'bar' }, 'external default'); + + /* eslint-disable no-prototype-builtins */ + t.is(namedExports.hasOwnProperty('foo'), true); + t.is(mixedExports.hasOwnProperty('foo'), true); + t.is(defaultExport.hasOwnProperty('foo'), false); + t.is(externalNamed.hasOwnProperty('foo'), true); + t.is(externalMixed.hasOwnProperty('foo'), true); + t.is(externalDefault.hasOwnProperty('foo'), false); + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +", +} +`; + +exports[`import-esm-require-returns-default-function 1`] = ` +{ + "main.js": "'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +function getAugmentedNamespace(n) { + if (Object.prototype.hasOwnProperty.call(n, '__esModule')) return n; + var f = n.default; + if (typeof f == "function") { + var a = function a () { + var isInstance = false; + try { + isInstance = this instanceof a; + } catch (e) {} + if (isInstance) { + return Reflect.construct(f, arguments, this.constructor); + } + return f.apply(this, arguments); + }; + a.prototype = f.prototype; + } else a = {}; + Object.defineProperty(a, '__esModule', {value: true}); + Object.keys(n).forEach(function (k) { + var d = Object.getOwnPropertyDescriptor(n, k); + Object.defineProperty(a, k, d.get ? d : { + enumerable: true, + get: function () { + return n[k]; + } + }); + }); + return a; +} + +var main$1 = {}; + +var dep_false_default_ = 'default'; + +var dep_false_default_$1 = /*#__PURE__*/Object.freeze({ + __proto__: null, + 'default': dep_false_default_ +}); + +var require$$0 = /*@__PURE__*/getAugmentedNamespace(dep_false_default_$1); + +var dep_false_mixed_ = 'default'; const named$4 = 'named'; + +var dep_false_mixed_$1 = /*#__PURE__*/Object.freeze({ + __proto__: null, + 'default': dep_false_mixed_, + named: named$4 +}); + +var require$$1 = /*@__PURE__*/getAugmentedNamespace(dep_false_mixed_$1); + +const named$3 = 'named'; + +var dep_false_named_ = /*#__PURE__*/Object.freeze({ + __proto__: null, + named: named$3 +}); + +var require$$2 = /*@__PURE__*/getAugmentedNamespace(dep_false_named_); + +var require$$3 = 'default'; + +var dep_auto_mixed_ = 'default'; const named$2 = 'named'; + +var dep_auto_mixed_$1 = /*#__PURE__*/Object.freeze({ + __proto__: null, + 'default': dep_auto_mixed_, + named: named$2 +}); + +const named$1 = 'named'; + +var dep_auto_named_ = /*#__PURE__*/Object.freeze({ + __proto__: null, + named: named$1 +}); + +var require$$6 = 'default'; + +var require$$7 = 'default'; + +const named = 'named'; + +var dep_preferred_named_ = /*#__PURE__*/Object.freeze({ + __proto__: null, + named: named +}); + +var require$$9 = 'default'; + +var require$$10 = 'default'; + +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + const falseDefault = require$$0; + const falseMixed = require$$1; + const falseNamed = require$$2; + + const autoDefault = require$$3; + const autoMixed = dep_auto_mixed_$1; + const autoNamed = dep_auto_named_; + + const preferredDefault = require$$6; + const preferredMixed = require$$7; + const preferredNamed = dep_preferred_named_; + + const trueDefault = require$$9; + const trueMixed = require$$10; + + t.deepEqual(falseDefault, { default: 'default' }, 'false default'); + t.deepEqual(falseMixed, { default: 'default', named: 'named' }, 'false mixed'); + t.deepEqual(falseNamed, { named: 'named' }, 'false named'); + + t.deepEqual(autoDefault, 'default', 'auto default'); + t.deepEqual(autoMixed, { default: 'default', named: 'named' }, 'auto mixed'); + t.deepEqual(autoNamed, { named: 'named' }, 'auto named'); + + t.deepEqual(preferredDefault, 'default', 'preferred default'); + t.deepEqual(preferredMixed, 'default', 'preferred mixed'); + t.deepEqual(preferredNamed, { named: 'named' }, 'preferred named'); + + t.deepEqual(trueDefault, 'default', 'true default'); + t.deepEqual(trueMixed, 'default', 'true mixed'); + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +", +} +`; + +exports[`import-esm-require-returns-default-function-called-once 1`] = ` +{ + "main.js": "'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var main$1 = {}; + +var other = {}; + +var require$$0 = 'other.js'; + +var require$$2 = 'both.js'; + +var hasRequiredOther; + +function requireOther () { + if (hasRequiredOther) return other; + hasRequiredOther = 1; + const other$1 = require$$0; + const both = require$$2; + + t.deepEqual(other$1, 'other.js', 'other other'); + t.deepEqual(both, 'both.js', 'other both'); + return other; +} + +var require$$1 = 'main.js'; + +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + requireOther(); + + const main = require$$1; + const both = require$$2; + + t.deepEqual(main, 'main.js', 'main main'); + t.deepEqual(both, 'both.js', 'main both'); + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +", +} +`; + +exports[`import-esm-require-returns-default-function-external 1`] = ` +{ + "main.js": "'use strict'; + +var externalEsmNamed = require('external-esm-named'); +var require$$1 = require('external-esm-mixed'); +var externalEsmDefault = require('external-esm-default'); + +function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } + +function _interopNamespace(e) { + if (e && e.__esModule) return e; + var n = Object.create(null); + if (e) { + Object.keys(e).forEach(function (k) { + if (k !== 'default') { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + } + n["default"] = e; + return Object.freeze(n); +} + +var externalEsmNamed__namespace = /*#__PURE__*/_interopNamespace(externalEsmNamed); +var require$$1__default = /*#__PURE__*/_interopDefaultLegacy(require$$1); +var externalEsmDefault__namespace = /*#__PURE__*/_interopNamespace(externalEsmDefault); + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +function getDefaultExportFromNamespaceIfNotNamed (n) { + return n && Object.prototype.hasOwnProperty.call(n, 'default') && Object.keys(n).length === 1 ? n['default'] : n; +} + +function getAugmentedNamespace(n) { + if (Object.prototype.hasOwnProperty.call(n, '__esModule')) return n; + var f = n.default; + if (typeof f == "function") { + var a = function a () { + var isInstance = false; + try { + isInstance = this instanceof a; + } catch (e) {} + if (isInstance) { + return Reflect.construct(f, arguments, this.constructor); + } + return f.apply(this, arguments); + }; + a.prototype = f.prototype; + } else a = {}; + Object.defineProperty(a, '__esModule', {value: true}); + Object.keys(n).forEach(function (k) { + var d = Object.getOwnPropertyDescriptor(n, k); + Object.defineProperty(a, k, d.get ? d : { + enumerable: true, + get: function () { + return n[k]; + } + }); + }); + return a; +} + +var main$1 = {}; + +var require$$0 = /*@__PURE__*/getDefaultExportFromNamespaceIfNotNamed(externalEsmNamed__namespace); + +var require$$2 = /*@__PURE__*/getAugmentedNamespace(externalEsmDefault__namespace); + +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + const externalNamed = require$$0; + const externalMixed = require$$1__default["default"]; + const externalDefault = require$$2; + + t.deepEqual( + externalNamed, + rollupMajor < 3 ? { foo: 'foo' } : { foo: 'foo', default: { foo: 'foo' } }, + 'named' + ); + t.deepEqual(externalMixed, 'bar', 'mixed'); + t.deepEqual(externalDefault, { default: 'bar' }, 'default'); + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +", +} +`; + +exports[`import-esm-require-returns-default-namespace 1`] = ` +{ + "main.js": "'use strict'; + +var externalEsmNamed = require('external-esm-named'); +var externalEsmMixed = require('external-esm-mixed'); +var externalEsmDefault = require('external-esm-default'); + +function _interopNamespace(e) { + if (e && e.__esModule) return e; + var n = Object.create(null); + if (e) { + Object.keys(e).forEach(function (k) { + if (k !== 'default') { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + } + n["default"] = e; + return Object.freeze(n); +} + +var externalEsmNamed__namespace = /*#__PURE__*/_interopNamespace(externalEsmNamed); +var externalEsmMixed__namespace = /*#__PURE__*/_interopNamespace(externalEsmMixed); +var externalEsmDefault__namespace = /*#__PURE__*/_interopNamespace(externalEsmDefault); + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var main$1 = {}; + +const foo$1 = 'foo'; + +var named = /*#__PURE__*/Object.freeze({ + __proto__: null, + foo: foo$1 +}); + +const foo = 'foo'; +var mixed = 'bar'; + +var mixed$1 = /*#__PURE__*/Object.freeze({ + __proto__: null, + foo: foo, + 'default': mixed +}); + +var _default = 'bar'; + +var _default$1 = /*#__PURE__*/Object.freeze({ + __proto__: null, + 'default': _default +}); + +var none = {}; + +var hasRequiredNone; + +function requireNone () { + if (hasRequiredNone) return none; + hasRequiredNone = 1; + + return none; +} + +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + const externalNamed = externalEsmNamed__namespace; + const externalMixed = externalEsmMixed__namespace; + const externalDefault = externalEsmDefault__namespace; + + const namedExports = named; + const mixedExports = mixed$1; + const defaultExport = _default$1; + const noExports = requireNone(); + + t.deepEqual(namedExports, { foo: 'foo' }, 'named exports'); + t.deepEqual(mixedExports, { foo: 'foo', default: 'bar' }, 'mixed exports'); + t.deepEqual(defaultExport, { default: 'bar' }, 'default export'); + t.deepEqual(noExports, {}, 'no exports'); + t.deepEqual( + externalNamed, + rollupMajor < 3 ? { foo: 'foo' } : { foo: 'foo', default: { foo: 'foo' } }, + 'external named' + ); + t.deepEqual(externalMixed, { foo: 'foo', default: 'bar' }, 'external mixed'); + t.deepEqual(externalDefault, { default: 'bar' }, 'external default'); + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +", +} +`; + +exports[`import-esm-require-returns-default-preferred 1`] = ` +{ + "main.js": "'use strict'; + +var externalEsmNamed = require('external-esm-named'); +var externalEsmMixed = require('external-esm-mixed'); +var externalEsmDefault = require('external-esm-default'); + +function _interopNamespace(e) { + if (e && e.__esModule) return e; + var n = Object.create(null); + if (e) { + Object.keys(e).forEach(function (k) { + if (k !== 'default') { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + } + n["default"] = e; + return Object.freeze(n); +} + +var externalEsmNamed__namespace = /*#__PURE__*/_interopNamespace(externalEsmNamed); +var externalEsmMixed__namespace = /*#__PURE__*/_interopNamespace(externalEsmMixed); +var externalEsmDefault__namespace = /*#__PURE__*/_interopNamespace(externalEsmDefault); + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +function getDefaultExportFromNamespaceIfPresent (n) { + return n && Object.prototype.hasOwnProperty.call(n, 'default') ? n['default'] : n; +} + +var main$1 = {}; + +var require$$0 = /*@__PURE__*/getDefaultExportFromNamespaceIfPresent(externalEsmNamed__namespace); + +var require$$1 = /*@__PURE__*/getDefaultExportFromNamespaceIfPresent(externalEsmMixed__namespace); + +var require$$2 = /*@__PURE__*/getDefaultExportFromNamespaceIfPresent(externalEsmDefault__namespace); + +const foo = 'foo'; + +var named = /*#__PURE__*/Object.freeze({ + __proto__: null, + foo: foo +}); + +var require$$4 = 'bar'; + +var require$$5 = 'bar'; + +var none = {}; + +var hasRequiredNone; + +function requireNone () { + if (hasRequiredNone) return none; + hasRequiredNone = 1; + + return none; +} + +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + const externalNamed = require$$0; + const externalMixed = require$$1; + const externalDefault = require$$2; + + const namedExports = named; + const mixedExports = require$$4; + const defaultExport = require$$5; + const noExports = requireNone(); + + t.deepEqual(namedExports, { foo: 'foo' }, 'named exports'); + t.deepEqual(mixedExports, 'bar', 'mixed exports'); + t.deepEqual(defaultExport, 'bar', 'default export'); + t.deepEqual(noExports, {}, 'no exports'); + t.deepEqual(externalNamed, { foo: 'foo' }, 'external named'); + t.deepEqual(externalMixed, 'bar', 'external mixed'); + t.deepEqual(externalDefault, 'bar', 'external default'); + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +", +} +`; + +exports[`import-esm-require-returns-default-true 1`] = ` +{ + "main.js": "'use strict'; + +var require$$0 = require('external-esm-named'); +var require$$1 = require('external-esm-mixed'); +var require$$2 = require('external-esm-default'); + +function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } + +var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0); +var require$$1__default = /*#__PURE__*/_interopDefaultLegacy(require$$1); +var require$$2__default = /*#__PURE__*/_interopDefaultLegacy(require$$2); + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var main$1 = {}; + +var require$$3 = 'bar'; + +var require$$4 = 'bar'; + +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + const externalNamed = require$$0__default["default"]; + const externalMixed = require$$1__default["default"]; + const externalDefault = require$$2__default["default"]; + + const mixedExports = require$$3; + const defaultExport = require$$4; + + t.deepEqual(mixedExports, 'bar', 'mixed exports'); + t.deepEqual(defaultExport, 'bar', 'default export'); + t.deepEqual(externalNamed, { foo: 'foo' }, 'external named'); + t.deepEqual(externalMixed, 'bar', 'external mixed'); + t.deepEqual(externalDefault, 'bar', 'external default'); + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +", +} +`; + +exports[`import-esm-require-returns-default-undefined 1`] = ` +{ + "main.js": "'use strict'; + +var externalEsmNamed = require('external-esm-named'); +var externalEsmMixed = require('external-esm-mixed'); +var externalEsmDefault = require('external-esm-default'); + +function _interopNamespace(e) { + if (e && e.__esModule) return e; + var n = Object.create(null); + if (e) { + Object.keys(e).forEach(function (k) { + if (k !== 'default') { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + } + n["default"] = e; + return Object.freeze(n); +} + +var externalEsmNamed__namespace = /*#__PURE__*/_interopNamespace(externalEsmNamed); +var externalEsmMixed__namespace = /*#__PURE__*/_interopNamespace(externalEsmMixed); +var externalEsmDefault__namespace = /*#__PURE__*/_interopNamespace(externalEsmDefault); + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +function getAugmentedNamespace(n) { + if (Object.prototype.hasOwnProperty.call(n, '__esModule')) return n; + var f = n.default; + if (typeof f == "function") { + var a = function a () { + var isInstance = false; + try { + isInstance = this instanceof a; + } catch (e) {} + if (isInstance) { + return Reflect.construct(f, arguments, this.constructor); + } + return f.apply(this, arguments); + }; + a.prototype = f.prototype; + } else a = {}; + Object.defineProperty(a, '__esModule', {value: true}); + Object.keys(n).forEach(function (k) { + var d = Object.getOwnPropertyDescriptor(n, k); + Object.defineProperty(a, k, d.get ? d : { + enumerable: true, + get: function () { + return n[k]; + } + }); + }); + return a; +} + +var main$1 = {}; + +var require$$0 = /*@__PURE__*/getAugmentedNamespace(externalEsmNamed__namespace); + +var require$$1 = /*@__PURE__*/getAugmentedNamespace(externalEsmMixed__namespace); + +var require$$2 = /*@__PURE__*/getAugmentedNamespace(externalEsmDefault__namespace); + +const foo$1 = 'foo'; + +var named = /*#__PURE__*/Object.freeze({ + __proto__: null, + foo: foo$1 +}); + +var require$$3 = /*@__PURE__*/getAugmentedNamespace(named); + +const foo = 'foo'; +var mixed = 'bar'; + +var mixed$1 = /*#__PURE__*/Object.freeze({ + __proto__: null, + foo: foo, + 'default': mixed +}); + +var require$$4 = /*@__PURE__*/getAugmentedNamespace(mixed$1); + +var _default = 'bar'; + +var _default$1 = /*#__PURE__*/Object.freeze({ + __proto__: null, + 'default': _default +}); + +var require$$5 = /*@__PURE__*/getAugmentedNamespace(_default$1); + +var none = {}; + +var hasRequiredNone; + +function requireNone () { + if (hasRequiredNone) return none; + hasRequiredNone = 1; + + return none; +} + +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + const externalNamed = require$$0; + const externalMixed = require$$1; + const externalDefault = require$$2; + + const namedExports = require$$3; + const mixedExports = require$$4; + const defaultExport = require$$5; + const noExports = requireNone(); + + t.deepEqual(namedExports, { foo: 'foo' }, 'named exports'); + t.deepEqual(mixedExports, { foo: 'foo', default: 'bar' }, 'mixed exports'); + t.deepEqual(defaultExport, { default: 'bar' }, 'default export'); + t.deepEqual(noExports, {}, 'no exports'); + t.deepEqual( + externalNamed, + rollupMajor < 3 ? { foo: 'foo' } : { foo: 'foo', default: { foo: 'foo' } }, + 'external named' + ); + t.deepEqual(externalMixed, { foo: 'foo', default: 'bar' }, 'external mixed'); + t.deepEqual(externalDefault, { default: 'bar' }, 'external default'); + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +", +} +`; + +exports[`import-esm-with-interop 1`] = ` +{ + "main.js": "'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +function getAugmentedNamespace(n) { + if (Object.prototype.hasOwnProperty.call(n, '__esModule')) return n; + var f = n.default; + if (typeof f == "function") { + var a = function a () { + var isInstance = false; + try { + isInstance = this instanceof a; + } catch (e) {} + if (isInstance) { + return Reflect.construct(f, arguments, this.constructor); + } + return f.apply(this, arguments); + }; + a.prototype = f.prototype; + } else a = {}; + Object.defineProperty(a, '__esModule', {value: true}); + Object.keys(n).forEach(function (k) { + var d = Object.getOwnPropertyDescriptor(n, k); + Object.defineProperty(a, k, d.get ? d : { + enumerable: true, + get: function () { + return n[k]; + } + }); + }); + return a; +} + +var main$1 = {}; + +/* eslint-disable import/no-mutable-exports */ +let foo = 'foo'; +let bar = 'bar'; + +function update(newFoo, newBar) { + foo = newFoo; + bar = newBar; +} + +var lib = /*#__PURE__*/Object.freeze({ + __proto__: null, + get default () { return foo; }, + get bar () { return bar; }, + update: update +}); + +var require$$0 = /*@__PURE__*/getAugmentedNamespace(lib); + +/* eslint-disable */ + +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + var lib = require$$0; + + function _interopDefault(e) { + return e && e.__esModule ? e : { default: e }; + } + + var lib__default = /*#__PURE__*/_interopDefault(lib); + t.is(lib__default['default'], 'foo'); + t.is(lib.bar, 'bar'); + + lib.update('newFoo', 'newBar'); + t.is(lib__default['default'], 'newFoo'); + t.is(lib.bar, 'newBar'); + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +", +} +`; + +exports[`indent-multiline-strings 1`] = ` +{ + "main.js": "'use strict'; + +var dep = {}; + +var hasRequiredDep; + +function requireDep () { + if (hasRequiredDep) return dep; + hasRequiredDep = 1; + requireMain(); + + dep.value = \` +dep +multi +line +string +\`; + return dep; +} + +var main$1; +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + requireDep(); + + main$1 = \` +main +multi +line +string +\`; + return main$1; +} + +var mainExports = requireMain(); +var main = mainExports.default; + +module.exports = main; +", +} +`; + +exports[`index 1`] = ` +{ + "main.js": "'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var main$1 = {}; + +var foo; +var hasRequiredFoo; + +function requireFoo () { + if (hasRequiredFoo) return foo; + hasRequiredFoo = 1; + foo = 42; + return foo; +} + +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + const foo = requireFoo(); + + t.is(foo, 42); + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +", +} +`; + +exports[`inline 1`] = ` +{ + "main.js": "'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var multiply; +var hasRequiredMultiply; + +function requireMultiply () { + if (hasRequiredMultiply) return multiply; + hasRequiredMultiply = 1; + multiply = function (a, b) { + return a * b; + }; + return multiply; +} + +var foo; +var hasRequiredFoo; + +function requireFoo () { + if (hasRequiredFoo) return foo; + hasRequiredFoo = 1; + foo = 1; + return foo; +} + +/* eslint-disable global-require */ + +var main$1; +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + main$1 = function () { + return requireMultiply()(2, requireFoo()); + }; + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +", +} +`; + +exports[`interop-esmodule-wrapped 1`] = ` +{ + "main.js": "'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var other = {exports: {}}; + +other.exports; + +var hasRequiredOther; + +function requireOther () { + if (hasRequiredOther) return other.exports; + hasRequiredOther = 1; + (function (module, exports) { + exports.default = 42; + + addCompiledMarker(module.exports); + + function addCompiledMarker(exports) { + // eslint-disable-next-line no-param-reassign + exports.__esModule = true; + } + } (other, other.exports)); + return other.exports; +} + +var otherExports = requireOther(); +var foo = /*@__PURE__*/getDefaultExportFromCjs(otherExports); + +t.deepEqual(foo, 42); +", +} +`; + +exports[`interop-no-esmodule-wrapped 1`] = ` +{ + "main.js": "'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var other = {exports: {}}; + +other.exports; + +var hasRequiredOther; + +function requireOther () { + if (hasRequiredOther) return other.exports; + hasRequiredOther = 1; + (function (module) { + addDefaultExport(module.exports); + + function addDefaultExport(exports) { + // eslint-disable-next-line no-param-reassign + exports.default = 42; + } + } (other)); + return other.exports; +} + +var otherExports = requireOther(); +var foo = /*@__PURE__*/getDefaultExportFromCjs(otherExports); + +t.deepEqual(foo, { default: 42 }); +", +} +`; + +exports[`interop-without-default-unwrapped 1`] = ` +{ + "main.js": "'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var other = {}; + +var hasRequiredOther; + +function requireOther () { + if (hasRequiredOther) return other; + hasRequiredOther = 1; + other.foo = '__esModule'; + return other; +} + +var otherExports = requireOther(); +var foo = /*@__PURE__*/getDefaultExportFromCjs(otherExports); + +t.deepEqual(foo, { foo: '__esModule' }); +", +} +`; + +exports[`late-entry-dependency 1`] = ` +{ + "main.js": "'use strict'; + +var other = require('./other2.js'); + +var main$1 = {}; + +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + const foo = other.requireOther(); + + t.is(foo, 'foo'); + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/other.getDefaultExportFromCjs(mainExports); + +module.exports = main; +", + "other.js": "'use strict'; + +var other$1 = require('./other2.js'); + +var otherExports = other$1.requireOther(); +var other = /*@__PURE__*/other$1.getDefaultExportFromCjs(otherExports); + +module.exports = other; +", + "other2.js": "'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var other; +var hasRequiredOther; + +function requireOther () { + if (hasRequiredOther) return other; + hasRequiredOther = 1; + other = 'foo'; + return other; +} + +exports.getDefaultExportFromCjs = getDefaultExportFromCjs; +exports.requireOther = requireOther; +", +} +`; + +exports[`leading-comment 1`] = ` +{ + "main.js": "'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +/* + * This comment could be really important and should not be removed + */ + +var main$1; +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + + main$1 = 'bar'; + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +", +} +`; + +exports[`leading-comment-imports 1`] = ` +{ + "main.js": "'use strict'; + +var require$$0 = require('external-cjs-exports'); + +function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } + +var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0); + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var main$1 = {}; + +/* + * This comment could be really important and should not be removed + */ + +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + + const externalExports = require$$0__default["default"]; + + t.is(externalExports.foo, 'foo'); + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +", +} +`; + +exports[`leading-comment-wrapped 1`] = ` +{ + "main.js": "'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var main$1 = {}; + +/* + * This comment could be really important and should not be removed + */ + +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + (function (exports) { + + modifyExports(exports); + + function modifyExports(exported) { + // eslint-disable-next-line no-param-reassign + exported.foo = 'bar'; + } + } (main$1)); + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +", +} +`; + +exports[`load-cycle-parallel 1`] = ` +{ + "main.js": "'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var main$1 = {}; + +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +", +} +`; + +exports[`module_require 1`] = ` +{ + "main.js": "'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var foo; +var hasRequiredFoo; + +function requireFoo () { + if (hasRequiredFoo) return foo; + hasRequiredFoo = 1; + foo = 21; + return foo; +} + +var main$1; +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + const foo = requireFoo(); + + main$1 = foo * 2; + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +", +} +`; + +exports[`module-meta-properties 1`] = ` +{ + "main.js": "'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var main$1 = {}; + +var dep = {}; + +var hasRequiredDep; + +function requireDep () { + if (hasRequiredDep) return dep; + hasRequiredDep = 1; + dep.foo = 'foo'; + return dep; +} + +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + const dep = requireDep(); + + t.is(dep.foo, 'foo'); + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +", +} +`; + +exports[`module-side-effects-external-node-builtin-wrapped 1`] = ` +{ + "main.js": "'use strict'; + +var node_module = require('node:module'); + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +node_module.createRequire((typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('main.js', document.baseURI).href))); + +var main$1; +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + + main$1 = 1; + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +", +} +`; + +exports[`module-side-effects-external-node-builtin-wrapped-default 1`] = ` +{ + "main.js": "'use strict'; + +require('node:crypto'); + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var main$1; +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + + main$1 = 1; + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +", +} +`; + +exports[`module-side-effects-import-wrapped 1`] = ` +{ + "main.js": "'use strict'; + +var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; + +var bar = {}; + +var hasRequiredBar; + +function requireBar () { + if (hasRequiredBar) return bar; + hasRequiredBar = 1; + commonjsGlobal.bar = 'bar'; + return bar; +} + +requireBar(); +", +} +`; + +exports[`module-side-effects-late-entry 1`] = ` +{ + "generated-foo.js": "'use strict'; + +var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; + +// This side-effect will only be respected if this is an entry point +commonjsGlobal.foo = 'foo'; +", + "generated-foo2.js": "'use strict'; + +require('./generated-foo.js'); + +var foo = {}; + +module.exports = foo; +", + "main.js": "'use strict'; + +require('./generated-foo.js'); + +var main = 'main'; + +module.exports = main; +", +} +`; + +exports[`module-side-effects-late-entry-strict 1`] = ` +{ + "generated-foo.js": "'use strict'; + +var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var foo$1 = {}; + +var hasRequiredFoo; + +function requireFoo () { + if (hasRequiredFoo) return foo$1; + hasRequiredFoo = 1; + // This side-effect will only be respected if this is an entry point + commonjsGlobal.foo = 'foo'; + return foo$1; +} + +var fooExports = requireFoo(); +var foo = /*@__PURE__*/getDefaultExportFromCjs(fooExports); + +module.exports = foo; +", + "main.js": "'use strict'; + +var main = 'main'; + +module.exports = main; +", +} +`; + +exports[`module-side-effects-require-wrapped 1`] = ` +{ + "main.js": "'use strict'; + +var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var main$1 = {}; + +var bar = {}; + +var hasRequiredBar; + +function requireBar () { + if (hasRequiredBar) return bar; + hasRequiredBar = 1; + commonjsGlobal.bar = 'bar'; + return bar; +} + +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + requireBar(); + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +", +} +`; + +exports[`multiple-define-compiled-esm 1`] = ` +{ + "main.js": "'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var foo$1 = {}; + +var hasRequiredFoo; + +function requireFoo () { + if (hasRequiredFoo) return foo$1; + hasRequiredFoo = 1; + Object.defineProperty(foo$1, '__esModule', { value: true }); + + Object.defineProperty(foo$1, '__esModule', { value: true }); + + foo$1.default = 'foo'; + return foo$1; +} + +var fooExports = requireFoo(); +var foo = /*@__PURE__*/getDefaultExportFromCjs(fooExports); + +t.deepEqual(foo, 'foo'); +", +} +`; + +exports[`named-exports 1`] = ` +{ + "main.js": "'use strict'; + +var foo = {}; + +var hasRequiredFoo; + +function requireFoo () { + if (hasRequiredFoo) return foo; + hasRequiredFoo = 1; + foo.a = 1; + foo.b = 2; + return foo; +} + +var fooExports = requireFoo(); + +t.is(fooExports.a, 1); +t.is(fooExports.b, 2); +", +} +`; + +exports[`named-exports-conditional 1`] = ` +{ + "main.js": "'use strict'; + +var x = {exports: {}}; + +var hasRequiredX; + +function requireX () { + if (hasRequiredX) return x.exports; + hasRequiredX = 1; + if (typeof someUnknownGlobal !== 'undefined') { + x.exports = { named: 'bar' }; + } else { + x.exports = { named: 'foo' }; + } + return x.exports; +} + +var xExports = requireX(); + +t.is(xExports.named, 'foo'); +", +} +`; + +exports[`named-exports-dynamic 1`] = ` +{ + "main.js": "'use strict'; + +var x = {exports: {}}; + +x.exports; + +var hasRequiredX; + +function requireX () { + if (hasRequiredX) return x.exports; + hasRequiredX = 1; + (function (module) { + window.addExport = (key, value) => { + module.exports[key] = value; + }; + } (x)); + return x.exports; +} + +var xExports = requireX(); + +t.is(xExports.named, undefined); + +window.addExport('named', 'foo'); + +t.is(xExports.named, 'foo'); +", +} +`; + +exports[`named-exports-object-define 1`] = ` +{ + "main.js": "'use strict'; + +var x = {exports: {}}; + +x.exports; + +var hasRequiredX; + +function requireX () { + if (hasRequiredX) return x.exports; + hasRequiredX = 1; + (function (module) { + Object.defineProperty(module.exports, 'named', { + enumerable: true, + get: function get() { + return 'foo'; + } + }); + } (x)); + return x.exports; +} + +var xExports = requireX(); + +t.is(xExports.named, 'foo'); +", +} +`; + +exports[`named-exports-reexport-default 1`] = ` +{ + "main.js": "'use strict'; + +var _export = {}; + +var hasRequired_export; + +function require_export () { + if (hasRequired_export) return _export; + hasRequired_export = 1; + _export.named = 2; + return _export; +} + +var reexport; +var hasRequiredReexport; + +function requireReexport () { + if (hasRequiredReexport) return reexport; + hasRequiredReexport = 1; + reexport = require_export(); + return reexport; +} + +var reexportExports = requireReexport(); + +t.is(reexportExports.named, 2); +", +} +`; + +exports[`named-exports-reexport-named 1`] = ` +{ + "main.js": "'use strict'; + +var reexport = {}; + +var _export = {}; + +var hasRequired_export; + +function require_export () { + if (hasRequired_export) return _export; + hasRequired_export = 1; + _export.named = 2; + return _export; +} + +var hasRequiredReexport; + +function requireReexport () { + if (hasRequiredReexport) return reexport; + hasRequiredReexport = 1; + const myModule = require_export(); + + reexport.named = myModule.named; + return reexport; +} + +var reexportExports = requireReexport(); + +t.is(reexportExports.named, 2); +", +} +`; + +exports[`named-exports-unexported 1`] = ` +{ + "main.js": "'use strict'; + +var x = {}; + +var hasRequiredX; + +function requireX () { + if (hasRequiredX) return x; + hasRequiredX = 1; + x.named = 2; + return x; +} + +var xExports = requireX(); + +t.is(xExports.nonExisting, undefined); +", +} +`; + +exports[`nested-define-compiled-esm-unused 1`] = ` +{ + "main.js": "'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var foo$1 = {}; + +var hasRequiredFoo; + +function requireFoo () { + if (hasRequiredFoo) return foo$1; + hasRequiredFoo = 1; + (function (exports) { + + exports.default = 'foo'; + } (foo$1)); + return foo$1; +} + +var fooExports = requireFoo(); +var foo = /*@__PURE__*/getDefaultExportFromCjs(fooExports); + +t.deepEqual(foo, { default: 'foo' }); +", +} +`; + +exports[`nested-define-compiled-esm-used 1`] = ` +{ + "main.js": "'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var foo$1 = {}; + +var hasRequiredFoo; + +function requireFoo () { + if (hasRequiredFoo) return foo$1; + hasRequiredFoo = 1; + (function (exports) { + Object.defineProperty(exports, '__esModule', { value: true }); + + { + Object.defineProperty(exports, '__esModule', { value: true }); + } + + exports.default = 'foo'; + } (foo$1)); + return foo$1; +} + +var fooExports = requireFoo(); +var foo = /*@__PURE__*/getDefaultExportFromCjs(fooExports); + +t.deepEqual(foo, 'foo'); +", +} +`; + +exports[`nested-named-export-assignments 1`] = ` +{ + "main.js": "'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var dep1 = {}; + +var hasRequiredDep1; + +function requireDep1 () { + if (hasRequiredDep1) return dep1; + hasRequiredDep1 = 1; + dep1.foo = 'first'; + + reassignSomeExports(); + reassignSomeMoreExports(); + + function reassignSomeExports() { + dep1.foo = 'second'; + dep1.bar = 'first'; + } + + function reassignSomeMoreExports() { + dep1.bar = 'second'; + } + return dep1; +} + +var dep1Exports = requireDep1(); +var dep = /*@__PURE__*/getDefaultExportFromCjs(dep1Exports); + +var dep2 = {}; + +var hasRequiredDep2; + +function requireDep2 () { + if (hasRequiredDep2) return dep2; + hasRequiredDep2 = 1; + dep2.foo = 'first'; + + reassignSomeExports(); + reassignSomeMoreExports(); + + function reassignSomeExports() { + dep2.foo = 'second'; + dep2.bar = 'first'; + } + + function reassignSomeMoreExports() { + dep2.bar = 'second'; + } + return dep2; +} + +var dep2Exports = requireDep2(); + +t.is(dep.foo, 'second'); +t.is(dep.bar, 'second'); +t.is(dep2Exports.foo, 'second'); +t.is(dep2Exports.bar, 'second'); +", +} +`; + +exports[`no-exports-entry 1`] = ` +{ + "main.js": "'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var main$1 = {}; + +var dep; +var hasRequiredDep; + +function requireDep () { + if (hasRequiredDep) return dep; + hasRequiredDep = 1; + dep = 42; + return dep; +} + +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + const dep = requireDep(); + + t.is(dep, 42); + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +", +} +`; + +exports[`no-side-effects 1`] = ` +{ + "main.js": "'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var main$1 = {}; + +var dep = {}; + +var hasRequiredDep; + +function requireDep () { + if (hasRequiredDep) return dep; + hasRequiredDep = 1; + dep.foo = 'bar'; + return dep; +} + +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + const dep = /*@__PURE__*/ requireDep(); + + t.is(dep.foo, 'bar'); + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +", +} +`; + +exports[`only-nested-module-exports-reassignment 1`] = ` +{ + "main.js": "'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var main$1 = {}; + +var dep1 = {exports: {}}; + +var hasRequiredDep1; + +function requireDep1 () { + if (hasRequiredDep1) return dep1.exports; + hasRequiredDep1 = 1; + if (reassignFirstModuleExports) { + dep1.exports = 'reassigned'; + } + return dep1.exports; +} + +var dep2 = {exports: {}}; + +var hasRequiredDep2; + +function requireDep2 () { + if (hasRequiredDep2) return dep2.exports; + hasRequiredDep2 = 1; + if (reassignSecondModuleExports) { + dep2.exports = 'reassigned'; + } + return dep2.exports; +} + +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + const dep1 = requireDep1(); + const dep2 = requireDep2(); + + t.is(dep1, 'reassigned'); + t.deepEqual(dep2, {}); + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +", +} +`; + +exports[`ordering 1`] = ` +{ + "main.js": "'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var main$1 = {}; + +var foo = {}; + +var shared; +var hasRequiredShared; + +function requireShared () { + if (hasRequiredShared) return shared; + hasRequiredShared = 1; + shared = { + fooLoaded: false + }; + return shared; +} + +var hasRequiredFoo; + +function requireFoo () { + if (hasRequiredFoo) return foo; + hasRequiredFoo = 1; + const shared = requireShared(); + + // Mutate the shared module + shared.fooLoaded = true; + return foo; +} + +var bar; +var hasRequiredBar; + +function requireBar () { + if (hasRequiredBar) return bar; + hasRequiredBar = 1; + const shared = requireShared(); + + bar = shared.fooLoaded; + return bar; +} + +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + requireFoo(); + + const fooLoaded = requireBar(); + + t.truthy(fooLoaded); + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +", +} +`; + +exports[`pass-require-to-node-resolve 1`] = ` +{ + "bar-imported-49e0dbcf.js": "'use strict'; + +var barImported = 'imported'; + +exports["default"] = barImported; +", + "main.js": "'use strict'; + +var foo = 'imported'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var requiring = {}; + +var fooRequired; +var hasRequiredFooRequired; + +function requireFooRequired () { + if (hasRequiredFooRequired) return fooRequired; + hasRequiredFooRequired = 1; + fooRequired = 'required'; + return fooRequired; +} + +var hasRequiredRequiring; + +function requireRequiring () { + if (hasRequiredRequiring) return requiring; + hasRequiredRequiring = 1; + requiring.foo = requireFooRequired(); + + requiring.barPromise = Promise.resolve().then(function () { return require('./bar-imported-49e0dbcf.js'); }); + return requiring; +} + +var requiringExports = requireRequiring(); +var required = /*@__PURE__*/getDefaultExportFromCjs(requiringExports); + +t.is(foo, 'imported'); +t.is(required.foo, 'required'); + +var main = Promise.all([Promise.resolve().then(function () { return require('./bar-imported-49e0dbcf.js'); }), required.barPromise]); + +module.exports = main; +", +} +`; + +exports[`plugin-isentry 1`] = ` +{ + "main.js": "'use strict'; + +global.entryDetected = true; + +var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var dep; +var hasRequiredDep; + +function requireDep () { + if (hasRequiredDep) return dep; + hasRequiredDep = 1; + t.is(commonjsGlobal.entryDetected, true); + dep = 'dep'; + return dep; +} + +var main$1; +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + t.is(commonjsGlobal.entryDetected, true); + main$1 = requireDep(); + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +", + "other.js": "'use strict'; + +Object.defineProperty(exports, '__esModule', { value: true }); + +const other = true; + +exports.other = other; +", +} +`; + +exports[`preserv-this-reference-in-the-child-class 1`] = ` +{ + "main.js": "'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +function getAugmentedNamespace(n) { + if (Object.prototype.hasOwnProperty.call(n, '__esModule')) return n; + var f = n.default; + if (typeof f == "function") { + var a = function a () { + var isInstance = false; + try { + isInstance = this instanceof a; + } catch (e) {} + if (isInstance) { + return Reflect.construct(f, arguments, this.constructor); + } + return f.apply(this, arguments); + }; + a.prototype = f.prototype; + } else a = {}; + Object.defineProperty(a, '__esModule', {value: true}); + Object.keys(n).forEach(function (k) { + var d = Object.getOwnPropertyDescriptor(n, k); + Object.defineProperty(a, k, d.get ? d : { + enumerable: true, + get: function () { + return n[k]; + } + }); + }); + return a; +} + +var main$1 = {}; + +function Dep(){} + +var dep = /*#__PURE__*/Object.freeze({ + __proto__: null, + 'default': Dep +}); + +var require$$0 = /*@__PURE__*/getAugmentedNamespace(dep); + +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + const Dep = require$$0; + + class Main extends Dep { + constructor() { + super(); + this.name = this.constructor.name; + } + static name = "main"; + } + + t.is(new Main().name, "main"); + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +", +} +`; + +exports[`preserve-modules 1`] = ` +{ + "_virtual/_commonjsHelpers.js": "'use strict'; + +Object.defineProperty(exports, '__esModule', { value: true }); + +var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +exports.commonjsGlobal = commonjsGlobal; +exports.getDefaultExportFromCjs = getDefaultExportFromCjs; +", + "main.js": "'use strict'; + +var _commonjsHelpers = require('./_virtual/_commonjsHelpers.js'); +var main$1 = require('./main2.js'); + +var mainExports = main$1.__require(); +var main = /*@__PURE__*/_commonjsHelpers.getDefaultExportFromCjs(mainExports); + +module.exports = main; +", + "main2.js": "'use strict'; + +Object.defineProperty(exports, '__esModule', { value: true }); + +var _commonjsHelpers = require('./_virtual/_commonjsHelpers.js'); + +var main; +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main; + hasRequiredMain = 1; + _commonjsHelpers.commonjsGlobal.main = 'main'; + console.log('main'); + + main = 'main'; + return main; +} + +exports.__require = requireMain; +", +} +`; + +exports[`react-apollo 1`] = ` +{ + "main.js": "'use strict'; + +var commonjsFoo = {}; + +var commonjsBar = {}; + +/* eslint-disable no-underscore-dangle */ + +var hasRequiredCommonjsBar; + +function requireCommonjsBar () { + if (hasRequiredCommonjsBar) return commonjsBar; + hasRequiredCommonjsBar = 1; + function Bar() { + this.x = 42; + } + + commonjsBar.__esModule = true; + commonjsBar.default = Bar; + return commonjsBar; +} + +/* eslint-disable no-underscore-dangle */ + +var hasRequiredCommonjsFoo; + +function requireCommonjsFoo () { + if (hasRequiredCommonjsFoo) return commonjsFoo; + hasRequiredCommonjsFoo = 1; + const Bar = requireCommonjsBar(); + + commonjsFoo.__esModule = true; + commonjsFoo.Bar = Bar.default; + return commonjsFoo; +} + +var commonjsFooExports = requireCommonjsFoo(); + +t.is(new commonjsFooExports.Bar().x, 42); +", +} +`; + +exports[`reassign-exports 1`] = ` +{ + "main.js": "'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var main$1 = {}; + +var identifier = {}; + +var hasRequiredIdentifier; + +function requireIdentifier () { + if (hasRequiredIdentifier) return identifier; + hasRequiredIdentifier = 1; + (function (exports) { + exports = 'foo'; + t.is(exports, 'foo'); + } (identifier)); + return identifier; +} + +var property = {}; + +var hasRequiredProperty; + +function requireProperty () { + if (hasRequiredProperty) return property; + hasRequiredProperty = 1; + (function (exports) { + ({ foo: exports } = { foo: 'foo' }); + t.is(exports, 'foo'); + } (property)); + return property; +} + +var arrayPattern = {}; + +var hasRequiredArrayPattern; + +function requireArrayPattern () { + if (hasRequiredArrayPattern) return arrayPattern; + hasRequiredArrayPattern = 1; + (function (exports) { + [exports] = ['foo']; + t.is(exports, 'foo'); + } (arrayPattern)); + return arrayPattern; +} + +var assignmentPattern = {}; + +var hasRequiredAssignmentPattern; + +function requireAssignmentPattern () { + if (hasRequiredAssignmentPattern) return assignmentPattern; + hasRequiredAssignmentPattern = 1; + (function (exports) { + ({ exports = 'foo' } = {}); + t.is(exports, 'foo'); + } (assignmentPattern)); + return assignmentPattern; +} + +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + const identifier = requireIdentifier(); + const property = requireProperty(); + const arrayPattern = requireArrayPattern(); + const assignmentPattern = requireAssignmentPattern(); + + t.deepEqual(identifier, {}); + t.deepEqual(property, {}); + t.deepEqual(arrayPattern, {}); + t.deepEqual(assignmentPattern, {}); + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +", +} +`; + +exports[`reassign-module 1`] = ` +{ + "main.js": "'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var main$1 = {}; + +var identifier = {exports: {}}; + +identifier.exports; + +var hasRequiredIdentifier; + +function requireIdentifier () { + if (hasRequiredIdentifier) return identifier.exports; + hasRequiredIdentifier = 1; + (function (module) { + // eslint-disable-next-line no-global-assign + module = 'foo'; + t.is(module, 'foo'); + } (identifier)); + return identifier.exports; +} + +var property = {exports: {}}; + +property.exports; + +var hasRequiredProperty; + +function requireProperty () { + if (hasRequiredProperty) return property.exports; + hasRequiredProperty = 1; + (function (module) { + // eslint-disable-next-line no-global-assign + ({ foo: module } = { foo: 'foo' }); + t.is(module, 'foo'); + } (property)); + return property.exports; +} + +var arrayPattern = {exports: {}}; + +arrayPattern.exports; + +var hasRequiredArrayPattern; + +function requireArrayPattern () { + if (hasRequiredArrayPattern) return arrayPattern.exports; + hasRequiredArrayPattern = 1; + (function (module) { + // eslint-disable-next-line no-global-assign + [module] = ['foo']; + t.is(module, 'foo'); + } (arrayPattern)); + return arrayPattern.exports; +} + +var assignmentPattern = {exports: {}}; + +assignmentPattern.exports; + +var hasRequiredAssignmentPattern; + +function requireAssignmentPattern () { + if (hasRequiredAssignmentPattern) return assignmentPattern.exports; + hasRequiredAssignmentPattern = 1; + (function (module) { + // eslint-disable-next-line no-global-assign + ({ module = 'foo' } = {}); + t.is(module, 'foo'); + } (assignmentPattern)); + return assignmentPattern.exports; +} + +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + const identifier = requireIdentifier(); + const property = requireProperty(); + const arrayPattern = requireArrayPattern(); + const assignmentPattern = requireAssignmentPattern(); + + t.deepEqual(identifier, {}, 'identifier'); + t.deepEqual(property, {}, 'property'); + t.deepEqual(arrayPattern, {}, 'arrayPattern'); + t.deepEqual(assignmentPattern, {}, 'assignmentPattern'); + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +", +} +`; + +exports[`reassign-module-exports-delayed 1`] = ` +{ + "main.js": "'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var main$1 = {}; + +var dep = {exports: {}}; + +dep.exports; + +var hasRequiredDep; + +function requireDep () { + if (hasRequiredDep) return dep.exports; + hasRequiredDep = 1; + (function (module, exports) { + exports.value = 'initial'; + exports.reassign = (newValue) => (module.exports = newValue); + } (dep, dep.exports)); + return dep.exports; +} + +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + const { value: initialValue, reassign } = requireDep(); + + t.is(initialValue, 'initial'); + reassign('new'); + t.is(requireDep(), 'new'); + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +", +} +`; + +exports[`reassigned-module-exports-object 1`] = ` +{ + "main.js": "'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var main$1 = {}; + +var dep = {exports: {}}; + +var hasRequiredDep; + +function requireDep () { + if (hasRequiredDep) return dep.exports; + hasRequiredDep = 1; + const exported = {}; + dep.exports = exported; + dep.exports.foo = 'foo'; + + t.deepEqual(exported, { foo: 'foo' }, 'exported in dep.js'); + return dep.exports; +} + +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + const dep = requireDep(); + + t.deepEqual(dep, { foo: 'foo' }, 'imported in main.js'); + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +", +} +`; + +exports[`reassignment 1`] = ` +{ + "main.js": "'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var main$1 = {}; + +var foo_1; +var hasRequiredFoo; + +function requireFoo () { + if (hasRequiredFoo) return foo_1; + hasRequiredFoo = 1; + function foo() {} + foo.something = false; + + foo_1 = foo; + return foo_1; +} + +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + let foo = requireFoo(); + + if (!foo.something) { + foo = function somethingElse() {}; + foo.something = true; + } + + t.truthy(foo.something); + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +", +} +`; + +exports[`relative-external 1`] = ` +{ + "main.js": "'use strict'; + +var require$$0 = require('../fixtures/function/relative-external/external.js'); + +function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } + +var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0); + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var main$1 = {}; + +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + const { foo } = require$$0__default["default"]; + + t.is(foo, 'foo'); + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +", +} +`; + +exports[`require-esm-with-named-namespace 1`] = ` +{ + "main.js": "'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var main$1 = {}; + +const foo = 'foo'; +var other = 'bar'; + +var other$1 = /*#__PURE__*/Object.freeze({ + __proto__: null, + foo: foo, + 'default': other +}); + +var dep = 'default'; + +var dep$1 = /*#__PURE__*/Object.freeze({ + __proto__: null, + 'default': dep, + ns: other$1 +}); + +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + const dep = dep$1; + + t.deepEqual(dep, { default: 'default', ns: { default: 'bar', foo: 'foo' } }); + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +", +} +`; + +exports[`require-esm-with-namespace-and-default 1`] = ` +{ + "main.js": "'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var main$1 = {}; + +const foo = 'foo'; + +var dep = 'default'; + +var dep$1 = /*#__PURE__*/Object.freeze({ + __proto__: null, + 'default': dep, + foo: foo +}); + +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + const dep = dep$1; + + t.deepEqual(dep, { default: 'default', foo: 'foo' }); + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +", +} +`; + +exports[`require-esm-with-namespace-named-default 1`] = ` +{ + "main.js": "'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var main$1 = {}; + +const foo = 'foo'; +var other = 'bar'; + +var other$1 = /*#__PURE__*/Object.freeze({ + __proto__: null, + foo: foo, + 'default': other +}); + +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + const dep = other$1; + + t.deepEqual(dep, { default: 'bar', foo: 'foo' }); + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +", +} +`; + +exports[`require-esm-with-namespace-prefer-default 1`] = ` +{ + "main.js": "'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var main$1 = {}; + +const foo = 'foo'; + +var dep = /*#__PURE__*/Object.freeze({ + __proto__: null, + foo: foo +}); + +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + const dep$1 = dep; + + t.deepEqual(dep$1, { foo: 'foo' }); + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +", +} +`; + +exports[`require-snapshotting 1`] = ` +{ + "main.js": "'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var main$1 = {}; + +var dep; +var hasRequiredDep; + +function requireDep () { + if (hasRequiredDep) return dep; + hasRequiredDep = 1; + dep = { + foo: 'foo', + update: () => (dep = { foo: 'bar' }) + }; + return dep; +} + +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + const dep = requireDep(); + + t.is(dep.foo, 'foo'); + + dep.update(); + + t.is(dep.foo, 'foo'); + t.is(requireDep().foo, 'bar'); + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +", +} +`; + +exports[`resolve-is-cjs-extension 1`] = ` +{ + "main.js": "'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +function getAugmentedNamespace(n) { + if (Object.prototype.hasOwnProperty.call(n, '__esModule')) return n; + var f = n.default; + if (typeof f == "function") { + var a = function a () { + var isInstance = false; + try { + isInstance = this instanceof a; + } catch (e) {} + if (isInstance) { + return Reflect.construct(f, arguments, this.constructor); + } + return f.apply(this, arguments); + }; + a.prototype = f.prototype; + } else a = {}; + Object.defineProperty(a, '__esModule', {value: true}); + Object.keys(n).forEach(function (k) { + var d = Object.getOwnPropertyDescriptor(n, k); + Object.defineProperty(a, k, d.get ? d : { + enumerable: true, + get: function () { + return n[k]; + } + }); + }); + return a; +} + +var main$1 = {}; + +const result = 'second'; + +var second = /*#__PURE__*/Object.freeze({ + __proto__: null, + result: result +}); + +var require$$0 = /*@__PURE__*/getAugmentedNamespace(second); + +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + t.is(require$$0.result, 'second'); + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +", +} +`; + +exports[`resolve-is-cjs-filtered 1`] = ` +{ + "main.js": "'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +function getAugmentedNamespace(n) { + if (Object.prototype.hasOwnProperty.call(n, '__esModule')) return n; + var f = n.default; + if (typeof f == "function") { + var a = function a () { + var isInstance = false; + try { + isInstance = this instanceof a; + } catch (e) {} + if (isInstance) { + return Reflect.construct(f, arguments, this.constructor); + } + return f.apply(this, arguments); + }; + a.prototype = f.prototype; + } else a = {}; + Object.defineProperty(a, '__esModule', {value: true}); + Object.keys(n).forEach(function (k) { + var d = Object.getOwnPropertyDescriptor(n, k); + Object.defineProperty(a, k, d.get ? d : { + enumerable: true, + get: function () { + return n[k]; + } + }); + }); + return a; +} + +var main$1 = {}; + +const result = 'second'; + +var second = /*#__PURE__*/Object.freeze({ + __proto__: null, + result: result +}); + +var require$$0 = /*@__PURE__*/getAugmentedNamespace(second); + +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + t.is(require$$0.result, 'second'); + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +", +} +`; + +exports[`shadowed-import 1`] = ` +{ + "main.js": "'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var main$1 = {}; + +var foo; +var hasRequiredFoo; + +function requireFoo () { + if (hasRequiredFoo) return foo; + hasRequiredFoo = 1; + foo = 'foo'; + return foo; +} + +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + const foo = requireFoo(); + + t.is(foo, 'foo'); + + { + // eslint-disable-next-line no-shadow + const foo = 'wrong'; + // eslint-disable-next-line global-require + const bar = requireFoo(); + t.is(foo, 'wrong'); + t.is(bar, 'foo'); + } + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +", +} +`; + +exports[`shadowing 1`] = ` +{ + "main.js": "'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var main$1 = {}; + +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + function foo(require) { + require('not-an-actual-require-statement'); + } + + let result; + + foo((msg) => { + result = msg; + }); + + t.is(result, 'not-an-actual-require-statement'); + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +", +} +`; + +exports[`shorthand-global 1`] = ` +{ + "main.js": "'use strict'; + +var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var main$1; +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + const HOST = { + global: commonjsGlobal + }; + + main$1 = { + HOST + }; + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +", +} +`; + +exports[`shorthand-require 1`] = ` +{ + "main.js": "'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +function commonjsRequire(path) { + throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.'); +} + +var main$1; +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + const HOST = { + require: commonjsRequire + }; + + main$1 = { + HOST + }; + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +", +} +`; + +exports[`skips-dead-branches 1`] = ` +{ + "main.js": "'use strict'; + +var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var main$1 = {}; + +var b; +var hasRequiredB; + +function requireB () { + if (hasRequiredB) return b; + hasRequiredB = 1; + commonjsGlobal.b = 2; + b = 'b'; + return b; +} + +/* eslint-disable */ + +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + + main$1.conditionalTrue = requireB() ; + main$1.conditionalFalse = requireB(); + main$1.logicalAnd1 = requireB(); + main$1.logicalAnd2 = false ; + main$1.logicalOr1 = true ; + main$1.logicalOr2 = requireB(); + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +", +} +`; + +exports[`strict-requires-auto 1`] = ` +{ + "main.js": "'use strict'; + +var main = {}; + +var aImportsB = {}; + +var bImportsC = {}; + +var cImportsA = {}; + +var hasRequiredCImportsA; + +function requireCImportsA () { + if (hasRequiredCImportsA) return cImportsA; + hasRequiredCImportsA = 1; + cImportsA.a = requireAImportsB().a; + return cImportsA; +} + +var hasRequiredBImportsC; + +function requireBImportsC () { + if (hasRequiredBImportsC) return bImportsC; + hasRequiredBImportsC = 1; + bImportsC.a = requireCImportsA().a; + return bImportsC; +} + +var hasRequiredAImportsB; + +function requireAImportsB () { + if (hasRequiredAImportsB) return aImportsB; + hasRequiredAImportsB = 1; + aImportsB.a = 'a'; + t.is(requireBImportsC().a, 'a'); + return aImportsB; +} + +requireAImportsB(); + +module.exports = main; +", +} +`; + +exports[`strict-requires-auto-external-node-builtin 1`] = ` +{ + "main.js": "'use strict'; + +var require$$0 = require('node:stream'); + +function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } + +var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0); + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +const stream = require$$0__default["default"]; +const readable = new stream.Readable({}); + +var main = { Readable: stream.Readable, readable }; + +var main$1 = /*@__PURE__*/getDefaultExportFromCjs(main); + +module.exports = main$1; +", +} +`; + +exports[`strict-requires-auto-external-node-builtin-default 1`] = ` +{ + "main.js": "'use strict'; + +var require$$0 = require('node:stream'); + +function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } + +var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0); + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +const stream = require$$0__default["default"]; +const readable = new stream.Readable({}); + +var main = { Readable: stream.Readable, readable }; + +var main$1 = /*@__PURE__*/getDefaultExportFromCjs(main); + +module.exports = main$1; +", +} +`; + +exports[`strict-requires-circular 1`] = ` +{ + "main.js": "'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var main$1 = {}; + +var other = {}; + +var hasRequiredOther; + +function requireOther () { + if (hasRequiredOther) return other; + hasRequiredOther = 1; + other.foo = requireMain().foo; + return other; +} + +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + main$1.foo = 'foo'; + t.is(requireOther().foo, 'foo'); + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +", +} +`; + +exports[`strict-requires-cycle-detection 1`] = ` +{ + "main.js": "'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var main$1 = {}; + +var aImportsB = {}; + +var bImportsC = {}; + +var cImportsA = {}; + +var hasRequiredCImportsA; + +function requireCImportsA () { + if (hasRequiredCImportsA) return cImportsA; + hasRequiredCImportsA = 1; + cImportsA.a = requireAImportsB().a; + return cImportsA; +} + +var hasRequiredBImportsC; + +function requireBImportsC () { + if (hasRequiredBImportsC) return bImportsC; + hasRequiredBImportsC = 1; + bImportsC.a = requireCImportsA().a; + return bImportsC; +} + +var hasRequiredAImportsB; + +function requireAImportsB () { + if (hasRequiredAImportsB) return aImportsB; + hasRequiredAImportsB = 1; + aImportsB.a = 'a'; + t.is(requireBImportsC().a, 'a'); + return aImportsB; +} + +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + requireAImportsB(); + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +", +} +`; + +exports[`strict-requires-debug 1`] = ` +{ + "main.js": "'use strict'; + +var main = {}; + +var aImportsB = {}; + +var bImportsC = {}; + +var cImportsA = {}; + +var hasRequiredCImportsA; + +function requireCImportsA () { + if (hasRequiredCImportsA) return cImportsA; + hasRequiredCImportsA = 1; + cImportsA.a = requireAImportsB().a; + return cImportsA; +} + +var hasRequiredBImportsC; + +function requireBImportsC () { + if (hasRequiredBImportsC) return bImportsC; + hasRequiredBImportsC = 1; + bImportsC.a = requireCImportsA().a; + return bImportsC; +} + +var hasRequiredAImportsB; + +function requireAImportsB () { + if (hasRequiredAImportsB) return aImportsB; + hasRequiredAImportsB = 1; + aImportsB.a = 'a'; + t.is(requireBImportsC().a, 'a'); + return aImportsB; +} + +requireAImportsB(); + +module.exports = main; +", +} +`; + +exports[`strict-requires-debug-none 1`] = ` +{ + "main.js": "'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var main = 'bar'; + +var main$1 = /*@__PURE__*/getDefaultExportFromCjs(main); + +module.exports = main$1; +", +} +`; + +exports[`strict-requires-detect-conditionals 1`] = ` +{ + "main.js": "'use strict'; + +var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var main$1 = {}; + +var throws = {}; + +var hasRequiredThrows; + +function requireThrows () { + if (hasRequiredThrows) return throws; + hasRequiredThrows = 1; + throw new Error('This should never be executed or imported'); +} + +var hoisted; +var hasRequiredHoisted; + +function requireHoisted () { + if (hasRequiredHoisted) return hoisted; + hasRequiredHoisted = 1; + hoisted = 'this should be top-level'; + return hoisted; +} + +/* eslint-disable global-require */ + +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + commonjsGlobal.false = false; + commonjsGlobal.true = true; + + if (commonjsGlobal.false) { + requireThrows(); + } + + if (commonjsGlobal.true) ; else { + requireThrows(); + } + + commonjsGlobal.false ? requireThrows() : null; + commonjsGlobal.true ? null : requireThrows(); + + commonjsGlobal.false && requireThrows(); + commonjsGlobal.true || requireThrows(); + + function requireFunctionDeclaration() { + requireThrows(); + } + + const requireFunctionExpression = function () { + requireThrows(); + }; + + const requireArrowFunction = () => requireThrows(); + + if (commonjsGlobal.false) { + requireFunctionDeclaration(); + requireFunctionExpression(); + requireArrowFunction(); + } + + // These should not cause wrapping + t.is( + (function () { + return requireHoisted(); + })(), + 'this should be top-level' + ); + t.is((() => requireHoisted())(), 'this should be top-level'); + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +", +} +`; + +exports[`strict-requires-entry-node-resolve 1`] = ` +{ + "main.js": "'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var main$1 = {}; + +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + main$1.foo = 'foo'; + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +", +} +`; + +exports[`strict-requires-exportmode-exports 1`] = ` +{ + "main.js": "'use strict'; + +var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; + +var main = {}; + +var assignExports = {}; + +var hasRequiredAssignExports; + +function requireAssignExports () { + if (hasRequiredAssignExports) return assignExports; + hasRequiredAssignExports = 1; + assignExports.foo = 'foo'; + assignExports.bar = 'bar'; + commonjsGlobal.hasAssignExportsRun = true; + return assignExports; +} + +var compiledEsm = {}; + +var hasRequiredCompiledEsm; + +function requireCompiledEsm () { + if (hasRequiredCompiledEsm) return compiledEsm; + hasRequiredCompiledEsm = 1; + compiledEsm.__esModule = true; + Object.defineProperty(compiledEsm, '__esModule', { value: true }); + compiledEsm.foo = 'foo'; + commonjsGlobal.hasCompiledEsmRun = true; + return compiledEsm; +} + +var wrappedExports = {}; + +var hasRequiredWrappedExports; + +function requireWrappedExports () { + if (hasRequiredWrappedExports) return wrappedExports; + hasRequiredWrappedExports = 1; + (function (exports) { + exports.foo = 'foo'; + exports = {}; + exports.bar = 'bar'; + commonjsGlobal.hasWrappedExportsRun = true; + } (wrappedExports)); + return wrappedExports; +} + +t.is(commonjsGlobal.hasAssignExportsRun, undefined, 'before require'); +t.deepEqual(requireAssignExports(), { foo: 'foo', bar: 'bar' }); + +t.is(commonjsGlobal.hasAssignExportsRun, true, 'after require'); +delete commonjsGlobal.hasAssignExportsRun; + +t.is(commonjsGlobal.hasCompiledEsmRun, undefined, 'before require'); +t.deepEqual(requireCompiledEsm(), { foo: 'foo', __esModule: true }); + +t.is(commonjsGlobal.hasCompiledEsmRun, true, 'after require'); +delete commonjsGlobal.hasCompiledEsmRun; + +t.is(commonjsGlobal.hasWrappedExportsRun, undefined, 'before require'); +t.deepEqual(requireWrappedExports(), { foo: 'foo' }); + +t.is(commonjsGlobal.hasWrappedExportsRun, true, 'after require'); +delete commonjsGlobal.hasWrappedExportsRun; + +module.exports = main; +", +} +`; + +exports[`strict-requires-exportmode-module 1`] = ` +{ + "main.js": "'use strict'; + +var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; + +var main = {}; + +var assignModuleExports = {exports: {}}; + +var hasRequiredAssignModuleExports; + +function requireAssignModuleExports () { + if (hasRequiredAssignModuleExports) return assignModuleExports.exports; + hasRequiredAssignModuleExports = 1; + if (Math.random() > 0.5) { + assignModuleExports.exports = { foo: 'foo' }; + } else { + assignModuleExports.exports = { foo: 'foo' }; + } + commonjsGlobal.hasAssignModuleExportsRun = true; + return assignModuleExports.exports; +} + +var assignModuleAndExports = {exports: {}}; + +var hasRequiredAssignModuleAndExports; + +function requireAssignModuleAndExports () { + if (hasRequiredAssignModuleAndExports) return assignModuleAndExports.exports; + hasRequiredAssignModuleAndExports = 1; + assignModuleAndExports.exports = { foo: 'foo' }; + assignModuleAndExports.exports.bar = 'bar'; + commonjsGlobal.hasAssignModuleAndExportsRun = true; + return assignModuleAndExports.exports; +} + +var wrappedModuleExports = {exports: {}}; + +wrappedModuleExports.exports; + +var hasRequiredWrappedModuleExports; + +function requireWrappedModuleExports () { + if (hasRequiredWrappedModuleExports) return wrappedModuleExports.exports; + hasRequiredWrappedModuleExports = 1; + (function (module, exports) { + module.exports = { foo: 'foo' }; + commonjsGlobal.hasWrappedModuleExportsRun = true; + } (wrappedModuleExports, wrappedModuleExports.exports)); + return wrappedModuleExports.exports; +} + +t.is(commonjsGlobal.hasAssignModuleExportsRun, undefined, 'before require'); +t.is(requireAssignModuleExports().foo, 'foo'); + +t.is(commonjsGlobal.hasAssignModuleExportsRun, true, 'after require'); +delete commonjsGlobal.hasAssignModuleExportsRun; + +t.is(commonjsGlobal.hasAssignModuleAndExportsRun, undefined, 'before require'); +t.is(requireAssignModuleAndExports().foo, 'foo'); + +t.is(commonjsGlobal.hasAssignModuleAndExportsRun, true, 'after require'); +delete commonjsGlobal.hasAssignModuleAndExportsRun; + +t.is(commonjsGlobal.hasWrappedModuleExportsRun, undefined, 'before require'); +t.is(requireWrappedModuleExports().foo, 'foo'); + +t.is(commonjsGlobal.hasWrappedModuleExportsRun, true, 'after require'); +delete commonjsGlobal.hasWrappedModuleExportsRun; + +module.exports = main; +", +} +`; + +exports[`strict-requires-exportmode-replace 1`] = ` +{ + "main.js": "'use strict'; + +var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; + +var main = {}; + +var replaceModuleExports; +var hasRequiredReplaceModuleExports; + +function requireReplaceModuleExports () { + if (hasRequiredReplaceModuleExports) return replaceModuleExports; + hasRequiredReplaceModuleExports = 1; + replaceModuleExports = { foo: 'foo' }; + commonjsGlobal.hasReplaceModuleExportsRun = true; + return replaceModuleExports; +} + +t.is(commonjsGlobal.hasReplaceModuleExportsRun, undefined, 'before require'); +t.is(requireReplaceModuleExports().foo, 'foo'); + +t.is(commonjsGlobal.hasReplaceModuleExportsRun, true, 'after require'); +delete commonjsGlobal.hasReplaceModuleExportsRun; + +module.exports = main; +", +} +`; + +exports[`strict-requires-external 1`] = ` +{ + "main.js": "'use strict'; + +var require$$0 = require('external'); + +function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } + +var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0); + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var main$1 = {}; + +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + t.is(require$$0__default["default"].message, 'it works'); + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +", +} +`; + +exports[`strict-requires-external-node-builtin 1`] = ` +{ + "main.js": "'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var main$1; +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + main$1 = 42; + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +", +} +`; + +exports[`strict-requires-external-node-builtin-default 1`] = ` +{ + "main.js": "'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var main$1; +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + main$1 = 42; + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +", +} +`; + +exports[`strict-requires-file-without-module-type 1`] = ` +{ + "main.js": "'use strict'; + +var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var main$1 = {}; + +var error = {}; + +var hasRequiredError; + +function requireError () { + if (hasRequiredError) return error; + hasRequiredError = 1; + throw new Error('FAIL'); +} + +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + commonjsGlobal.null = 0; + + // eslint-disable-next-line global-require + t.is(commonjsGlobal.null && requireError(), 0); + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +", +} +`; + +exports[`strict-requires-from-esm 1`] = ` +{ + "main.js": "'use strict'; + +var strict = {}; + +var hasRequiredStrict; + +function requireStrict () { + if (hasRequiredStrict) return strict; + hasRequiredStrict = 1; + strict.foo = 'foo'; + return strict; +} + +var strictExports = requireStrict(); + +t.is(requireStrict().foo, 'foo'); + +t.is(strictExports.foo, 'foo'); +", +} +`; + +exports[`strict-requires-mixed-esm 1`] = ` +{ + "main.js": "'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var require$1 = {}; + +var hasRequiredRequire; + +function requireRequire () { + if (hasRequiredRequire) return require$1; + hasRequiredRequire = 1; + require$1.foo = 'foo'; + return require$1; +} + +var _import = {}; + +var hasRequired_import; + +function require_import () { + if (hasRequired_import) return _import; + hasRequired_import = 1; + _import.foo = 'foo'; + return _import; +} + +var _importExports = require_import(); +var esm = /*@__PURE__*/getDefaultExportFromCjs(_importExports); + +const cjs = requireRequire(); + +t.is(esm.foo, 'foo'); +t.is(cjs.foo, 'foo'); +", +} +`; + +exports[`strict-requires-multiple-entry 1`] = ` +{ + "generated-main.js": "'use strict'; + +var main = {}; + +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main; + hasRequiredMain = 1; + main.foo = 'foo'; + return main; +} + +exports.requireMain = requireMain; +", + "main.js": "'use strict'; + +var main$1 = require('./generated-main.js'); + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var mainExports = main$1.requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +", + "other.js": "'use strict'; + +var main = require('./generated-main.js'); + +var other = {}; + +t.is(main.requireMain().foo, 'foo'); + +module.exports = other; +", +} +`; + +exports[`this 1`] = ` +{ + "main.js": "'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var main$1 = {}; + +var foo = {}; + +var hasRequiredFoo; + +function requireFoo () { + if (hasRequiredFoo) return foo; + hasRequiredFoo = 1; + foo.augmentThis = function augmentThis() { + this.x = 'x'; + }; + + foo.y = 'y'; + + foo.classThis = class classThis { + constructor(){ + class _classThis { + y = 'yyy' + yyy = this.y + } + this._instance = new _classThis(); + } + y = 'yy' + yy = this.y + }; + return foo; +} + +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + const { augmentThis, classThis, y } = requireFoo(); + + const obj = {}; + augmentThis.call(obj); + + t.is(obj.x, 'x'); + t.is(main$1.y, undefined); + t.is(y, 'y'); + + const instance = new classThis(); + + t.is(instance.yy,'yy'); + t.is(instance._instance.yyy,'yyy'); + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +", +} +`; + +exports[`top-level-and-nested-module-exports-reassignment 1`] = ` +{ + "main.js": "'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var main$1 = {}; + +var dep1; +var hasRequiredDep1; + +function requireDep1 () { + if (hasRequiredDep1) return dep1; + hasRequiredDep1 = 1; + dep1 = 'original'; + if (reassignFirstModuleExports) { + dep1 = 'reassigned'; + } + return dep1; +} + +var dep2; +var hasRequiredDep2; + +function requireDep2 () { + if (hasRequiredDep2) return dep2; + hasRequiredDep2 = 1; + dep2 = 'original'; + if (reassignSecondModuleExports) { + dep2 = 'reassigned'; + } + return dep2; +} + +var dep3; +var hasRequiredDep3; + +function requireDep3 () { + if (hasRequiredDep3) return dep3; + hasRequiredDep3 = 1; + if (reassignFirstModuleExports) { + dep3 = 'reassigned'; + } + dep3 = 'final'; + return dep3; +} + +var dep4; +var hasRequiredDep4; + +function requireDep4 () { + if (hasRequiredDep4) return dep4; + hasRequiredDep4 = 1; + if (reassignSecondModuleExports) { + dep4 = 'reassigned'; + } + dep4 = 'final'; + return dep4; +} + +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + const dep1 = requireDep1(); + const dep2 = requireDep2(); + const dep3 = requireDep3(); + const dep4 = requireDep4(); + + t.is(dep1, 'reassigned'); + t.is(dep2, 'original'); + t.is(dep3, 'final'); + t.is(dep4, 'final'); + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +", +} +`; + +exports[`toplevel-return 1`] = ` +{ + "main.js": "'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +/* eslint-disable */ + +var main$1; +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + + main$1 = 'foo'; + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +", +} +`; + +exports[`toplevel-return-complex 1`] = ` +{ + "main.js": "'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var foo = {exports: {}}; + +var bar; +var hasRequiredBar; + +function requireBar () { + if (hasRequiredBar) return bar; + hasRequiredBar = 1; + bar = function () { + return true; + }; + return bar; +} + +foo.exports; + +var hasRequiredFoo; + +function requireFoo () { + if (hasRequiredFoo) return foo.exports; + hasRequiredFoo = 1; + (function (module) { + const bar = requireBar(); + + module.exports = 'bar'; + if (bar()) { + return; + } + module.exports = 'foo'; + } (foo)); + return foo.exports; +} + +var main$1; +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + const foo = requireFoo(); + + main$1 = foo; + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +", +} +`; + +exports[`trailing-slash 1`] = ` +{ + "main.js": "'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var main$1 = {}; + +var foo; +var hasRequiredFoo; + +function requireFoo () { + if (hasRequiredFoo) return foo; + hasRequiredFoo = 1; + foo = 42; + return foo; +} + +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + const foo = requireFoo(); + + t.is(foo, 42); + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +", +} +`; + +exports[`transform-mixed-modules 1`] = ` +{ + "main.js": "'use strict'; + +function getAugmentedNamespace(n) { + if (Object.prototype.hasOwnProperty.call(n, '__esModule')) return n; + var f = n.default; + if (typeof f == "function") { + var a = function a () { + var isInstance = false; + try { + isInstance = this instanceof a; + } catch (e) {} + if (isInstance) { + return Reflect.construct(f, arguments, this.constructor); + } + return f.apply(this, arguments); + }; + a.prototype = f.prototype; + } else a = {}; + Object.defineProperty(a, '__esModule', {value: true}); + Object.keys(n).forEach(function (k) { + var d = Object.getOwnPropertyDescriptor(n, k); + Object.defineProperty(a, k, d.get ? d : { + enumerable: true, + get: function () { + return n[k]; + } + }); + }); + return a; +} + +var other$1; +var hasRequiredOther; + +function requireOther () { + if (hasRequiredOther) return other$1; + hasRequiredOther = 1; + other$1 = 'other'; + return other$1; +} + +const other = requireOther(); + +var dep$1 = /*#__PURE__*/Object.freeze({ + __proto__: null, + other: other +}); + +var require$$0 = /*@__PURE__*/getAugmentedNamespace(dep$1); + +const dep = require$$0; + +t.is(other, 'other'); +t.deepEqual(dep, { other: 'other' }); +", +} +`; + +exports[`transform-mixed-modules-esmodule 1`] = ` +{ + "main.js": "'use strict'; + +function getAugmentedNamespace(n) { + if (Object.prototype.hasOwnProperty.call(n, '__esModule')) return n; + var f = n.default; + if (typeof f == "function") { + var a = function a () { + var isInstance = false; + try { + isInstance = this instanceof a; + } catch (e) {} + if (isInstance) { + return Reflect.construct(f, arguments, this.constructor); + } + return f.apply(this, arguments); + }; + a.prototype = f.prototype; + } else a = {}; + Object.defineProperty(a, '__esModule', {value: true}); + Object.keys(n).forEach(function (k) { + var d = Object.getOwnPropertyDescriptor(n, k); + Object.defineProperty(a, k, d.get ? d : { + enumerable: true, + get: function () { + return n[k]; + } + }); + }); + return a; +} + +var other$2 = {exports: {}}; + +var other$1 = other$2.exports; + +var hasRequiredOther; + +function requireOther () { + if (hasRequiredOther) return other$2.exports; + hasRequiredOther = 1; + Object.defineProperty(other$1, '__esModule', { + value: true + }); + other$2.exports = 'other'; + return other$2.exports; +} + +const other = requireOther(); + +var dep$1 = /*#__PURE__*/Object.freeze({ + __proto__: null, + other: other +}); + +var require$$0 = /*@__PURE__*/getAugmentedNamespace(dep$1); + +const dep = require$$0; + +t.is(other, 'other'); +t.deepEqual(dep, { other: 'other' }); +", +} +`; + +exports[`transpiled-esm-default 1`] = ` +{ + "main.js": "'use strict'; + +var external = require('external-esm-default'); + +function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } + +var external__default = /*#__PURE__*/_interopDefaultLegacy(external); + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var dep$1 = {}; + +var hasRequiredDep; + +function requireDep () { + if (hasRequiredDep) return dep$1; + hasRequiredDep = 1; + Object.defineProperty(dep$1, '__esModule', { value: true }); + dep$1.default = 'default'; + return dep$1; +} + +var depExports = requireDep(); +var dep = /*@__PURE__*/getDefaultExportFromCjs(depExports); + +t.is(dep, 'default'); +t.is(external__default["default"], 'bar'); +", +} +`; + +exports[`transpiled-esm-entry-default 1`] = ` +{ + "entry-a4826916.js": "'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var entry = {}; + +var hasRequiredEntry; + +function requireEntry () { + if (hasRequiredEntry) return entry; + hasRequiredEntry = 1; + Object.defineProperty(entry, '__esModule', { value: true }); + entry.default = 'default'; + return entry; +} + +exports.getDefaultExportFromCjs = getDefaultExportFromCjs; +exports.requireEntry = requireEntry; +", + "entry.js": "'use strict'; + +var entry$1 = require('./entry-a4826916.js'); + +var entryExports = entry$1.requireEntry(); +var entry = /*@__PURE__*/entry$1.getDefaultExportFromCjs(entryExports); + +module.exports = entry; +", + "main.js": "'use strict'; + +var entry$2 = require('./entry-a4826916.js'); + +function _mergeNamespaces(n, m) { + m.forEach(function (e) { + e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) { + if (k !== 'default' && !(k in n)) { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + }); + return Object.freeze(n); +} + +var entryExports = entry$2.requireEntry(); +var entry = /*@__PURE__*/entry$2.getDefaultExportFromCjs(entryExports); + +var entry$1 = /*#__PURE__*/Object.freeze(/*#__PURE__*/_mergeNamespaces({ + __proto__: null, + 'default': entry +}, [entryExports])); + +t.deepEqual(entry$1, { default: 'default' }); +", +} +`; + +exports[`transpiled-esm-entry-mixed 1`] = ` +{ + "entry-b41f5984.js": "'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var entry = {}; + +var hasRequiredEntry; + +function requireEntry () { + if (hasRequiredEntry) return entry; + hasRequiredEntry = 1; + Object.defineProperty(entry, '__esModule', { value: true }); + entry.default = 'default'; + entry.named = 'named'; + return entry; +} + +exports.getDefaultExportFromCjs = getDefaultExportFromCjs; +exports.requireEntry = requireEntry; +", + "entry.js": "'use strict'; + +var entry$1 = require('./entry-b41f5984.js'); + +var entryExports = entry$1.requireEntry(); +var entry = /*@__PURE__*/entry$1.getDefaultExportFromCjs(entryExports); + +module.exports = entry; +", + "main.js": "'use strict'; + +var entry$2 = require('./entry-b41f5984.js'); + +function _mergeNamespaces(n, m) { + m.forEach(function (e) { + e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) { + if (k !== 'default' && !(k in n)) { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + }); + return Object.freeze(n); +} + +var entryExports = entry$2.requireEntry(); +var entry = /*@__PURE__*/entry$2.getDefaultExportFromCjs(entryExports); + +var entry$1 = /*#__PURE__*/Object.freeze(/*#__PURE__*/_mergeNamespaces({ + __proto__: null, + 'default': entry +}, [entryExports])); + +t.deepEqual(entry$1, { default: 'default', named: 'named' }); +", +} +`; + +exports[`transpiled-esm-entry-named 1`] = ` +{ + "entry.js": "'use strict'; + +var entry$1 = require('./generated-entry.js'); + +var entryExports = entry$1.requireEntry(); +var entry = /*@__PURE__*/entry$1.getDefaultExportFromCjs(entryExports); + +module.exports = entry; +", + "generated-entry.js": "'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var entry = {}; + +var hasRequiredEntry; + +function requireEntry () { + if (hasRequiredEntry) return entry; + hasRequiredEntry = 1; + Object.defineProperty(entry, '__esModule', { value: true }); + entry.named = 'named'; + return entry; +} + +exports.getDefaultExportFromCjs = getDefaultExportFromCjs; +exports.requireEntry = requireEntry; +", + "main.js": "'use strict'; + +var entry$2 = require('./generated-entry.js'); + +function _mergeNamespaces(n, m) { + m.forEach(function (e) { + e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) { + if (k !== 'default' && !(k in n)) { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + }); + return Object.freeze(n); +} + +var entryExports = entry$2.requireEntry(); +var entry = /*@__PURE__*/entry$2.getDefaultExportFromCjs(entryExports); + +var entry$1 = /*#__PURE__*/Object.freeze(/*#__PURE__*/_mergeNamespaces({ + __proto__: null, + 'default': entry +}, [entryExports])); + +t.deepEqual(entry$1, { + default: { + named: 'named' + }, + named: 'named' +}); +", +} +`; + +exports[`transpiled-esm-mixed 1`] = ` +{ + "main.js": "'use strict'; + +var external = require('external-esm-mixed'); + +function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } + +var external__default = /*#__PURE__*/_interopDefaultLegacy(external); + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var dep$1 = {}; + +var hasRequiredDep; + +function requireDep () { + if (hasRequiredDep) return dep$1; + hasRequiredDep = 1; + Object.defineProperty(dep$1, '__esModule', { value: true }); + dep$1.named = 'named'; + dep$1.default = 'default'; + return dep$1; +} + +var depExports = requireDep(); +var dep = /*@__PURE__*/getDefaultExportFromCjs(depExports); + +t.is(dep, 'default'); +t.is(depExports.named, 'named'); +t.is(external__default["default"], 'bar'); +t.is(external.foo, 'foo'); +", +} +`; + +exports[`transpiled-esm-named 1`] = ` +{ + "main.js": "'use strict'; + +var externalEsmNamed = require('external-esm-named'); + +var dep = {}; + +var hasRequiredDep; + +function requireDep () { + if (hasRequiredDep) return dep; + hasRequiredDep = 1; + Object.defineProperty(dep, '__esModule', { value: true }); + dep.named = 'named'; + return dep; +} + +var depExports = requireDep(); + +t.is(depExports.named, 'named'); +t.is(externalEsmNamed.foo, 'foo'); +", +} +`; + +exports[`transpiled-esm-namespace-default 1`] = ` +{ + "main.js": "'use strict'; + +var external = require('external-esm-default'); + +function _interopNamespace(e) { + if (e && e.__esModule) return e; + var n = Object.create(null); + if (e) { + Object.keys(e).forEach(function (k) { + if (k !== 'default') { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + } + n["default"] = e; + return Object.freeze(n); +} + +function _mergeNamespaces(n, m) { + m.forEach(function (e) { + e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) { + if (k !== 'default' && !(k in n)) { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + }); + return Object.freeze(n); +} + +var external__namespace = /*#__PURE__*/_interopNamespace(external); + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var dep$2 = {}; + +var hasRequiredDep; + +function requireDep () { + if (hasRequiredDep) return dep$2; + hasRequiredDep = 1; + Object.defineProperty(dep$2, '__esModule', { value: true }); + dep$2.default = 'default'; + return dep$2; +} + +var depExports = requireDep(); +var dep = /*@__PURE__*/getDefaultExportFromCjs(depExports); + +var dep$1 = /*#__PURE__*/Object.freeze(/*#__PURE__*/_mergeNamespaces({ + __proto__: null, + 'default': dep +}, [depExports])); + +t.deepEqual(dep$1, { + default: 'default' +}); + +t.deepEqual(external__namespace, { + default: 'bar' +}); +", +} +`; + +exports[`transpiled-esm-namespace-mixed 1`] = ` +{ + "main.js": "'use strict'; + +var external = require('external-esm-mixed'); + +function _interopNamespace(e) { + if (e && e.__esModule) return e; + var n = Object.create(null); + if (e) { + Object.keys(e).forEach(function (k) { + if (k !== 'default') { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + } + n["default"] = e; + return Object.freeze(n); +} + +function _mergeNamespaces(n, m) { + m.forEach(function (e) { + e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) { + if (k !== 'default' && !(k in n)) { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + }); + return Object.freeze(n); +} + +var external__namespace = /*#__PURE__*/_interopNamespace(external); + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var dep$2 = {}; + +var hasRequiredDep; + +function requireDep () { + if (hasRequiredDep) return dep$2; + hasRequiredDep = 1; + Object.defineProperty(dep$2, '__esModule', { value: true }); + dep$2.named = 'named'; + dep$2.default = 'default'; + return dep$2; +} + +var depExports = requireDep(); +var dep = /*@__PURE__*/getDefaultExportFromCjs(depExports); + +var dep$1 = /*#__PURE__*/Object.freeze(/*#__PURE__*/_mergeNamespaces({ + __proto__: null, + 'default': dep +}, [depExports])); + +t.deepEqual(dep$1, { + default: 'default', + named: 'named' +}); + +t.deepEqual(external__namespace, { + default: 'bar', + foo: 'foo' +}); +", +} +`; + +exports[`transpiled-esm-namespace-named 1`] = ` +{ + "main.js": "'use strict'; + +var external = require('external-esm-named'); + +function _interopNamespace(e) { + if (e && e.__esModule) return e; + var n = Object.create(null); + if (e) { + Object.keys(e).forEach(function (k) { + if (k !== 'default') { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + } + n["default"] = e; + return Object.freeze(n); +} + +function _mergeNamespaces(n, m) { + m.forEach(function (e) { + e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) { + if (k !== 'default' && !(k in n)) { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + }); + return Object.freeze(n); +} + +var external__namespace = /*#__PURE__*/_interopNamespace(external); + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var dep$2 = {}; + +var hasRequiredDep; + +function requireDep () { + if (hasRequiredDep) return dep$2; + hasRequiredDep = 1; + Object.defineProperty(dep$2, '__esModule', { value: true }); + dep$2.named = 'named'; + return dep$2; +} + +var depExports = requireDep(); +var dep = /*@__PURE__*/getDefaultExportFromCjs(depExports); + +var dep$1 = /*#__PURE__*/Object.freeze(/*#__PURE__*/_mergeNamespaces({ + __proto__: null, + 'default': dep +}, [depExports])); + +t.deepEqual(dep$1, { + default: { + named: 'named' + }, + named: 'named' +}); + +t.deepEqual( + external__namespace, + rollupMajor < 3 ? { foo: 'foo' } : { foo: 'foo', default: { foo: 'foo' } } +); +", +} +`; + +exports[`transpiled-esm-nested-module-exports 1`] = ` +{ + "main.js": "'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var dep$1 = {exports: {}}; + +var hasRequiredDep; + +function requireDep () { + if (hasRequiredDep) return dep$1.exports; + hasRequiredDep = 1; + Object.defineProperty(dep$1.exports, '__esModule', { value: true }); + + if (globalValue) { + dep$1.exports = 'first'; + } else { + dep$1.exports = 'second'; + } + return dep$1.exports; +} + +var depExports = requireDep(); +var dep = /*@__PURE__*/getDefaultExportFromCjs(depExports); + +t.is(dep, 'first'); +", +} +`; + +exports[`transpiled-esm-nested-module-exports2 1`] = ` +{ + "main.js": "'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var dep$1 = {exports: {}}; + +var hasRequiredDep; + +function requireDep () { + if (hasRequiredDep) return dep$1.exports; + hasRequiredDep = 1; + if (globalValue) { + dep$1.exports = { default: 'first' }; + } else { + dep$1.exports = { default: 'second' }; + } + + Object.defineProperty(dep$1.exports, '__esModule', { value: true }); + return dep$1.exports; +} + +var depExports = requireDep(); +var dep = /*@__PURE__*/getDefaultExportFromCjs(depExports); + +t.is(dep, 'first'); +", +} +`; + +exports[`transpiled-esm-reexported-default 1`] = ` +{ + "main.js": "'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var dep$1 = {}; + +var hasRequiredDep; + +function requireDep () { + if (hasRequiredDep) return dep$1; + hasRequiredDep = 1; + Object.defineProperty(dep$1, '__esModule', { value: true }); + dep$1.default = 'default'; + return dep$1; +} + +var proxy; +var hasRequiredProxy; + +function requireProxy () { + if (hasRequiredProxy) return proxy; + hasRequiredProxy = 1; + proxy = requireDep(); + return proxy; +} + +var proxyExports = requireProxy(); +var dep = /*@__PURE__*/getDefaultExportFromCjs(proxyExports); + +t.is(dep, 'default'); +", +} +`; + +exports[`transpiled-esm-reexported-entry-default 1`] = ` +{ + "main.js": "'use strict'; + +function _mergeNamespaces(n, m) { + m.forEach(function (e) { + e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) { + if (k !== 'default' && !(k in n)) { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + }); + return Object.freeze(n); +} + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var entry$1 = {}; + +var hasRequiredEntry; + +function requireEntry () { + if (hasRequiredEntry) return entry$1; + hasRequiredEntry = 1; + Object.defineProperty(entry$1, '__esModule', { value: true }); + entry$1.default = 'default'; + return entry$1; +} + +var proxy$1; +var hasRequiredProxy; + +function requireProxy () { + if (hasRequiredProxy) return proxy$1; + hasRequiredProxy = 1; + proxy$1 = requireEntry(); + return proxy$1; +} + +var proxyExports = requireProxy(); +var proxy = /*@__PURE__*/getDefaultExportFromCjs(proxyExports); + +var entry = /*#__PURE__*/Object.freeze(/*#__PURE__*/_mergeNamespaces({ + __proto__: null, + 'default': proxy +}, [proxyExports])); + +t.deepEqual(entry, { default: 'default' }); +", +} +`; + +exports[`transpiled-esm-reexported-entry-mixed 1`] = ` +{ + "main.js": "'use strict'; + +function _mergeNamespaces(n, m) { + m.forEach(function (e) { + e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) { + if (k !== 'default' && !(k in n)) { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + }); + return Object.freeze(n); +} + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var entry$1 = {}; + +var hasRequiredEntry; + +function requireEntry () { + if (hasRequiredEntry) return entry$1; + hasRequiredEntry = 1; + Object.defineProperty(entry$1, '__esModule', { value: true }); + entry$1.default = 'default'; + entry$1.named = 'named'; + return entry$1; +} + +var proxy$1; +var hasRequiredProxy; + +function requireProxy () { + if (hasRequiredProxy) return proxy$1; + hasRequiredProxy = 1; + proxy$1 = requireEntry(); + return proxy$1; +} + +var proxyExports = requireProxy(); +var proxy = /*@__PURE__*/getDefaultExportFromCjs(proxyExports); + +var entry = /*#__PURE__*/Object.freeze(/*#__PURE__*/_mergeNamespaces({ + __proto__: null, + 'default': proxy +}, [proxyExports])); + +t.deepEqual(entry, { default: 'default', named: 'named' }); +", +} +`; + +exports[`transpiled-esm-reexported-entry-named 1`] = ` +{ + "main.js": "'use strict'; + +function _mergeNamespaces(n, m) { + m.forEach(function (e) { + e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) { + if (k !== 'default' && !(k in n)) { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + }); + return Object.freeze(n); +} + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var entry$1 = {}; + +var hasRequiredEntry; + +function requireEntry () { + if (hasRequiredEntry) return entry$1; + hasRequiredEntry = 1; + Object.defineProperty(entry$1, '__esModule', { value: true }); + entry$1.named = 'named'; + return entry$1; +} + +var proxy$1; +var hasRequiredProxy; + +function requireProxy () { + if (hasRequiredProxy) return proxy$1; + hasRequiredProxy = 1; + proxy$1 = requireEntry(); + return proxy$1; +} + +var proxyExports = requireProxy(); +var proxy = /*@__PURE__*/getDefaultExportFromCjs(proxyExports); + +var entry = /*#__PURE__*/Object.freeze(/*#__PURE__*/_mergeNamespaces({ + __proto__: null, + 'default': proxy +}, [proxyExports])); + +t.deepEqual(entry, { + default: { + named: 'named', + }, + named: 'named' +}); +", +} +`; + +exports[`transpiled-esm-reexported-mixed 1`] = ` +{ + "main.js": "'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var dep$1 = {}; + +var hasRequiredDep; + +function requireDep () { + if (hasRequiredDep) return dep$1; + hasRequiredDep = 1; + Object.defineProperty(dep$1, '__esModule', { value: true }); + dep$1.named = 'named'; + dep$1.default = 'default'; + return dep$1; +} + +var proxy; +var hasRequiredProxy; + +function requireProxy () { + if (hasRequiredProxy) return proxy; + hasRequiredProxy = 1; + proxy = requireDep(); + return proxy; +} + +var proxyExports = requireProxy(); +var dep = /*@__PURE__*/getDefaultExportFromCjs(proxyExports); + +t.is(dep, 'default'); +t.is(proxyExports.named, 'named'); +", +} +`; + +exports[`transpiled-esm-reexported-named 1`] = ` +{ + "main.js": "'use strict'; + +var dep = {}; + +var hasRequiredDep; + +function requireDep () { + if (hasRequiredDep) return dep; + hasRequiredDep = 1; + Object.defineProperty(dep, '__esModule', { value: true }); + dep.named = 'named'; + return dep; +} + +var proxy; +var hasRequiredProxy; + +function requireProxy () { + if (hasRequiredProxy) return proxy; + hasRequiredProxy = 1; + proxy = requireDep(); + return proxy; +} + +var proxyExports = requireProxy(); + +t.is(proxyExports.named, 'named'); +", +} +`; + +exports[`transpiled-esm-required 1`] = ` +{ + "main.js": "'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var main$1 = {}; + +var dep = {}; + +var hasRequiredDep; + +function requireDep () { + if (hasRequiredDep) return dep; + hasRequiredDep = 1; + Object.defineProperty(dep, '__esModule', { value: true }); + dep.named = 'named'; + dep.default = 'default'; + return dep; +} + +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + const dep = requireDep(); + + t.deepEqual(dep, { + default: 'default', + named: 'named' + }); + + // eslint-disable-next-line no-prototype-builtins + t.is(dep.hasOwnProperty('named'), true); + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +", +} +`; + +exports[`transpiled-esm-transpiled-importer 1`] = ` +{ + "main.js": "'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var main$1 = {}; + +var dep = {}; + +var hasRequiredDep; + +function requireDep () { + if (hasRequiredDep) return dep; + hasRequiredDep = 1; + Object.defineProperty(dep, '__esModule', { value: true }); + dep.default = 'default'; + return dep; +} + +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + const dep = requireDep(); + + function _interopDefault(e) { + return e && e.__esModule ? e : { default: e }; + } + + t.is(dep.__esModule, true); + const dep__default = /* #__PURE__*/ _interopDefault(dep); + t.is(dep__default.default, 'default'); + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +", +} +`; + +exports[`try-catch 1`] = ` +{ + "main.js": "'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var main$1 = {}; + +/* eslint-disable global-require */ + +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + try { + require('uninstalled-external-module'); + } catch (ignored) { + /* ignore */ + } + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +", +} +`; + +exports[`try-catch-ids-array 1`] = ` +{ + "main.js": "'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var main$1 = {}; + +/* eslint-disable global-require */ + +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + try { + require('uninstalled-external-module'); + } catch (ignored) { + /* ignore */ + } + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +", +} +`; + +exports[`try-catch-ids-function 1`] = ` +{ + "main.js": "'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var main$1 = {}; + +/* eslint-disable global-require */ + +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + try { + require('uninstalled-external-module'); + } catch (ignored) { + /* ignore */ + } + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +", +} +`; + +exports[`try-catch-internal 1`] = ` +{ + "main.js": "'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var main$1 = {}; + +var dep = {}; + +var hasRequiredDep; + +function requireDep () { + if (hasRequiredDep) return dep; + hasRequiredDep = 1; + dep.foo = 'foo'; + return dep; +} + +var throws = {}; + +var hasRequiredThrows; + +function requireThrows () { + if (hasRequiredThrows) return throws; + hasRequiredThrows = 1; + throw new Error('Expected error'); +} + +/* eslint-disable global-require */ + +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + try { + t.is(requireDep().foo, 'foo'); + } catch (err) { + throw new Error(\`Could not require: \${err}\`); + } + + try { + requireThrows(); + } catch (err) { + t.is(err.message, 'Expected error'); + } + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +", +} +`; + +exports[`try-catch-remove 1`] = ` +{ + "main.js": "'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var main$1 = {}; + +/* eslint-disable global-require */ + +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +", +} +`; + +exports[`typeof-module-require 1`] = ` +{ + "main.js": "'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +function commonjsRequire(path) { + throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.'); +} + +var foo$1 = {exports: {}}; + +var hasRequiredFoo; + +function requireFoo () { + if (hasRequiredFoo) return foo$1.exports; + hasRequiredFoo = 1; + if (typeof commonjsRequire === 'function' && commonjsRequire) { + foo$1.exports = 'require detected'; + } else { + foo$1.exports = 'could not detect require'; + } + return foo$1.exports; +} + +var fooExports = requireFoo(); +var foo = /*@__PURE__*/getDefaultExportFromCjs(fooExports); + +t.is(foo, 'require detected'); +", +} +`; + +exports[`typeof-require 1`] = ` +{ + "main.js": "'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +function commonjsRequire(path) { + throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.'); +} + +var foo$1 = {exports: {}}; + +var hasRequiredFoo; + +function requireFoo () { + if (hasRequiredFoo) return foo$1.exports; + hasRequiredFoo = 1; + if (typeof commonjsRequire === 'function' && commonjsRequire) { + foo$1.exports = 1; + } else { + foo$1.exports = 2; + } + return foo$1.exports; +} + +var fooExports = requireFoo(); +var foo = /*@__PURE__*/getDefaultExportFromCjs(fooExports); + +t.is(foo, 1); +", +} +`; + +exports[`unresolved-dependencies 1`] = ` +{ + "main.js": "'use strict'; + +var require$$0 = require('path'); + +function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } + +var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0); + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var main$1 = {}; + +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + const path = require$$0__default["default"]; + + t.is(typeof path.resolve, 'function'); + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +", +} +`; + +exports[`warn-this-resolve-without-options 1`] = ` +{ + "main.js": "'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var foo; +var hasRequiredFoo; + +function requireFoo () { + if (hasRequiredFoo) return foo; + hasRequiredFoo = 1; + foo = 21; + return foo; +} + +var main$1; +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + const foo = requireFoo(); + + main$1 = foo * 2; + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +", +} +`; diff --git a/packages/commonjs/test/snapshots-earliest/test.js.snap b/packages/commonjs/test/snapshots-earliest/test.js.snap new file mode 100644 index 000000000..3979c7d6a --- /dev/null +++ b/packages/commonjs/test/snapshots-earliest/test.js.snap @@ -0,0 +1,490 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`can spread an object into module.exports 1`] = ` +"'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var main$1; +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + const obj = { + a: 'b', + b: 'c' + }; + + main$1 = { + ...obj + }; + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +" +`; + +exports[`does not transform typeof exports for mixed modules 1`] = ` +"var foo$1; +var hasRequiredFoo; + +function requireFoo () { + if (hasRequiredFoo) return foo$1; + hasRequiredFoo = 1; + foo$1 = 21; + return foo$1; +} + +const foo = requireFoo(); + +if (typeof exports !== 'undefined') { + throw new Error('There should be no global exports in an ES module'); +} + +export { foo as default }; +" +`; + +exports[`handles ESM cycles when using the cache 1`] = ` +"'use strict'; + +console.log('dep'); + +console.log('main'); +" +`; + +exports[`handles array destructuring assignment 1`] = ` +"'use strict'; + +Object.defineProperty(exports, '__esModule', { value: true }); + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var main$1 = {}; + +/* eslint-disable */ + +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + function shuffleArray(array) { + for (let i = array.length - 1; i > 0; i--) { + const j = Math.floor(Math.random() * (i + 1)); + [array[i], array[j]] = [array[j], array[i]]; + } + } + + main$1.shuffleArray = shuffleArray; + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +exports["default"] = main; +" +`; + +exports[`handles external dependencies when using the cache 1`] = ` +"'use strict'; + +var require$$0 = require('external'); + +function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } + +var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0); + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var second$1; +var hasRequiredSecond; + +function requireSecond () { + if (hasRequiredSecond) return second$1; + hasRequiredSecond = 1; + second$1 = require$$0__default["default"].second; + return second$1; +} + +var secondExports = requireSecond(); +var second = /*@__PURE__*/getDefaultExportFromCjs(secondExports); + +var main = require$$0.first + second; + +module.exports = main; +" +`; + +exports[`handles when a required dependency of a CJS module changes type 1`] = ` +"'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +function getAugmentedNamespace(n) { + if (Object.prototype.hasOwnProperty.call(n, '__esModule')) return n; + var f = n.default; + if (typeof f == "function") { + var a = function a () { + var isInstance = false; + try { + isInstance = this instanceof a; + } catch (e) {} + if (isInstance) { + return Reflect.construct(f, arguments, this.constructor); + } + return f.apply(this, arguments); + }; + a.prototype = f.prototype; + } else a = {}; + Object.defineProperty(a, '__esModule', {value: true}); + Object.keys(n).forEach(function (k) { + var d = Object.getOwnPropertyDescriptor(n, k); + Object.defineProperty(a, k, d.get ? d : { + enumerable: true, + get: function () { + return n[k]; + } + }); + }); + return a; +} + +const dep = 'esm'; + +var dep$1 = /*#__PURE__*/Object.freeze({ + __proto__: null, + dep: dep +}); + +var require$$0 = /*@__PURE__*/getAugmentedNamespace(dep$1); + +var main$1; +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + main$1 = require$$0.dep; + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +" +`; + +exports[`handles when a required dependency of a CJS module changes type 2`] = ` +"'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var dep = {}; + +var hasRequiredDep; + +function requireDep () { + if (hasRequiredDep) return dep; + hasRequiredDep = 1; + dep.dep = 'cjs'; + return dep; +} + +var main$1; +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + main$1 = requireDep().dep; + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +" +`; + +exports[`handles when a required dependency of a CJS module changes type 3`] = ` +"'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var dep = {}; + +var hasRequiredDep; + +function requireDep () { + if (hasRequiredDep) return dep; + hasRequiredDep = 1; + dep.dep = 'cjs'; dep.dep += requireDep().dep; + return dep; +} + +var main$1; +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + main$1 = requireDep().dep; + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +" +`; + +exports[`handles when a required dependency of a mixed ES module changes type 1`] = ` +"'use strict'; + +function getAugmentedNamespace(n) { + if (Object.prototype.hasOwnProperty.call(n, '__esModule')) return n; + var f = n.default; + if (typeof f == "function") { + var a = function a () { + var isInstance = false; + try { + isInstance = this instanceof a; + } catch (e) {} + if (isInstance) { + return Reflect.construct(f, arguments, this.constructor); + } + return f.apply(this, arguments); + }; + a.prototype = f.prototype; + } else a = {}; + Object.defineProperty(a, '__esModule', {value: true}); + Object.keys(n).forEach(function (k) { + var d = Object.getOwnPropertyDescriptor(n, k); + Object.defineProperty(a, k, d.get ? d : { + enumerable: true, + get: function () { + return n[k]; + } + }); + }); + return a; +} + +const dep = 'esm'; + +var dep$1 = /*#__PURE__*/Object.freeze({ + __proto__: null, + dep: dep +}); + +var require$$0 = /*@__PURE__*/getAugmentedNamespace(dep$1); + +var main = require$$0.dep; + +module.exports = main; +" +`; + +exports[`handles when a required dependency of a mixed ES module changes type 2`] = ` +"'use strict'; + +var dep = {}; + +var hasRequiredDep; + +function requireDep () { + if (hasRequiredDep) return dep; + hasRequiredDep = 1; + dep.dep = 'cjs'; + return dep; +} + +var main = requireDep().dep; + +module.exports = main; +" +`; + +exports[`handles when a required dependency of a mixed ES module changes type 3`] = ` +"'use strict'; + +var dep = {}; + +var hasRequiredDep; + +function requireDep () { + if (hasRequiredDep) return dep; + hasRequiredDep = 1; + dep.dep = 'cjs'; dep.dep += requireDep().dep; + return dep; +} + +var main = requireDep().dep; + +module.exports = main; +" +`; + +exports[`handles when an imported dependency of an ES module changes type 1`] = ` +"'use strict'; + +const dep = 'esm'; + +module.exports = dep; +" +`; + +exports[`handles when an imported dependency of an ES module changes type 2`] = ` +"'use strict'; + +var dep$1 = {}; + +var hasRequiredDep; + +function requireDep () { + if (hasRequiredDep) return dep$1; + hasRequiredDep = 1; + dep$1.dep = 'cjs'; + return dep$1; +} + +var depExports = requireDep(); + +var dep = depExports.dep; + +module.exports = dep; +" +`; + +exports[`handles when an imported dependency of an ES module changes type 3`] = ` +"'use strict'; + +var dep$1 = {}; + +var hasRequiredDep; + +function requireDep () { + if (hasRequiredDep) return dep$1; + hasRequiredDep = 1; + dep$1.dep = 'cjs'; dep$1.dep += requireDep().dep; + return dep$1; +} + +var depExports = requireDep(); + +var dep = depExports.dep; + +module.exports = dep; +" +`; + +exports[`produces optimized code when importing esm with a known default export 1`] = ` +"'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var require$$0 = "default"; + +var main$1; +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + main$1 = require$$0; + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +" +`; + +exports[`produces optimized code when importing esm without a default export 1`] = ` +"'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +function getAugmentedNamespace(n) { + if (Object.prototype.hasOwnProperty.call(n, '__esModule')) return n; + var f = n.default; + if (typeof f == "function") { + var a = function a () { + var isInstance = false; + try { + isInstance = this instanceof a; + } catch (e) {} + if (isInstance) { + return Reflect.construct(f, arguments, this.constructor); + } + return f.apply(this, arguments); + }; + a.prototype = f.prototype; + } else a = {}; + Object.defineProperty(a, '__esModule', {value: true}); + Object.keys(n).forEach(function (k) { + var d = Object.getOwnPropertyDescriptor(n, k); + Object.defineProperty(a, k, d.get ? d : { + enumerable: true, + get: function () { + return n[k]; + } + }); + }); + return a; +} + +const value = "value"; + +var esm = /*#__PURE__*/Object.freeze({ + __proto__: null, + value: value +}); + +var require$$0 = /*@__PURE__*/getAugmentedNamespace(esm); + +var main$1; +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main$1; + hasRequiredMain = 1; + main$1 = require$$0; + return main$1; +} + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +module.exports = main; +" +`; diff --git a/packages/commonjs/test/snapshots/function.js.snap b/packages/commonjs/test/snapshots/function.js.snap index 1ecce0bb1..2049bfed7 100644 --- a/packages/commonjs/test/snapshots/function.js.snap +++ b/packages/commonjs/test/snapshots/function.js.snap @@ -4340,7 +4340,11 @@ function requireMain () { const externalMixed = require$$1; const externalDefault = require$$2; - t.deepEqual(externalNamed, { foo: 'foo', default: { foo: 'foo' } }, 'external named'); + t.deepEqual( + externalNamed, + rollupMajor < 3 ? { foo: 'foo' } : { foo: 'foo', default: { foo: 'foo' } }, + 'external named' + ); t.deepEqual(externalMixed, { default: 'bar', foo: 'foo' }, 'external mixed'); t.deepEqual(externalDefault, { default: 'bar' }, 'external default'); return main$1; @@ -4786,14 +4790,14 @@ exports[`expose-file-type-detection 1`] = ` { "main.js": "'use strict'; -var other = require('./other-UXsUMMAz.js'); +var other = require('./other-BucbZjd3.js'); var otherExports = other.requireOther(); var foo = /*@__PURE__*/other.getDefaultExportFromCjs(otherExports); t.is(foo, 'foo'); ", - "other-UXsUMMAz.js": "'use strict'; + "other-BucbZjd3.js": "'use strict'; function getDefaultExportFromCjs (x) { return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; @@ -4814,7 +4818,7 @@ exports.requireOther = requireOther; ", "other.js": "'use strict'; -var other$1 = require('./other-UXsUMMAz.js'); +var other$1 = require('./other-BucbZjd3.js'); var otherExports = other$1.requireOther(); var other = /*@__PURE__*/other$1.getDefaultExportFromCjs(otherExports); @@ -5103,7 +5107,11 @@ function requireMain () { t.deepEqual(mixedExports, { foo: 'foo', default: 'bar' }, 'mixed exports'); t.deepEqual(defaultExport, 'bar', 'default export'); t.deepEqual(noExports, {}, 'no exports'); - t.deepEqual(externalNamed, { foo: 'foo', default: { foo: 'foo' } }, 'external named'); + t.deepEqual( + externalNamed, + rollupMajor < 3 ? { foo: 'foo' } : { foo: 'foo', default: { foo: 'foo' } }, + 'external named' + ); t.deepEqual(externalMixed, { foo: 'foo', default: 'bar' }, 'external mixed'); t.deepEqual(externalDefault, 'bar', 'external default'); return main$1; @@ -5246,7 +5254,11 @@ function requireMain () { t.deepEqual(mixedExports, { foo: 'foo', default: 'bar' }, 'mixed exports'); t.deepEqual(defaultExport, { default: 'bar' }, 'default export'); t.deepEqual(noExports, {}, 'no exports'); - t.deepEqual(externalNamed, { foo: 'foo', default: { foo: 'foo' } }, 'external named'); + t.deepEqual( + externalNamed, + rollupMajor < 3 ? { foo: 'foo' } : { foo: 'foo', default: { foo: 'foo' } }, + 'external named' + ); t.deepEqual(externalMixed, { foo: 'foo', default: 'bar' }, 'external mixed'); t.deepEqual(externalDefault, { default: 'bar' }, 'external default'); @@ -5550,7 +5562,11 @@ function requireMain () { const externalMixed = require$$1__default.default; const externalDefault = require$$2; - t.deepEqual(externalNamed, { foo: 'foo', default: { foo: 'foo' } }, 'named'); + t.deepEqual( + externalNamed, + rollupMajor < 3 ? { foo: 'foo' } : { foo: 'foo', default: { foo: 'foo' } }, + 'named' + ); t.deepEqual(externalMixed, 'bar', 'mixed'); t.deepEqual(externalDefault, { default: 'bar' }, 'default'); return main$1; @@ -5652,7 +5668,11 @@ function requireMain () { t.deepEqual(mixedExports, { foo: 'foo', default: 'bar' }, 'mixed exports'); t.deepEqual(defaultExport, { default: 'bar' }, 'default export'); t.deepEqual(noExports, {}, 'no exports'); - t.deepEqual(externalNamed, { foo: 'foo', default: { foo: 'foo' } }, 'external named'); + t.deepEqual( + externalNamed, + rollupMajor < 3 ? { foo: 'foo' } : { foo: 'foo', default: { foo: 'foo' } }, + 'external named' + ); t.deepEqual(externalMixed, { foo: 'foo', default: 'bar' }, 'external mixed'); t.deepEqual(externalDefault, { default: 'bar' }, 'external default'); return main$1; @@ -5947,7 +5967,11 @@ function requireMain () { t.deepEqual(mixedExports, { foo: 'foo', default: 'bar' }, 'mixed exports'); t.deepEqual(defaultExport, { default: 'bar' }, 'default export'); t.deepEqual(noExports, {}, 'no exports'); - t.deepEqual(externalNamed, { foo: 'foo', default: { foo: 'foo' } }, 'external named'); + t.deepEqual( + externalNamed, + rollupMajor < 3 ? { foo: 'foo' } : { foo: 'foo', default: { foo: 'foo' } }, + 'external named' + ); t.deepEqual(externalMixed, { foo: 'foo', default: 'bar' }, 'external mixed'); t.deepEqual(externalDefault, { default: 'bar' }, 'external default'); return main$1; @@ -6143,16 +6167,6 @@ function getDefaultExportFromCjs (x) { return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; } -var foo; -var hasRequiredFoo; - -function requireFoo () { - if (hasRequiredFoo) return foo; - hasRequiredFoo = 1; - foo = 1; - return foo; -} - var multiply; var hasRequiredMultiply; @@ -6165,6 +6179,16 @@ function requireMultiply () { return multiply; } +var foo; +var hasRequiredFoo; + +function requireFoo () { + if (hasRequiredFoo) return foo; + hasRequiredFoo = 1; + foo = 1; + return foo; +} + /* eslint-disable global-require */ var main$1; @@ -6564,7 +6588,7 @@ function getDefaultExportFromCjs (x) { return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; } -node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('main.js', document.baseURI).href))); +node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('main.js', document.baseURI).href))); var main$1; var hasRequiredMain; @@ -6640,22 +6664,22 @@ exports[`module-side-effects-late-entry 1`] = ` { "generated-foo.js": "'use strict'; -var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; +require('./generated-foo2.js'); -// This side-effect will only be respected if this is an entry point -commonjsGlobal.foo = 'foo'; +var foo = {}; + +module.exports = foo; ", "generated-foo2.js": "'use strict'; -require('./generated-foo.js'); - -var foo = {}; +var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; -module.exports = foo; +// This side-effect will only be respected if this is an entry point +commonjsGlobal.foo = 'foo'; ", "main.js": "'use strict'; -require('./generated-foo.js'); +require('./generated-foo2.js'); var main = 'main'; @@ -7308,7 +7332,7 @@ module.exports = main; exports[`pass-require-to-node-resolve 1`] = ` { - "bar-imported-QFe_5Jm2.js": "'use strict'; + "bar-imported-D3D8389F.js": "'use strict'; var barImported = 'imported'; @@ -7341,7 +7365,7 @@ function requireRequiring () { hasRequiredRequiring = 1; requiring.foo = requireFooRequired(); - requiring.barPromise = Promise.resolve().then(function () { return require('./bar-imported-QFe_5Jm2.js'); }); + requiring.barPromise = Promise.resolve().then(function () { return require('./bar-imported-D3D8389F.js'); }); return requiring; } @@ -7351,7 +7375,7 @@ var required = /*@__PURE__*/getDefaultExportFromCjs(requiringExports); t.is(foo, 'imported'); t.is(required.foo, 'required'); -var main = Promise.all([Promise.resolve().then(function () { return require('./bar-imported-QFe_5Jm2.js'); }), required.barPromise]); +var main = Promise.all([Promise.resolve().then(function () { return require('./bar-imported-D3D8389F.js'); }), required.barPromise]); module.exports = main; ", @@ -8447,8 +8471,8 @@ function requireMain () { main$1.conditionalTrue = requireB() ; main$1.conditionalFalse = requireB(); main$1.logicalAnd1 = requireB(); - main$1.logicalAnd2 = false ; - main$1.logicalOr1 = true ; + main$1.logicalAnd2 = false; + main$1.logicalOr1 = true; main$1.logicalOr2 = requireB(); return main$1; } @@ -8527,9 +8551,9 @@ const readable = new stream.Readable({}); var main = { Readable: stream.Readable, readable }; -var main$1 = /*@__PURE__*/getDefaultExportFromCjs(main); +var main_default = /*@__PURE__*/getDefaultExportFromCjs(main); -module.exports = main$1; +module.exports = main_default; ", } `; @@ -8553,9 +8577,9 @@ const readable = new stream.Readable({}); var main = { Readable: stream.Readable, readable }; -var main$1 = /*@__PURE__*/getDefaultExportFromCjs(main); +var main_default = /*@__PURE__*/getDefaultExportFromCjs(main); -module.exports = main$1; +module.exports = main_default; ", } `; @@ -8712,14 +8736,14 @@ exports[`strict-requires-debug-none 1`] = ` "main.js": "'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; } var main = 'bar'; -var main$1 = /*@__PURE__*/getDefaultExportFromCjs(main); +var main_default = /*@__PURE__*/getDefaultExportFromCjs(main); -module.exports = main$1; +module.exports = main_default; ", } `; @@ -9698,7 +9722,7 @@ t.is(external__default.default, 'bar'); exports[`transpiled-esm-entry-default 1`] = ` { - "entry-ix7rhf3Z.js": "'use strict'; + "entry-BHDxPxXK.js": "'use strict'; function getDefaultExportFromCjs (x) { return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; @@ -9721,7 +9745,7 @@ exports.requireEntry = requireEntry; ", "entry.js": "'use strict'; -var entry$1 = require('./entry-ix7rhf3Z.js'); +var entry$1 = require('./entry-BHDxPxXK.js'); var entryExports = entry$1.requireEntry(); var entry = /*@__PURE__*/entry$1.getDefaultExportFromCjs(entryExports); @@ -9730,7 +9754,7 @@ module.exports = entry; ", "main.js": "'use strict'; -var entry$2 = require('./entry-ix7rhf3Z.js'); +var entry$2 = require('./entry-BHDxPxXK.js'); function _mergeNamespaces(n, m) { m.forEach(function (e) { @@ -9762,7 +9786,7 @@ t.deepEqual(entry$1, { default: 'default' }); exports[`transpiled-esm-entry-mixed 1`] = ` { - "entry-Fl2t-jMB.js": "'use strict'; + "entry-wxX_Yv_b.js": "'use strict'; function getDefaultExportFromCjs (x) { return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; @@ -9786,7 +9810,7 @@ exports.requireEntry = requireEntry; ", "entry.js": "'use strict'; -var entry$1 = require('./entry-Fl2t-jMB.js'); +var entry$1 = require('./entry-wxX_Yv_b.js'); var entryExports = entry$1.requireEntry(); var entry = /*@__PURE__*/entry$1.getDefaultExportFromCjs(entryExports); @@ -9795,7 +9819,7 @@ module.exports = entry; ", "main.js": "'use strict'; -var entry$2 = require('./entry-Fl2t-jMB.js'); +var entry$2 = require('./entry-wxX_Yv_b.js'); function _mergeNamespaces(n, m) { m.forEach(function (e) { @@ -10185,10 +10209,10 @@ t.deepEqual(dep$1, { named: 'named' }); -t.deepEqual(external__namespace, { - foo: 'foo', - default: { foo: 'foo' } -}); +t.deepEqual( + external__namespace, + rollupMajor < 3 ? { foo: 'foo' } : { foo: 'foo', default: { foo: 'foo' } } +); ", } `; diff --git a/packages/commonjs/test/test.js b/packages/commonjs/test/test.js index dcf3b3c72..2ab89dbe0 100644 --- a/packages/commonjs/test/test.js +++ b/packages/commonjs/test/test.js @@ -5,7 +5,7 @@ const path = require('path'); const { nodeResolve } = require('@rollup/plugin-node-resolve'); const { getLocator } = require('locate-character'); -const { rollup } = require('rollup'); +const { rollup, VERSION } = require('rollup'); const { install } = require('source-map-support'); const { testBundle } = require('../../../util/test'); @@ -18,6 +18,12 @@ const { normalizePathSlashes } = require('./helpers/util.js'); +const [rollupMajor, rollupMinor] = VERSION.split('.').map(Number); + +// rollup 4.13.0 augments plugin warnings and errors with a "[plugin commonjs] " prefix +const pluginMessagePrefix = + rollupMajor > 4 || (rollupMajor === 4 && rollupMinor >= 13) ? '[plugin commonjs] ' : ''; + const avaAssertions = { is(actual, expected, message) { expect(actual, message).toBe(expected); @@ -506,9 +512,19 @@ test('creates an error with a code frame when parsing fails', async () => { plugins: [commonjs()] }); } catch (error) { - expect(error.frame).toBe(`1: /* eslint-disable */ + expect(error.frame).toBe( + rollupMajor < 4 + ? `1: /* eslint-disable */ +2: export const foo = 2, + ^` + : rollupMajor === 4 && rollupMinor < 48 + ? `1: /* eslint-disable */ 2: export const foo = 2, - ^`); + ^` + : `1: /* eslint-disable */ +2: export const foo = 2, + ^` + ); } }); @@ -640,7 +656,7 @@ test('logs a warning when the deprecated namedExports option is used', async () }); await getCodeFromBundle(bundle); expect(message).toBe( - 'The namedExports option from "@rollup/plugin-commonjs" is deprecated. Named exports are now handled automatically.' + `${pluginMessagePrefix}The namedExports option from "@rollup/plugin-commonjs" is deprecated. Named exports are now handled automatically.` ); }); @@ -659,7 +675,7 @@ if (Number(/^v(\d+)/.exec(process.version)[1]) >= 12) { const getRollupUpCodeWithCache = new Worker( path.join(__dirname, 'fixtures/samples/caching/rollupWorker.js'), { - workerData: cache + workerData: { cache, rollupPath: require.resolve('rollup') } } ); expect(code).toBe(await new Promise((done) => getRollupUpCodeWithCache.on('message', done))); @@ -736,8 +752,13 @@ test('throws when there is a dynamic require from outside dynamicRequireRoot', a const minimalDynamicRequireRoot = normalizePathSlashes( path.join(cwd, 'fixtures/samples/dynamic-require-outside-root') ); + // rollup 4.13.0 also prepends the relative id and error position to augmented plugin errors + const augmentedErrorPrefix = + rollupMajor > 4 || (rollupMajor === 4 && rollupMinor >= 13) + ? `${pluginMessagePrefix}${normalizePathSlashes(path.relative(cwd, id))} (3:9): ` + : ''; expect(error).toMatchObject({ - message: `"${id}" contains dynamic require statements but it is not within the current dynamicRequireRoot "${dynamicRequireRoot}". You should set dynamicRequireRoot to "${minimalDynamicRequireRoot}" or one of its parent directories.`, + message: `${augmentedErrorPrefix}"${id}" contains dynamic require statements but it is not within the current dynamicRequireRoot "${dynamicRequireRoot}". You should set dynamicRequireRoot to "${minimalDynamicRequireRoot}" or one of its parent directories.`, pluginCode: 'DYNAMIC_REQUIRE_OUTSIDE_ROOT', normalizedId: id, normalizedDynamicRequireRoot: dynamicRequireRoot @@ -1322,7 +1343,7 @@ test('allows the config to be reused', async () => { }); expect(bundle.cache.modules.map(({ id }) => id)).toEqual(['bar.js']); }); -test('keep the shebang at the top of the file content', async () => { +test.skipIf(rollupMajor < 3)('keep the shebang at the top of the file content', async () => { const bundle = await rollup({ input: ['fixtures/samples/shebang/main.js'], plugins: [commonjs()] diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 30569e7b8..22cceb2fb 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -112,13 +112,13 @@ importers: devDependencies: '@rollup/plugin-node-resolve': specifier: ^15.0.0 - version: 15.0.0(rollup@4.0.0-24) + version: 15.0.0(rollup@4.65.1) '@rollup/plugin-node-resolve-earliest': specifier: npm:@rollup/plugin-node-resolve@11.2.1 - version: '@rollup/plugin-node-resolve@11.2.1(rollup@4.0.0-24)' + version: '@rollup/plugin-node-resolve@11.2.1(rollup@4.65.1)' '@rollup/plugin-typescript': specifier: ^9.0.1 - version: 9.0.1(rollup@4.0.0-24)(tslib@2.4.0)(typescript@4.8.4) + version: 9.0.1(rollup@4.65.1)(tslib@2.4.0)(typescript@4.8.4) del: specifier: ^6.1.1 version: 6.1.1 @@ -126,8 +126,8 @@ importers: specifier: ^1.0.0 version: 1.0.0 rollup: - specifier: ^4.0.0-24 - version: 4.0.0-24 + specifier: 'catalog:' + version: 4.65.1 rollup-earliest: specifier: npm:rollup@1.20.0 version: rollup@1.20.0 @@ -254,6 +254,9 @@ importers: '@rollup/plugin-node-resolve': specifier: ^15.0.0 version: 15.0.0(rollup@4.0.0-24) + '@rollup/plugin-node-resolve-earliest': + specifier: npm:@rollup/plugin-node-resolve@13.3.0 + version: '@rollup/plugin-node-resolve@13.3.0(rollup@4.0.0-24)' locate-character: specifier: ^2.0.5 version: 2.0.5 @@ -263,6 +266,9 @@ importers: rollup: specifier: ^4.0.0-24 version: 4.0.0-24 + rollup-earliest: + specifier: npm:rollup@2.68.0 + version: rollup@2.68.0 source-map: specifier: ^0.7.4 version: 0.7.4 @@ -1879,6 +1885,12 @@ packages: peerDependencies: rollup: ^1.20.0||^2.0.0 + '@rollup/plugin-node-resolve@13.3.0': + resolution: {integrity: sha512-Lus8rbUo1eEcnS4yTFKLZrVumLPY+YayBdWXgFSHYhTT2iJbMhoaaBL3xl5NCdeRytErGr8tZ0L71BMRmnlwSw==} + engines: {node: '>= 10.0.0'} + peerDependencies: + rollup: ^2.42.0 + '@rollup/plugin-node-resolve@15.0.0': resolution: {integrity: sha512-iwJbzfTzlzDDQcGmkS7EkCKwe2kSkdBrjX87Fy/KrNjr6UNnLpod0t6X66e502LRe5JJCA4FFqrEscWPnZAkig==} engines: {node: '>=14.0.0'} @@ -4916,6 +4928,11 @@ packages: engines: {node: '>=10.0.0'} hasBin: true + rollup@2.68.0: + resolution: {integrity: sha512-XrMKOYK7oQcTio4wyTz466mucnd8LzkiZLozZ4Rz0zQD+HeX4nUK4B8GrTX/2EvN2/vBF/i2WnaXboPxo0JylA==} + engines: {node: '>=10.0.0'} + hasBin: true + rollup@2.78.0: resolution: {integrity: sha512-4+YfbQC9QEVvKTanHhIAFVUFSRsezvQF8vFOJwtGfb9Bb+r014S+qryr9PSmw8x6sMnPkmFBGAvIFVQxvJxjtg==} engines: {node: '>=10.0.0'} @@ -6717,25 +6734,25 @@ snapshots: optionalDependencies: rollup: 4.65.1 - '@rollup/plugin-node-resolve@11.2.1(rollup@4.0.0-24)': + '@rollup/plugin-node-resolve@11.2.1(rollup@4.65.1)': dependencies: - '@rollup/pluginutils': 3.1.0(rollup@4.0.0-24) + '@rollup/pluginutils': 3.1.0(rollup@4.65.1) '@types/resolve': 1.17.1 builtin-modules: 3.3.0 deepmerge: 4.2.2 is-module: 1.0.0 resolve: 1.22.1 - rollup: 4.0.0-24 + rollup: 4.65.1 - '@rollup/plugin-node-resolve@11.2.1(rollup@4.65.1)': + '@rollup/plugin-node-resolve@13.3.0(rollup@4.0.0-24)': dependencies: - '@rollup/pluginutils': 3.1.0(rollup@4.65.1) + '@rollup/pluginutils': 3.1.0(rollup@4.0.0-24) '@types/resolve': 1.17.1 - builtin-modules: 3.3.0 deepmerge: 4.2.2 + is-builtin-module: 3.2.0 is-module: 1.0.0 resolve: 1.22.1 - rollup: 4.65.1 + rollup: 4.0.0-24 '@rollup/plugin-node-resolve@15.0.0(rollup@4.0.0-24)': dependencies: @@ -9949,6 +9966,10 @@ snapshots: optionalDependencies: fsevents: 2.3.3 + rollup@2.68.0: + optionalDependencies: + fsevents: 2.3.3 + rollup@2.78.0: optionalDependencies: fsevents: 2.3.3 From a124f3a83b1d14ad1bb4d8916304a77ab803ac40 Mon Sep 17 00:00:00 2001 From: Lukas Taegert-Atkinson Date: Fri, 23 Oct 2026 19:49:14 +0200 Subject: [PATCH 30/43] test(typescript): test against earliest supported rollup Run the test suite a second time with rollup pinned to the earliest supported version (2.14.0). @rollup/plugin-commonjs is pinned to 14.0.0, the last version supporting rollup 2.14. Branch expectations on the rollup version where inlineDynamicImports and preserveModules are still input options, bundle.close is missing, entry chunks are emitted in a different order and the pinned commonjs plugin does not unwrap the default export of __esModule modules. Fork the snapshots whose serialized errors and warnings differ at that version. --- packages/typescript/package.json | 5 +- .../test/snapshots-earliest/tslib.js.snap | 3 + .../test/snapshots-earliest/warnings.js.snap | 12 ++ .../typescript/test/snapshots/tslib.js.snap | 2 +- .../test/snapshots/warnings.js.snap | 3 +- packages/typescript/test/test.js | 116 +++++++++++++----- packages/typescript/test/tslib.js | 14 ++- pnpm-lock.yaml | 61 ++++++--- 8 files changed, 158 insertions(+), 58 deletions(-) create mode 100644 packages/typescript/test/snapshots-earliest/tslib.js.snap create mode 100644 packages/typescript/test/snapshots-earliest/warnings.js.snap diff --git a/packages/typescript/package.json b/packages/typescript/package.json index efcd000f5..e902c668f 100644 --- a/packages/typescript/package.json +++ b/packages/typescript/package.json @@ -35,6 +35,7 @@ "pretest": "pnpm build", "release": "pnpm --workspace-root package:release $(pwd)", "test": "vitest --config ../../.config/vitest.config.mts run", + "test:earliest": "pnpm test -- --mode earliest", "test:ts": "tsc --noEmit" }, "files": [ @@ -71,10 +72,12 @@ "devDependencies": { "@rollup/plugin-buble": "^1.0.0", "@rollup/plugin-commonjs": "^23.0.0", + "@rollup/plugin-commonjs-earliest": "npm:@rollup/plugin-commonjs@14.0.0", "@types/node": "^14.18.30", "@types/resolve": "^1.20.2", "buble": "^0.20.0", - "rollup": "^4.0.0-24", + "rollup": "catalog:", + "rollup-earliest": "npm:rollup@2.14.0", "typescript": "^4.8.3" }, "types": "./types/index.d.ts" diff --git a/packages/typescript/test/snapshots-earliest/tslib.js.snap b/packages/typescript/test/snapshots-earliest/tslib.js.snap new file mode 100644 index 000000000..de251c1ea --- /dev/null +++ b/packages/typescript/test/snapshots-earliest/tslib.js.snap @@ -0,0 +1,3 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`fails without tslib installed 1`] = `[Error: @rollup/plugin-typescript: Could not find module 'tslib', which is required by this plugin. Is it installed?]`; diff --git a/packages/typescript/test/snapshots-earliest/warnings.js.snap b/packages/typescript/test/snapshots-earliest/warnings.js.snap new file mode 100644 index 000000000..268abb065 --- /dev/null +++ b/packages/typescript/test/snapshots-earliest/warnings.js.snap @@ -0,0 +1,12 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`bad module in tsconfig 1`] = ` +[ + { + "code": "PLUGIN_WARNING", + "message": "@rollup/plugin-typescript: Rollup requires that TypeScript produces ES Modules. Unfortunately your configuration specifies a "module" other than "esnext". Unless you know what you're doing, please change "module" to "esnext" in the target tsconfig.json file or plugin options.", + "plugin": "typescript", + "toString": [Function], + }, +] +`; diff --git a/packages/typescript/test/snapshots/tslib.js.snap b/packages/typescript/test/snapshots/tslib.js.snap index 45675c289..cea800cd3 100644 --- a/packages/typescript/test/snapshots/tslib.js.snap +++ b/packages/typescript/test/snapshots/tslib.js.snap @@ -1,3 +1,3 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`fails without tslib installed 1`] = `[RollupError: @rollup/plugin-typescript: Could not find module 'tslib', which is required by this plugin. Is it installed?]`; +exports[`fails without tslib installed 1`] = `[RollupError: [plugin typescript] @rollup/plugin-typescript: Could not find module 'tslib', which is required by this plugin. Is it installed?]`; diff --git a/packages/typescript/test/snapshots/warnings.js.snap b/packages/typescript/test/snapshots/warnings.js.snap index b2a3d7588..91f9873b2 100644 --- a/packages/typescript/test/snapshots/warnings.js.snap +++ b/packages/typescript/test/snapshots/warnings.js.snap @@ -4,8 +4,9 @@ exports[`bad module in tsconfig 1`] = ` [ { "code": "PLUGIN_WARNING", - "message": "@rollup/plugin-typescript: Rollup requires that TypeScript produces ES Modules. Unfortunately your configuration specifies a "module" other than "esnext". Unless you know what you're doing, please change "module" to "esnext" in the target tsconfig.json file or plugin options.", + "message": "[plugin typescript] @rollup/plugin-typescript: Rollup requires that TypeScript produces ES Modules. Unfortunately your configuration specifies a "module" other than "esnext". Unless you know what you're doing, please change "module" to "esnext" in the target tsconfig.json file or plugin options.", "plugin": "typescript", + Symbol(augmented): true, }, ] `; diff --git a/packages/typescript/test/test.js b/packages/typescript/test/test.js index dbadde532..d2b29bfad 100644 --- a/packages/typescript/test/test.js +++ b/packages/typescript/test/test.js @@ -2,7 +2,7 @@ const path = require('path'); const fs = require('fs'); const commonjs = require('@rollup/plugin-commonjs'); -const { rollup, watch } = require('rollup'); +const { rollup, VERSION, watch } = require('rollup'); const ts = require('typescript'); const { evaluateBundle, getCode, getFiles, onwarn } = require('../../../util/test'); @@ -10,6 +10,13 @@ const typescript = require('..'); const { fakeTypescript, forceRemove, waitForWatcherEvent } = require('./helpers'); +const [rollupMajor, rollupMinor] = VERSION.split('.').map(Number); +// bundle.close() was added in rollup 2.35.0 +const hasBundleClose = rollupMajor > 2 || (rollupMajor === 2 && rollupMinor >= 35); +// rollup 4.13.0 augments plugin warnings and errors with a "[plugin ]" message prefix +// and, if the log has a location, an additional "relativeId (line:column)" segment +const hasAugmentedPluginLogs = rollupMajor > 4 || (rollupMajor === 4 && rollupMinor >= 13); + beforeEach(() => process.chdir(__dirname)); const outputOptions = { format: 'es' @@ -375,14 +382,23 @@ test.sequential('warns for invalid module types', async () => { } }) ); - expect(warnings).toEqual([ + const expectedWarnings = [ { code: 'PLUGIN_WARNING', plugin: 'typescript', pluginCode: 'TS6046', - message: `@rollup/plugin-typescript TS6046: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015', 'es2020', 'es2022', 'esnext', 'node16', 'nodenext'.` + message: `${ + hasAugmentedPluginLogs ? '[plugin typescript] ' : '' + }@rollup/plugin-typescript TS6046: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015', 'es2020', 'es2022', 'esnext', 'node16', 'nodenext'.` } - ]); + ]; + if (hasAugmentedPluginLogs) { + // rollup marks augmented warnings with an internal symbol; include it in the expectation + for (const [index, warning] of warnings.entries()) { + expectedWarnings[index][Object.getOwnPropertySymbols(warning)[0]] = true; + } + } + expect(warnings).toEqual(expectedWarnings); }); test.sequential('ignores case of module types', async () => { await expectNoError( @@ -472,7 +488,13 @@ test.sequential('reports diagnostics and throws if errors occur during transpila onwarn }) ); - expect(caughtError.message).toBe('@rollup/plugin-typescript TS1110: Type expected.'); + expect(caughtError.message).toBe( + `${ + hasAugmentedPluginLogs + ? '[plugin typescript] fixtures/syntax-error/missing-type.ts (1:8): ' + : '' + }@rollup/plugin-typescript TS1110: Type expected.` + ); expect(caughtError.pluginCode).toBe('TS1110'); }); test.sequential('ignore type errors if noEmitOnError is false', async () => { @@ -494,7 +516,13 @@ test.sequential('ignore type errors if noEmitOnError is false', async () => { expect(warnings[0].code).toBe('PLUGIN_WARNING'); expect(warnings[0].plugin).toBe('typescript'); expect(warnings[0].pluginCode).toBe('TS1110'); - expect(warnings[0].message).toBe('@rollup/plugin-typescript TS1110: Type expected.'); + expect(warnings[0].message).toBe( + `${ + hasAugmentedPluginLogs + ? '[plugin typescript] fixtures/syntax-error/missing-type.ts (1:8): ' + : '' + }@rollup/plugin-typescript TS1110: Type expected.` + ); expect(warnings[0].loc.line).toBe(1); expect(warnings[0].loc.column).toBe(8); expect(warnings[0].loc.file.includes('missing-type.ts')).toBe(true); @@ -772,14 +800,23 @@ test.sequential('should throw on bad options', async () => { message: "@rollup/plugin-typescript: Couldn't process compiler options" } ); - expect(warnings).toEqual([ + const expectedWarnings = [ { code: 'PLUGIN_WARNING', plugin: 'typescript', pluginCode: 'TS5023', - message: `@rollup/plugin-typescript TS5023: Unknown compiler option 'foo'.` + message: `${ + hasAugmentedPluginLogs ? '[plugin typescript] ' : '' + }@rollup/plugin-typescript TS5023: Unknown compiler option 'foo'.` } - ]); + ]; + if (hasAugmentedPluginLogs) { + // rollup marks augmented warnings with an internal symbol; include it in the expectation + for (const [index, warning] of warnings.entries()) { + expectedWarnings[index][Object.getOwnPropertySymbols(warning)[0]] = true; + } + } + expect(warnings).toEqual(expectedWarnings); }); test.sequential('should handle re-exporting types', async () => { const bundle = await rollup({ @@ -900,20 +937,21 @@ test.sequential('should allow merging an exported function and namespace', async expect(f.foo).toBe('2'); }); test.sequential('supports dynamic imports', async () => { + // inlineDynamicImports became an output option in rollup 2.18.0; before that, it was an input option + const inlineDynamicImportsOnOutput = rollupMajor > 2 || (rollupMajor === 2 && rollupMinor >= 18); + const bundle = await rollup({ + input: 'fixtures/dynamic-imports/main.ts', + plugins: [ + typescript({ + tsconfig: 'fixtures/dynamic-imports/tsconfig.json' + }) + ], + onwarn, + ...(inlineDynamicImportsOnOutput ? {} : { inlineDynamicImports: true }) + }); const code = await getCode( - await rollup({ - input: 'fixtures/dynamic-imports/main.ts', - plugins: [ - typescript({ - tsconfig: 'fixtures/dynamic-imports/tsconfig.json' - }) - ], - onwarn - }), - { - ...outputOptions, - inlineDynamicImports: true - } + bundle, + inlineDynamicImportsOnOutput ? { ...outputOptions, inlineDynamicImports: true } : outputOptions ); expect(code.includes("console.log('dynamic')")).toBe(true); }); @@ -932,7 +970,13 @@ test.sequential('supports CommonJS imports when the output format is CommonJS', onwarn }); const output = await evaluateBundle(bundle); - expect(output).toBe('exported from commonjs'); + // @rollup/plugin-commonjs 14, pinned for the earliest rollup, does not unwrap + // the default export of modules marked with __esModule + if (rollupMajor >= 3) { + expect(output).toBe('exported from commonjs'); + } else { + expect(output).toEqual({ __esModule: true, default: 'exported from commonjs' }); + } }); test.sequential('supports optional chaining', async () => { const bundle = await rollup({ @@ -1357,8 +1401,14 @@ test.sequential('normalizes resolved ids to avoid duplicate output on windows', true ); expect(files.length).toBe(2); - expect(files[0].fileName.includes('two.js'), files[1].fileName).toBe(true); - expect(files[0].code.includes("import { one } from './one.js';"), files[1].code).toBe(true); + // rollup 3.17.0 reversed the order in which entry chunks are emitted + if (rollupMajor >= 4 || (rollupMajor === 3 && rollupMinor >= 17)) { + expect(files[0].fileName.includes('two.js'), files[1].fileName).toBe(true); + expect(files[0].code.includes("import { one } from './one.js';"), files[1].code).toBe(true); + } else { + expect(files[1].fileName.includes('two.js'), files[0].fileName).toBe(true); + expect(files[1].code.includes("import { one } from './one.js';"), files[0].code).toBe(true); + } }); test.sequential('does it support tsconfig.rootDir for filtering', async () => { process.chdir('fixtures/root-dir/packages/test-1'); @@ -1944,7 +1994,9 @@ test.sequential( }; expect(bundle.watchFiles.every((f) => !isInside(outDirAbs, f))).toBe(true); } finally { - await bundle.close(); + if (hasBundleClose) { + await bundle.close(); + } fs.rmSync(outDir, { recursive: true, force: true @@ -2042,7 +2094,9 @@ test.sequential( } ]); } finally { - await bundle.close(); + if (hasBundleClose) { + await bundle.close(); + } // tidy emitted file to avoid cross-test interference if ordering changes if (fs.existsSync(outputJs)) fs.unlinkSync(outputJs); } @@ -2129,7 +2183,9 @@ test.sequential('recreates typeChecker-based transformers per rebuild in watch m ); expect(observations).toEqual(['tc-one', 'tc-two']); } finally { - await bundle.close(); + if (hasBundleClose) { + await bundle.close(); + } // tidy emitted file to avoid cross-test interference if ordering changes if (fs.existsSync(outputJs)) fs.unlinkSync(outputJs); } @@ -2209,7 +2265,9 @@ test.sequential('defaults to legacy behavior: reuses factories across watch rebu } ]); } finally { - await bundle.close(); + if (hasBundleClose) { + await bundle.close(); + } if (fs.existsSync(outputJs)) fs.unlinkSync(outputJs); } }); diff --git a/packages/typescript/test/tslib.js b/packages/typescript/test/tslib.js index 892731a83..a946fc022 100644 --- a/packages/typescript/test/tslib.js +++ b/packages/typescript/test/tslib.js @@ -1,8 +1,10 @@ -import { rollup } from 'rollup'; +import { rollup, VERSION } from 'rollup'; import typescript from '..'; import { evaluateBundle, getCode, onwarn } from '../../../util/test.js'; +const [rollupMajor, rollupMinor] = VERSION.split('.').map(Number); + const captureThrownError = async (valueOrFactory) => { try { await (typeof valueOrFactory === 'function' ? valueOrFactory() : valueOrFactory); @@ -79,6 +81,8 @@ test.sequential('fails without tslib installed', async () => { expect(error).toMatchSnapshot(); }); test.sequential('creates _tslib.js file when preserveModules is used', async () => { + // preserveModules became an output option in rollup 2.18.0; before that, it was an input option + const preserveModulesOnOutput = rollupMajor > 2 || (rollupMajor === 2 && rollupMinor >= 18); const bundle = await rollup({ input: 'fixtures/preserve-modules/main.ts', plugins: [ @@ -86,14 +90,12 @@ test.sequential('creates _tslib.js file when preserveModules is used', async () tsconfig: 'fixtures/preserve-modules/tsconfig.json' }) ], - onwarn + onwarn, + ...(preserveModulesOnOutput ? {} : { preserveModules: true }) }); const files = await getCode( bundle, - { - format: 'es', - preserveModules: true - }, + preserveModulesOnOutput ? { format: 'es', preserveModules: true } : { format: 'es' }, true ); expect(files[0].fileName.includes('main.js'), files[0].fileName).toBe(true); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 22cceb2fb..631d511bc 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -228,7 +228,7 @@ importers: dependencies: '@rollup/pluginutils': specifier: ^5.0.1 - version: 5.0.1(rollup@4.0.0-24) + version: 5.0.1(rollup@4.65.1) commondir: specifier: ^1.0.1 version: 1.0.1 @@ -250,13 +250,13 @@ importers: devDependencies: '@rollup/plugin-json': specifier: ^5.0.0 - version: 5.0.0(rollup@4.0.0-24) + version: 5.0.0(rollup@4.65.1) '@rollup/plugin-node-resolve': specifier: ^15.0.0 - version: 15.0.0(rollup@4.0.0-24) + version: 15.0.0(rollup@4.65.1) '@rollup/plugin-node-resolve-earliest': specifier: npm:@rollup/plugin-node-resolve@13.3.0 - version: '@rollup/plugin-node-resolve@13.3.0(rollup@4.0.0-24)' + version: '@rollup/plugin-node-resolve@13.3.0(rollup@4.65.1)' locate-character: specifier: ^2.0.5 version: 2.0.5 @@ -264,8 +264,8 @@ importers: specifier: ^0.8.7 version: 0.8.7 rollup: - specifier: ^4.0.0-24 - version: 4.0.0-24 + specifier: 'catalog:' + version: 4.65.1 rollup-earliest: specifier: npm:rollup@2.68.0 version: rollup@2.68.0 @@ -811,6 +811,9 @@ importers: '@rollup/plugin-commonjs': specifier: ^23.0.0 version: 23.0.0(rollup@4.0.0-24) + '@rollup/plugin-commonjs-earliest': + specifier: npm:@rollup/plugin-commonjs@14.0.0 + version: '@rollup/plugin-commonjs@14.0.0(rollup@4.0.0-24)' '@types/node': specifier: ^14.18.30 version: 14.18.31 @@ -823,6 +826,9 @@ importers: rollup: specifier: ^4.0.0-24 version: 4.0.0-24 + rollup-earliest: + specifier: npm:rollup@2.14.0 + version: rollup@2.14.0 typescript: specifier: ^4.8.3 version: 4.8.4 @@ -1861,6 +1867,12 @@ packages: rollup: optional: true + '@rollup/plugin-commonjs@14.0.0': + resolution: {integrity: sha512-+PSmD9ePwTAeU106i9FRdc+Zb3XUWyW26mo5Atr2mk82hor8+nPwkztEjFo8/B1fJKfaQDg9aM2bzQkjhi7zOw==} + engines: {node: '>= 8.0.0'} + peerDependencies: + rollup: ^2.3.4 + '@rollup/plugin-commonjs@23.0.0': resolution: {integrity: sha512-JbrTRyDNtLQj/rhl7RFUuYXwQ2fac+33oLDAu2k++WD95zweyo28UAomLVA0JMGx4vmCa7Nw4T6k/1F6lelExg==} engines: {node: '>=14.0.0'} @@ -4923,6 +4935,11 @@ packages: engines: {node: '>=10.0.0'} hasBin: true + rollup@2.14.0: + resolution: {integrity: sha512-SUsFh2bBemQqCXOCBWRayjK3/6kNHVR8PbSKKYWIdI6e4zuGSW5B1hGVkFi40805dUrqosMLLxMuEyJMylC9YA==} + engines: {node: '>=10.0.0'} + hasBin: true + rollup@2.53.1: resolution: {integrity: sha512-yiTCvcYXZEulNWNlEONOQVlhXA/hgxjelFSjNcrwAAIfYx/xqjSHwqg/cCaWOyFRKr+IQBaXwt723m8tCaIUiw==} engines: {node: '>=10.0.0'} @@ -6700,6 +6717,17 @@ snapshots: optionalDependencies: rollup: 4.65.1 + '@rollup/plugin-commonjs@14.0.0(rollup@4.0.0-24)': + dependencies: + '@rollup/pluginutils': 3.1.0(rollup@4.0.0-24) + commondir: 1.0.1 + estree-walker: 1.0.1 + glob: 7.2.3 + is-reference: 1.2.1 + magic-string: 0.25.9 + resolve: 1.22.1 + rollup: 4.0.0-24 + '@rollup/plugin-commonjs@23.0.0(rollup@4.0.0-24)': dependencies: '@rollup/pluginutils': 4.2.1 @@ -6744,26 +6772,15 @@ snapshots: resolve: 1.22.1 rollup: 4.65.1 - '@rollup/plugin-node-resolve@13.3.0(rollup@4.0.0-24)': + '@rollup/plugin-node-resolve@13.3.0(rollup@4.65.1)': dependencies: - '@rollup/pluginutils': 3.1.0(rollup@4.0.0-24) + '@rollup/pluginutils': 3.1.0(rollup@4.65.1) '@types/resolve': 1.17.1 deepmerge: 4.2.2 is-builtin-module: 3.2.0 is-module: 1.0.0 resolve: 1.22.1 - rollup: 4.0.0-24 - - '@rollup/plugin-node-resolve@15.0.0(rollup@4.0.0-24)': - dependencies: - '@rollup/pluginutils': 4.2.1 - '@types/resolve': 1.20.2 - deepmerge: 4.2.2 - is-builtin-module: 3.2.0 - is-module: 1.0.0 - resolve: 1.22.1 - optionalDependencies: - rollup: 4.0.0-24 + rollup: 4.65.1 '@rollup/plugin-node-resolve@15.0.0(rollup@4.65.1)': dependencies: @@ -9962,6 +9979,10 @@ snapshots: optionalDependencies: fsevents: 2.1.3 + rollup@2.14.0: + optionalDependencies: + fsevents: 2.1.3 + rollup@2.53.1: optionalDependencies: fsevents: 2.3.3 From 8d89c12747d435474d47b1b1d896633dc10a812e Mon Sep 17 00:00:00 2001 From: Lukas Taegert-Atkinson Date: Fri, 23 Oct 2026 20:08:18 +0200 Subject: [PATCH 31/43] test(dynamic-import-vars): test against earliest supported rollup Run the test suite a second time with rollup pinned to the earliest supported version (1.20.0). Skip the import assertions fixture for rollup versions before 3.0.0, whose bundled parser does not understand import assertions yet, and fork the snapshots because rollup 1 uses a different chunk hash format. --- packages/dynamic-import-vars/package.json | 6 +- .../rollup-plugin-dynamic-import-vars.test.js | 14 +- ...up-plugin-dynamic-import-vars.test.js.snap | 214 ++++++++++++++++++ ...up-plugin-dynamic-import-vars.test.js.snap | 54 ++--- pnpm-lock.yaml | 44 +--- 5 files changed, 268 insertions(+), 64 deletions(-) create mode 100644 packages/dynamic-import-vars/test/snapshots-earliest/rollup-plugin-dynamic-import-vars.test.js.snap diff --git a/packages/dynamic-import-vars/package.json b/packages/dynamic-import-vars/package.json index 778de9c31..c37748d1d 100644 --- a/packages/dynamic-import-vars/package.json +++ b/packages/dynamic-import-vars/package.json @@ -34,7 +34,8 @@ "prerelease": "pnpm build", "pretest": "pnpm build --sourcemap", "release": "pnpm --workspace-root package:release $(pwd)", - "test": "vitest --config ../../.config/vitest.config.mts run" + "test": "vitest --config ../../.config/vitest.config.mts run", + "test:earliest": "pnpm test -- --mode earliest" }, "files": [ "dist", @@ -73,7 +74,8 @@ "devDependencies": { "acorn": "^8.8.0", "prettier": "^2.7.1", - "rollup": "^4.0.0-24" + "rollup": "catalog:", + "rollup-earliest": "npm:rollup@1.20.0" }, "types": "./types/index.d.ts" } diff --git a/packages/dynamic-import-vars/test/rollup-plugin-dynamic-import-vars.test.js b/packages/dynamic-import-vars/test/rollup-plugin-dynamic-import-vars.test.js index 63e1144c1..471ec6bfb 100644 --- a/packages/dynamic-import-vars/test/rollup-plugin-dynamic-import-vars.test.js +++ b/packages/dynamic-import-vars/test/rollup-plugin-dynamic-import-vars.test.js @@ -2,10 +2,12 @@ const { join } = require('path'); -const { rollup } = require('rollup'); +const { rollup, VERSION } = require('rollup'); const dynamicImportVars = require('current-package'); +const [rollupMajor, rollupMinor] = VERSION.split('.').map(Number); + process.chdir(join(__dirname, 'fixtures')); test('single dir', async () => { const bundle = await rollup({ @@ -158,7 +160,8 @@ test('throws an error on failure', async () => { } expect(thrown).toBe(true); }); -test('dynamic imports assertions', async () => { +// import assertions were added to rollup's parser in rollup 3.0.0 +test.skipIf(rollupMajor < 3)('dynamic imports assertions', async () => { const bundle = await rollup({ input: 'fixture-assert.js', plugins: [dynamicImportVars()] @@ -208,6 +211,11 @@ test('throws if no files in dir when `errorWhenNoFilesFound` is set', async () = expect(thrown).toBe(true); }); test('warns if no files in dir when `errorWhenNoFilesFound` and `warnOnError` are both set', async () => { + // rollup 4.13.0 prefixes plugin warnings with the plugin name and the id of the related file + const pluginMessagePrefix = + rollupMajor > 4 || (rollupMajor === 4 && rollupMinor >= 13) + ? '[plugin rollup-plugin-dynamic-import-variables] fixture-no-files.js: ' + : ''; let warningEmitted = false; await rollup({ input: 'fixture-no-files.js', @@ -219,7 +227,7 @@ test('warns if no files in dir when `errorWhenNoFilesFound` and `warnOnError` ar ], onwarn(warning) { expect(warning.message).toEqual( - `No files found in ./module-dir-c/*.js when trying to dynamically load concatted string from ${require.resolve( + `${pluginMessagePrefix}No files found in ./module-dir-c/*.js when trying to dynamically load concatted string from ${require.resolve( './fixtures/fixture-no-files.js' )}` ); diff --git a/packages/dynamic-import-vars/test/snapshots-earliest/rollup-plugin-dynamic-import-vars.test.js.snap b/packages/dynamic-import-vars/test/snapshots-earliest/rollup-plugin-dynamic-import-vars.test.js.snap new file mode 100644 index 000000000..8df9fa781 --- /dev/null +++ b/packages/dynamic-import-vars/test/snapshots-earliest/rollup-plugin-dynamic-import-vars.test.js.snap @@ -0,0 +1,214 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`can exclude files 1`] = ` +"function importModule(name) { + return import(\`./module-dir-a/\${name}.js\`); +} + +export { importModule }; +" +`; + +exports[`complex concatenation 1`] = ` +"function __variableDynamicImportRuntime0__(path) { + switch (path) { + case './module-dir-a/module-a-1.js': return import('./module-a-1-2243d07c.js'); + case './module-dir-a/module-a-2.js': return import('./module-a-2-b525581e.js'); + case './module-dir-b/module-b-1.js': return import('./module-b-1-ae7b2126.js'); + case './module-dir-b/module-b-2.js': return import('./module-b-2-904f10ba.js'); + default: return new Promise(function(resolve, reject) { + (typeof queueMicrotask === 'function' ? queueMicrotask : setTimeout)( + reject.bind(null, new Error("Unknown variable dynamic import: " + path)) + ); + }) + } + } + +function importModule(dirName, name) { + return __variableDynamicImportRuntime0__(\`\${\`./\${\`module-dir-\${dirName}\`}\` + '/'}\${name}.js\`); +} + +export { importModule }; +" +`; + +exports[`doesn't change imports that should not be changed 1`] = ` +"console.log('a-1'); + +function importModuleA() { + return import('./module-a-2-b525581e.js'); +} + +function importModuleB() { + return import('./' + 'module-dir-a' + '/' + 'module-a-2' + '.js'); +} + +export { importModuleA, importModuleB }; +" +`; + +exports[`dynamic imports assertions 1`] = ` +"function __variableDynamicImportRuntime0__(path) { + switch (path) { + case './module-dir-a/module-a-1.js': return import('./module-a-1-fiunS6HF.js'); + case './module-dir-a/module-a-2.js': return import('./module-a-2-qepdcyXv.js'); + default: return new Promise(function(resolve, reject) { + (typeof queueMicrotask === 'function' ? queueMicrotask : setTimeout)( + reject.bind(null, new Error("Unknown variable dynamic import: " + path)) + ); + }) + } + } + +function importModule(name) { + return __variableDynamicImportRuntime0__(\`./module-dir-a/\${name}.js\`); +} + +export { importModule }; +" +`; + +exports[`multiple dirs 1`] = ` +"function __variableDynamicImportRuntime0__(path) { + switch (path) { + case './module-dir-a/module-a-1.js': return import('./module-a-1-2243d07c.js'); + case './module-dir-a/module-a-2.js': return import('./module-a-2-b525581e.js'); + case './module-dir-b/module-b-1.js': return import('./module-b-1-ae7b2126.js'); + case './module-dir-b/module-b-2.js': return import('./module-b-2-904f10ba.js'); + case './sub-dir/fixture-upwards-path.js': return import('./fixture-upwards-path-35660ba5.js'); + default: return new Promise(function(resolve, reject) { + (typeof queueMicrotask === 'function' ? queueMicrotask : setTimeout)( + reject.bind(null, new Error("Unknown variable dynamic import: " + path)) + ); + }) + } + } + +function importModule(dir, name) { + return __variableDynamicImportRuntime0__(\`./\${dir}/\${name}.js\`); +} + +export { importModule }; +" +`; + +exports[`multiple dynamic imports 1`] = ` +"function __variableDynamicImportRuntime2__(path) { + switch (path) { + case './module-dir-a/module-a-1.js': return import('./module-a-1-2243d07c.js'); + case './module-dir-a/module-a-2.js': return import('./module-a-2-b525581e.js'); + case './module-dir-b/module-b-1.js': return import('./module-b-1-ae7b2126.js'); + case './module-dir-b/module-b-2.js': return import('./module-b-2-904f10ba.js'); + case './sub-dir/fixture-upwards-path.js': return import('./fixture-upwards-path-35660ba5.js'); + default: return new Promise(function(resolve, reject) { + (typeof queueMicrotask === 'function' ? queueMicrotask : setTimeout)( + reject.bind(null, new Error("Unknown variable dynamic import: " + path)) + ); + }) + } + } + +function __variableDynamicImportRuntime1__(path) { + switch (path) { + case './module-dir-a/module-a-1.js': return import('./module-a-1-2243d07c.js'); + case './module-dir-a/module-a-2.js': return import('./module-a-2-b525581e.js'); + default: return new Promise(function(resolve, reject) { + (typeof queueMicrotask === 'function' ? queueMicrotask : setTimeout)( + reject.bind(null, new Error("Unknown variable dynamic import: " + path)) + ); + }) + } + } + +function __variableDynamicImportRuntime0__(path) { + switch (path) { + case './module-dir-a/module-a-1.js': return import('./module-a-1-2243d07c.js'); + case './module-dir-a/module-a-2.js': return import('./module-a-2-b525581e.js'); + default: return new Promise(function(resolve, reject) { + (typeof queueMicrotask === 'function' ? queueMicrotask : setTimeout)( + reject.bind(null, new Error("Unknown variable dynamic import: " + path)) + ); + }) + } + } + +class Foo { + importModule(name) { + return __variableDynamicImportRuntime0__(\`./module-dir-a/\${name}.js\`); + } +} + +__variableDynamicImportRuntime1__(\`./module-dir-a/\${name}.js\`).then((module) => { + console.log('imported', module); +}); + +function importModuleFromDir(dir, name) { + return __variableDynamicImportRuntime2__(\`./\${dir}/\${name}.js\`); +} + +export { Foo, importModuleFromDir }; +" +`; + +exports[`own directory 1`] = ` +"function __variableDynamicImportRuntime0__(path) { + switch (path) { + case './root-module-a.js': return import('./root-module-a-f97df467.js'); + case './root-module-b.js': return import('./root-module-b-8d9601c6.js'); + default: return new Promise(function(resolve, reject) { + (typeof queueMicrotask === 'function' ? queueMicrotask : setTimeout)( + reject.bind(null, new Error("Unknown variable dynamic import: " + path)) + ); + }) + } + } + +function importModule(name) { + return __variableDynamicImportRuntime0__(\`./root-module-\${name}.js\`); +} + +export { importModule }; +" +`; + +exports[`single dir 1`] = ` +"function __variableDynamicImportRuntime0__(path) { + switch (path) { + case './module-dir-a/module-a-1.js': return import('./module-a-1-2243d07c.js'); + case './module-dir-a/module-a-2.js': return import('./module-a-2-b525581e.js'); + default: return new Promise(function(resolve, reject) { + (typeof queueMicrotask === 'function' ? queueMicrotask : setTimeout)( + reject.bind(null, new Error("Unknown variable dynamic import: " + path)) + ); + }) + } + } + +function importModule(name) { + return __variableDynamicImportRuntime0__(\`./module-dir-a/\${name}.js\`); +} + +export { importModule }; +" +`; + +exports[`upwards dir path 1`] = ` +"function __variableDynamicImportRuntime0__(path) { + switch (path) { + case '../module-dir-a/module-a-1.js': return import('./module-a-1-2243d07c.js'); + case '../module-dir-a/module-a-2.js': return import('./module-a-2-b525581e.js'); + default: return new Promise(function(resolve, reject) { + (typeof queueMicrotask === 'function' ? queueMicrotask : setTimeout)( + reject.bind(null, new Error("Unknown variable dynamic import: " + path)) + ); + }) + } + } + +function importModule(name) { + return __variableDynamicImportRuntime0__(\`../module-dir-a/\${name}.js\`); +} + +export { importModule }; +" +`; diff --git a/packages/dynamic-import-vars/test/snapshots/rollup-plugin-dynamic-import-vars.test.js.snap b/packages/dynamic-import-vars/test/snapshots/rollup-plugin-dynamic-import-vars.test.js.snap index c82ca964e..b55053e2a 100644 --- a/packages/dynamic-import-vars/test/snapshots/rollup-plugin-dynamic-import-vars.test.js.snap +++ b/packages/dynamic-import-vars/test/snapshots/rollup-plugin-dynamic-import-vars.test.js.snap @@ -12,10 +12,10 @@ export { importModule }; exports[`complex concatenation 1`] = ` "function __variableDynamicImportRuntime0__(path) { switch (path) { - case './module-dir-a/module-a-1.js': return import('./module-a-1-fiunS6HF.js'); - case './module-dir-a/module-a-2.js': return import('./module-a-2-qepdcyXv.js'); - case './module-dir-b/module-b-1.js': return import('./module-b-1-3qdzaV4G.js'); - case './module-dir-b/module-b-2.js': return import('./module-b-2-_8gpxG1i.js'); + case './module-dir-a/module-a-1.js': return import('./module-a-1-DigFCZAs.js'); + case './module-dir-a/module-a-2.js': return import('./module-a-2-CBwBchsa.js'); + case './module-dir-b/module-b-1.js': return import('./module-b-1-B1WHOdOw.js'); + case './module-dir-b/module-b-2.js': return import('./module-b-2-BrHQGuGy.js'); default: return new Promise(function(resolve, reject) { (typeof queueMicrotask === 'function' ? queueMicrotask : setTimeout)( reject.bind(null, new Error("Unknown variable dynamic import: " + path)) @@ -36,7 +36,7 @@ exports[`doesn't change imports that should not be changed 1`] = ` "console.log('a-1'); function importModuleA() { - return import('./module-a-2-qepdcyXv.js'); + return import('./module-a-2-CBwBchsa.js'); } function importModuleB() { @@ -50,8 +50,8 @@ export { importModuleA, importModuleB }; exports[`dynamic imports assertions 1`] = ` "function __variableDynamicImportRuntime0__(path) { switch (path) { - case './module-dir-a/module-a-1.js': return import('./module-a-1-fiunS6HF.js'); - case './module-dir-a/module-a-2.js': return import('./module-a-2-qepdcyXv.js'); + case './module-dir-a/module-a-1.js': return import('./module-a-1-DigFCZAs.js'); + case './module-dir-a/module-a-2.js': return import('./module-a-2-CBwBchsa.js'); default: return new Promise(function(resolve, reject) { (typeof queueMicrotask === 'function' ? queueMicrotask : setTimeout)( reject.bind(null, new Error("Unknown variable dynamic import: " + path)) @@ -71,11 +71,11 @@ export { importModule }; exports[`multiple dirs 1`] = ` "function __variableDynamicImportRuntime0__(path) { switch (path) { - case './module-dir-a/module-a-1.js': return import('./module-a-1-fiunS6HF.js'); - case './module-dir-a/module-a-2.js': return import('./module-a-2-qepdcyXv.js'); - case './module-dir-b/module-b-1.js': return import('./module-b-1-3qdzaV4G.js'); - case './module-dir-b/module-b-2.js': return import('./module-b-2-_8gpxG1i.js'); - case './sub-dir/fixture-upwards-path.js': return import('./fixture-upwards-path-jrfqlYMu.js'); + case './module-dir-a/module-a-1.js': return import('./module-a-1-DigFCZAs.js'); + case './module-dir-a/module-a-2.js': return import('./module-a-2-CBwBchsa.js'); + case './module-dir-b/module-b-1.js': return import('./module-b-1-B1WHOdOw.js'); + case './module-dir-b/module-b-2.js': return import('./module-b-2-BrHQGuGy.js'); + case './sub-dir/fixture-upwards-path.js': return import('./fixture-upwards-path-CrflyznY.js'); default: return new Promise(function(resolve, reject) { (typeof queueMicrotask === 'function' ? queueMicrotask : setTimeout)( reject.bind(null, new Error("Unknown variable dynamic import: " + path)) @@ -95,11 +95,11 @@ export { importModule }; exports[`multiple dynamic imports 1`] = ` "function __variableDynamicImportRuntime2__(path) { switch (path) { - case './module-dir-a/module-a-1.js': return import('./module-a-1-fiunS6HF.js'); - case './module-dir-a/module-a-2.js': return import('./module-a-2-qepdcyXv.js'); - case './module-dir-b/module-b-1.js': return import('./module-b-1-3qdzaV4G.js'); - case './module-dir-b/module-b-2.js': return import('./module-b-2-_8gpxG1i.js'); - case './sub-dir/fixture-upwards-path.js': return import('./fixture-upwards-path-jrfqlYMu.js'); + case './module-dir-a/module-a-1.js': return import('./module-a-1-DigFCZAs.js'); + case './module-dir-a/module-a-2.js': return import('./module-a-2-CBwBchsa.js'); + case './module-dir-b/module-b-1.js': return import('./module-b-1-B1WHOdOw.js'); + case './module-dir-b/module-b-2.js': return import('./module-b-2-BrHQGuGy.js'); + case './sub-dir/fixture-upwards-path.js': return import('./fixture-upwards-path-CrflyznY.js'); default: return new Promise(function(resolve, reject) { (typeof queueMicrotask === 'function' ? queueMicrotask : setTimeout)( reject.bind(null, new Error("Unknown variable dynamic import: " + path)) @@ -110,8 +110,8 @@ exports[`multiple dynamic imports 1`] = ` function __variableDynamicImportRuntime1__(path) { switch (path) { - case './module-dir-a/module-a-1.js': return import('./module-a-1-fiunS6HF.js'); - case './module-dir-a/module-a-2.js': return import('./module-a-2-qepdcyXv.js'); + case './module-dir-a/module-a-1.js': return import('./module-a-1-DigFCZAs.js'); + case './module-dir-a/module-a-2.js': return import('./module-a-2-CBwBchsa.js'); default: return new Promise(function(resolve, reject) { (typeof queueMicrotask === 'function' ? queueMicrotask : setTimeout)( reject.bind(null, new Error("Unknown variable dynamic import: " + path)) @@ -122,8 +122,8 @@ function __variableDynamicImportRuntime1__(path) { function __variableDynamicImportRuntime0__(path) { switch (path) { - case './module-dir-a/module-a-1.js': return import('./module-a-1-fiunS6HF.js'); - case './module-dir-a/module-a-2.js': return import('./module-a-2-qepdcyXv.js'); + case './module-dir-a/module-a-1.js': return import('./module-a-1-DigFCZAs.js'); + case './module-dir-a/module-a-2.js': return import('./module-a-2-CBwBchsa.js'); default: return new Promise(function(resolve, reject) { (typeof queueMicrotask === 'function' ? queueMicrotask : setTimeout)( reject.bind(null, new Error("Unknown variable dynamic import: " + path)) @@ -153,8 +153,8 @@ export { Foo, importModuleFromDir }; exports[`own directory 1`] = ` "function __variableDynamicImportRuntime0__(path) { switch (path) { - case './root-module-a.js': return import('./root-module-a-lF5i40jF.js'); - case './root-module-b.js': return import('./root-module-b-F1yin99u.js'); + case './root-module-a.js': return import('./root-module-a-D2fW8xde.js'); + case './root-module-b.js': return import('./root-module-b-DYGa4ib9.js'); default: return new Promise(function(resolve, reject) { (typeof queueMicrotask === 'function' ? queueMicrotask : setTimeout)( reject.bind(null, new Error("Unknown variable dynamic import: " + path)) @@ -174,8 +174,8 @@ export { importModule }; exports[`single dir 1`] = ` "function __variableDynamicImportRuntime0__(path) { switch (path) { - case './module-dir-a/module-a-1.js': return import('./module-a-1-fiunS6HF.js'); - case './module-dir-a/module-a-2.js': return import('./module-a-2-qepdcyXv.js'); + case './module-dir-a/module-a-1.js': return import('./module-a-1-DigFCZAs.js'); + case './module-dir-a/module-a-2.js': return import('./module-a-2-CBwBchsa.js'); default: return new Promise(function(resolve, reject) { (typeof queueMicrotask === 'function' ? queueMicrotask : setTimeout)( reject.bind(null, new Error("Unknown variable dynamic import: " + path)) @@ -195,8 +195,8 @@ export { importModule }; exports[`upwards dir path 1`] = ` "function __variableDynamicImportRuntime0__(path) { switch (path) { - case '../module-dir-a/module-a-1.js': return import('./module-a-1-fiunS6HF.js'); - case '../module-dir-a/module-a-2.js': return import('./module-a-2-qepdcyXv.js'); + case '../module-dir-a/module-a-1.js': return import('./module-a-1-DigFCZAs.js'); + case '../module-dir-a/module-a-2.js': return import('./module-a-2-CBwBchsa.js'); default: return new Promise(function(resolve, reject) { (typeof queueMicrotask === 'function' ? queueMicrotask : setTimeout)( reject.bind(null, new Error("Unknown variable dynamic import: " + path)) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 631d511bc..9b203f632 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -353,6 +353,9 @@ importers: rollup: specifier: ^4.0.0-24 version: 4.0.0-24 + rollup-earliest: + specifier: npm:rollup@1.20.0 + version: rollup@1.20.0 packages/eslint: dependencies: @@ -797,7 +800,7 @@ importers: dependencies: '@rollup/pluginutils': specifier: ^5.1.0 - version: 5.1.0(rollup@4.0.0-24) + version: 5.1.0(rollup@4.65.1) resolve: specifier: ^1.22.1 version: 1.22.1 @@ -807,13 +810,13 @@ importers: devDependencies: '@rollup/plugin-buble': specifier: ^1.0.0 - version: 1.0.0(rollup@4.0.0-24) + version: 1.0.0(rollup@4.65.1) '@rollup/plugin-commonjs': specifier: ^23.0.0 - version: 23.0.0(rollup@4.0.0-24) + version: 23.0.0(rollup@4.65.1) '@rollup/plugin-commonjs-earliest': specifier: npm:@rollup/plugin-commonjs@14.0.0 - version: '@rollup/plugin-commonjs@14.0.0(rollup@4.0.0-24)' + version: '@rollup/plugin-commonjs@14.0.0(rollup@4.65.1)' '@types/node': specifier: ^14.18.30 version: 14.18.31 @@ -824,8 +827,8 @@ importers: specifier: ^0.20.0 version: 0.20.0 rollup: - specifier: ^4.0.0-24 - version: 4.0.0-24 + specifier: 'catalog:' + version: 4.65.1 rollup-earliest: specifier: npm:rollup@2.14.0 version: rollup@2.14.0 @@ -6701,14 +6704,6 @@ snapshots: '@types/babel__core': 7.1.19 rollup: 4.0.0-24 - '@rollup/plugin-buble@1.0.0(rollup@4.0.0-24)': - dependencies: - '@rollup/pluginutils': 4.2.1 - '@types/buble': 0.19.2 - buble: 0.20.0 - optionalDependencies: - rollup: 4.0.0-24 - '@rollup/plugin-buble@1.0.0(rollup@4.65.1)': dependencies: '@rollup/pluginutils': 4.2.1 @@ -6717,16 +6712,16 @@ snapshots: optionalDependencies: rollup: 4.65.1 - '@rollup/plugin-commonjs@14.0.0(rollup@4.0.0-24)': + '@rollup/plugin-commonjs@14.0.0(rollup@4.65.1)': dependencies: - '@rollup/pluginutils': 3.1.0(rollup@4.0.0-24) + '@rollup/pluginutils': 3.1.0(rollup@4.65.1) commondir: 1.0.1 estree-walker: 1.0.1 glob: 7.2.3 is-reference: 1.2.1 magic-string: 0.25.9 resolve: 1.22.1 - rollup: 4.0.0-24 + rollup: 4.65.1 '@rollup/plugin-commonjs@23.0.0(rollup@4.0.0-24)': dependencies: @@ -6824,13 +6819,6 @@ snapshots: optionalDependencies: rollup: 4.65.1 - '@rollup/pluginutils@3.1.0(rollup@4.0.0-24)': - dependencies: - '@types/estree': 0.0.39 - estree-walker: 1.0.1 - picomatch: 2.3.1 - rollup: 4.0.0-24 - '@rollup/pluginutils@3.1.0(rollup@4.65.1)': dependencies: '@types/estree': 0.0.39 @@ -6867,14 +6855,6 @@ snapshots: optionalDependencies: rollup: 4.65.1 - '@rollup/pluginutils@5.1.0(rollup@4.0.0-24)': - dependencies: - '@types/estree': 1.0.0 - estree-walker: 2.0.2 - picomatch: 2.3.1 - optionalDependencies: - rollup: 4.0.0-24 - '@rollup/pluginutils@5.1.0(rollup@4.65.1)': dependencies: '@types/estree': 1.0.0 From 0af4f8bd54d9d5ec080871c419bec3bab08030c7 Mon Sep 17 00:00:00 2001 From: Lukas Taegert-Atkinson Date: Fri, 23 Oct 2026 20:10:14 +0200 Subject: [PATCH 32/43] test(url): test against earliest supported rollup Run the test suite a second time with rollup pinned to the earliest supported version (1.20.0). Fork the snapshots because rollup 1 renders the default export of the entry module as `export default x` while rollup 4 uses `export { x as default }`. --- packages/url/package.json | 6 +- .../url/test/snapshots-earliest/test.js.snap | 212 ++++++++++++++++++ pnpm-lock.yaml | 9 +- 3 files changed, 222 insertions(+), 5 deletions(-) create mode 100644 packages/url/test/snapshots-earliest/test.js.snap diff --git a/packages/url/package.json b/packages/url/package.json index 2063fdb84..b452bf8e9 100644 --- a/packages/url/package.json +++ b/packages/url/package.json @@ -34,7 +34,8 @@ "prerelease": "pnpm build", "pretest": "pnpm build", "release": "pnpm --workspace-root package:release $(pwd)", - "test": "vitest --config ../../.config/vitest.config.mts run" + "test": "vitest --config ../../.config/vitest.config.mts run", + "test:earliest": "pnpm test -- --mode earliest" }, "files": [ "dist", @@ -65,7 +66,8 @@ "devDependencies": { "del": "^6.1.1", "globby": "^11.1.0", - "rollup": "^4.0.0-24" + "rollup": "catalog:", + "rollup-earliest": "npm:rollup@1.20.0" }, "types": "./types/index.d.ts" } diff --git a/packages/url/test/snapshots-earliest/test.js.snap b/packages/url/test/snapshots-earliest/test.js.snap new file mode 100644 index 000000000..771f8e1e7 --- /dev/null +++ b/packages/url/test/snapshots-earliest/test.js.snap @@ -0,0 +1,212 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`copy "large" binary files, limit: 10 1`] = ` +"var svg = "98ea1a8cc8cd9baf.svg"; + +export default svg; +" +`; + +exports[`copy "large" binary files, limit: 10 2`] = ` +[ + "output/98ea1a8cc8cd9baf.svg", +] +`; + +exports[`copy files with include by absolute path, limit: 0 1`] = ` +"var svg = "98ea1a8cc8cd9baf.svg"; + +export default svg; +" +`; + +exports[`copy files with include by absolute path, limit: 0 2`] = ` +[ + "output/98ea1a8cc8cd9baf.svg", +] +`; + +exports[`copy files, limit: 0 1`] = ` +"var svg = "98ea1a8cc8cd9baf.svg"; + +export default svg; +" +`; + +exports[`copy files, limit: 0 2`] = ` +[ + "output/98ea1a8cc8cd9baf.svg", +] +`; + +exports[`copy the file according to destDir option 1`] = ` +"var png = "fixtures/6b71fbe07b498a82.png"; + +export default png; +" +`; + +exports[`copy the file according to destDir option 2`] = ` +[ + "output/dest/fixtures/6b71fbe07b498a82.png", +] +`; + +exports[`create a file with the name and extension of the file 1`] = ` +"var png = "png.png"; + +export default png; +" +`; + +exports[`create a file with the name and extension of the file 2`] = ` +[ + "output/png.png", +] +`; + +exports[`create a file with the name, hash and extension of the file 1`] = ` +"var png = "png-6b71fbe07b498a82.png"; + +export default png; +" +`; + +exports[`create a file with the name, hash and extension of the file 2`] = ` +[ + "output/png-6b71fbe07b498a82.png", +] +`; + +exports[`create a nested directory for the output, if required 1`] = ` +"var png = "joker/6b71fbe07b498a82.png"; + +export default png; +" +`; + +exports[`create a nested directory for the output, if required 2`] = ` +[ + "output/joker/6b71fbe07b498a82.png", +] +`; + +exports[`inline "large" files 1`] = ` +"var svg = "98ea1a8cc8cd9baf.svg"; + +export default svg; +" +`; + +exports[`inline "large" files 2`] = `[]`; + +exports[`inline gif files 1`] = ` +"var gif = "data:image/gif;base64,R0lGODlhAQABAPAAAP///wAAACH5BAAAAAAAIf8LSW1hZ2VNYWdpY2sOZ2FtbWE9MC40NTQ1NDUALAAAAAABAAEAAAICRAEAOw=="; + +export default gif; +" +`; + +exports[`inline gif files 2`] = `[]`; + +exports[`inline jpeg files 1`] = ` +"var jpeg = "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAFA3PEY8MlBGQUZaVVBfeMiCeG5uePWvuZHI////////////////////////////////////////////////////wAALCAABAAEBAREA/8QAFAABAAAAAAAAAAAAAAAAAAAABP/EABQQAQAAAAAAAAAAAAAAAAAAAAD/2gAIAQEAAD8Aa//Z"; + +export default jpeg; +" +`; + +exports[`inline jpeg files 2`] = `[]`; + +exports[`inline jpg files 1`] = ` +"var jpg = "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAFA3PEY8MlBGQUZaVVBfeMiCeG5uePWvuZHI////////////////////////////////////////////////////wAALCAABAAEBAREA/8QAFAABAAAAAAAAAAAAAAAAAAAABP/EABQQAQAAAAAAAAAAAAAAAAAAAAD/2gAIAQEAAD8Aa//Z"; + +export default jpg; +" +`; + +exports[`inline jpg files 2`] = `[]`; + +exports[`inline png files 1`] = ` +"var png = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAAAAAA6fptVAAAACklEQVR4nGP6DwABBQECz6AuzQAAAABJRU5ErkJggg=="; + +export default png; +" +`; + +exports[`inline png files 2`] = `[]`; + +exports[`inline text files 1`] = ` +"var svg = "data:image/svg+xml,%3Csvg%3E%3Cpath%20d%3D%22%22%2F%3E%3C%2Fsvg%3E"; + +export default svg; +" +`; + +exports[`inline text files 2`] = `[]`; + +exports[`inline webp files 1`] = ` +"var webp = "data:image/webp;base64,UklGRiQAAABXRUJQVlA4IBgAAAAwAQCdASoBAAEAB0CWJaQAA3AA/u9gAAA="; + +export default webp; +" +`; + +exports[`inline webp files 2`] = `[]`; + +exports[`limit: 0, emitFiles: false, publicPath: empty 1`] = ` +"var svg = "98ea1a8cc8cd9baf.svg"; + +export default svg; +" +`; + +exports[`limit: 0, emitFiles: false, publicPath: empty 2`] = `[]`; + +exports[`prefix the file with the parent directory of the source file 1`] = ` +"var png = "fixtures/6b71fbe07b498a82.png"; + +export default png; +" +`; + +exports[`prefix the file with the parent directory of the source file 2`] = ` +[ + "output/fixtures/6b71fbe07b498a82.png", +] +`; + +exports[`prefix the file with the parent directory of the source file, relative to the sourceDir option 1`] = ` +"var png = "test/fixtures/6b71fbe07b498a82.png"; + +export default png; +" +`; + +exports[`prefix the file with the parent directory of the source file, relative to the sourceDir option 2`] = ` +[ + "output/test/fixtures/6b71fbe07b498a82.png", +] +`; + +exports[`use publicPath 1`] = ` +"var png = "/batman/6b71fbe07b498a82.png"; + +export default png; +" +`; + +exports[`use publicPath 2`] = `[]`; + +exports[`use publicPath with file that has empty dirname 1`] = ` +"var png = "/batman/6b71fbe07b498a82.png"; + +export default png; +" +`; + +exports[`use publicPath with file that has empty dirname 2`] = ` +[ + "output/6b71fbe07b498a82.png", +] +`; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 9b203f632..a8f918c25 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -330,7 +330,7 @@ importers: dependencies: '@rollup/pluginutils': specifier: ^5.0.1 - version: 5.0.1(rollup@4.0.0-24) + version: 5.0.1(rollup@4.65.1) astring: specifier: ^1.8.5 version: 1.8.5 @@ -351,8 +351,8 @@ importers: specifier: ^2.7.1 version: 2.7.1 rollup: - specifier: ^4.0.0-24 - version: 4.0.0-24 + specifier: 'catalog:' + version: 4.65.1 rollup-earliest: specifier: npm:rollup@1.20.0 version: rollup@1.20.0 @@ -857,6 +857,9 @@ importers: rollup: specifier: ^4.0.0-24 version: 4.0.0-24 + rollup-earliest: + specifier: npm:rollup@1.20.0 + version: rollup@1.20.0 packages/virtual: devDependencies: From 1710ba5f6972147523045b254ac29b694792e7ab Mon Sep 17 00:00:00 2001 From: Lukas Taegert-Atkinson Date: Fri, 23 Oct 2026 20:21:44 +0200 Subject: [PATCH 33/43] test(html): test against earliest supported rollup Run the test suite a second time with rollup pinned to 1.21.0, the earliest rollup version the plugin works with: it detects entry chunks via the bundle file type property, which rollup only adds to output files from 1.21.0, although the declared peer range starts at 1.20.0. Fork the snapshots because rollup 1 renders UMD and IIFE wrappers differently, hashes chunks differently and warns differently about empty bundles. --- packages/html/package.json | 4 +- .../html/test/snapshots-earliest/test.js.snap | 477 ++++++++++++++++++ packages/html/test/snapshots/test.js.snap | 16 +- pnpm-lock.yaml | 19 +- 4 files changed, 503 insertions(+), 13 deletions(-) create mode 100644 packages/html/test/snapshots-earliest/test.js.snap diff --git a/packages/html/package.json b/packages/html/package.json index b80bde9c2..9abbe04c8 100644 --- a/packages/html/package.json +++ b/packages/html/package.json @@ -35,6 +35,7 @@ "pretest": "pnpm build", "release": "pnpm --workspace-root package:release $(pwd)", "test": "vitest --config ../../.config/vitest.config.mts run", + "test:earliest": "pnpm test -- --mode earliest", "test:ts": "tsc --noEmit" }, "files": [ @@ -62,7 +63,8 @@ "devDependencies": { "@rollup/plugin-typescript": "^9.0.1", "postcss": "^8.4.16", - "rollup": "^4.0.0-24", + "rollup": "catalog:", + "rollup-earliest": "npm:rollup@1.21.0", "rollup-plugin-postcss": "^4.0.2", "typescript": "^4.8.3" }, diff --git a/packages/html/test/snapshots-earliest/test.js.snap b/packages/html/test/snapshots-earliest/test.js.snap new file mode 100644 index 000000000..8e534f8ad --- /dev/null +++ b/packages/html/test/snapshots-earliest/test.js.snap @@ -0,0 +1,477 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`attributes 1`] = ` +[ + { + "code": "(function (factory) { + typeof define === 'function' && define.amd ? define(factory) : + factory(); +}(function () { 'use strict'; + + + +})); +", + "fileName": "joker.js", + "map": null, + "source": undefined, + }, + { + "code": undefined, + "fileName": "joker.css", + "map": undefined, + "source": { + "data": [ + 42, + 32, + 123, + 32, + 119, + 105, + 100, + 116, + 104, + 58, + 32, + 49, + 48, + 48, + 37, + 59, + 32, + 125, + 10, + ], + "type": "Buffer", + }, + }, + { + "code": undefined, + "fileName": "index.html", + "map": undefined, + "source": " + + + + + Rollup Bundle + + + + + +", + }, +] +`; + +exports[`css 1`] = ` +[ + { + "code": "(function (factory) { + typeof define === 'function' && define.amd ? define(factory) : + factory(); +}(function () { 'use strict'; + + + +})); +", + "fileName": "joker.js", + "map": null, + "source": undefined, + }, + { + "code": undefined, + "fileName": "joker.css", + "map": undefined, + "source": { + "data": [ + 42, + 32, + 123, + 32, + 119, + 105, + 100, + 116, + 104, + 58, + 32, + 49, + 48, + 48, + 37, + 59, + 32, + 125, + 10, + ], + "type": "Buffer", + }, + }, + { + "code": undefined, + "fileName": "index.html", + "map": undefined, + "source": " + + + + + Rollup Bundle + + + + + +", + }, +] +`; + +exports[`default options 1`] = ` +[ + { + "code": "(function (factory) { + typeof define === 'function' && define.amd ? define(factory) : + factory(); +}(function () { 'use strict'; + + + +})); +", + "fileName": "batman.js", + "map": null, + "source": undefined, + }, + { + "code": undefined, + "fileName": "index.html", + "map": undefined, + "source": " + + + + + Rollup Bundle + + + + + +", + }, +] +`; + +exports[`dynamic_imports_not_loaded 1`] = ` +[ + { + "code": "if (Math.random() % 2) { + import('./batman-dce5b48d.js'); +} +", + "fileName": "catwoman.js", + "map": null, + "source": undefined, + }, + { + "code": " +", + "fileName": "batman-dce5b48d.js", + "map": null, + "source": undefined, + }, + { + "code": undefined, + "fileName": "index.html", + "map": undefined, + "source": " + + + + + Rollup Bundle + + + + + +", + }, +] +`; + +exports[`esm 1`] = ` +[ + { + "code": " +", + "fileName": "batman.js", + "map": null, + "source": undefined, + }, + { + "code": undefined, + "fileName": "index.html", + "map": undefined, + "source": " + + + + + Rollup Bundle + + + + + +", + }, +] +`; + +exports[`iife 1`] = ` +[ + { + "code": "(function () { + 'use strict'; + + + +}()); +", + "fileName": "batman.js", + "map": null, + "source": undefined, + }, + { + "code": undefined, + "fileName": "index.html", + "map": undefined, + "source": " + + + + + Rollup Bundle + + + + + +", + }, +] +`; + +exports[`imports 1`] = ` +[ + { + "code": "(function (factory) { + typeof define === 'function' && define.amd ? define(factory) : + factory(); +}(function () { 'use strict'; + + + +})); +", + "fileName": "robin.js", + "map": null, + "source": undefined, + }, + { + "code": undefined, + "fileName": "index.html", + "map": undefined, + "source": " + + + + + Rollup Bundle + + + + + +", + }, +] +`; + +exports[`options 1`] = ` +[ + { + "code": "(function (factory) { + typeof define === 'function' && define.amd ? define(factory) : + factory(); +}(function () { 'use strict'; + + + +})); +", + "fileName": "batman.js", + "map": null, + "source": undefined, + }, + { + "code": undefined, + "fileName": "batman.html", + "map": undefined, + "source": " + + + + + + Batcave + + + + + +", + }, +] +`; + +exports[`scripts on head 1`] = ` +[ + { + "code": "(function (factory) { + typeof define === 'function' && define.amd ? define(factory) : + factory(); +}(function () { 'use strict'; + + + +})); +", + "fileName": "joker.js", + "map": null, + "source": undefined, + }, + { + "code": undefined, + "fileName": "joker.css", + "map": undefined, + "source": { + "data": [ + 42, + 32, + 123, + 32, + 119, + 105, + 100, + 116, + 104, + 58, + 32, + 49, + 48, + 48, + 37, + 59, + 32, + 125, + 10, + ], + "type": "Buffer", + }, + }, + { + "code": undefined, + "fileName": "index.html", + "map": undefined, + "source": " + + + + + Rollup Bundle + + + + + +", + }, +] +`; + +exports[`template 1`] = ` +[ + { + "code": "(function (factory) { + typeof define === 'function' && define.amd ? define(factory) : + factory(); +}(function () { 'use strict'; + + + +})); +", + "fileName": "batman.js", + "map": null, + "source": undefined, + }, + { + "code": undefined, + "fileName": "index.html", + "map": undefined, + "source": "
", + }, +] +`; + +exports[`unsupported output format 1`] = ` +[ + { + "code": "'use strict'; + +", + "fileName": "batman.js", + "map": null, + "source": undefined, + }, + { + "code": undefined, + "fileName": "index.html", + "map": undefined, + "source": " + + + + + Rollup Bundle + + + + + +", + }, +] +`; + +exports[`unsupported output format 2`] = ` +[ + { + "code": "EMPTY_BUNDLE", + "message": "Generated an empty bundle", + "toString": [Function], + }, + { + "code": "PLUGIN_WARNING", + "message": "plugin-html: The output format 'cjs' is not directly supported. A custom \`template\` is probably required. Supported formats include: es, esm, iife, umd", + "plugin": "html", + "toString": [Function], + }, +] +`; diff --git a/packages/html/test/snapshots/test.js.snap b/packages/html/test/snapshots/test.js.snap index bc9d7c124..6385eb719 100644 --- a/packages/html/test/snapshots/test.js.snap +++ b/packages/html/test/snapshots/test.js.snap @@ -170,20 +170,17 @@ exports[`dynamic_imports_not_loaded 1`] = ` [ { "code": "if (Math.random() % 2) { - import('./batman-w40geAFS.js'); + Promise.resolve().then(function () { return batman; }); } + +var batman = /*#__PURE__*/Object.freeze({ + __proto__: null +}); ", "fileName": "catwoman.js", "map": null, "source": undefined, }, - { - "code": " -", - "fileName": "batman-w40geAFS.js", - "map": null, - "source": undefined, - }, { "code": undefined, "fileName": "index.html", @@ -471,8 +468,9 @@ exports[`unsupported output format 2`] = ` }, { "code": "PLUGIN_WARNING", - "message": "plugin-html: The output format 'cjs' is not directly supported. A custom \`template\` is probably required. Supported formats include: es, esm, iife, umd", + "message": "[plugin html] plugin-html: The output format 'cjs' is not directly supported. A custom \`template\` is probably required. Supported formats include: es, esm, iife, umd", "plugin": "html", + Symbol(augmented): true, }, ] `; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a8f918c25..878106707 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -446,6 +446,9 @@ importers: rollup: specifier: ^4.0.0-24 version: 4.0.0-24 + rollup-earliest: + specifier: npm:rollup@1.21.0 + version: rollup@1.21.0 rollup-plugin-postcss: specifier: ^4.0.2 version: 4.0.2(postcss@8.4.17)(ts-node@10.9.1(@swc/core@1.3.78)(@types/node@20.19.23)(typescript@4.8.4)) @@ -840,7 +843,7 @@ importers: dependencies: '@rollup/pluginutils': specifier: ^5.0.1 - version: 5.0.1(rollup@4.0.0-24) + version: 5.0.1(rollup@4.65.1) make-dir: specifier: ^3.1.0 version: 3.1.0 @@ -855,8 +858,8 @@ importers: specifier: ^11.1.0 version: 11.1.0 rollup: - specifier: ^4.0.0-24 - version: 4.0.0-24 + specifier: 'catalog:' + version: 4.65.1 rollup-earliest: specifier: npm:rollup@1.20.0 version: rollup@1.20.0 @@ -4936,6 +4939,10 @@ packages: resolution: {integrity: sha512-zW80j9RSJ0VV0VOxP1i7cF279+IlAaD49Ihwqb87PDR0555Fvk10HKmh2yUtXCdBb37bELuhHWZTJc4uoCo8Vw==} hasBin: true + rollup@1.21.0: + resolution: {integrity: sha512-FDIPkcIdLg7262zzqteTWNr7GxU7hw3nJiiKY9P38LE3BAZ7tFC0Di/AzISIxHEQBvneu5bW51a7o50P1NgDCg==} + hasBin: true + rollup@2.0.0: resolution: {integrity: sha512-tbvWownITR+0ebaX6iRr7IcLkziTCJacRpmWz03NIj3CZDmGlergYSwdG8wPx68LT0ms1YzqmbjUQHb6ut8pdw==} engines: {node: '>=10.0.0'} @@ -9958,6 +9965,12 @@ snapshots: '@types/node': 12.20.55 acorn: 7.4.1 + rollup@1.21.0: + dependencies: + '@types/estree': 0.0.39 + '@types/node': 12.20.55 + acorn: 7.4.1 + rollup@2.0.0: optionalDependencies: fsevents: 2.1.3 From dc6a1728b0b87a7160d4bebffde77732b3545429 Mon Sep 17 00:00:00 2001 From: Lukas Taegert-Atkinson Date: Fri, 23 Oct 2026 21:11:13 +0200 Subject: [PATCH 34/43] test(node-resolve): test against earliest supported rollup Run the test suite a second time with rollup pinned to the earliest supported version (2.78.0). Branch the expected resolveId options on the rollup version, which gained an "assertions" property in rollup 3 and an "attributes" property in rollup 4, and branch the fields and message wording of unresolved import warnings and entry errors, which changed in rollup 3. Fork the snapshots whose warnings and error messages differ in rollup 2. --- packages/node-resolve/package.json | 4 +- packages/node-resolve/test/jail.js | 16 +++- packages/node-resolve/test/prefer-builtins.js | 16 +++- .../prefer-builtins.js.snap | 12 +++ .../test/snapshots-earliest/test.mjs.snap | 59 ++++++++++++ .../node-resolve/test/snapshots/test.mjs.snap | 3 +- packages/node-resolve/test/test.mjs | 91 ++++++++++++------- pnpm-lock.yaml | 18 ++-- 8 files changed, 161 insertions(+), 58 deletions(-) create mode 100644 packages/node-resolve/test/snapshots-earliest/prefer-builtins.js.snap create mode 100644 packages/node-resolve/test/snapshots-earliest/test.mjs.snap diff --git a/packages/node-resolve/package.json b/packages/node-resolve/package.json index f06f248d0..069086044 100644 --- a/packages/node-resolve/package.json +++ b/packages/node-resolve/package.json @@ -36,6 +36,7 @@ "pretest": "pnpm build", "release": "pnpm --workspace-root package:release $(pwd)", "test": "pnpm test:ts && vitest --config ../../.config/vitest.config.mts run", + "test:earliest": "pnpm test -- --mode earliest", "test:ts": "tsc types/index.d.ts test/types.ts --noEmit" }, "files": [ @@ -75,7 +76,8 @@ "@rollup/plugin-commonjs": "^23.0.0", "@rollup/plugin-json": "^5.0.0", "es5-ext": "^0.10.62", - "rollup": "^4.0.0-24", + "rollup": "catalog:", + "rollup-earliest": "npm:rollup@2.78.0", "source-map": "^0.7.4", "string-capitalize": "^1.0.1" }, diff --git a/packages/node-resolve/test/jail.js b/packages/node-resolve/test/jail.js index e7544a488..8f1bdbc17 100644 --- a/packages/node-resolve/test/jail.js +++ b/packages/node-resolve/test/jail.js @@ -1,10 +1,12 @@ const { join } = require('path'); -const { rollup } = require('rollup'); +const { rollup, VERSION } = require('rollup'); const { getImports } = require('../../../util/test'); const { nodeResolve } = require('..'); +const rollupMajor = Number(VERSION.split('.')[0]); + process.chdir(join(__dirname, 'fixtures')); test('mark module outside the jail as external', async () => { const warnings = []; @@ -21,9 +23,15 @@ test('mark module outside the jail as external', async () => { const imports = await getImports(bundle); expect(imports).toEqual(['string/uppercase.js']); expect(warnings.length, 'number of warnings').toBe(1); - const [{ exporter, id }] = warnings; - expect(exporter, 'exporter').toBe('string/uppercase.js'); - expect(id.endsWith('jail.js'), 'id').toBe(true); + const [{ exporter, id, importer, source }] = warnings; + if (rollupMajor >= 3) { + expect(exporter, 'exporter').toBe('string/uppercase.js'); + expect(id.endsWith('jail.js'), 'id').toBe(true); + } else { + // rollup 2 names the unresolved module "source" and the importing module "importer" + expect(source, 'source').toBe('string/uppercase.js'); + expect(importer, 'importer').toBe('jail.js'); + } }); test('bundle module defined inside the jail', async () => { const bundle = await rollup({ diff --git a/packages/node-resolve/test/prefer-builtins.js b/packages/node-resolve/test/prefer-builtins.js index 16701ad36..863665404 100644 --- a/packages/node-resolve/test/prefer-builtins.js +++ b/packages/node-resolve/test/prefer-builtins.js @@ -1,10 +1,12 @@ const { join, resolve } = require('path'); -const { rollup } = require('rollup'); +const { rollup, VERSION } = require('rollup'); const { getImports, testBundle } = require('../../../util/test'); const { nodeResolve } = require('..'); +const [rollupMajor, rollupMinor] = VERSION.split('.').map(Number); + process.chdir(join(__dirname, 'fixtures')); const avaAssertions = { is(actual, expected, message) { @@ -43,11 +45,15 @@ test('warning when preferring a builtin module, no explicit configuration', asyn plugins: [nodeResolve()] }); const localPath = resolve('node_modules/events/index.js'); - expect(warning).toBe( + const expectedWarning = `preferring built-in module 'events' over local alternative ` + - `at '${localPath}', pass 'preferBuiltins: false' to disable this behavior ` + - `or 'preferBuiltins: true' to disable this warning.` + - `or passing a function to 'preferBuiltins' to provide more fine-grained control over which built-in modules to prefer.` + `at '${localPath}', pass 'preferBuiltins: false' to disable this behavior ` + + `or 'preferBuiltins: true' to disable this warning.` + + `or passing a function to 'preferBuiltins' to provide more fine-grained control over which built-in modules to prefer.`; + expect(warning).toBe( + rollupMajor > 4 || (rollupMajor === 4 && rollupMinor >= 13) + ? `[plugin node-resolve] ${expectedWarning}` + : expectedWarning ); }); test('true allows preferring a builtin to a local module of the same name', async () => { diff --git a/packages/node-resolve/test/snapshots-earliest/prefer-builtins.js.snap b/packages/node-resolve/test/snapshots-earliest/prefer-builtins.js.snap new file mode 100644 index 000000000..aa1f3162e --- /dev/null +++ b/packages/node-resolve/test/snapshots-earliest/prefer-builtins.js.snap @@ -0,0 +1,12 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`false allows resolving a local module with the same name as a builtin module 1`] = ` +[ + { + "chunkName": "prefer-builtin", + "code": "EMPTY_BUNDLE", + "message": "Generated an empty chunk: "prefer-builtin"", + "toString": [Function], + }, +] +`; diff --git a/packages/node-resolve/test/snapshots-earliest/test.mjs.snap b/packages/node-resolve/test/snapshots-earliest/test.mjs.snap new file mode 100644 index 000000000..263473da7 --- /dev/null +++ b/packages/node-resolve/test/snapshots-earliest/test.mjs.snap @@ -0,0 +1,59 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`allows custom moduleDirectories with legacy customResolveOptions.moduleDirectory 1`] = ` +[ + { + "code": "PLUGIN_WARNING", + "message": "node-resolve: The \`customResolveOptions.moduleDirectory\` option has been deprecated. Use \`moduleDirectories\`, which must be an array.", + "plugin": "node-resolve", + "toString": [Function], + }, +] +`; + +exports[`has default config 1`] = ` +{ + "allowExportsFolderMapping": true, + "dedupe": [], + "extensions": [ + ".mjs", + ".js", + ".json", + ".node", + ], + "ignoreSideEffectsForRoot": false, + "moduleDirectories": [ + "node_modules", + ], + "modulePaths": [], + "resolveOnly": [], +} +`; + +exports[`throws error for removed customResolveOptions.basedir option 1`] = `[Error: node-resolve: \`customResolveOptions.basedir\` is no longer an option. If you need this, please open an issue.]`; + +exports[`throws error for removed customResolveOptions.extensions option 1`] = `[Error: node-resolve: \`customResolveOptions.extensions\` is no longer an option. If you need this, please open an issue.]`; + +exports[`throws error for removed customResolveOptions.includeCoreModules option 1`] = `[Error: node-resolve: \`customResolveOptions.includeCoreModules\` is no longer an option. If you need this, please open an issue.]`; + +exports[`throws error for removed customResolveOptions.isDirectory option 1`] = `[Error: node-resolve: \`customResolveOptions.isDirectory\` is no longer an option. If you need this, please open an issue.]`; + +exports[`throws error for removed customResolveOptions.isFile option 1`] = `[Error: node-resolve: \`customResolveOptions.isFile\` is no longer an option. If you need this, please open an issue.]`; + +exports[`throws error for removed customResolveOptions.package option 1`] = `[Error: node-resolve: \`customResolveOptions.package\` is no longer an option. If you need this, please open an issue.]`; + +exports[`throws error for removed customResolveOptions.packageFilter option 1`] = `[Error: node-resolve: \`customResolveOptions.packageFilter\` is no longer an option. If you need this, please open an issue.]`; + +exports[`throws error for removed customResolveOptions.packageIterator option 1`] = `[Error: node-resolve: \`customResolveOptions.packageIterator\` is no longer an option. If you need this, please open an issue.]`; + +exports[`throws error for removed customResolveOptions.pathFilter option 1`] = `[Error: node-resolve: \`customResolveOptions.pathFilter\` is no longer an option. If you need this, please open an issue.]`; + +exports[`throws error for removed customResolveOptions.paths option 1`] = `[Error: node-resolve: \`customResolveOptions.paths\` is no longer an option. If you need this, please open an issue.]`; + +exports[`throws error for removed customResolveOptions.preserveSymlinks option 1`] = `[Error: node-resolve: \`customResolveOptions.preserveSymlinks\` is no longer an option. We now always use the rollup \`preserveSymlinks\` option.]`; + +exports[`throws error for removed customResolveOptions.readFile option 1`] = `[Error: node-resolve: \`customResolveOptions.readFile\` is no longer an option. If you need this, please open an issue.]`; + +exports[`throws error for removed customResolveOptions.realpath option 1`] = `[Error: node-resolve: \`customResolveOptions.realpath\` is no longer an option. If you need this, please open an issue.]`; + +exports[`throws error if local id is not resolved 1`] = `"Could not resolve './foo' from unresolved-local.js"`; diff --git a/packages/node-resolve/test/snapshots/test.mjs.snap b/packages/node-resolve/test/snapshots/test.mjs.snap index 7d419c9ec..fb70176f2 100644 --- a/packages/node-resolve/test/snapshots/test.mjs.snap +++ b/packages/node-resolve/test/snapshots/test.mjs.snap @@ -4,8 +4,9 @@ exports[`allows custom moduleDirectories with legacy customResolveOptions.module [ { "code": "PLUGIN_WARNING", - "message": "node-resolve: The \`customResolveOptions.moduleDirectory\` option has been deprecated. Use \`moduleDirectories\`, which must be an array.", + "message": "[plugin node-resolve] node-resolve: The \`customResolveOptions.moduleDirectory\` option has been deprecated. Use \`moduleDirectories\`, which must be an array.", "plugin": "node-resolve", + Symbol(augmented): true, }, ] `; diff --git a/packages/node-resolve/test/test.mjs b/packages/node-resolve/test/test.mjs index 84f03cdf8..f92a9d709 100755 --- a/packages/node-resolve/test/test.mjs +++ b/packages/node-resolve/test/test.mjs @@ -1,13 +1,24 @@ import { dirname, join, resolve } from 'path'; import { fileURLToPath } from 'url'; + import { babel } from '@rollup/plugin-babel'; import commonjs from '@rollup/plugin-commonjs'; -import { rollup } from 'rollup'; +import { rollup, VERSION } from 'rollup'; + import { nodeResolve, DEFAULTS } from 'current-package'; + import { evaluateBundle, getCode, getImports, testBundle } from '../../../util/test.js'; const DIRNAME = fileURLToPath(new URL('.', import.meta.url)); +const [rollupMajor, rollupMinor] = VERSION.split('.').map(Number); process.chdir(join(DIRNAME, 'fixtures')); +// the resolveId options gained an "assertions" property in rollup 3 and an "attributes" property in rollup 4 +const expectedResolveIdOptions = (options) => + rollupMajor >= 4 + ? { attributes: {}, ...options } + : rollupMajor >= 3 + ? { assertions: {}, ...options } + : options; const avaAssertions = { is(actual, expected, message) { expect(actual, message).toBe(expected); @@ -372,9 +383,15 @@ test('ignores deep-import non-modules', async () => { const imports = await getImports(bundle); expect(imports).toEqual(['foo/deep']); expect(warnings.length, 'number of warnings').toBe(1); - const [{ exporter, id }] = warnings; - expect(exporter, 'exporter').toBe('foo/deep'); - expect(id.endsWith('deep-import-non-module.js'), 'id').toBe(true); + const [{ exporter, id, importer, source }] = warnings; + if (rollupMajor >= 3) { + expect(exporter, 'exporter').toBe('foo/deep'); + expect(id.endsWith('deep-import-non-module.js'), 'id').toBe(true); + } else { + // rollup 2 names the unresolved module "source" and the importing module "importer" + expect(source, 'source').toBe('foo/deep'); + expect(importer, 'importer').toBe('deep-import-non-module.js'); + } }); test('generates manual chunks', async () => { const chunkName = 'mychunk'; @@ -510,6 +527,11 @@ test('marks a module as external if the resolved version is external', async () }); test('passes on "isEntry" flag and original importee', async () => { const resolveOptions = []; + // the resolveId options gained an own "importerAttributes" property in rollup 4.57 + const expectedImporterAttributes = (attributes) => + rollupMajor > 4 || (rollupMajor === 4 && rollupMinor >= 57) + ? { importerAttributes: attributes } + : {}; await rollup({ input: 'entry/main.js', onwarn: failOnWarn, @@ -539,26 +561,26 @@ test('passes on "isEntry" flag and original importee', async () => { [ 'other.js', 'main.js', - { - attributes: {}, + expectedResolveIdOptions({ + ...expectedImporterAttributes(void 0), custom: {}, isEntry: true - } + }) ], [ 'main.js', void 0, - { - attributes: {}, + expectedResolveIdOptions({ + ...expectedImporterAttributes(void 0), custom: {}, isEntry: true - } + }) ], [ 'other.js', 'main.js', - { - attributes: {}, + expectedResolveIdOptions({ + ...expectedImporterAttributes(void 0), custom: { 'node-resolve': { resolved: { @@ -569,13 +591,13 @@ test('passes on "isEntry" flag and original importee', async () => { } }, isEntry: true - } + }) ], [ 'main.js', void 0, - { - attributes: {}, + expectedResolveIdOptions({ + ...expectedImporterAttributes(void 0), custom: { 'node-resolve': { resolved: { @@ -586,22 +608,22 @@ test('passes on "isEntry" flag and original importee', async () => { } }, isEntry: true - } + }) ], [ 'dep.js', 'main.js', - { - attributes: {}, + expectedResolveIdOptions({ + ...expectedImporterAttributes({}), custom: {}, isEntry: false - } + }) ], [ 'dep.js', 'main.js', - { - attributes: {}, + expectedResolveIdOptions({ + ...expectedImporterAttributes({}), custom: { 'node-resolve': { resolved: { @@ -612,7 +634,7 @@ test('passes on "isEntry" flag and original importee', async () => { } }, isEntry: false - } + }) ] ]); }); @@ -648,19 +670,17 @@ test('passes on custom options', async () => { [ 'main.js', void 0, - { - attributes: {}, + expectedResolveIdOptions({ custom: { test: 42 }, isEntry: false - } + }) ], [ 'main.js', void 0, - { - attributes: {}, + expectedResolveIdOptions({ custom: { test: 42, 'node-resolve': { @@ -672,22 +692,20 @@ test('passes on custom options', async () => { } }, isEntry: false - } + }) ], [ 'other.js', void 0, - { - attributes: {}, + expectedResolveIdOptions({ custom: {}, isEntry: true - } + }) ], [ 'other.js', void 0, - { - attributes: {}, + expectedResolveIdOptions({ custom: { 'node-resolve': { resolved: { @@ -698,7 +716,7 @@ test('passes on custom options', async () => { } }, isEntry: true - } + }) ] ]); }); @@ -769,5 +787,8 @@ test('error message for invalid entry', async () => { onwarn: failOnWarn, plugins: [nodeResolve()] }).catch((caught) => caught); - expect(error.message).toBe(`Could not resolve entry module "".`); + expect(error.message).toBe( + // rollup 3 changed the quoting of the entry module in this error message + rollupMajor >= 3 ? 'Could not resolve entry module "".' : 'Could not resolve entry module ().' + ); }); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 878106707..5fdb3d282 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -439,13 +439,13 @@ importers: devDependencies: '@rollup/plugin-typescript': specifier: ^9.0.1 - version: 9.0.1(rollup@4.0.0-24)(tslib@2.4.0)(typescript@4.8.4) + version: 9.0.1(rollup@4.65.1)(tslib@2.4.0)(typescript@4.8.4) postcss: specifier: ^8.4.16 version: 8.4.17 rollup: - specifier: ^4.0.0-24 - version: 4.0.0-24 + specifier: 'catalog:' + version: 4.65.1 rollup-earliest: specifier: npm:rollup@1.21.0 version: rollup@1.21.0 @@ -608,6 +608,9 @@ importers: rollup: specifier: ^4.0.0-24 version: 4.0.0-24 + rollup-earliest: + specifier: npm:rollup@2.78.0 + version: rollup@2.78.0 source-map: specifier: ^0.7.4 version: 0.7.4 @@ -6807,15 +6810,6 @@ snapshots: rollup: 3.0.0 tslib: 2.4.0 - '@rollup/plugin-typescript@9.0.1(rollup@4.0.0-24)(tslib@2.4.0)(typescript@4.8.4)': - dependencies: - '@rollup/pluginutils': 4.2.1 - resolve: 1.22.1 - typescript: 4.8.4 - optionalDependencies: - rollup: 4.0.0-24 - tslib: 2.4.0 - '@rollup/plugin-typescript@9.0.1(rollup@4.65.1)(tslib@2.4.0)(typescript@4.8.4)': dependencies: '@rollup/pluginutils': 4.2.1 From fac1c8bf8f5267da5f345899323501d99ff07a9b Mon Sep 17 00:00:00 2001 From: Lukas Taegert-Atkinson Date: Fri, 23 Oct 2026 21:18:18 +0200 Subject: [PATCH 35/43] test(beep): test against earliest supported rollup Run the test suite a second time with rollup pinned to the earliest supported version (1.20.0). As the tests spawn the rollup CLI as a subprocess, bypassing the earliest-mode module redirect, resolve the CLI from the rollup module that is active in the current test mode. The CLI output for the tested scenarios only differs in timing, which the snapshot normalization already covers, so the snapshots do not need to be forked. --- packages/beep/package.json | 6 +- packages/beep/test/test.js | 10 ++- pnpm-lock.yaml | 156 ++++--------------------------------- 3 files changed, 25 insertions(+), 147 deletions(-) diff --git a/packages/beep/package.json b/packages/beep/package.json index ac48a2964..382ddb3ca 100644 --- a/packages/beep/package.json +++ b/packages/beep/package.json @@ -23,7 +23,8 @@ "ci:lint:commits": "commitlint --from=${CIRCLE_BRANCH} --to=${CIRCLE_SHA1}", "ci:test": "pnpm test -- --reporter=verbose", "release": "pnpm --workspace-root package:release $(pwd)", - "test": "vitest --config ../../.config/vitest.config.mts run" + "test": "vitest --config ../../.config/vitest.config.mts run", + "test:earliest": "pnpm test -- --mode earliest" }, "files": [ "lib/", @@ -46,7 +47,8 @@ } }, "devDependencies": { - "rollup": "^4.0.0-24", + "rollup": "catalog:", + "rollup-earliest": "npm:rollup@1.20.0", "strip-ansi": "^7.0.1" }, "types": "types/index.d.ts" diff --git a/packages/beep/test/test.js b/packages/beep/test/test.js index bbe9cd5e8..52322901c 100644 --- a/packages/beep/test/test.js +++ b/packages/beep/test/test.js @@ -1,10 +1,16 @@ +const { dirname, resolve } = require('path'); + const execa = require('execa'); +// Resolve the CLI from the rollup module that is active in the current test mode +// ("rollup-earliest" in earliest mode) so that the subprocess matches the module under test. +const rollupCli = resolve(dirname(require.resolve('rollup')), 'bin/rollup'); + const options = { cwd: __dirname }; test('pass', async () => { const args = '--config fixtures/pass.config.js'.split(' '); - const { stderr } = await execa('rollup', args, options); + const { stderr } = await execa(rollupCli, args, options); const { default: strip } = await import('strip-ansi'); expect(strip(stderr.replace(/\d+ms|[\d.]+s/, '