From dca2d049c5323c8784926ed1bd7f5fd38cdb2d05 Mon Sep 17 00:00:00 2001 From: Josh Wooding <12938082+joshwooding@users.noreply.github.com> Date: Tue, 24 Sep 2024 11:14:24 +0100 Subject: [PATCH] Fix theme package (#667) --- .changeset/ten-carrots-mix.md | 5 +++++ packages/theme/package.json | 5 +++-- packages/theme/scripts/{bundle.js => bundle.mjs} | 11 +++++------ ...publicImageResolver.js => publicImageResolver.mjs} | 8 +++----- .../scripts/{saltIconNames.js => saltIconNames.mjs} | 8 +++----- 5 files changed, 19 insertions(+), 18 deletions(-) create mode 100644 .changeset/ten-carrots-mix.md rename packages/theme/scripts/{bundle.js => bundle.mjs} (86%) rename packages/theme/scripts/{publicImageResolver.js => publicImageResolver.mjs} (77%) rename packages/theme/scripts/{saltIconNames.js => saltIconNames.mjs} (87%) diff --git a/.changeset/ten-carrots-mix.md b/.changeset/ten-carrots-mix.md new file mode 100644 index 00000000..bfcb2805 --- /dev/null +++ b/.changeset/ten-carrots-mix.md @@ -0,0 +1,5 @@ +--- +'@jpmorganchase/mosaic-theme': patch +--- + +Added type:module to the package.json diff --git a/packages/theme/package.json b/packages/theme/package.json index b256e6a4..e354e459 100644 --- a/packages/theme/package.json +++ b/packages/theme/package.json @@ -9,6 +9,7 @@ "url": "git@github.com:jpmorganchase/mosaic.git", "directory": "packages/theme" }, + "type": "module", "types": "./dist/index.d.ts", "style": "./dist/index.css", "exports": { @@ -28,11 +29,11 @@ ], "scripts": { "build": "npm-run-all --parallel build:*", - "build:bundle": "node ./scripts/bundle.js", + "build:bundle": "node ./scripts/bundle.mjs", "build:types": "tsc", "clean": "npx del-cli 'dist/**' && find . -type d -empty -delete", "lint": "eslint --ignore-pattern \"**/__tests__/**\"", - "dev": "node ./scripts/bundle.js watch" + "dev": "node ./scripts/bundle.mjs watch" }, "devDependencies": { "@vanilla-extract/esbuild-plugin": "^2.0.0", diff --git a/packages/theme/scripts/bundle.js b/packages/theme/scripts/bundle.mjs similarity index 86% rename from packages/theme/scripts/bundle.js rename to packages/theme/scripts/bundle.mjs index 94d9a947..5cb290e9 100644 --- a/packages/theme/scripts/bundle.js +++ b/packages/theme/scripts/bundle.mjs @@ -1,10 +1,9 @@ -const path = require('path'); -const esbuild = require('esbuild'); -const { vanillaExtractPlugin } = require('@vanilla-extract/esbuild-plugin'); -const glob = require('fast-glob'); +import esbuild from 'esbuild'; +import { vanillaExtractPlugin } from '@vanilla-extract/esbuild-plugin'; +import glob from 'fast-glob'; -const publicImageResolver = require('./publicImageResolver'); -const saltIconNames = require('./saltIconNames'); +import { publicImageResolver } from './publicImageResolver.mjs'; +import { saltIconNames } from './saltIconNames.mjs'; const args = process.argv.slice(2); const watchEnabled = args[0] === 'watch'; diff --git a/packages/theme/scripts/publicImageResolver.js b/packages/theme/scripts/publicImageResolver.mjs similarity index 77% rename from packages/theme/scripts/publicImageResolver.js rename to packages/theme/scripts/publicImageResolver.mjs index 4711240f..5d83649f 100644 --- a/packages/theme/scripts/publicImageResolver.js +++ b/packages/theme/scripts/publicImageResolver.mjs @@ -1,9 +1,9 @@ -const path = require('path'); -const fs = require('fs'); +import path from 'node:path'; +import fs from 'node:fs'; const publicPath = path.join(process.cwd(), 'src/assets'); -const publicImageResolver = { +export const publicImageResolver = { name: 'imagePlugin', setup(build) { build.onResolve({ filter: /^img_/ }, args => ({ @@ -18,5 +18,3 @@ const publicImageResolver = { }); } }; - -module.exports = publicImageResolver; diff --git a/packages/theme/scripts/saltIconNames.js b/packages/theme/scripts/saltIconNames.mjs similarity index 87% rename from packages/theme/scripts/saltIconNames.js rename to packages/theme/scripts/saltIconNames.mjs index 0d59020f..494e4ac3 100644 --- a/packages/theme/scripts/saltIconNames.js +++ b/packages/theme/scripts/saltIconNames.mjs @@ -1,5 +1,5 @@ -const fs = require('fs'); -const path = require('path'); +import fs from 'node:fs'; +import path from 'node:path'; const typesPath = path.join(process.cwd(), 'types/saltIconNames.d.ts'); @@ -13,7 +13,7 @@ ${iconItems.join('\n')}; `; } -const saltIconNames = { +export const saltIconNames = { name: 'iconEnum', setup(build) { const icons = []; @@ -31,5 +31,3 @@ const saltIconNames = { }); } }; - -module.exports = saltIconNames;