An open source design system that's fully customizable and agent ready
TypeScript
fix(charts,richtext,lab): declare `"type": "module"` for the ESM-only dist (#5001)
Ishan Jaincd1a2daa59af
diff --git a/packages/charts/babel.config.js b/packages/charts/babel.config.jsdeleted file mode 100644index 149808a0cb..0000000000--- a/packages/charts/babel.config.js+++ /dev/null@@ -1,46 +0,0 @@-// Copyright (c) Meta Platforms, Inc. and affiliates.--/**- * @file babel.config.js- * @input Uses @babel/preset-react, @babel/preset-typescript, the local- * add-extensions plugin, and @stylexjs/babel-plugin- * @output Babel config for compiling charts src -> dist (ESM .js with StyleX)- * @position Build config for @astryxdesign/charts- *- * Mirrors packages/lab/babel.config.js: charts consumes core's StyleX theme- * tokens (@astryxdesign/core/theme/tokens.stylex), a cross-package reference- * core never makes. The StyleX resolver therefore needs an alias to core's- * source and a monorepo-root rootDir.- *- * SYNC: When modified, update this header and /packages/charts/README.md- */--/* global module, require, __dirname */-// eslint-disable-next-line @typescript-eslint/no-require-imports-const path = require('node:path');--const rootDir = path.resolve(__dirname, '../..');--module.exports = {- presets: [- ['@babel/preset-react', {runtime: 'automatic', development: false}],- ['@babel/preset-typescript', {isTSX: true, allExtensions: true}],- ],- plugins: [- './babel-plugin-add-extensions.cjs',- [- '@stylexjs/babel-plugin',- {- dev: false,- runtimeInjection: false,- genConditionalClasses: true,- treeshakeCompensation: true,- aliases: {- '@astryxdesign/core/*': [path.join(rootDir, 'packages/core/src/*')],- '@astryxdesign/core': [path.join(rootDir, 'packages/core/src')],- },- unstable_moduleResolution: {type: 'commonJS', rootDir},- },- ],- ],-};diff --git a/packages/charts/babel.config.json b/packages/charts/babel.config.jsonnew file mode 100644index 0000000000..83f8a6a536--- /dev/null+++ b/packages/charts/babel.config.json@@ -0,0 +1,23 @@+{+ "presets": [+ ["@babel/preset-react", {"runtime": "automatic", "development": false}],+ ["@babel/preset-typescript", {"isTSX": true, "allExtensions": true}]+ ],+ "plugins": [+ "./babel-plugin-add-extensions.cjs",+ [+ "@stylexjs/babel-plugin",+ {+ "dev": false,+ "runtimeInjection": false,+ "genConditionalClasses": true,+ "treeshakeCompensation": true,+ "aliases": {+ "@astryxdesign/core/*": ["../../packages/core/src/*"],+ "@astryxdesign/core": ["../../packages/core/src"]+ },+ "unstable_moduleResolution": {"type": "commonJS", "rootDir": "../.."}+ }+ ]+ ]+}diff --git a/packages/charts/package.json b/packages/charts/package.jsonindex e2e5284d42..96138c17ed 100644--- a/packages/charts/package.json+++ b/packages/charts/package.json@@ -24,8 +24,8 @@"canaryOnly": true,"_comment": "Published ONLY to the @canary dist-tag (see .github/workflows/release.yml). Never published as a stable `latest` release. `private: true` is intentional and must stay — it is npm's hard guarantee against an accidental stable publish."},+ "type": "module","main": "./dist/index.js",- "module": "./dist/index.js","types": "./dist/index.d.ts","sideEffects": false,"files": [@@ -47,9 +47,9 @@"scripts": {"prepack": "pnpm build","build": "rimraf dist && pnpm build:esm && tsc --project tsconfig.build.json && pnpm build:css && node ../../scripts/check-no-dev-jsx.mjs && node ../../scripts/check-fully-specified.mjs",- "build:esm": "babel src --out-dir dist --extensions .ts,.tsx --out-file-extension .js --ignore \"**/*.test.ts,**/*.test.tsx,**/__tests__/**,**/*.perf.test.*,**/*.doc.mjs,**/*.d.ts,**/*.css,**/*.css.d.ts\" --config-file ./babel.config.js",+ "build:esm": "babel src --out-dir dist --extensions .ts,.tsx --out-file-extension .js --ignore \"**/*.test.ts,**/*.test.tsx,**/__tests__/**,**/*.perf.test.*,**/*.doc.mjs,**/*.d.ts,**/*.css,**/*.css.d.ts\" --config-file ./babel.config.json","build:css": "node ../../scripts/build-css.mjs --package charts",- "dev": "babel src --watch --out-dir dist --extensions .ts,.tsx --out-file-extension .js --ignore \"**/*.test.*,**/*.doc.mjs,**/*.d.ts,**/*.css*\" --config-file ./babel.config.js",+ "dev": "babel src --watch --out-dir dist --extensions .ts,.tsx --out-file-extension .js --ignore \"**/*.test.*,**/*.doc.mjs,**/*.d.ts,**/*.css*\" --config-file ./babel.config.json","test": "vitest run --root ../..","test:watch": "vitest --root ../..","lint": "eslint src",diff --git a/packages/lab/babel.config.js b/packages/lab/babel.config.jsdeleted file mode 100644index 31cedcd53b..0000000000--- a/packages/lab/babel.config.js+++ /dev/null@@ -1,46 +0,0 @@-// Copyright (c) Meta Platforms, Inc. and affiliates.--/**- * @file babel.config.js- * @input Uses @babel/preset-react, @babel/preset-typescript, the local- * add-extensions plugin, and @stylexjs/babel-plugin- * @output Babel config for compiling lab src → dist (ESM .js with StyleX)- * @position Build config for @astryxdesign/lab- *- * Mirrors packages/core/babel.config.json, with one difference: lab consumes- * core's StyleX theme tokens (@astryxdesign/core/theme/tokens.stylex), a- * cross-package reference core never makes. The StyleX resolver therefore- * needs an alias to core's source and a monorepo-root rootDir.- *- * SYNC: When modified, update this header and /packages/lab/README.md- */--/* global module, require, __dirname */-// eslint-disable-next-line @typescript-eslint/no-require-imports-const path = require('node:path');--const rootDir = path.resolve(__dirname, '../..');--module.exports = {- presets: [- ['@babel/preset-react', {runtime: 'automatic', development: false}],- ['@babel/preset-typescript', {isTSX: true, allExtensions: true}],- ],- plugins: [- './babel-plugin-add-extensions.cjs',- [- '@stylexjs/babel-plugin',- {- dev: false,- runtimeInjection: false,- genConditionalClasses: true,- treeshakeCompensation: true,- aliases: {- '@astryxdesign/core/*': [path.join(rootDir, 'packages/core/src/*')],- '@astryxdesign/core': [path.join(rootDir, 'packages/core/src')],- },- unstable_moduleResolution: {type: 'commonJS', rootDir},- },- ],- ],-};diff --git a/packages/lab/babel.config.json b/packages/lab/babel.config.jsonnew file mode 100644index 0000000000..83f8a6a536--- /dev/null+++ b/packages/lab/babel.config.json@@ -0,0 +1,23 @@+{+ "presets": [+ ["@babel/preset-react", {"runtime": "automatic", "development": false}],+ ["@babel/preset-typescript", {"isTSX": true, "allExtensions": true}]+ ],+ "plugins": [+ "./babel-plugin-add-extensions.cjs",+ [+ "@stylexjs/babel-plugin",+ {+ "dev": false,+ "runtimeInjection": false,+ "genConditionalClasses": true,+ "treeshakeCompensation": true,+ "aliases": {+ "@astryxdesign/core/*": ["../../packages/core/src/*"],+ "@astryxdesign/core": ["../../packages/core/src"]+ },+ "unstable_moduleResolution": {"type": "commonJS", "rootDir": "../.."}+ }+ ]+ ]+}diff --git a/packages/lab/package.json b/packages/lab/package.jsonindex 3f871389ed..6e2a652e44 100644--- a/packages/lab/package.json+++ b/packages/lab/package.json@@ -24,8 +24,8 @@"canaryOnly": true,"_comment": "Published ONLY to the @canary dist-tag (see .github/workflows/release.yml). Never published as a stable `latest` release. `private: true` is intentional and must stay — it is npm's hard guarantee against an accidental stable publish."},+ "type": "module","main": "./dist/index.js",- "module": "./dist/index.js","types": "./dist/index.d.ts","sideEffects": false,"files": [@@ -47,9 +47,9 @@"scripts": {"prepack": "pnpm build","build": "rimraf dist && pnpm build:esm && tsc --project tsconfig.build.json && pnpm build:css && node ../../scripts/check-no-dev-jsx.mjs && node ../../scripts/check-fully-specified.mjs",- "build:esm": "babel src --out-dir dist --extensions .ts,.tsx --out-file-extension .js --ignore \"**/*.test.ts,**/*.test.tsx,**/__tests__/**,**/*.perf.test.*,**/*.doc.mjs,**/*.d.ts,**/*.css,**/*.css.d.ts\" --config-file ./babel.config.js",+ "build:esm": "babel src --out-dir dist --extensions .ts,.tsx --out-file-extension .js --ignore \"**/*.test.ts,**/*.test.tsx,**/__tests__/**,**/*.perf.test.*,**/*.doc.mjs,**/*.d.ts,**/*.css,**/*.css.d.ts\" --config-file ./babel.config.json","build:css": "node ../../scripts/build-css.mjs --package lab",- "dev": "babel src --watch --out-dir dist --extensions .ts,.tsx --out-file-extension .js --ignore \"**/*.test.*,**/*.doc.mjs,**/*.d.ts,**/*.css*\" --config-file ./babel.config.js",+ "dev": "babel src --watch --out-dir dist --extensions .ts,.tsx --out-file-extension .js --ignore \"**/*.test.*,**/*.doc.mjs,**/*.d.ts,**/*.css*\" --config-file ./babel.config.json","test": "vitest run --root ../..","test:watch": "vitest --root ../..","lint": "eslint src",diff --git a/packages/richtext/babel.config.js b/packages/richtext/babel.config.jsdeleted file mode 100644index 8fa6b58127..0000000000--- a/packages/richtext/babel.config.js+++ /dev/null@@ -1,46 +0,0 @@-// Copyright (c) Meta Platforms, Inc. and affiliates.--/**- * @file babel.config.js- * @input Uses @babel/preset-react, @babel/preset-typescript, the local- * add-extensions plugin, and @stylexjs/babel-plugin- * @output Babel config for compiling richtext src -> dist (ESM .js with StyleX)- * @position Build config for @astryxdesign/richtext- *- * Mirrors packages/lab/babel.config.js: richtext consumes core's StyleX theme- * tokens (@astryxdesign/core/theme/tokens.stylex), a cross-package reference- * core never makes. The StyleX resolver therefore needs an alias to core's- * source and a monorepo-root rootDir.- *- * SYNC: When modified, update this header and /packages/richtext/README.md- */--/* global module, require, __dirname */-// eslint-disable-next-line @typescript-eslint/no-require-imports-const path = require('node:path');--const rootDir = path.resolve(__dirname, '../..');--module.exports = {- presets: [- ['@babel/preset-react', {runtime: 'automatic', development: false}],- ['@babel/preset-typescript', {isTSX: true, allExtensions: true}],- ],- plugins: [- './babel-plugin-add-extensions.cjs',- [- '@stylexjs/babel-plugin',- {- dev: false,- runtimeInjection: false,- genConditionalClasses: true,- treeshakeCompensation: true,- aliases: {- '@astryxdesign/core/*': [path.join(rootDir, 'packages/core/src/*')],- '@astryxdesign/core': [path.join(rootDir, 'packages/core/src')],- },- unstable_moduleResolution: {type: 'commonJS', rootDir},- },- ],- ],-};diff --git a/packages/richtext/babel.config.json b/packages/richtext/babel.config.jsonnew file mode 100644index 0000000000..83f8a6a536--- /dev/null+++ b/packages/richtext/babel.config.json@@ -0,0 +1,23 @@+{+ "presets": [+ ["@babel/preset-react", {"runtime": "automatic", "development": false}],+ ["@babel/preset-typescript", {"isTSX": true, "allExtensions": true}]+ ],+ "plugins": [+ "./babel-plugin-add-extensions.cjs",+ [+ "@stylexjs/babel-plugin",+ {+ "dev": false,+ "runtimeInjection": false,+ "genConditionalClasses": true,+ "treeshakeCompensation": true,+ "aliases": {+ "@astryxdesign/core/*": ["../../packages/core/src/*"],+ "@astryxdesign/core": ["../../packages/core/src"]+ },+ "unstable_moduleResolution": {"type": "commonJS", "rootDir": "../.."}+ }+ ]+ ]+}diff --git a/packages/richtext/package.json b/packages/richtext/package.jsonindex acea8a8e68..ca5a94514d 100644--- a/packages/richtext/package.json+++ b/packages/richtext/package.json@@ -26,8 +26,8 @@"canaryOnly": true,"_comment": "Published ONLY to the @canary dist-tag (see .github/workflows/release.yml). Never released as a stable `latest` release. `private: true` is intentional and must stay — it is npm\"s hard guarantee against an accidental stable publish."},+ "type": "module","main": "./dist/index.js",- "module": "./dist/index.js","types": "./dist/index.d.ts","sideEffects": false,"files": [@@ -49,9 +49,9 @@"scripts": {"prepack": "pnpm build","build": "rimraf dist && pnpm build:esm && tsc --project tsconfig.build.json && pnpm build:css && node ../../scripts/check-no-dev-jsx.mjs && node ../../scripts/check-fully-specified.mjs",- "build:esm": "babel src --out-dir dist --extensions \".ts,.tsx\" --out-file-extension \".js\" --ignore \"**/*.test.ts,**/*.test.tsx,**/__tests__/**,**/*.perf.test.*,**/*.doc.mjs,**/*.d.ts,**/*.css,**/*.css.d.ts\" --config-file ./babel.config.js",+ "build:esm": "babel src --out-dir dist --extensions \".ts,.tsx\" --out-file-extension \".js\" --ignore \"**/*.test.ts,**/*.test.tsx,**/__tests__/**,**/*.perf.test.*,**/*.doc.mjs,**/*.d.ts,**/*.css,**/*.css.d.ts\" --config-file ./babel.config.json","build:css": "node ../../scripts/build-css.mjs --package richtext",- "dev": "babel src --watch --out-dir dist --extensions \".ts,.tsx\" --out-file-extension \".js\" --ignore \"**/*.test.*,**/*.doc.mjs,**/*.d.ts,**/*.css*\" --config-file ./babel.config.js",+ "dev": "babel src --watch --out-dir dist --extensions \".ts,.tsx\" --out-file-extension \".js\" --ignore \"**/*.test.*,**/*.doc.mjs,**/*.d.ts,**/*.css*\" --config-file ./babel.config.json","test": "vitest run --root ../..","test:watch": "vitest --root ../..","lint": "eslint src",diff --git a/scripts/check-portable-scripts.test.mjs b/scripts/check-portable-scripts.test.mjsindex 7056e954f9..ad51224a6e 100644--- a/scripts/check-portable-scripts.test.mjs+++ b/scripts/check-portable-scripts.test.mjs@@ -156,11 +156,13 @@ describe('the repo itself (#3637)', () => {const {scripts} = read(`${dir}/package.json`);const core = read('packages/core/package.json');- // Same flags, same quoting as core — only the babel config file differs- // (lab/charts author theirs in .js, core in .json).+ // Same flags, same quoting as core. The config filename is normalised so+ // the assertion holds whichever extension a package authors its babel+ // config in.+ const config = /\.\/babel\.config\.\w+/;for (const name of ['build:esm', 'dev']) {- expect(scripts[name].replace('./babel.config.js', 'CONFIG')).toBe(- core.scripts[name].replace('./babel.config.json', 'CONFIG'),+ expect(scripts[name].replace(config, 'CONFIG')).toBe(+ core.scripts[name].replace(config, 'CONFIG'),);}},