From 4ae2d89686237ffd393277500f8a6d7c2160d944 Mon Sep 17 00:00:00 2001 From: Julie Muzina Date: Thu, 26 Sep 2024 15:01:54 -0400 Subject: [PATCH] Revert "chore: Add an ESM submodule export to the build output (#1129)" This reverts commit e0b66f7354aca1a569a345744876ab8d7eacc7f1. --- .babelrc | 24 +++++++++++++++++ .gitignore | 2 -- .storybook/main.js | 3 +-- babel.config.js | 65 ---------------------------------------------- package.json | 13 ++++------ 5 files changed, 30 insertions(+), 77 deletions(-) create mode 100644 .babelrc delete mode 100644 babel.config.js diff --git a/.babelrc b/.babelrc new file mode 100644 index 000000000..41184ca53 --- /dev/null +++ b/.babelrc @@ -0,0 +1,24 @@ +{ + "presets": [ + "@babel/preset-env", + "@babel/preset-react", + "@babel/preset-typescript" + ], + "plugins": [ + "@babel/plugin-proposal-class-properties", + "babel-plugin-typescript-to-proptypes", + [ + "module-resolver", + { + "root": ["./src"], + "alias": { + "enums": "./src/enums", + "components": "./src/components", + "hooks": "./src/hooks", + "types": "./src/types", + "utils": "./src/utils" + } + } + ] + ] +} diff --git a/.gitignore b/.gitignore index 2bd454db0..905295616 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,5 @@ node_modules dist -dist-esm -dist-types .env.local .DS_Store .idea diff --git a/.storybook/main.js b/.storybook/main.js index 8cdde7f98..3619b4061 100644 --- a/.storybook/main.js +++ b/.storybook/main.js @@ -7,10 +7,9 @@ const config = { "@storybook/addon-docs", "@storybook/addon-controls", "@storybook/addon-a11y", - "@storybook/addon-webpack5-compiler-babel", + "@storybook/addon-webpack5-compiler-babel" ], webpackFinal: async (config) => { - process.env.BABEL_ENV = "cjs"; config.module.rules.push({ test: /\.scss$/, use: ["style-loader", "css-loader", "sass-loader"], diff --git a/babel.config.js b/babel.config.js deleted file mode 100644 index c6a6e30a1..000000000 --- a/babel.config.js +++ /dev/null @@ -1,65 +0,0 @@ -const commonJs = { - presets: [ - "@babel/preset-env", - "@babel/preset-react", - "@babel/preset-typescript", - ], - plugins: [ - "@babel/plugin-proposal-class-properties", - "babel-plugin-typescript-to-proptypes", - [ - "module-resolver", - { - root: ["./src"], - alias: { - enums: "./src/enums", - components: "./src/components", - hooks: "./src/hooks", - types: "./src/types", - utils: "./src/utils", - }, - }, - ], - ], -}; -const esm = { - presets: [ - [ - "@babel/preset-env", - { - modules: false, - targets: { - esmodules: true, - chrome: "120", - }, - }, - ], - "@babel/preset-react", - "@babel/preset-typescript", - ], - plugins: [ - "@babel/plugin-proposal-class-properties", - "babel-plugin-typescript-to-proptypes", - [ - "module-resolver", - { - root: ["./src"], - alias: { - enums: "./src/enums", - components: "./src/components", - hooks: "./src/hooks", - types: "./src/types", - utils: "./src/utils", - }, - }, - ], - ], -}; - -module.exports = { - env: { - cjs: commonJs, - test: commonJs, - esm, - }, -}; diff --git a/package.json b/package.json index 5034e7a65..95febcebb 100644 --- a/package.json +++ b/package.json @@ -2,8 +2,7 @@ "name": "@canonical/react-components", "version": "0.47.3", "main": "dist/index.js", - "module": "dist-esm/index.js", - "types": "dist-types/index.d.ts", + "module": "dist/index.js", "author": { "email": "webteam@canonical.com", "name": "Canonical Webteam" @@ -129,12 +128,10 @@ "vanilla-framework": "^3.15.1 || ^4.0.0" }, "scripts": { - "build": "yarn build-cjs && yarn build-declaration && yarn build-esm", - "build-base": "rm -rf $OUT_DIR && NODE_ENV=production BABEL_ENV=$BABEL_ENV babel src --out-dir $OUT_DIR --copy-files --no-copy-ignored --extensions '.js,.jsx,.ts,.tsx,.snap' --ignore '**/*.test.ts','**/*.test.tsx','**/*.stories.tsx','**/__snapshots__','src/setupTests.js','src/testing'", - "build-cjs": "OUT_DIR=dist BABEL_ENV=cjs yarn run build-base", - "build-esm": "OUT_DIR=dist-esm BABEL_ENV=esm yarn run build-base", - "build-declaration": "rm -rf dist-types && tsc --project tsconfig.build.json --outDir dist-types && tsc-alias -p tsconfig.build.json --outDir dist-types", - "build-watch": "yarn run build-cjs --watch", + "build": "rm -rf dist && yarn build-local; yarn build-declaration", + "build-local": "NODE_ENV=production babel src --out-dir dist --copy-files --no-copy-ignored --extensions '.js,.jsx,.ts,.tsx,.snap' --ignore '**/*.test.ts','**/*.test.tsx','**/*.stories.tsx','**/__snapshots__','src/setupTests.js','src/testing'", + "build-declaration": "tsc --project tsconfig.build.json && tsc-alias -p tsconfig.build.json", + "build-watch": "yarn run build-local --watch", "build-docs": "storybook build -c .storybook -o docs", "clean": "rm -rf node_modules dist .out", "docs": "storybook dev -p ${PORT:-9009} --no-open",