diff options
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) { |