@@ -58,6 +58,53 @@ const libBundle = createWebpackConfig({
5858 concatenateModules : false ,
5959 splitChunks : false ,
6060 } ,
61+ experiments : {
62+ asyncWebAssembly : true , // 启用 WebAssembly 支持
63+ } ,
64+ } ,
65+ } ) ;
66+
67+ const libBundleWithReact = createWebpackConfig ( {
68+ mode : 'production' ,
69+ tsconfigPath : path . join ( __dirname , '../../../tsconfig.json' ) ,
70+ outputPath : path . join ( __dirname , '../../core/bundle' ) ,
71+ define : {
72+ ...Object . keys ( define ) . reduce ( ( obj , key ) => {
73+ obj [ key ] = JSON . stringify ( define [ key ] ) ;
74+ return obj ;
75+ } , { } ) ,
76+ __non_webpack_require__ : '() => {}' ,
77+ } ,
78+ webpackConfig : {
79+ context : path . join ( __dirname , '../../..' ) ,
80+ entry : {
81+ [ config . appEntryWithReact ] : './packages/core/src' ,
82+ } ,
83+ // 此处 bundle 的包仅作为 commonjs 使用,但因为 external 原因会导致 webpack4 加载 bundle 出错,因此还是使用 umd
84+ output : {
85+ library : 'AlexLib' ,
86+ libraryTarget : 'umd' ,
87+ } ,
88+ externals : [
89+ // 此处没有 external React,将 React 打包进去以应对 React16 的集成方
90+ {
91+ moment : {
92+ root : 'moment' ,
93+ commonjs2 : 'moment' ,
94+ commonjs : 'moment' ,
95+ amd : 'moment' ,
96+ } ,
97+ } ,
98+ '@codeblitzjs/ide-registry' ,
99+ ] ,
100+ optimization : {
101+ minimize : false ,
102+ concatenateModules : false ,
103+ splitChunks : false ,
104+ } ,
105+ experiments : {
106+ asyncWebAssembly : true , // 启用 WebAssembly 支持
107+ } ,
61108 } ,
62109} ) ;
63110
@@ -105,4 +152,4 @@ const globalBundle = createWebpackConfig({
105152 } ,
106153} ) ;
107154
108- module . exports = [ libBundle , globalBundle ] ;
155+ module . exports = [ libBundle , libBundleWithReact , globalBundle ] ;
0 commit comments