diff --git a/packages/keystatic/package.json b/packages/keystatic/package.json index 0184d7048..7c591e93a 100644 --- a/packages/keystatic/package.json +++ b/packages/keystatic/package.json @@ -105,7 +105,7 @@ "dist" ], "scripts": { - "setup": "ts-gql build && tsx scripts/l10n.cts && tsx scripts/build-prism.cts", + "setup": "ts-gql build && tsx scripts/l10n.ts && tsx scripts/build-prism.ts", "build": "pnpm run setup && next build", "dev": "next dev", "start": "next start" diff --git a/packages/keystatic/scripts/build-prism.cts b/packages/keystatic/scripts/build-prism.ts similarity index 78% rename from packages/keystatic/scripts/build-prism.cts rename to packages/keystatic/scripts/build-prism.ts index 73a14fb84..647916f4c 100644 --- a/packages/keystatic/scripts/build-prism.cts +++ b/packages/keystatic/scripts/build-prism.ts @@ -1,4 +1,5 @@ import fs from 'fs/promises'; +import { fileURLToPath } from 'url'; const languages = [ 'clike', @@ -45,11 +46,18 @@ const languages = [ const otherLanguages = ( await Promise.all( languages.map(lang => - fs.readFile(require.resolve(`prismjs/components/prism-${lang}`), 'utf8') + fs.readFile( + fileURLToPath( + import.meta.resolve(`prismjs/components/prism-${lang}`) + ), + 'utf8' + ) ) ) ).join('\n\n'); - const prism = (await fs.readFile(require.resolve('prismjs'), 'utf8')) + const prism = ( + await fs.readFile(fileURLToPath(import.meta.resolve('prismjs')), 'utf8') + ) .replace( `if (typeof module !== 'undefined' && module.exports) { \tmodule.exports = Prism; @@ -72,7 +80,7 @@ if (typeof global !== 'undefined') { `var _self = globalThis;` ); await fs.writeFile( - `${__dirname}/../src/form/fields/document/DocumentEditor/prism.js`, + `src/form/fields/document/DocumentEditor/prism.js`, '/* eslint-disable */\nglobalThis.Prism = { manual: true };\n' + prism + '\n' + diff --git a/packages/keystatic/scripts/l10n.cts b/packages/keystatic/scripts/l10n.ts similarity index 96% rename from packages/keystatic/scripts/l10n.cts rename to packages/keystatic/scripts/l10n.ts index 40a0d05ff..6ba1a7a17 100644 --- a/packages/keystatic/scripts/l10n.cts +++ b/packages/keystatic/scripts/l10n.ts @@ -2,7 +2,7 @@ import fs from 'fs/promises'; import path from 'path'; import { compileString } from '@internationalized/string-compiler'; -const localesDir = path.join(__dirname, '../src/app/l10n'); +const localesDir = 'src/app/l10n'; (async () => { const locales: Record> = {}; await Promise.all(