diff --git a/bin/prepare-package.js b/bin/prepare-package.mjs similarity index 53% rename from bin/prepare-package.js rename to bin/prepare-package.mjs index ee9cf9f2d..4bf0543a0 100755 --- a/bin/prepare-package.js +++ b/bin/prepare-package.mjs @@ -1,11 +1,13 @@ #!/usr/bin/env node 'use strict'; -const fs = require('fs'); +import fs from 'fs'; +import path from 'path'; -const paths = require('../config/paths'); +const APP_DIRECTORY = fs.realpathSync(process.cwd()); +const PACKAGE_JSON_PATH = path.resolve(APP_DIRECTORY, 'package.json'); -const packageJson = JSON.parse(fs.readFileSync(paths.appPackageJson, 'utf-8')); +const packageJson = JSON.parse(fs.readFileSync(PACKAGE_JSON_PATH, 'utf-8')); // make package.json modifications to be able to publish the package. Workspaces require // private=true, but to publish it, it must be private=false. While publishing the @@ -13,4 +15,4 @@ const packageJson = JSON.parse(fs.readFileSync(paths.appPackageJson, 'utf-8')); packageJson.private = false; const stringified = JSON.stringify(packageJson, null, 2) + '\n'; -fs.writeFileSync(paths.appPackageJson, stringified); +fs.writeFileSync(PACKAGE_JSON_PATH, stringified); diff --git a/package.json b/package.json index 0c1363732..0036d438b 100644 --- a/package.json +++ b/package.json @@ -71,7 +71,7 @@ "build": "BUILD_TARGET=umd vite build && BUILD_TARGET=esm vite build", "test": "TZ=Europe/Amsterdam vitest", "test:storybook": "test-storybook --coverage", - "prepare-package": "node bin/prepare-package.js", + "prepare-package": "node bin/prepare-package.mjs", "makemessages-en": "formatjs extract 'src/**/*.{js,jsx}' --format bin/i18n-formatter.js --out-file src/i18n/messages/en.json --id-interpolation-pattern '[sha512:contenthash:base64:6]'", "makemessages-nl": "formatjs extract 'src/**/*.{js,jsx}' --format bin/i18n-formatter.js --out-file src/i18n/messages/nl.json --id-interpolation-pattern '[sha512:contenthash:base64:6]'", "makemessages": "npm run makemessages-nl && npm run makemessages-en",