Skip to content

Commit

Permalink
fix(runtime): fix the alias problem on windows (web-infra-dev#6233)
Browse files Browse the repository at this point in the history
  • Loading branch information
yimingjfe authored Sep 20, 2024
1 parent b4714d9 commit b36bf9f
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 12 deletions.
6 changes: 6 additions & 0 deletions .changeset/olive-colts-smoke.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@modern-js/runtime': patch
---

fix(runtime): fix the alias problem on windows
fix(runtime): 修复 windows 下 alias 的问题
10 changes: 10 additions & 0 deletions packages/runtime/plugin-runtime/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@ module.exports = {
...sharedConfig,
setupFiles: ['../../../tests/setEnvVars.js'],
rootDir: __dirname,
moduleNameMapper: {
'^@modern-js/runtime/browser$': require.resolve(
'@modern-js/runtime/browser',
),
'^@modern-js/runtime/react$': require.resolve('@modern-js/runtime/react'),
'^@modern-js/runtime/context$': require.resolve(
'@modern-js/runtime/context',
),
'^@modern-js/runtime$': require.resolve('@modern-js/runtime'),
},
transformIgnorePatterns: [
'/node_modules/.pnpm/(?!(@modern-js-reduck|@babel))',
],
Expand Down
22 changes: 10 additions & 12 deletions packages/runtime/plugin-runtime/src/cli/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,18 +109,16 @@ export const runtimePlugin = (params?: {
* Compatible with the reference path of the old version of the plugin.
*/
[`@${metaName}/runtime/plugins`]: pluginsExportsUtils.getPath(),
'@meta/runtime/browser$': require
.resolve('../core/browser')
.replace('/cjs/', '/esm/'),
'@meta/runtime/react$': require
.resolve('../core/react')
.replace('/cjs/', '/esm/'),
'@meta/runtime/context$': require
.resolve('../core/context')
.replace('/cjs/', '/esm/'),
'@meta/runtime$': require
.resolve('../index')
.replace('/cjs/', '/esm/'),
'@meta/runtime/browser$': require.resolve(
'@modern-js/runtime/browser',
),
'@meta/runtime/react$': require.resolve(
'@modern-js/runtime/react',
),
'@meta/runtime/context$': require.resolve(
'@modern-js/runtime/context',
),
'@meta/runtime$': require.resolve('@modern-js/runtime'),
},
globalVars: {
'process.env.IS_REACT18': process.env.IS_REACT18,
Expand Down
6 changes: 6 additions & 0 deletions tests/jest-ut.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ module.exports = {
'^@meta/runtime$': '<rootDir>/packages/runtime/plugin-runtime/src',
'^@meta/runtime/context$':
'<rootDir>/packages/runtime/plugin-runtime/src/core/context',
'^@modern-js/runtime/browser$':
'<rootDir>/packages/runtime/plugin-runtime/src/core/browser',
'^@modern-js/runtime/react$':
'<rootDir>/packages/runtime/plugin-runtime/src/core/react',
'^@modern-js/runtime$':
'<rootDir>/packages/runtime/plugin-runtime/src/index',
},
globals: {},
resolver: '<rootDir>/tests/jest.resolver.js',
Expand Down

0 comments on commit b36bf9f

Please sign in to comment.