diff options
author | 2024-08-20 18:25:04 +0800 | |
---|---|---|
committer | 2024-08-20 18:25:04 +0800 | |
commit | 1fd84b6bbc42885d0a80ea65a87b4a7946320924 (patch) | |
tree | 6bf19520a56b9c7cecdf3a64f2f9e65d868bb8bd /scripts/cmd/prebuild.js | |
parent | 88b6dca63b56ef12b92543384365f8f7f1cad85d (diff) | |
download | astro-1fd84b6bbc42885d0a80ea65a87b4a7946320924.tar.gz astro-1fd84b6bbc42885d0a80ea65a87b4a7946320924.tar.zst astro-1fd84b6bbc42885d0a80ea65a87b4a7946320924.zip |
Remove unused code in internal scripts (#11769)
Diffstat (limited to 'scripts/cmd/prebuild.js')
-rw-r--r-- | scripts/cmd/prebuild.js | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/scripts/cmd/prebuild.js b/scripts/cmd/prebuild.js index de3a36910..7c4174abf 100644 --- a/scripts/cmd/prebuild.js +++ b/scripts/cmd/prebuild.js @@ -1,9 +1,9 @@ -import esbuild from 'esbuild'; -import { red } from 'kleur/colors'; import fs from 'node:fs'; import path from 'node:path'; import { fileURLToPath, pathToFileURL } from 'node:url'; -import glob from 'tiny-glob'; +import esbuild from 'esbuild'; +import glob from 'fast-glob'; +import { red } from 'kleur/colors'; function escapeTemplateLiterals(str) { return str.replace(/\`/g, '\\`').replace(/\$\{/g, '\\${'); @@ -23,10 +23,11 @@ export default async function prebuild(...args) { } let patterns = args; + // NOTE: absolute paths returned are forward slashes on windows let entryPoints = [].concat( ...(await Promise.all( - patterns.map((pattern) => glob(pattern, { filesOnly: true, absolute: true })) - )) + patterns.map((pattern) => glob(pattern, { onlyFiles: true, absolute: true })), + )), ); function getPrebuildURL(entryfilepath, dev = false) { @@ -43,20 +44,20 @@ export default async function prebuild(...args) { let tscode = await fs.promises.readFile(filepath, 'utf-8'); // If we're bundling a client directive, modify the code to match `packages/astro/src/core/client-directive/build.ts`. // If updating this code, make sure to also update that file. - if (filepath.includes(`runtime${path.sep}client`)) { + if (filepath.includes('runtime/client')) { // `export default xxxDirective` is a convention used in the current client directives that we use // to make sure we bundle this right. We'll error below if this convention isn't followed. const newTscode = tscode.replace( /export default (.*?)Directive/, (_, name) => - `(self.Astro || (self.Astro = {})).${name} = ${name}Directive;window.dispatchEvent(new Event('astro:${name}'))` + `(self.Astro || (self.Astro = {})).${name} = ${name}Directive;window.dispatchEvent(new Event('astro:${name}'))`, ); if (newTscode === tscode) { console.error( red( `${filepath} doesn't follow the \`export default xxxDirective\` convention. The prebuilt output may be wrong. ` + - `For more information, check out ${fileURLToPath(import.meta.url)}` - ) + `For more information, check out ${fileURLToPath(import.meta.url)}`, + ), ); } tscode = newTscode; @@ -91,7 +92,7 @@ export default async function prebuild(...args) { dev: true, } : undefined, - ].filter((entry) => entry) + ].filter((entry) => entry), ); for (const result of results) { |