Skip to content
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

fix: internal styled-components babel plugin lost since umi@4.0.88 #741

Merged
merged 1 commit into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"@vercel/ncc": "0.33.3",
"babel-plugin-dynamic-import-node": "2.3.3",
"babel-plugin-module-resolver": "4.1.0",
"babel-plugin-styled-components": "2.1.4",
"babel-plugin-transform-define": "2.0.1",
"enhanced-resolve": "5.9.3",
"fast-glob": "3.2.12",
Expand Down
115 changes: 112 additions & 3 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 7 additions & 4 deletions src/builder/bundle/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ async function bundle(opts: IBundleOpts): Promise<void | IBundleWatcher> {
const config = opts.configProvider.configs[i];
const { plugins: extraPostCSSPlugins, ...postcssLoader } =
config.postcssOptions || {};
const babelSCOpts = getBabelStyledComponentsOpts(opts.configProvider.pkg);
// workaround for combine continuous onBuildComplete log in watch mode
const logStatus = lodash.debounce(
() =>
Expand Down Expand Up @@ -105,12 +106,14 @@ async function bundle(opts: IBundleOpts): Promise<void | IBundleWatcher> {
pluginTransformRuntime: {},
pluginLockCoreJS: {},
pluginDynamicImportNode: false,
pluginStyledComponents: getBabelStyledComponentsOpts(
opts.configProvider.pkg,
),
},
],
beforeBabelPlugins: [require.resolve('babel-plugin-dynamic-import-node')],
beforeBabelPlugins: [
require.resolve('babel-plugin-dynamic-import-node'),
...(babelSCOpts
? [[require.resolve('babel-plugin-styled-components'), babelSCOpts]]
: []),
],
extraBabelPresets: config.extraBabelPresets,
extraBabelPlugins: config.extraBabelPlugins,

Expand Down
5 changes: 4 additions & 1 deletion src/builder/bundless/loaders/javascript/babel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ const babelTransformer: IJSTransformer = function (content) {
path.dirname(this.paths.fileAbsPath),
),
presetTypeScript: {},
pluginStyledComponents: getBabelStyledComponentsOpts(this.pkg),
};
const pluginSCOpts = getBabelStyledComponentsOpts(this.pkg);

// transform alias to relative path for babel-plugin-module-resolver
const alias = Object.entries(oAlias).reduce<typeof oAlias>(
Expand Down Expand Up @@ -99,6 +99,9 @@ const babelTransformer: IJSTransformer = function (content) {
extensions: ['.js', '.jsx', '.ts', '.tsx', '.mjs', '.json'],
},
],
...(pluginSCOpts
? [[require.resolve('babel-plugin-styled-components'), pluginSCOpts]]
: []),
...(define
? [
[
Expand Down
Loading