Skip to content

Commit

Permalink
fix(utils): using universal build config and fix compatibility issue (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
chenjiahan authored Jul 18, 2023
1 parent 5dabe04 commit 91d14b8
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 29 deletions.
7 changes: 7 additions & 0 deletions .changeset/funny-pigs-travel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@modern-js/utils': patch
---

fix(utils): using universal build config and fix compatibility issue

fix(utils): 使用 universal 构建配置,修复兼容性问题
7 changes: 6 additions & 1 deletion packages/server/server/src/dev-tools/dev-middleware/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { sep } from 'path';
import { Server } from 'http';
import { EventEmitter } from 'events';
import {
Expand Down Expand Up @@ -26,7 +27,11 @@ function getHMRClientPath(client: DevServerOptions['client']) {
'@modern-js/server/hmr-client',
)}?${host}${path}${port}${protocol}`;

return clientEntry;
// replace cjs with esm because we want to use the es5 version
return clientEntry.replace(
`${sep}cjs${sep}dev-tools`,
`${sep}esm${sep}dev-tools`,
);
}

export default class DevMiddleware extends EventEmitter {
Expand Down
37 changes: 9 additions & 28 deletions packages/toolkit/utils/modern.config.js
Original file line number Diff line number Diff line change
@@ -1,37 +1,18 @@
const { universalBuildConfig } = require('@scripts/build');

module.exports = {
buildConfig: [
{
buildType: 'bundleless',
format: 'cjs',
target: 'es2019',
dts: false,
outDir: './dist/cjs',
copy: {
buildConfig: universalBuildConfig.map((item, index) => {
if (index === 0) {
item.copy = {
patterns: [
{
from: './compiled',
context: __dirname,
to: '../compiled',
},
],
},
externalHelpers: true,
},
{
buildType: 'bundleless',
format: 'esm',
target: 'es2019',
dts: false,
outDir: './dist/esm',
externalHelpers: true,
},
{
buildType: 'bundleless',
dts: {
only: true,
},
outDir: './dist/types',
externalHelpers: true,
},
],
};
}
return item;
}),
};

0 comments on commit 91d14b8

Please sign in to comment.