-
Notifications
You must be signed in to change notification settings - Fork 408
feat(ui): Switch to ESM only builds #7264
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,14 @@ | ||
| // @ts-check | ||
| const rspack = require('@rspack/core'); | ||
| const packageJSON = require('./package.json'); | ||
| const path = require('path'); | ||
| const { merge } = require('webpack-merge'); | ||
| const ReactRefreshPlugin = require('@rspack/plugin-react-refresh'); | ||
| const { svgLoader, typescriptLoaderProd, typescriptLoaderDev } = require('../../scripts/rspack-common'); | ||
| import rspack from '@rspack/core'; | ||
| import packageJSON from './package.json' with { type: 'json' }; | ||
| import path from 'path'; | ||
| import { fileURLToPath } from 'url'; | ||
| import { merge } from 'webpack-merge'; | ||
| import ReactRefreshPlugin from '@rspack/plugin-react-refresh'; | ||
| import { svgLoader, typescriptLoaderProd, typescriptLoaderDev } from '../../scripts/rspack-common.js'; | ||
|
|
||
| const __filename = fileURLToPath(import.meta.url); | ||
| const __dirname = path.dirname(__filename); | ||
|
|
||
|
Comment on lines
+2
to
12
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @nikosdouvlis do we still need this file ?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tagging @dstaley to answer both questions at the same time :) |
||
| const isProduction = mode => mode === 'production'; | ||
| const isDevelopment = mode => !isProduction(mode); | ||
|
|
@@ -228,23 +232,6 @@ const prodConfig = mode => { | |
| }, | ||
| }); | ||
|
|
||
| // CJS module bundle (no chunks) | ||
| const uiCjs = merge(entryForVariant(variants.ui), common({ mode, variant: variants.ui }), commonForProdBundled(), { | ||
| output: { | ||
| filename: '[name].js', | ||
| libraryTarget: 'commonjs', | ||
| }, | ||
| plugins: [ | ||
| // Bundle everything into a single file for CJS | ||
| new rspack.optimize.LimitChunkCountPlugin({ | ||
| maxChunks: 1, | ||
| }), | ||
| ], | ||
| optimization: { | ||
| splitChunks: false, | ||
| }, | ||
| }); | ||
|
|
||
| // Entry ESM module bundle (no chunks) | ||
| const entryEsm = merge( | ||
| entryForVariant(variants.entry), | ||
|
|
@@ -270,29 +257,7 @@ const prodConfig = mode => { | |
| }, | ||
| ); | ||
|
|
||
| // Entry CJS module bundle (no chunks) | ||
| const entryCjs = merge( | ||
| entryForVariant(variants.entry), | ||
| common({ mode, variant: variants.entry }), | ||
| commonForProdBundled(), | ||
| { | ||
| output: { | ||
| filename: '[name].js', | ||
| libraryTarget: 'commonjs', | ||
| }, | ||
| plugins: [ | ||
| // Bundle everything into a single file for CJS | ||
| new rspack.optimize.LimitChunkCountPlugin({ | ||
| maxChunks: 1, | ||
| }), | ||
| ], | ||
| optimization: { | ||
| splitChunks: false, | ||
| }, | ||
| }, | ||
| ); | ||
|
|
||
| return [uiBrowser, uiEsm, uiCjs, entryEsm, entryCjs]; | ||
| return [uiBrowser, uiEsm, entryEsm]; | ||
| }; | ||
|
|
||
| /** | ||
|
|
@@ -338,7 +303,7 @@ const devConfig = (mode, env) => { | |
| }); | ||
| }; | ||
|
|
||
| module.exports = env => { | ||
| export default env => { | ||
| const mode = env.production ? 'production' : 'development'; | ||
| return isProduction(mode) ? prodConfig(mode) : devConfig(mode, env); | ||
| }; | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"type": "module"will treat all files in the current directory as ESM by default, so shouldn't this berspack.config.js? I don't think we need the.mjsextension.