-
Notifications
You must be signed in to change notification settings - Fork 370
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feat/storybook-rsbuild
- Loading branch information
Showing
46 changed files
with
2,178 additions
and
1,915 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
'@modern-js/uni-builder': patch | ||
--- | ||
|
||
fix(uni-builder): apply babel preset-react when using ts-loader | ||
|
||
fix(uni-builder): 使用 ts-loader 时开启 babel preset-react |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
'@modern-js/prod-server': minor | ||
'@modern-js/server-core': minor | ||
--- | ||
|
||
feat: add server SSR fallback hook | ||
feat: 新增 server SSR 降级 hook 实现 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
'@modern-js/uni-builder': patch | ||
--- | ||
|
||
fix(uni-builder): repeatedly insert babel plugin when using tsLoader in some edge case | ||
|
||
fix(uni-builder): 修复在一些边界场景下使用 tsLoader 时会重复添加 babel plugin 的问题 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { isServerTarget, type RsbuildPlugin } from '@rsbuild/shared'; | ||
|
||
const getAntdMajorVersion = (appDirectory: string) => { | ||
try { | ||
const pkgJsonPath = require.resolve('antd/package.json', { | ||
paths: [appDirectory], | ||
}); | ||
const { version } = require(pkgJsonPath); | ||
return Number(version.split('.')[0]); | ||
} catch (err) { | ||
return null; | ||
} | ||
}; | ||
|
||
export const pluginAntd = (): RsbuildPlugin => ({ | ||
name: 'uni-builder:antd', | ||
setup(api) { | ||
api.modifyRsbuildConfig(rsbuildConfig => { | ||
rsbuildConfig.source ??= {}; | ||
|
||
if ( | ||
rsbuildConfig.source.transformImport === false || | ||
rsbuildConfig.source.transformImport?.some( | ||
item => item.libraryName === 'antd', | ||
) | ||
) { | ||
return; | ||
} | ||
|
||
const antdMajorVersion = getAntdMajorVersion(api.context.rootPath); | ||
// antd >= v5 no longer need babel-plugin-import | ||
// see: https://ant.design/docs/react/migration-v5#remove-babel-plugin-import | ||
if (antdMajorVersion && antdMajorVersion < 5) { | ||
rsbuildConfig.source ??= {}; | ||
rsbuildConfig.source.transformImport = [ | ||
...(rsbuildConfig.source.transformImport || []), | ||
{ | ||
libraryName: 'antd', | ||
libraryDirectory: isServerTarget(api.context.targets) | ||
? 'lib' | ||
: 'es', | ||
style: true, | ||
}, | ||
]; | ||
} | ||
}); | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { isServerTarget, type RsbuildPlugin } from '@rsbuild/shared'; | ||
import { isPackageInstalled } from '@modern-js/utils'; | ||
|
||
export const pluginArco = (): RsbuildPlugin => ({ | ||
name: 'uni-builder:arco', | ||
|
||
setup(api) { | ||
const ARCO_NAME = '@arco-design/web-react'; | ||
const ARCO_ICON = `${ARCO_NAME}/icon`; | ||
|
||
api.modifyRsbuildConfig(rsbuildConfig => { | ||
const { transformImport = [] } = rsbuildConfig.source || {}; | ||
|
||
if ( | ||
transformImport === false || | ||
!isPackageInstalled(ARCO_NAME, api.context.rootPath) | ||
) { | ||
return; | ||
} | ||
|
||
const isUseSSR = isServerTarget(api.context.targets); | ||
|
||
if (!transformImport?.some(item => item.libraryName === ARCO_NAME)) { | ||
transformImport.push({ | ||
libraryName: ARCO_NAME, | ||
libraryDirectory: isUseSSR ? 'lib' : 'es', | ||
camelToDashComponentName: false, | ||
style: true, | ||
}); | ||
} | ||
|
||
if (!transformImport?.some(item => item.libraryName === ARCO_ICON)) { | ||
transformImport.push({ | ||
libraryName: ARCO_ICON, | ||
libraryDirectory: isUseSSR ? 'react-icon-cjs' : 'react-icon', | ||
camelToDashComponentName: false, | ||
}); | ||
} | ||
|
||
rsbuildConfig.source ||= {}; | ||
rsbuildConfig.source.transformImport = transformImport; | ||
}); | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 2 additions & 6 deletions
8
packages/builder/uni-builder/src/shared/plugins/splitChunk.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.