From c946af29d3d65e4e78c03f0bbcb2376fd9d8c469 Mon Sep 17 00:00:00 2001 From: Liam DeBeasi Date: Fri, 30 Sep 2022 11:01:48 -0500 Subject: [PATCH] refactor(react): only ship es modules (#26044) BREAKING CHANGE: `@ionic/react` and `@ionic/react-router` no longer ship a CommonJS entry point. Instead, only an ES Module entry point is provided for improved compatibility with Vite. --- BREAKING.md | 5 +++++ packages/react-router/package.json | 1 - packages/react-router/rollup.config.js | 9 ++------- packages/react/package.json | 1 - packages/react/rollup.config.js | 12 +++--------- 5 files changed, 10 insertions(+), 18 deletions(-) diff --git a/BREAKING.md b/BREAKING.md index 137bd71113..1b6d9a574c 100644 --- a/BREAKING.md +++ b/BREAKING.md @@ -25,6 +25,7 @@ This is a comprehensive list of the breaking changes introduced in the major ver - [Textarea](#version-7x-textarea) - [Virtual Scroll](#version-7x-virtual-scroll) - [JavaScript Frameworks](#version-7x-javascript-frameworks) + - [React](#version-7x-react) - [Vue](#version-7x-vue) - [Utilities](#version-7x-utilities) - [hidden attribute](#version-7x-hidden-attribute) @@ -143,6 +144,10 @@ Any references to the virtual scroll types from `@ionic/core` have been removed.

JavaScript Frameworks

+

React

+ +`@ionic/react` and `@ionic/react-router` no longer ship a CommonJS entry point. Instead, only an ES Module entry point is provided for improved compatibility with Vite. +

Vue

`@ionic/vue` and `@ionic/vue-router` no longer ship a CommonJS entry point. Instead, only an ES Module entry point is provided for improved compatibility with Vite. diff --git a/packages/react-router/package.json b/packages/react-router/package.json index 64a92236ee..d55b8481b1 100644 --- a/packages/react-router/package.json +++ b/packages/react-router/package.json @@ -31,7 +31,6 @@ "sync": "sh ./scripts/sync.sh" }, "main": "dist/index.js", - "module": "dist/index.esm.js", "types": "dist/types/index.d.ts", "files": [ "dist/" diff --git a/packages/react-router/rollup.config.js b/packages/react-router/rollup.config.js index be7afdd679..639dffa80e 100644 --- a/packages/react-router/rollup.config.js +++ b/packages/react-router/rollup.config.js @@ -5,15 +5,10 @@ export default { input: 'dist-transpiled/index.js', output: [ { - file: 'dist/index.esm.js', + file: 'dist/index.js', format: 'es', sourcemap: true, - }, - { - file: 'dist/index.js', - format: 'commonjs', - sourcemap: true, - }, + } ], external: (id) => !/^(\.|\/)/.test(id), plugins: [resolve(), sourcemaps()], diff --git a/packages/react/package.json b/packages/react/package.json index 7324159fa5..475135e051 100644 --- a/packages/react/package.json +++ b/packages/react/package.json @@ -34,7 +34,6 @@ "sync": "sh ./scripts/sync.sh" }, "main": "dist/index.js", - "module": "dist/index.esm.js", "types": "dist/types/index.d.ts", "files": [ "dist/", diff --git a/packages/react/rollup.config.js b/packages/react/rollup.config.js index cb1bebe310..1af9f78dc4 100644 --- a/packages/react/rollup.config.js +++ b/packages/react/rollup.config.js @@ -10,17 +10,11 @@ export default { output: [ { dir: 'dist/', - entryFileNames: '[name].esm.js', - chunkFileNames: '[name]-[hash].esm.js', + entryFileNames: '[name].js', + chunkFileNames: '[name]-[hash].js', format: 'es', sourcemap: true, - }, - { - dir: 'dist/', - format: 'commonjs', - preferConst: true, - sourcemap: true, - }, + } ], external: (id) => !/^(\.|\/)/.test(id), plugins: [