diff --git a/.changeset/twenty-eels-fry.md b/.changeset/twenty-eels-fry.md new file mode 100644 index 000000000..a181386d7 --- /dev/null +++ b/.changeset/twenty-eels-fry.md @@ -0,0 +1,6 @@ +--- +'@web/rollup-plugin-copy': patch +'@web/rollup-plugin-html': patch +--- + +Update the `glob` dependency diff --git a/package-lock.json b/package-lock.json index 8f313dd86..c7f43bce6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6686,17 +6686,6 @@ "@types/node": "*" } }, - "node_modules/@types/glob": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/@types/glob/-/glob-7.2.0.tgz", - "integrity": "sha512-ZUxbzKl0IfJILTS6t7ip5fQQM/J3TJYubDm3nMbgubNNYS62eXeUpoLUC8/7fJNiFYHTrGPQn7hspDUzIHX3UA==", - "dev": true, - "license": "MIT", - "dependencies": { - "@types/minimatch": "*", - "@types/node": "*" - } - }, "node_modules/@types/hast": { "version": "2.3.5", "resolved": "https://registry.npmjs.org/@types/hast/-/hast-2.3.5.tgz", @@ -36353,30 +36342,80 @@ "version": "0.5.0", "license": "MIT", "dependencies": { - "glob": "^7.1.6" + "glob": "^10.0.0" }, "devDependencies": { - "@types/glob": "^7.1.3" + "@types/glob": "^8.1.0" }, "engines": { "node": ">=18.0.0" } }, + "packages/rollup-plugin-copy/node_modules/@types/glob": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/@types/glob/-/glob-8.1.0.tgz", + "integrity": "sha512-IO+MJPVhoqz+28h1qLAcBEH2+xHMK6MTyHJc7MTnnYb6wsoLR29POVGJ7LycmVXIqyy/4/2ShP5sUwTXuOwb/w==", + "dev": true, + "dependencies": { + "@types/minimatch": "^5.1.2", + "@types/node": "*" + } + }, + "packages/rollup-plugin-copy/node_modules/brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dependencies": { + "balanced-match": "^1.0.0" + } + }, "packages/rollup-plugin-copy/node_modules/glob": { - "version": "7.2.3", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", - "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", - "license": "ISC", + "version": "10.3.10", + "resolved": "https://registry.npmjs.org/glob/-/glob-10.3.10.tgz", + "integrity": "sha512-fa46+tv1Ak0UPK1TOy/pZrIybNNt4HCv7SDzwyfiOZkvZLEbjsZkJBPtDHVshZjbecAoAGSC20MjLDG/qr679g==", "dependencies": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.1.1", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" + "foreground-child": "^3.1.0", + "jackspeak": "^2.3.5", + "minimatch": "^9.0.1", + "minipass": "^5.0.0 || ^6.0.2 || ^7.0.0", + "path-scurry": "^1.10.1" + }, + "bin": { + "glob": "dist/esm/bin.mjs" }, "engines": { - "node": "*" + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "packages/rollup-plugin-copy/node_modules/jackspeak": { + "version": "2.3.6", + "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-2.3.6.tgz", + "integrity": "sha512-N3yCS/NegsOBokc8GAdM8UcmfsKiSS8cipheD/nivzr700H+nsMOxJjQnvwOcRYVuFkdH0wGUvW2WbXGmrZGbQ==", + "dependencies": { + "@isaacs/cliui": "^8.0.2" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + }, + "optionalDependencies": { + "@pkgjs/parseargs": "^0.11.0" + } + }, + "packages/rollup-plugin-copy/node_modules/minimatch": { + "version": "9.0.3", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.3.tgz", + "integrity": "sha512-RHiac9mvaRw0x3AYRgDC1CxAP7HTcNrrECeA8YYJeWnpo+2Q5CegtZjaotWTWxDG3UeGA1coE05iH1mPjT/2mg==", + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=16 || 14 >=14.17" }, "funding": { "url": "https://github.com/sponsors/isaacs" @@ -36388,7 +36427,7 @@ "license": "MIT", "dependencies": { "@web/parse5-utils": "^2.1.0", - "glob": "^7.1.6", + "glob": "^10.0.0", "html-minifier-terser": "^7.1.0", "parse5": "^6.0.1" }, @@ -36400,21 +36439,61 @@ "node": ">=18.0.0" } }, + "packages/rollup-plugin-html/node_modules/brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dependencies": { + "balanced-match": "^1.0.0" + } + }, "packages/rollup-plugin-html/node_modules/glob": { - "version": "7.2.3", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", - "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", - "license": "ISC", + "version": "10.3.10", + "resolved": "https://registry.npmjs.org/glob/-/glob-10.3.10.tgz", + "integrity": "sha512-fa46+tv1Ak0UPK1TOy/pZrIybNNt4HCv7SDzwyfiOZkvZLEbjsZkJBPtDHVshZjbecAoAGSC20MjLDG/qr679g==", "dependencies": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.1.1", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" + "foreground-child": "^3.1.0", + "jackspeak": "^2.3.5", + "minimatch": "^9.0.1", + "minipass": "^5.0.0 || ^6.0.2 || ^7.0.0", + "path-scurry": "^1.10.1" + }, + "bin": { + "glob": "dist/esm/bin.mjs" }, "engines": { - "node": "*" + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "packages/rollup-plugin-html/node_modules/jackspeak": { + "version": "2.3.6", + "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-2.3.6.tgz", + "integrity": "sha512-N3yCS/NegsOBokc8GAdM8UcmfsKiSS8cipheD/nivzr700H+nsMOxJjQnvwOcRYVuFkdH0wGUvW2WbXGmrZGbQ==", + "dependencies": { + "@isaacs/cliui": "^8.0.2" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + }, + "optionalDependencies": { + "@pkgjs/parseargs": "^0.11.0" + } + }, + "packages/rollup-plugin-html/node_modules/minimatch": { + "version": "9.0.3", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.3.tgz", + "integrity": "sha512-RHiac9mvaRw0x3AYRgDC1CxAP7HTcNrrECeA8YYJeWnpo+2Q5CegtZjaotWTWxDG3UeGA1coE05iH1mPjT/2mg==", + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=16 || 14 >=14.17" }, "funding": { "url": "https://github.com/sponsors/isaacs" diff --git a/packages/rollup-plugin-copy/package.json b/packages/rollup-plugin-copy/package.json index eb7987ee9..e2c1f7129 100644 --- a/packages/rollup-plugin-copy/package.json +++ b/packages/rollup-plugin-copy/package.json @@ -45,10 +45,10 @@ "copy" ], "dependencies": { - "glob": "^7.1.6" + "glob": "^10.0.0" }, "devDependencies": { - "@types/glob": "^7.1.3" + "@types/glob": "^8.1.0" }, "types": "dist/copy.d.ts" } diff --git a/packages/rollup-plugin-copy/src/listFiles.js b/packages/rollup-plugin-copy/src/listFiles.js index 3c2db105d..53d3bdc84 100644 --- a/packages/rollup-plugin-copy/src/listFiles.js +++ b/packages/rollup-plugin-copy/src/listFiles.js @@ -1,4 +1,4 @@ -const glob = require('glob'); +const { glob } = require('glob'); const fs = require('fs'); const path = require('path'); @@ -11,19 +11,15 @@ const path = require('path'); * @param {string} rootDir * @param {string|string[]} [ignore] */ -function listFiles(fromGlob, rootDir, ignore) { - return new Promise(resolve => { - glob(fromGlob, { cwd: rootDir, dot: true, ignore }, (er, files) => { - // remember, each filepath returned is relative to rootDir - resolve( - files - // fully resolve the filename relative to rootDir - .map(filePath => path.resolve(rootDir, filePath)) - // filter out directories - .filter(filePath => !fs.lstatSync(filePath).isDirectory()), - ); - }); - }); +async function listFiles(fromGlob, rootDir, ignore) { + // remember, each filepath returned is relative to rootDir + return ( + (await glob(fromGlob, { cwd: rootDir, dot: true, ignore })) + // fully resolve the filename relative to rootDir + .map(filePath => path.resolve(rootDir, filePath)) + // filter out directories + .filter(filePath => !fs.lstatSync(filePath).isDirectory()) + ); } module.exports = { listFiles }; diff --git a/packages/rollup-plugin-copy/test/integration.test.js b/packages/rollup-plugin-copy/test/integration.test.js index c83dada38..32fbc98d5 100644 --- a/packages/rollup-plugin-copy/test/integration.test.js +++ b/packages/rollup-plugin-copy/test/integration.test.js @@ -13,9 +13,11 @@ describe('rollup-plugin-copy', () => { const { output } = await bundle.generate({ format: 'es' }); expect(output.length).to.equal(5); - expect(output[1].fileName).to.equal('a.svg'); - expect(output[2].fileName).to.equal('b.svg'); - expect(output[3].fileName).to.equal(`sub${path.sep}sub-a.svg`); - expect(output[4].fileName).to.equal(`sub${path.sep}sub-b.mark.svg`); + expect(output.map(x => x.fileName).filter(x => x.endsWith('.svg'))).to.have.members([ + 'a.svg', + 'b.svg', + 'sub/sub-a.svg', + 'sub/sub-b.mark.svg', + ]); }); }); diff --git a/packages/rollup-plugin-copy/test/listFiles.test.js b/packages/rollup-plugin-copy/test/listFiles.test.js index d0ec36839..c51a77123 100644 --- a/packages/rollup-plugin-copy/test/listFiles.test.js +++ b/packages/rollup-plugin-copy/test/listFiles.test.js @@ -7,17 +7,21 @@ describe('listFiles', () => { it('gives a list of files', async () => { const files = await listFiles('*.svg', path.resolve(__dirname, './fixture/')); expect(files.length).to.equal(2); - expect(files[0]).to.match(/fixture(\/|\\)a\.svg$/); - expect(files[1]).to.match(/fixture(\/|\\)b\.svg$/); + expect(files).to.have.members([ + path.join(__dirname, './fixture/a.svg'), + path.join(__dirname, './fixture/b.svg'), + ]); }); it('only gives files and no folders', async () => { const files = await listFiles('**/*.svg', path.resolve(__dirname, './fixture/')); expect(files.length).to.equal(4); - expect(files[0]).to.match(/fixture(\/|\\)a\.svg$/); - expect(files[1]).to.match(/fixture(\/|\\)b\.svg$/); - expect(files[2]).to.match(/fixture(\/|\\)sub(\/|\\)sub-a\.svg$/); - expect(files[3]).to.match(/fixture(\/|\\)sub(\/|\\)sub-b\.mark\.svg$/); + expect(files).to.have.members([ + path.join(__dirname, './fixture/a.svg'), + path.join(__dirname, './fixture/b.svg'), + path.join(__dirname, './fixture/sub/sub-b.mark.svg'), + path.join(__dirname, './fixture/sub/sub-a.svg'), + ]); }); it('will copy files inside dot folders', async () => { diff --git a/packages/rollup-plugin-copy/test/patternsToFiles.test.js b/packages/rollup-plugin-copy/test/patternsToFiles.test.js index 627e5685f..c681efe94 100644 --- a/packages/rollup-plugin-copy/test/patternsToFiles.test.js +++ b/packages/rollup-plugin-copy/test/patternsToFiles.test.js @@ -7,8 +7,10 @@ describe('patternsToFiles', () => { it('works with a string', async () => { const files = await patternsToFiles('*.svg', path.resolve(__dirname, './fixture/')); expect(files.length).to.equal(2); - expect(files[0]).to.match(/fixture(\/|\\)a\.svg$/); - expect(files[1]).to.match(/fixture(\/|\\)b\.svg$/); + expect(files).to.have.members([ + path.join(__dirname, './fixture/a.svg'), + path.join(__dirname, './fixture/b.svg'), + ]); }); it('works with an array of strings ', async () => { @@ -17,8 +19,10 @@ describe('patternsToFiles', () => { path.resolve(__dirname, './fixture/'), ); expect(files.length).to.equal(3); - expect(files[0]).to.match(/fixture(\/|\\)a\.svg$/); - expect(files[1]).to.match(/fixture(\/|\\)b\.svg$/); - expect(files[2]).to.match(/fixture(\/|\\)sub(\/|\\)sub-b\.mark\.svg$/); + expect(files).to.have.members([ + path.join(__dirname, './fixture/a.svg'), + path.join(__dirname, './fixture/b.svg'), + path.join(__dirname, './fixture/sub/sub-b.mark.svg'), + ]); }); }); diff --git a/packages/rollup-plugin-html/package.json b/packages/rollup-plugin-html/package.json index 86551318e..f0e19dc35 100644 --- a/packages/rollup-plugin-html/package.json +++ b/packages/rollup-plugin-html/package.json @@ -45,7 +45,7 @@ ], "dependencies": { "@web/parse5-utils": "^2.1.0", - "glob": "^7.1.6", + "glob": "^10.0.0", "html-minifier-terser": "^7.1.0", "parse5": "^6.0.1" }, diff --git a/packages/rollup-plugin-html/src/input/getInputData.ts b/packages/rollup-plugin-html/src/input/getInputData.ts index b33008017..25d3a02e6 100644 --- a/packages/rollup-plugin-html/src/input/getInputData.ts +++ b/packages/rollup-plugin-html/src/input/getInputData.ts @@ -1,6 +1,6 @@ import fs from 'fs'; import path from 'path'; -import glob from 'glob'; +import { globSync, GlobOptionsWithFileTypesFalse } from 'glob'; import { createError } from '../utils.js'; import { RollupPluginHTMLOptions } from '../RollupPluginHTMLOptions.js'; @@ -9,8 +9,8 @@ import { normalizeInputOptions } from './normalizeInputOptions.js'; import { extractModulesAndAssets } from './extract/extractModulesAndAssets.js'; import { InputOption } from 'rollup'; -function resolveGlob(fromGlob: string, opts: glob.IOptions) { - const files = glob.sync(fromGlob, { ...opts, absolute: true }); +function resolveGlob(fromGlob: string, opts: GlobOptionsWithFileTypesFalse) { + const files = globSync(fromGlob, { ...opts, absolute: true }); return ( files // filter out directories diff --git a/packages/rollup-plugin-html/test/src/input/InputData.test.ts b/packages/rollup-plugin-html/test/src/input/InputData.test.ts index ce6354002..3c8b67639 100644 --- a/packages/rollup-plugin-html/test/src/input/InputData.test.ts +++ b/packages/rollup-plugin-html/test/src/input/InputData.test.ts @@ -258,15 +258,15 @@ describe('getInputData()', () => { const result = getInputData({ input: 'pages/**/*.html', rootDir }); expect(cleanupResult(result)).to.eql([ { - filePath: path.join(rootDir, 'pages', 'page-a.html').split(path.sep).join('/'), - html: '
page-a.html
', + filePath: path.join(rootDir, 'pages', 'page-c.html').split(path.sep).join('/'), + html: 'page-c.html
', inlineModules: [], moduleImports: [ - { importPath: path.join(rootDir, 'pages', 'page-a.js'), attributes: [] }, + { importPath: path.join(rootDir, 'pages', 'page-c.js'), attributes: [] }, { importPath: path.join(rootDir, 'pages', 'shared.js'), attributes: [] }, ], assets: [], - name: 'page-a.html', + name: 'page-c.html', }, { filePath: path.join(rootDir, 'pages', 'page-b.html').split(path.sep).join('/'), @@ -280,15 +280,15 @@ describe('getInputData()', () => { name: 'page-b.html', }, { - filePath: path.join(rootDir, 'pages', 'page-c.html').split(path.sep).join('/'), - html: 'page-c.html
', + filePath: path.join(rootDir, 'pages', 'page-a.html').split(path.sep).join('/'), + html: 'page-a.html
', inlineModules: [], moduleImports: [ - { importPath: path.join(rootDir, 'pages', 'page-c.js'), attributes: [] }, + { importPath: path.join(rootDir, 'pages', 'page-a.js'), attributes: [] }, { importPath: path.join(rootDir, 'pages', 'shared.js'), attributes: [] }, ], assets: [], - name: 'page-c.html', + name: 'page-a.html', }, ]); }); @@ -297,15 +297,15 @@ describe('getInputData()', () => { const result = getInputData({ input: 'pages/**/*.html', flattenOutput: false, rootDir }); expect(cleanupResult(result)).to.eql([ { - filePath: path.join(rootDir, 'pages', 'page-a.html').split(path.sep).join('/'), - html: 'page-a.html
', + filePath: path.join(rootDir, 'pages', 'page-c.html').split(path.sep).join('/'), + html: 'page-c.html
', inlineModules: [], moduleImports: [ - { importPath: path.join(rootDir, 'pages', 'page-a.js'), attributes: [] }, + { importPath: path.join(rootDir, 'pages', 'page-c.js'), attributes: [] }, { importPath: path.join(rootDir, 'pages', 'shared.js'), attributes: [] }, ], assets: [], - name: `pages${path.sep}page-a.html`, + name: `pages${path.sep}page-c.html`, }, { filePath: path.join(rootDir, 'pages', 'page-b.html').split(path.sep).join('/'), @@ -319,15 +319,15 @@ describe('getInputData()', () => { name: `pages${path.sep}page-b.html`, }, { - filePath: path.join(rootDir, 'pages', 'page-c.html').split(path.sep).join('/'), - html: 'page-c.html
', + filePath: path.join(rootDir, 'pages', 'page-a.html').split(path.sep).join('/'), + html: 'page-a.html
', inlineModules: [], moduleImports: [ - { importPath: path.join(rootDir, 'pages', 'page-c.js'), attributes: [] }, + { importPath: path.join(rootDir, 'pages', 'page-a.js'), attributes: [] }, { importPath: path.join(rootDir, 'pages', 'shared.js'), attributes: [] }, ], assets: [], - name: `pages${path.sep}page-c.html`, + name: `pages${path.sep}page-a.html`, }, ]); });