@umijs/bundler-webpack 4.0.0-rc.9 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/client/client/client.js +65 -37
- package/client/constants.js +9 -0
- package/compiled/css-minimizer-webpack-plugin/index.js +7 -7
- package/compiled/cssnano/index.js +6 -6
- package/compiled/fork-ts-checker-webpack-plugin/index.js +7 -13
- package/compiled/{tapable → react-refresh}/LICENSE +6 -6
- package/compiled/react-refresh/index.js +9 -7
- package/compiled/react-refresh/package.json +1 -0
- package/compiled/webpack/BasicEffectRulePlugin.js +1 -0
- package/compiled/webpack/BasicMatcherRulePlugin.js +1 -0
- package/compiled/webpack/HotModuleReplacement.runtime.js +29 -14
- package/compiled/webpack/JavascriptHotModuleReplacement.runtime.js +4 -3
- package/compiled/webpack/ObjectMatcherRulePlugin.js +1 -0
- package/compiled/webpack/RuleSetCompiler.js +1 -0
- package/compiled/webpack/UseEffectRulePlugin.js +1 -0
- package/compiled/webpack/deepImports.json +6 -1
- package/compiled/webpack/index.js +3978 -3167
- package/compiled/webpack/types.d.ts +606 -171
- package/compiled/webpack-dev-middleware/index.js +8 -7
- package/compiled/webpack-manifest-plugin/index.js +1 -1
- package/dist/build.d.ts +1 -0
- package/dist/build.js +49 -56
- package/dist/cli.js +6 -15
- package/dist/client/client.js +52 -50
- package/dist/config/_sampleFeature.js +6 -17
- package/dist/config/assetRules.js +44 -55
- package/dist/config/bundleAnalyzerPlugin.js +12 -23
- package/dist/config/compressPlugin.js +89 -70
- package/dist/config/config.d.ts +2 -0
- package/dist/config/config.js +181 -179
- package/dist/config/copyPlugin.js +29 -40
- package/dist/config/cssRules.js +114 -83
- package/dist/config/definePlugin.js +11 -19
- package/dist/config/detectDeadCodePlugin.js +16 -21
- package/dist/config/fastRefreshPlugin.js +11 -22
- package/dist/config/forkTSCheckerPlugin.js +11 -22
- package/dist/config/harmonyLinkingErrorPlugin.js +3 -14
- package/dist/config/ignorePlugin.js +10 -21
- package/dist/config/javaScriptRules.d.ts +1 -0
- package/dist/config/javaScriptRules.js +152 -136
- package/dist/config/manifestPlugin.d.ts +1 -1
- package/dist/config/manifestPlugin.js +10 -18
- package/dist/config/miniCSSExtractPlugin.js +15 -23
- package/dist/config/nodePolyfill.js +14 -20
- package/dist/config/nodePrefixPlugin.d.ts +11 -0
- package/dist/config/nodePrefixPlugin.js +14 -0
- package/dist/config/progressPlugin.js +7 -18
- package/dist/config/purgecssWebpackPlugin.js +15 -26
- package/dist/config/speedMeasureWebpackPlugin.js +12 -23
- package/dist/config/ssrPlugin.d.ts +11 -0
- package/dist/config/ssrPlugin.js +66 -0
- package/dist/config/svgRules.js +44 -47
- package/dist/constants.d.ts +1 -0
- package/dist/constants.js +7 -1
- package/dist/dev.d.ts +4 -0
- package/dist/dev.js +113 -93
- package/dist/index.d.ts +3 -0
- package/dist/index.js +16 -0
- package/dist/loader/svgr.js +4 -13
- package/dist/loader/swc.js +9 -14
- package/dist/plugins/ProgressPlugin.js +3 -3
- package/dist/plugins/RuntimePublicPathPlugin.js +4 -1
- package/dist/schema.js +21 -6
- package/dist/server/server.d.ts +3 -1
- package/dist/server/server.js +165 -159
- package/dist/server/ws.d.ts +7 -2
- package/dist/types.d.ts +3 -0
- package/dist/utils/getEsBuildTarget.d.ts +5 -0
- package/dist/utils/getEsBuildTarget.js +12 -0
- package/package.json +22 -20
- package/compiled/tapable/index.js +0 -1
- package/compiled/tapable/package.json +0 -1
- package/compiled/tapable/tapable.d.ts +0 -116
- package/dist/plugins/ESBuildCSSMinifyPlugin.d.ts +0 -11
- package/dist/plugins/ESBuildCSSMinifyPlugin.js +0 -63
- package/dist/plugins/ParcelCSSMinifyPlugin.d.ts +0 -10
- package/dist/plugins/ParcelCSSMinifyPlugin.js +0 -75
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(){"use strict";var e={156:function(e,t,s){Object.defineProperty(t,"__esModule",{value:true});t.transformFiles=t.reduceChunk=t.reduceAssets=t.generateManifest=void 0;const n=s(17);const generateManifest=(e,t,{generate:s,seed:n={}})=>{let o;if(s){const i=Array.from(e.entrypoints.entries());const a=i.reduce(((e,[t,s])=>Object.assign(e,{[t]:s.getFiles()})),{});o=s(n,t,a)}else{o=t.reduce(((e,t)=>Object.assign(e,{[t.name]:t.path})),n)}return o};t.generateManifest=generateManifest;const getFileType=(e,{transformExtensions:t})=>{const s=e.replace(/\?.*/,"");const n=s.split(".");const o=n.pop();return t.test(o)?`${n.pop()}.${o}`:o};const reduceAssets=(e,t,s)=>{let o;if(s[t.name]){o=s[t.name]}else if(t.info.sourceFilename){o=n.join(n.dirname(t.name),n.basename(t.info.sourceFilename))}if(o){return e.concat({isAsset:true,isChunk:false,isInitial:false,isModuleAsset:true,name:o,path:t.name})}const i=t.chunks&&t.chunks.length>0;if(i){return e}return e.concat({isAsset:true,isChunk:false,isInitial:false,isModuleAsset:false,name:t.name,path:t.name})};t.reduceAssets=reduceAssets;const reduceChunk=(e,t,s,o)=>{Array.from(t.auxiliaryFiles||[]).forEach((e=>{o[e]={isAsset:true,isChunk:false,isInitial:false,isModuleAsset:true,name:n.basename(e),path:e}}));return Array.from(t.files).reduce(((e,n)=>{let o=t.name?t.name:null;o=o?s.useEntryKeys&&!n.endsWith(".map")?o:`${o}.${getFileType(n,s)}`:n;return e.concat({chunk:t,isAsset:false,isChunk:true,isInitial:t.isOnlyInitial(),isModuleAsset:false,name:o,path:n})}),e)};t.reduceChunk=reduceChunk;const standardizeFilePaths=e=>{const t=Object.assign({},e);t.name=e.name.replace(/\\/g,"/");t.path=e.path.replace(/\\/g,"/");return t};const transformFiles=(e,t)=>["filter","map","sort"].filter((e=>!!t[e])).reduce(((e,s)=>e[s](t[s])),e).map(standardizeFilePaths);t.transformFiles=transformFiles},874:function(e,t,s){Object.defineProperty(t,"__esModule",{value:true});t.normalModuleLoaderHook=t.getCompilerHooks=t.emitHook=t.beforeRunHook=void 0;const n=s(147);const o=s(17);const i=s(535);const a=s(728);const r=s(156);const u=new WeakMap;const getCompilerHooks=e=>{let t=u.get(e);if(typeof t==="undefined"){t={afterEmit:new i.SyncWaterfallHook(["manifest"]),beforeEmit:new i.SyncWaterfallHook(["manifest"])};u.set(e,t)}return t};t.getCompilerHooks=getCompilerHooks;const beforeRunHook=({emitCountMap:e,manifestFileName:t},s,n)=>{const o=e.get(t)||0;e.set(t,o+1);if(n){n()}};t.beforeRunHook=beforeRunHook;const l=function emit({compiler:e,emitCountMap:t,manifestAssetId:s,manifestFileName:i,moduleAssets:u,options:l},c){const p=t.get(i)-1;const m=c.getStats().toJson({all:false,assets:true,cachedAssets:true,ids:true,publicPath:true});const f=l.publicPath!==null?l.publicPath:m.publicPath;const{basePath:d,removeKeyHash:h}=l;t.set(i,p);const k={};let b=Array.from(c.chunks).reduce(((e,t)=>r.reduceChunk(e,t,l,k)),[]);b=m.assets.reduce(((e,t)=>r.reduceAssets(e,t,u)),b);b=b.filter((({name:s,path:n})=>{var i;return!n.includes("hot-update")&&typeof t.get(o.join(((i=e.options.output)===null||i===void 0?void 0:i.path)||"<unknown>",s))==="undefined"}));b.forEach((e=>{delete k[e.path]}));Object.keys(k).forEach((e=>{b=b.concat(k[e])}));b=b.map((e=>{const normalizePath=e=>{if(!e.endsWith("/")){return`${e}/`}return e};const t={name:d?normalizePath(d)+e.name:e.name,path:f?normalizePath(f)+e.path:e.path};t.name=h?t.name.replace(h,""):t.name;return Object.assign(e,t)}));b=r.transformFiles(b,l);let g=r.generateManifest(c,b,l);const _=p===0;g=getCompilerHooks(e).beforeEmit.call(g);if(_){const e=l.serialize(g);c.emitAsset(s,new a.RawSource(e));if(l.writeToFileEmit){n.mkdirSync(o.dirname(i),{recursive:true});n.writeFileSync(i,e)}}getCompilerHooks(e).afterEmit.call(g)};t.emitHook=l;const normalModuleLoaderHook=({moduleAssets:e},t,s)=>{const{emitFile:n}=t;t.emitFile=(t,i,a)=>{if(s.userRequest&&!e[t]){Object.assign(e,{[t]:o.join(o.dirname(t),o.basename(s.userRequest))})}return n.call(s,t,i,a)}};t.normalModuleLoaderHook=normalModuleLoaderHook},131:function(e,t,s){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:true});t.WebpackManifestPlugin=t.getCompilerHooks=void 0;const o=s(17);const i=n(s(205));const a=s(874);Object.defineProperty(t,"getCompilerHooks",{enumerable:true,get:function(){return a.getCompilerHooks}});const r=new Map;const u={assetHookStage:Infinity,basePath:"",fileName:"manifest.json",filter:null,generate:void 0,map:null,publicPath:null,removeKeyHash:/([a-f0-9]{16,32}\.?)/gi,seed:void 0,serialize(e){return JSON.stringify(e,null,2)},sort:null,transformExtensions:/^(gz|map)$/i,useEntryKeys:false,useLegacyEmit:false,writeToFileEmit:false};class WebpackManifestPlugin{constructor(e){this.options=Object.assign({},u,e)}apply(e){var t,s;const n={};const u=o.resolve(((t=e.options.output)===null||t===void 0?void 0:t.path)||"./",this.options.fileName);const l=o.relative(((s=e.options.output)===null||s===void 0?void 0:s.path)||"./",u);const c=a.beforeRunHook.bind(this,{emitCountMap:r,manifestFileName:u});const p=a.emitHook.bind(this,{compiler:e,emitCountMap:r,manifestAssetId:l,manifestFileName:u,moduleAssets:n,options:this.options});const m=a.normalModuleLoaderHook.bind(this,{moduleAssets:n});const f={name:"WebpackManifestPlugin",stage:this.options.assetHookStage};e.hooks.compilation.tap(f,(e=>{const t=!i.default.getCompilationHooks?e.hooks.normalModuleLoader:i.default.getCompilationHooks(e).loader;t.tap(f,m)}));if(this.options.useLegacyEmit===true){e.hooks.emit.tap(f,p)}else{e.hooks.thisCompilation.tap(f,(e=>{e.hooks.processAssets.tap(f,(()=>p(e)))}))}e.hooks.run.tapAsync(f,c);e.hooks.watchRun.tapAsync(f,c)}}t.WebpackManifestPlugin=WebpackManifestPlugin},205:function(e){e.exports=require("../webpack/NormalModule")},535:function(e){e.exports=require("@umijs/bundler-
|
|
1
|
+
(function(){"use strict";var e={156:function(e,t,s){Object.defineProperty(t,"__esModule",{value:true});t.transformFiles=t.reduceChunk=t.reduceAssets=t.generateManifest=void 0;const n=s(17);const generateManifest=(e,t,{generate:s,seed:n={}})=>{let o;if(s){const i=Array.from(e.entrypoints.entries());const a=i.reduce(((e,[t,s])=>Object.assign(e,{[t]:s.getFiles()})),{});o=s(n,t,a)}else{o=t.reduce(((e,t)=>Object.assign(e,{[t.name]:t.path})),n)}return o};t.generateManifest=generateManifest;const getFileType=(e,{transformExtensions:t})=>{const s=e.replace(/\?.*/,"");const n=s.split(".");const o=n.pop();return t.test(o)?`${n.pop()}.${o}`:o};const reduceAssets=(e,t,s)=>{let o;if(s[t.name]){o=s[t.name]}else if(t.info.sourceFilename){o=n.join(n.dirname(t.name),n.basename(t.info.sourceFilename))}if(o){return e.concat({isAsset:true,isChunk:false,isInitial:false,isModuleAsset:true,name:o,path:t.name})}const i=t.chunks&&t.chunks.length>0;if(i){return e}return e.concat({isAsset:true,isChunk:false,isInitial:false,isModuleAsset:false,name:t.name,path:t.name})};t.reduceAssets=reduceAssets;const reduceChunk=(e,t,s,o)=>{Array.from(t.auxiliaryFiles||[]).forEach((e=>{o[e]={isAsset:true,isChunk:false,isInitial:false,isModuleAsset:true,name:n.basename(e),path:e}}));return Array.from(t.files).reduce(((e,n)=>{let o=t.name?t.name:null;o=o?s.useEntryKeys&&!n.endsWith(".map")?o:`${o}.${getFileType(n,s)}`:n;return e.concat({chunk:t,isAsset:false,isChunk:true,isInitial:t.isOnlyInitial(),isModuleAsset:false,name:o,path:n})}),e)};t.reduceChunk=reduceChunk;const standardizeFilePaths=e=>{const t=Object.assign({},e);t.name=e.name.replace(/\\/g,"/");t.path=e.path.replace(/\\/g,"/");return t};const transformFiles=(e,t)=>["filter","map","sort"].filter((e=>!!t[e])).reduce(((e,s)=>e[s](t[s])),e).map(standardizeFilePaths);t.transformFiles=transformFiles},874:function(e,t,s){Object.defineProperty(t,"__esModule",{value:true});t.normalModuleLoaderHook=t.getCompilerHooks=t.emitHook=t.beforeRunHook=void 0;const n=s(147);const o=s(17);const i=s(535);const a=s(728);const r=s(156);const u=new WeakMap;const getCompilerHooks=e=>{let t=u.get(e);if(typeof t==="undefined"){t={afterEmit:new i.SyncWaterfallHook(["manifest"]),beforeEmit:new i.SyncWaterfallHook(["manifest"])};u.set(e,t)}return t};t.getCompilerHooks=getCompilerHooks;const beforeRunHook=({emitCountMap:e,manifestFileName:t},s,n)=>{const o=e.get(t)||0;e.set(t,o+1);if(n){n()}};t.beforeRunHook=beforeRunHook;const l=function emit({compiler:e,emitCountMap:t,manifestAssetId:s,manifestFileName:i,moduleAssets:u,options:l},c){const p=t.get(i)-1;const m=c.getStats().toJson({all:false,assets:true,cachedAssets:true,ids:true,publicPath:true});const f=l.publicPath!==null?l.publicPath:m.publicPath;const{basePath:d,removeKeyHash:h}=l;t.set(i,p);const k={};let b=Array.from(c.chunks).reduce(((e,t)=>r.reduceChunk(e,t,l,k)),[]);b=m.assets.reduce(((e,t)=>r.reduceAssets(e,t,u)),b);b=b.filter((({name:s,path:n})=>{var i;return!n.includes("hot-update")&&typeof t.get(o.join(((i=e.options.output)===null||i===void 0?void 0:i.path)||"<unknown>",s))==="undefined"}));b.forEach((e=>{delete k[e.path]}));Object.keys(k).forEach((e=>{b=b.concat(k[e])}));b=b.map((e=>{const normalizePath=e=>{if(!e.endsWith("/")){return`${e}/`}return e};const t={name:d?normalizePath(d)+e.name:e.name,path:f?normalizePath(f)+e.path:e.path};t.name=h?t.name.replace(h,""):t.name;return Object.assign(e,t)}));b=r.transformFiles(b,l);let g=r.generateManifest(c,b,l);const _=p===0;g=getCompilerHooks(e).beforeEmit.call(g);if(_){const e=l.serialize(g);c.emitAsset(s,new a.RawSource(e));if(l.writeToFileEmit){n.mkdirSync(o.dirname(i),{recursive:true});n.writeFileSync(i,e)}}getCompilerHooks(e).afterEmit.call(g)};t.emitHook=l;const normalModuleLoaderHook=({moduleAssets:e},t,s)=>{const{emitFile:n}=t;t.emitFile=(t,i,a)=>{if(s.userRequest&&!e[t]){Object.assign(e,{[t]:o.join(o.dirname(t),o.basename(s.userRequest))})}return n.call(s,t,i,a)}};t.normalModuleLoaderHook=normalModuleLoaderHook},131:function(e,t,s){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:true});t.WebpackManifestPlugin=t.getCompilerHooks=void 0;const o=s(17);const i=n(s(205));const a=s(874);Object.defineProperty(t,"getCompilerHooks",{enumerable:true,get:function(){return a.getCompilerHooks}});const r=new Map;const u={assetHookStage:Infinity,basePath:"",fileName:"manifest.json",filter:null,generate:void 0,map:null,publicPath:null,removeKeyHash:/([a-f0-9]{16,32}\.?)/gi,seed:void 0,serialize(e){return JSON.stringify(e,null,2)},sort:null,transformExtensions:/^(gz|map)$/i,useEntryKeys:false,useLegacyEmit:false,writeToFileEmit:false};class WebpackManifestPlugin{constructor(e){this.options=Object.assign({},u,e)}apply(e){var t,s;const n={};const u=o.resolve(((t=e.options.output)===null||t===void 0?void 0:t.path)||"./",this.options.fileName);const l=o.relative(((s=e.options.output)===null||s===void 0?void 0:s.path)||"./",u);const c=a.beforeRunHook.bind(this,{emitCountMap:r,manifestFileName:u});const p=a.emitHook.bind(this,{compiler:e,emitCountMap:r,manifestAssetId:l,manifestFileName:u,moduleAssets:n,options:this.options});const m=a.normalModuleLoaderHook.bind(this,{moduleAssets:n});const f={name:"WebpackManifestPlugin",stage:this.options.assetHookStage};e.hooks.compilation.tap(f,(e=>{const t=!i.default.getCompilationHooks?e.hooks.normalModuleLoader:i.default.getCompilationHooks(e).loader;t.tap(f,m)}));if(this.options.useLegacyEmit===true){e.hooks.emit.tap(f,p)}else{e.hooks.thisCompilation.tap(f,(e=>{e.hooks.processAssets.tap(f,(()=>p(e)))}))}e.hooks.run.tapAsync(f,c);e.hooks.watchRun.tapAsync(f,c)}}t.WebpackManifestPlugin=WebpackManifestPlugin},205:function(e){e.exports=require("../webpack/NormalModule")},535:function(e){e.exports=require("@umijs/bundler-utils/compiled/tapable")},728:function(e){e.exports=require("@umijs/bundler-webpack/compiled/webpack-sources")},147:function(e){e.exports=require("fs")},17:function(e){e.exports=require("path")}};var t={};function __nccwpck_require__(s){var n=t[s];if(n!==undefined){return n.exports}var o=t[s]={exports:{}};var i=true;try{e[s].call(o.exports,o,o.exports,__nccwpck_require__);i=false}finally{if(i)delete t[s]}return o.exports}if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var s=__nccwpck_require__(131);module.exports=s})();
|
package/dist/build.d.ts
CHANGED
package/dist/build.js
CHANGED
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
4
|
};
|
|
@@ -17,56 +8,58 @@ const utils_1 = require("@umijs/utils");
|
|
|
17
8
|
const webpack_1 = __importDefault(require("../compiled/webpack"));
|
|
18
9
|
const config_1 = require("./config/config");
|
|
19
10
|
const types_1 = require("./types");
|
|
20
|
-
function build(opts) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
11
|
+
async function build(opts) {
|
|
12
|
+
const webpackConfig = await (0, config_1.getConfig)({
|
|
13
|
+
cwd: opts.cwd,
|
|
14
|
+
rootDir: opts.rootDir,
|
|
15
|
+
env: types_1.Env.production,
|
|
16
|
+
entry: opts.entry,
|
|
17
|
+
userConfig: opts.config,
|
|
18
|
+
analyze: process.env.ANALYZE,
|
|
19
|
+
babelPreset: opts.babelPreset,
|
|
20
|
+
extraBabelPlugins: [
|
|
21
|
+
...(opts.beforeBabelPlugins || []),
|
|
22
|
+
...(opts.extraBabelPlugins || []),
|
|
23
|
+
],
|
|
24
|
+
extraBabelPresets: [
|
|
25
|
+
...(opts.beforeBabelPresets || []),
|
|
26
|
+
...(opts.extraBabelPresets || []),
|
|
27
|
+
],
|
|
28
|
+
extraBabelIncludes: opts.config.extraBabelIncludes,
|
|
29
|
+
chainWebpack: opts.chainWebpack,
|
|
30
|
+
modifyWebpackConfig: opts.modifyWebpackConfig,
|
|
31
|
+
cache: opts.cache,
|
|
32
|
+
});
|
|
33
|
+
let isFirstCompile = true;
|
|
34
|
+
return new Promise((resolve, reject) => {
|
|
35
|
+
if (opts.clean) {
|
|
43
36
|
utils_1.rimraf.sync(webpackConfig.output.path);
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
if (stats) {
|
|
60
|
-
const errorMsg = stats.toString('errors-only');
|
|
61
|
-
// console.error(errorMsg);
|
|
62
|
-
reject(new Error(errorMsg));
|
|
63
|
-
}
|
|
37
|
+
}
|
|
38
|
+
const compiler = (0, webpack_1.default)(webpackConfig);
|
|
39
|
+
compiler.run((err, stats) => {
|
|
40
|
+
var _a;
|
|
41
|
+
(_a = opts.onBuildComplete) === null || _a === void 0 ? void 0 : _a.call(opts, {
|
|
42
|
+
err,
|
|
43
|
+
stats,
|
|
44
|
+
isFirstCompile,
|
|
45
|
+
time: stats ? stats.endTime - stats.startTime : null,
|
|
46
|
+
});
|
|
47
|
+
isFirstCompile = false;
|
|
48
|
+
if (err || (stats === null || stats === void 0 ? void 0 : stats.hasErrors())) {
|
|
49
|
+
if (err) {
|
|
50
|
+
// console.error(err);
|
|
51
|
+
reject(err);
|
|
64
52
|
}
|
|
65
|
-
|
|
66
|
-
|
|
53
|
+
if (stats) {
|
|
54
|
+
const errorMsg = stats.toString('errors-only');
|
|
55
|
+
// console.error(errorMsg);
|
|
56
|
+
reject(new Error(errorMsg));
|
|
67
57
|
}
|
|
68
|
-
|
|
69
|
-
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
resolve(stats);
|
|
61
|
+
}
|
|
62
|
+
compiler.close(() => { });
|
|
70
63
|
});
|
|
71
64
|
});
|
|
72
65
|
}
|
package/dist/cli.js
CHANGED
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
4
|
};
|
|
@@ -40,11 +31,11 @@ if ((0, fs_1.existsSync)(configFile)) {
|
|
|
40
31
|
}
|
|
41
32
|
Object.assign(config, args);
|
|
42
33
|
if (command === 'build') {
|
|
43
|
-
(() =>
|
|
34
|
+
(async () => {
|
|
44
35
|
process.env.NODE_ENV = 'production';
|
|
45
36
|
(0, assert_1.default)(entry, `Build failed: entry not found.`);
|
|
46
37
|
try {
|
|
47
|
-
|
|
38
|
+
await (0, build_1.build)({
|
|
48
39
|
config,
|
|
49
40
|
cwd,
|
|
50
41
|
entry: {
|
|
@@ -55,14 +46,14 @@ if (command === 'build') {
|
|
|
55
46
|
catch (e) {
|
|
56
47
|
console.error(e);
|
|
57
48
|
}
|
|
58
|
-
})
|
|
49
|
+
})();
|
|
59
50
|
}
|
|
60
51
|
else if (command === 'dev') {
|
|
61
|
-
(() =>
|
|
52
|
+
(async () => {
|
|
62
53
|
process.env.NODE_ENV = 'development';
|
|
63
54
|
try {
|
|
64
55
|
(0, assert_1.default)(entry, `Build failed: entry not found.`);
|
|
65
|
-
|
|
56
|
+
await (0, dev_1.dev)({
|
|
66
57
|
config,
|
|
67
58
|
cwd,
|
|
68
59
|
port: process.env.PORT,
|
|
@@ -77,7 +68,7 @@ else if (command === 'dev') {
|
|
|
77
68
|
catch (e) {
|
|
78
69
|
console.error(e);
|
|
79
70
|
}
|
|
80
|
-
})
|
|
71
|
+
})();
|
|
81
72
|
}
|
|
82
73
|
else {
|
|
83
74
|
error(`Unsupported command ${command}.`);
|
package/dist/client/client.js
CHANGED
|
@@ -22,15 +22,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
22
22
|
__setModuleDefault(result, mod);
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
25
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
35
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
27
|
};
|
|
@@ -41,15 +32,30 @@ const ErrorOverlay = __importStar(require("react-error-overlay"));
|
|
|
41
32
|
const constants_1 = require("../constants");
|
|
42
33
|
const formatWebpackMessages_1 = require("../utils/formatWebpackMessages");
|
|
43
34
|
console.log('[webpack] connecting...');
|
|
35
|
+
function getHost() {
|
|
36
|
+
if (process.env.SOCKET_SERVER) {
|
|
37
|
+
return new URL(process.env.SOCKET_SERVER);
|
|
38
|
+
}
|
|
39
|
+
return location;
|
|
40
|
+
}
|
|
41
|
+
function getSocketUrl() {
|
|
42
|
+
let h = getHost();
|
|
43
|
+
const host = h.host;
|
|
44
|
+
const isHttps = h.protocol === 'https:';
|
|
45
|
+
return `${isHttps ? 'wss' : 'ws'}://${host}`;
|
|
46
|
+
}
|
|
47
|
+
function getPingUrl() {
|
|
48
|
+
const h = getHost();
|
|
49
|
+
return `${h.protocol}//${h.host}/__umi_ping`;
|
|
50
|
+
}
|
|
44
51
|
let pingTimer = null;
|
|
45
|
-
const host = location.host;
|
|
46
|
-
const wsUrl = `ws://${host}`;
|
|
47
52
|
let isFirstCompilation = true;
|
|
48
53
|
let mostRecentCompilationHash = null;
|
|
49
54
|
let hasCompileErrors = false;
|
|
50
55
|
let hadRuntimeError = false;
|
|
51
|
-
const
|
|
52
|
-
socket
|
|
56
|
+
const pingUrl = getPingUrl();
|
|
57
|
+
const socket = new WebSocket(getSocketUrl(), 'webpack-hmr');
|
|
58
|
+
socket.addEventListener('message', async ({ data }) => {
|
|
53
59
|
data = JSON.parse(data);
|
|
54
60
|
if (data.type === 'connected') {
|
|
55
61
|
console.log(`[webpack] connected.`);
|
|
@@ -60,28 +66,26 @@ socket.addEventListener('message', ({ data }) => __awaiter(void 0, void 0, void
|
|
|
60
66
|
else {
|
|
61
67
|
handleMessage(data).catch(console.error);
|
|
62
68
|
}
|
|
63
|
-
})
|
|
64
|
-
function waitForSuccessfulPing(ms = 1000) {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
break;
|
|
71
|
-
}
|
|
72
|
-
catch (e) {
|
|
73
|
-
yield new Promise((resolve) => setTimeout(resolve, ms));
|
|
74
|
-
}
|
|
69
|
+
});
|
|
70
|
+
async function waitForSuccessfulPing(ms = 1000) {
|
|
71
|
+
// eslint-disable-next-line no-constant-condition
|
|
72
|
+
while (true) {
|
|
73
|
+
try {
|
|
74
|
+
await fetch(pingUrl);
|
|
75
|
+
break;
|
|
75
76
|
}
|
|
76
|
-
|
|
77
|
+
catch (e) {
|
|
78
|
+
await new Promise((resolve) => setTimeout(resolve, ms));
|
|
79
|
+
}
|
|
80
|
+
}
|
|
77
81
|
}
|
|
78
|
-
socket.addEventListener('close', () =>
|
|
82
|
+
socket.addEventListener('close', async () => {
|
|
79
83
|
if (pingTimer)
|
|
80
84
|
clearInterval(pingTimer);
|
|
81
85
|
console.info('[webpack] Dev server disconnected. Polling for restart...');
|
|
82
|
-
|
|
86
|
+
await waitForSuccessfulPing();
|
|
83
87
|
location.reload();
|
|
84
|
-
})
|
|
88
|
+
});
|
|
85
89
|
ErrorOverlay.startReportingRuntimeErrors({
|
|
86
90
|
onError: function () {
|
|
87
91
|
hadRuntimeError = true;
|
|
@@ -219,25 +223,23 @@ function tryApplyUpdates(onHotUpdateSuccess) {
|
|
|
219
223
|
handleApplyUpdates(err, null);
|
|
220
224
|
});
|
|
221
225
|
}
|
|
222
|
-
function handleMessage(payload) {
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
}
|
|
242
|
-
});
|
|
226
|
+
async function handleMessage(payload) {
|
|
227
|
+
// console.log('[payload]', payload);
|
|
228
|
+
switch (payload.type) {
|
|
229
|
+
case constants_1.MESSAGE_TYPE.hash:
|
|
230
|
+
handleAvailableHash(payload.data);
|
|
231
|
+
break;
|
|
232
|
+
case constants_1.MESSAGE_TYPE.stillOk:
|
|
233
|
+
case constants_1.MESSAGE_TYPE.ok:
|
|
234
|
+
handleSuccess();
|
|
235
|
+
break;
|
|
236
|
+
case constants_1.MESSAGE_TYPE.errors:
|
|
237
|
+
handleErrors(payload.data);
|
|
238
|
+
break;
|
|
239
|
+
case constants_1.MESSAGE_TYPE.warnings:
|
|
240
|
+
handleWarnings(payload.data);
|
|
241
|
+
break;
|
|
242
|
+
default:
|
|
243
|
+
// Do nothing
|
|
244
|
+
}
|
|
243
245
|
}
|
|
@@ -1,22 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.addSampleFeature = void 0;
|
|
13
|
-
function addSampleFeature(opts) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
env;
|
|
20
|
-
});
|
|
4
|
+
async function addSampleFeature(opts) {
|
|
5
|
+
const { config, userConfig, cwd, env } = opts;
|
|
6
|
+
config;
|
|
7
|
+
userConfig;
|
|
8
|
+
cwd;
|
|
9
|
+
env;
|
|
21
10
|
}
|
|
22
11
|
exports.addSampleFeature = addSampleFeature;
|
|
@@ -1,61 +1,50 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.addAssetRules = void 0;
|
|
13
|
-
function addAssetRules(opts) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
filename: `${opts.staticPathPrefix}[name].[hash:8].[ext]`,
|
|
58
|
-
});
|
|
4
|
+
async function addAssetRules(opts) {
|
|
5
|
+
const { config, userConfig } = opts;
|
|
6
|
+
const inlineLimit = parseInt(userConfig.inlineLimit || '10000', 10);
|
|
7
|
+
const rule = config.module.rule('asset');
|
|
8
|
+
rule
|
|
9
|
+
.oneOf('avif')
|
|
10
|
+
.test(/\.avif$/)
|
|
11
|
+
.type('asset')
|
|
12
|
+
.mimetype('image/avif')
|
|
13
|
+
.parser({
|
|
14
|
+
dataUrlCondition: {
|
|
15
|
+
maxSize: inlineLimit,
|
|
16
|
+
},
|
|
17
|
+
})
|
|
18
|
+
.generator({
|
|
19
|
+
filename: `${opts.staticPathPrefix}[name].[hash:8].[ext]`,
|
|
20
|
+
});
|
|
21
|
+
rule
|
|
22
|
+
.oneOf('image')
|
|
23
|
+
.test(/\.(bmp|gif|jpg|jpeg|png)$/)
|
|
24
|
+
.type('asset')
|
|
25
|
+
.parser({
|
|
26
|
+
dataUrlCondition: {
|
|
27
|
+
maxSize: inlineLimit,
|
|
28
|
+
},
|
|
29
|
+
})
|
|
30
|
+
.generator({
|
|
31
|
+
filename: `${opts.staticPathPrefix}[name].[hash:8].[ext]`,
|
|
32
|
+
});
|
|
33
|
+
const fallback = rule
|
|
34
|
+
.oneOf('fallback')
|
|
35
|
+
.exclude.add(/^$/) /* handle data: resources */
|
|
36
|
+
.add(/\.(js|mjs|jsx|ts|tsx)$/)
|
|
37
|
+
.add(/\.(css|less|sass|scss|stylus)$/)
|
|
38
|
+
.add(/\.html$/)
|
|
39
|
+
.add(/\.json$/);
|
|
40
|
+
if (userConfig.mdx) {
|
|
41
|
+
fallback.add(/\.mdx?$/);
|
|
42
|
+
}
|
|
43
|
+
fallback
|
|
44
|
+
.end()
|
|
45
|
+
.type('asset/resource')
|
|
46
|
+
.generator({
|
|
47
|
+
filename: `${opts.staticPathPrefix}[name].[hash:8].[ext]`,
|
|
59
48
|
});
|
|
60
49
|
}
|
|
61
50
|
exports.addAssetRules = addAssetRules;
|
|
@@ -1,30 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.addBundleAnalyzerPlugin = void 0;
|
|
13
4
|
// @ts-ignore
|
|
14
5
|
const webpack_bundle_analyzer_1 = require("@umijs/bundler-webpack/compiled/webpack-bundle-analyzer");
|
|
15
|
-
function addBundleAnalyzerPlugin(opts) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
]);
|
|
28
|
-
});
|
|
6
|
+
async function addBundleAnalyzerPlugin(opts) {
|
|
7
|
+
const { config } = opts;
|
|
8
|
+
config.plugin('webpack-bundle-analyzer').use(webpack_bundle_analyzer_1.BundleAnalyzerPlugin, [
|
|
9
|
+
// https://github.com/webpack-contrib/webpack-bundle-analyzer
|
|
10
|
+
{
|
|
11
|
+
analyzerMode: 'server',
|
|
12
|
+
analyzerPort: process.env.ANALYZE_PORT || 8888,
|
|
13
|
+
openAnalyzer: false,
|
|
14
|
+
logLevel: 'info',
|
|
15
|
+
defaultSizes: 'parsed',
|
|
16
|
+
},
|
|
17
|
+
]);
|
|
29
18
|
}
|
|
30
19
|
exports.addBundleAnalyzerPlugin = addBundleAnalyzerPlugin;
|