From 30abc596ea7019e9a5e6a47e4827b65a98d5fb2a Mon Sep 17 00:00:00 2001 From: Ben McCann <322311+benmccann@users.noreply.github.com> Date: Tue, 15 Oct 2024 19:09:45 -0700 Subject: [PATCH 1/6] chore(dynamic-import-vars): switch to tinyglobby for fewer dependencies (#1780) --- packages/dynamic-import-vars/package.json | 4 +-- .../src/dynamic-import-to-glob.js | 4 +-- packages/dynamic-import-vars/src/index.js | 4 +-- pnpm-lock.yaml | 35 ++++++++++++++++--- 4 files changed, 37 insertions(+), 10 deletions(-) diff --git a/packages/dynamic-import-vars/package.json b/packages/dynamic-import-vars/package.json index d25ea21b9..771023228 100644 --- a/packages/dynamic-import-vars/package.json +++ b/packages/dynamic-import-vars/package.json @@ -66,8 +66,8 @@ "@rollup/pluginutils": "^5.0.1", "astring": "^1.8.5", "estree-walker": "^2.0.2", - "fast-glob": "^3.2.12", - "magic-string": "^0.30.3" + "magic-string": "^0.30.3", + "tinyglobby": "^0.2.8" }, "devDependencies": { "acorn": "^8.8.0", diff --git a/packages/dynamic-import-vars/src/dynamic-import-to-glob.js b/packages/dynamic-import-vars/src/dynamic-import-to-glob.js index ed1ae978e..de63b90b1 100644 --- a/packages/dynamic-import-vars/src/dynamic-import-to-glob.js +++ b/packages/dynamic-import-vars/src/dynamic-import-to-glob.js @@ -1,6 +1,6 @@ import path from 'path'; -import fastGlob from 'fast-glob'; +import { escapePath } from 'tinyglobby'; export class VariableDynamicImportError extends Error {} @@ -12,7 +12,7 @@ function sanitizeString(str) { if (str.includes('*')) { throw new VariableDynamicImportError('A dynamic import cannot contain * characters.'); } - return fastGlob.escapePath(str); + return escapePath(str); } function templateLiteralToGlob(node) { diff --git a/packages/dynamic-import-vars/src/index.js b/packages/dynamic-import-vars/src/index.js index b44770c45..3351a1582 100644 --- a/packages/dynamic-import-vars/src/index.js +++ b/packages/dynamic-import-vars/src/index.js @@ -2,7 +2,7 @@ import path from 'path'; import { walk } from 'estree-walker'; import MagicString from 'magic-string'; -import fastGlob from 'fast-glob'; +import { globSync } from 'tinyglobby'; import { generate } from 'astring'; import { createFilter } from '@rollup/pluginutils'; @@ -50,7 +50,7 @@ function dynamicImportVariables({ include, exclude, warnOnError, errorWhenNoFile } // execute the glob - const result = fastGlob.sync(glob, { cwd: path.dirname(id) }); + const result = globSync(glob, { cwd: path.dirname(id), expandDirectories: false }); const paths = result.map((r) => r.startsWith('./') || r.startsWith('../') ? r : `./${r}` ); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 66a7d6c92..454644781 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -295,12 +295,12 @@ importers: estree-walker: specifier: ^2.0.2 version: 2.0.2 - fast-glob: - specifier: ^3.2.12 - version: 3.2.12 magic-string: specifier: ^0.30.3 version: 0.30.3 + tinyglobby: + specifier: ^0.2.8 + version: 0.2.8 devDependencies: acorn: specifier: ^8.8.0 @@ -2286,7 +2286,7 @@ packages: resolution: {integrity: sha512-W9pAhw0ja1Edb5GVdIF1mjZw/ASI0AlShXM83UUGe2DVr5TdAPEA1OA8m/g8zWp9x6On7gqufY+FatDbC3MDQg==} concat-map@0.0.1: - resolution: {integrity: sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==} + resolution: {integrity: sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=} concat-with-sourcemaps@1.1.0: resolution: {integrity: sha512-4gEjHJFT9e+2W/77h/DS5SGUgwDaOwprX8L/gl5+3ixnzkVJJsZWDSelmN3Oilw3LNDZjZV0yqH1hLG3k6nghg==} @@ -2731,6 +2731,14 @@ packages: picomatch: optional: true + fdir@6.4.0: + resolution: {integrity: sha512-3oB133prH1o4j/L5lLW7uOCF1PlD+/It2L0eL/iAqWMB91RBbqTewABqxhj0ibBd90EEmWZq7ntIWzVaWcXTGQ==} + peerDependencies: + picomatch: ^3 || ^4 + peerDependenciesMeta: + picomatch: + optional: true + figures@4.0.1: resolution: {integrity: sha512-rElJwkA/xS04Vfg+CaZodpso7VqBknOYbzi6I76hI4X80RUjkSxO2oAyPmGbuXUppywjqndOrQDl817hDnI++w==} engines: {node: '>=12'} @@ -3669,6 +3677,10 @@ packages: resolution: {integrity: sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==} engines: {node: '>=8.6'} + picomatch@4.0.2: + resolution: {integrity: sha512-M7BAV6Rlcy5u+m6oPhAPFgJTzAioX/6B0DxyvDlo9l8+T3nLKbrczg2WLUyzd45L8RqfUMyGPzekbMvX2Ldkwg==} + engines: {node: '>=12'} + pify@4.0.1: resolution: {integrity: sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g==} engines: {node: '>=6'} @@ -4403,6 +4415,10 @@ packages: resolution: {integrity: sha512-TIsDdtKo6+XrPtiTm1ssmMngN1sAhyKnTO2kunQWqNPWIVvCm15Wmw4SWInwTVgJ5u/Tr04+8Ei9TNcw4x4ONA==} engines: {node: '>=4'} + tinyglobby@0.2.8: + resolution: {integrity: sha512-AMLZywN0vbhiZi2neFEaj9VIIxC+PjDMsp0nAK6tpR86LJavZgHqGz0S/FOONwBygC+mu7R0/TyAQw0gx0Mu9Q==} + engines: {node: '>=12.0.0'} + to-fast-properties@2.0.0: resolution: {integrity: sha512-/OaKK0xYrs3DmxRYqL/yDc+FxFUVYhDlXMhRmv3z915w2HF1tnN1omB354j8VUGO/hbRzyD6Y3sA7v7GS/ceog==} engines: {node: '>=4'} @@ -6963,6 +6979,10 @@ snapshots: optionalDependencies: picomatch: 2.3.1 + fdir@6.4.0(picomatch@4.0.2): + optionalDependencies: + picomatch: 4.0.2 + figures@4.0.1: dependencies: escape-string-regexp: 5.0.0 @@ -7880,6 +7900,8 @@ snapshots: picomatch@2.3.1: {} + picomatch@4.0.2: {} + pify@4.0.1: {} pify@5.0.0: {} @@ -8620,6 +8642,11 @@ snapshots: time-zone@1.0.0: {} + tinyglobby@0.2.8: + dependencies: + fdir: 6.4.0(picomatch@4.0.2) + picomatch: 4.0.2 + to-fast-properties@2.0.0: {} to-regex-range@5.0.1: From 4799541b788d2a0a321f9f9205e748bd0b539876 Mon Sep 17 00:00:00 2001 From: Release Workflow Date: Wed, 16 Oct 2024 02:11:17 +0000 Subject: [PATCH 2/6] chore(release): dynamic-import-vars v2.1.4 --- packages/dynamic-import-vars/CHANGELOG.md | 8 ++++++++ packages/dynamic-import-vars/package.json | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/dynamic-import-vars/CHANGELOG.md b/packages/dynamic-import-vars/CHANGELOG.md index 660134aa5..835d6e1ff 100644 --- a/packages/dynamic-import-vars/CHANGELOG.md +++ b/packages/dynamic-import-vars/CHANGELOG.md @@ -1,5 +1,13 @@ # @rollup/plugin-dynamic-import-vars ChangeLog +## v2.1.4 + +_2024-10-16_ + +### Updates + +- chore: switch to tinyglobby for fewer dependencies (#1780) + ## v2.1.3 _2024-09-22_ diff --git a/packages/dynamic-import-vars/package.json b/packages/dynamic-import-vars/package.json index 771023228..a3e6b46b2 100644 --- a/packages/dynamic-import-vars/package.json +++ b/packages/dynamic-import-vars/package.json @@ -1,6 +1,6 @@ { "name": "@rollup/plugin-dynamic-import-vars", - "version": "2.1.3", + "version": "2.1.4", "publishConfig": { "access": "public" }, From cc55c4403c69ddf20b6377dddbcd27f3523647ea Mon Sep 17 00:00:00 2001 From: michael faith Date: Tue, 15 Oct 2024 21:25:42 -0500 Subject: [PATCH 3/6] fix(typescript): allow for files to be nested in folders within outDir (#1783) fix(typescript): allow for files to be nested within outDir This change corrects a regression introduced by #1728, preventing dual bundle configs from writing output files to directories nested within the directory defined in the tsconfig's outDir property. Example: ```js export default { input: 'src/index.ts', // Replace with the path to your entry TypeScript file output: [ { dir: 'dist/cjs', format: 'cjs', sourcemap: true, preserveModules: true }, { dir: 'dist/esm', format: 'esm', sourcemap: true, preserveModules: true } ], plugins: [ json(), resolve(), commonjs(), typescript({ tsconfig: 'tsconfig.json', compilerOptions: { /* Basic Options */ target: 'ES5', module: 'ES2020', lib: ['ES2019', 'ES2020'], allowJs: true, checkJs: false, /* Strict Type-Checking Options */ strict: true, /* Module Resolution Options */ moduleResolution: 'node', esModuleInterop: true, /* Advanced Options */ forceConsistentCasingInFileNames: true, skipDefaultLibCheck: true, skipLibCheck: true, outDir: path.join(__dirname, 'dist') } }) ], external: deps // Add any external dependencies you don't want to bundle }; ``` --- packages/typescript/src/options/validate.ts | 11 +++++--- packages/typescript/test/test.js | 30 +++++++++++++++++++++ 2 files changed, 37 insertions(+), 4 deletions(-) diff --git a/packages/typescript/src/options/validate.ts b/packages/typescript/src/options/validate.ts index d0f22e3de..ae53834a3 100644 --- a/packages/typescript/src/options/validate.ts +++ b/packages/typescript/src/options/validate.ts @@ -58,13 +58,16 @@ export function validatePaths( for (const dirProperty of DIRECTORY_PROPS) { if (compilerOptions[dirProperty] && outputDir) { // Checks if the given path lies within Rollup output dir - const fromRollupDirToTs = relative(outputDir, compilerOptions[dirProperty]!); - if (fromRollupDirToTs.startsWith('..')) { - if (outputOptions.dir) { + if (outputOptions.dir) { + const fromRollupDirToTs = relative(outputDir, compilerOptions[dirProperty]!); + if (fromRollupDirToTs.startsWith('..')) { context.error( `@rollup/plugin-typescript: Path of Typescript compiler option '${dirProperty}' must be located inside Rollup 'dir' option.` ); - } else { + } + } else { + const fromTsDirToRollup = relative(compilerOptions[dirProperty]!, outputDir); + if (fromTsDirToRollup.startsWith('..')) { context.error( `@rollup/plugin-typescript: Path of Typescript compiler option '${dirProperty}' must be located inside the same directory as the Rollup 'file' option.` ); diff --git a/packages/typescript/test/test.js b/packages/typescript/test/test.js index efed9b397..e0b83fd0d 100644 --- a/packages/typescript/test/test.js +++ b/packages/typescript/test/test.js @@ -129,6 +129,36 @@ test.serial( } ); +test.serial( + 'ensures output files can be written to subdirectories within the tsconfig outDir', + async (t) => { + const warnings = []; + const outputOpts = { format: 'es', file: 'fixtures/basic/dist/esm/main.js' }; + const bundle = await rollup({ + input: 'fixtures/basic/main.ts', + output: outputOpts, + plugins: [ + typescript({ + tsconfig: 'fixtures/basic/tsconfig.json', + outDir: 'fixtures/basic/dist' + }) + ], + onwarn(warning) { + warnings.push(warning); + } + }); + + // This should not throw an error + const output = await getFiles(bundle, outputOpts); + + t.deepEqual( + output.map((out) => out.fileName), + ['fixtures/basic/dist/esm/main.js'] + ); + t.is(warnings.length, 0); + } +); + test.serial('ensures multiple outputs can be built', async (t) => { // In a rollup.config.js we would pass an array // The rollup method that's exported as a library won't do that so we must make two calls From c358dae8f48eee3e4f4f3dbd5751eaabf7986caf Mon Sep 17 00:00:00 2001 From: Release Workflow Date: Wed, 16 Oct 2024 02:27:58 +0000 Subject: [PATCH 4/6] chore(release): typescript v12.1.1 --- packages/typescript/CHANGELOG.md | 8 ++++++++ packages/typescript/package.json | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/typescript/CHANGELOG.md b/packages/typescript/CHANGELOG.md index e37cd8d34..cee7c0b14 100644 --- a/packages/typescript/CHANGELOG.md +++ b/packages/typescript/CHANGELOG.md @@ -1,5 +1,13 @@ # @rollup/plugin-typescript ChangeLog +## v12.1.1 + +_2024-10-16_ + +### Bugfixes + +- fix: allow for files to be nested in folders within outDir (#1783) + ## v12.1.0 _2024-09-22_ diff --git a/packages/typescript/package.json b/packages/typescript/package.json index 3504f38e3..d1ac060ed 100644 --- a/packages/typescript/package.json +++ b/packages/typescript/package.json @@ -1,6 +1,6 @@ { "name": "@rollup/plugin-typescript", - "version": "12.1.0", + "version": "12.1.1", "publishConfig": { "access": "public" }, From dd1deeeae611499ac73f86a69ff00208b745e4d1 Mon Sep 17 00:00:00 2001 From: Ben McCann <322311+benmccann@users.noreply.github.com> Date: Tue, 15 Oct 2024 19:33:38 -0700 Subject: [PATCH 5/6] chore(commonjs): upgrade picomatch (#1775) chore: upgrade picomatch --- packages/commonjs/package.json | 4 ++-- pnpm-lock.yaml | 18 +++++++++--------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/packages/commonjs/package.json b/packages/commonjs/package.json index 83fe1254e..91890ab24 100644 --- a/packages/commonjs/package.json +++ b/packages/commonjs/package.json @@ -65,10 +65,10 @@ "@rollup/pluginutils": "^5.0.1", "commondir": "^1.0.1", "estree-walker": "^2.0.2", - "fdir": "^6.1.1", + "fdir": "^6.2.0", "is-reference": "1.2.1", "magic-string": "^0.30.3", - "picomatch": "^2.3.1" + "picomatch": "^4.0.2" }, "devDependencies": { "@rollup/plugin-json": "^5.0.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 454644781..3d2776de6 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -206,8 +206,8 @@ importers: specifier: ^2.0.2 version: 2.0.2 fdir: - specifier: ^6.1.1 - version: 6.1.1(picomatch@2.3.1) + specifier: ^6.2.0 + version: 6.3.0(picomatch@4.0.2) is-reference: specifier: 1.2.1 version: 1.2.1 @@ -215,8 +215,8 @@ importers: specifier: ^0.30.3 version: 0.30.3 picomatch: - specifier: ^2.3.1 - version: 2.3.1 + specifier: ^4.0.2 + version: 4.0.2 devDependencies: '@rollup/plugin-json': specifier: ^5.0.0 @@ -2723,10 +2723,10 @@ packages: fastq@1.13.0: resolution: {integrity: sha512-YpkpUnK8od0o1hmeSc7UUs/eB/vIPWJYjKck2QKIzAf71Vm1AAQ3EbuZB3g2JIy+pg+ERD0vqI79KyZiB2e2Nw==} - fdir@6.1.1: - resolution: {integrity: sha512-QfKBVg453Dyn3mr0Q0O+Tkr1r79lOTAKSi9f/Ot4+qVEwxWhav2Z+SudrG9vQjM2aYRMQQZ2/Q1zdA8ACM1pDg==} + fdir@6.3.0: + resolution: {integrity: sha512-QOnuT+BOtivR77wYvCWHfGt9s4Pz1VIMbD463vegT5MLqNXy8rYFT/lPVEqf/bhYeT6qmqrNHhsX+rWwe3rOCQ==} peerDependencies: - picomatch: 3.x + picomatch: ^3 || ^4 peerDependenciesMeta: picomatch: optional: true @@ -6975,9 +6975,9 @@ snapshots: dependencies: reusify: 1.0.4 - fdir@6.1.1(picomatch@2.3.1): + fdir@6.3.0(picomatch@4.0.2): optionalDependencies: - picomatch: 2.3.1 + picomatch: 4.0.2 fdir@6.4.0(picomatch@4.0.2): optionalDependencies: From 0f452340894517cfad63757eb494207c6804da3e Mon Sep 17 00:00:00 2001 From: Release Workflow Date: Wed, 16 Oct 2024 02:35:14 +0000 Subject: [PATCH 6/6] chore(release): commonjs v28.0.1 --- packages/commonjs/CHANGELOG.md | 8 ++++++++ packages/commonjs/package.json | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/commonjs/CHANGELOG.md b/packages/commonjs/CHANGELOG.md index 322a3e90d..36f5cc402 100644 --- a/packages/commonjs/CHANGELOG.md +++ b/packages/commonjs/CHANGELOG.md @@ -1,5 +1,13 @@ # @rollup/plugin-commonjs ChangeLog +## v28.0.1 + +_2024-10-16_ + +### Updates + +- chore: upgrade picomatch (#1775) + ## v28.0.0 _2024-09-23_ diff --git a/packages/commonjs/package.json b/packages/commonjs/package.json index 91890ab24..f2b352869 100644 --- a/packages/commonjs/package.json +++ b/packages/commonjs/package.json @@ -1,6 +1,6 @@ { "name": "@rollup/plugin-commonjs", - "version": "28.0.0", + "version": "28.0.1", "publishConfig": { "access": "public" },