@umijs/bundler-webpack 4.0.0-beta.15 → 4.0.0-beta.16
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/compiled/fork-ts-checker-webpack-plugin/LICENSE +21 -0
- package/compiled/fork-ts-checker-webpack-plugin/fsevents.node +0 -0
- package/compiled/fork-ts-checker-webpack-plugin/index.js +49 -0
- package/compiled/fork-ts-checker-webpack-plugin/package.json +1 -0
- package/compiled/webpack-manifest-plugin/LICENSE +21 -0
- package/compiled/webpack-manifest-plugin/index.js +1 -0
- package/compiled/webpack-manifest-plugin/package.json +1 -0
- package/dist/build.d.ts +3 -2
- package/dist/build.js +1 -0
- package/dist/config/config.d.ts +6 -2
- package/dist/config/config.js +36 -3
- package/dist/config/cssRules.js +1 -1
- package/dist/config/forkTSCheckerPlugin.d.ts +11 -0
- package/dist/config/forkTSCheckerPlugin.js +34 -0
- package/dist/config/harmonyLinkingErrorPlugin.js +4 -1
- package/dist/config/manifestPlugin.d.ts +11 -0
- package/dist/config/manifestPlugin.js +25 -0
- package/dist/config/miniCSSExtractPlugin.d.ts +1 -0
- package/dist/config/miniCSSExtractPlugin.js +2 -3
- package/dist/dev.d.ts +3 -2
- package/dist/dev.js +10 -3
- package/dist/schema.js +5 -5
- package/dist/server/server.js +5 -3
- package/package.json +13 -5
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"name":"fork-ts-checker-webpack-plugin","author":"Piotr Oleś <piotrek.oles@gmail.com>","license":"MIT","types":"lib/index.d.ts"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) Dane Thurber <dane.thurber@gmail.com>
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(){"use strict";var e={927: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},961: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(927);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 t={name:d?d+e.name:e.name,path:f?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},871: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(27));const a=n(s(205));const r=s(961);Object.defineProperty(t,"getCompilerHooks",{enumerable:true,get:function(){return r.getCompilerHooks}});const u=new Map;const l={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({},l,e)}apply(e){var t,s,n;const l={};const c=o.resolve(((t=e.options.output)===null||t===void 0?void 0:t.path)||"./",this.options.fileName);const p=o.relative(((s=e.options.output)===null||s===void 0?void 0:s.path)||"./",c);const m=r.beforeRunHook.bind(this,{emitCountMap:u,manifestFileName:c});const f=r.emitHook.bind(this,{compiler:e,emitCountMap:u,manifestAssetId:p,manifestFileName:c,moduleAssets:l,options:this.options});const d=r.normalModuleLoaderHook.bind(this,{moduleAssets:l});const h={name:"WebpackManifestPlugin",stage:Infinity};e.hooks.compilation.tap(h,(e=>{const t=!a.default.getCompilationHooks?e.hooks.normalModuleLoader:a.default.getCompilationHooks(e).loader;t.tap(h,d)}));if(((n=i.default.version)===null||n===void 0?void 0:n.startsWith("4"))||this.options.useLegacyEmit===true){e.hooks.emit.tap(h,f)}else{e.hooks.thisCompilation.tap(h,(e=>{e.hooks.processAssets.tap(h,(()=>f(e)))}))}e.hooks.run.tap(h,m);e.hooks.watchRun.tap(h,m)}}t.WebpackManifestPlugin=WebpackManifestPlugin},205:function(e){e.exports=require("../webpack/NormalModule")},535:function(e){e.exports=require("@umijs/bundler-webpack/compiled/tapable")},27:function(e){e.exports=require("@umijs/bundler-webpack/compiled/webpack")},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__(871);module.exports=s})();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"name":"webpack-manifest-plugin","author":"Dane Thurber <dane.thurber@gmail.com>","license":"MIT"}
|
package/dist/build.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { IOpts as IConfigOpts } from './config/config';
|
|
1
2
|
import { IConfig } from './types';
|
|
2
|
-
|
|
3
|
+
declare type IOpts = {
|
|
3
4
|
cwd: string;
|
|
4
5
|
entry: Record<string, string>;
|
|
5
6
|
config: IConfig;
|
|
@@ -12,6 +13,6 @@ interface IOpts {
|
|
|
12
13
|
extraBabelPlugins?: any[];
|
|
13
14
|
extraBabelPresets?: any[];
|
|
14
15
|
clean?: boolean;
|
|
15
|
-
}
|
|
16
|
+
} & Pick<IConfigOpts, 'cache'>;
|
|
16
17
|
export declare function build(opts: IOpts): Promise<void>;
|
|
17
18
|
export {};
|
package/dist/build.js
CHANGED
package/dist/config/config.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Configuration } from '../../compiled/webpack';
|
|
2
2
|
import { Env, IConfig } from '../types';
|
|
3
|
-
interface IOpts {
|
|
3
|
+
export interface IOpts {
|
|
4
4
|
cwd: string;
|
|
5
5
|
env: Env;
|
|
6
6
|
entry: Record<string, string>;
|
|
@@ -15,6 +15,10 @@ interface IOpts {
|
|
|
15
15
|
userConfig: IConfig;
|
|
16
16
|
analyze?: any;
|
|
17
17
|
name?: string;
|
|
18
|
+
cache?: {
|
|
19
|
+
absNodeModulesPath?: string;
|
|
20
|
+
buildDependencies?: string[];
|
|
21
|
+
cacheDirectory?: string;
|
|
22
|
+
};
|
|
18
23
|
}
|
|
19
24
|
export declare function getConfig(opts: IOpts): Promise<Configuration>;
|
|
20
|
-
export {};
|
package/dist/config/config.js
CHANGED
|
@@ -27,9 +27,11 @@ const copyPlugin_1 = require("./copyPlugin");
|
|
|
27
27
|
const cssRules_1 = require("./cssRules");
|
|
28
28
|
const definePlugin_1 = require("./definePlugin");
|
|
29
29
|
const fastRefreshPlugin_1 = require("./fastRefreshPlugin");
|
|
30
|
+
const forkTSCheckerPlugin_1 = require("./forkTSCheckerPlugin");
|
|
30
31
|
const harmonyLinkingErrorPlugin_1 = require("./harmonyLinkingErrorPlugin");
|
|
31
32
|
const ignorePlugin_1 = require("./ignorePlugin");
|
|
32
33
|
const javaScriptRules_1 = require("./javaScriptRules");
|
|
34
|
+
const manifestPlugin_1 = require("./manifestPlugin");
|
|
33
35
|
const miniCSSExtractPlugin_1 = require("./miniCSSExtractPlugin");
|
|
34
36
|
const nodePolyfill_1 = require("./nodePolyfill");
|
|
35
37
|
const progressPlugin_1 = require("./progressPlugin");
|
|
@@ -43,6 +45,7 @@ function getConfig(opts) {
|
|
|
43
45
|
userConfig.targets = userConfig.targets || {
|
|
44
46
|
chrome: 80,
|
|
45
47
|
};
|
|
48
|
+
const useHash = !!(opts.hash || (userConfig.hash && !isDev));
|
|
46
49
|
const applyOpts = {
|
|
47
50
|
name: opts.name,
|
|
48
51
|
config,
|
|
@@ -55,6 +58,7 @@ function getConfig(opts) {
|
|
|
55
58
|
browsers: (0, browsersList_1.getBrowsersList)({
|
|
56
59
|
targets: userConfig.targets,
|
|
57
60
|
}),
|
|
61
|
+
useHash,
|
|
58
62
|
staticPathPrefix: opts.staticPathPrefix !== undefined ? opts.staticPathPrefix : 'static/',
|
|
59
63
|
};
|
|
60
64
|
// mode
|
|
@@ -76,7 +80,6 @@ function getConfig(opts) {
|
|
|
76
80
|
: userConfig.devtool);
|
|
77
81
|
// output
|
|
78
82
|
const absOutputPath = (0, path_1.join)(opts.cwd, userConfig.outputPath || constants_1.DEFAULT_OUTPUT_PATH);
|
|
79
|
-
const useHash = opts.hash || (userConfig.hash && !isDev);
|
|
80
83
|
const disableCompress = process.env.COMPRESS === 'none';
|
|
81
84
|
config.output
|
|
82
85
|
.path(absOutputPath)
|
|
@@ -132,10 +135,12 @@ function getConfig(opts) {
|
|
|
132
135
|
yield (0, fastRefreshPlugin_1.addFastRefreshPlugin)(applyOpts);
|
|
133
136
|
// progress
|
|
134
137
|
yield (0, progressPlugin_1.addProgressPlugin)(applyOpts);
|
|
138
|
+
// fork-ts-checker
|
|
139
|
+
yield (0, forkTSCheckerPlugin_1.addForkTSCheckerPlugin)(applyOpts);
|
|
135
140
|
// copy
|
|
136
141
|
yield (0, copyPlugin_1.addCopyPlugin)(applyOpts);
|
|
137
|
-
//
|
|
138
|
-
|
|
142
|
+
// manifest
|
|
143
|
+
yield (0, manifestPlugin_1.addManifestPlugin)(applyOpts);
|
|
139
144
|
// hmr
|
|
140
145
|
if (isDev && opts.hmr) {
|
|
141
146
|
config.plugin('hmr').use(webpack_1.default.HotModuleReplacementPlugin);
|
|
@@ -150,6 +155,34 @@ function getConfig(opts) {
|
|
|
150
155
|
if (userConfig.runtimePublicPath) {
|
|
151
156
|
config.plugin('runtimePublicPath').use(RuntimePublicPathPlugin_1.RuntimePublicPathPlugin);
|
|
152
157
|
}
|
|
158
|
+
// cache
|
|
159
|
+
if (opts.cache) {
|
|
160
|
+
config.cache({
|
|
161
|
+
type: 'filesystem',
|
|
162
|
+
version: require('../../package.json').version,
|
|
163
|
+
buildDependencies: {
|
|
164
|
+
config: opts.cache.buildDependencies || [],
|
|
165
|
+
},
|
|
166
|
+
cacheDirectory: opts.cache.cacheDirectory ||
|
|
167
|
+
(0, path_1.join)(opts.cwd, 'node_modules', '.cache', 'bundler-webpack'),
|
|
168
|
+
});
|
|
169
|
+
// tnpm 安装依赖的情况 webpack 默认的 managedPaths 不生效
|
|
170
|
+
// 使用 immutablePaths 避免 node_modules 的内容被写入缓存
|
|
171
|
+
// tnpm 安装的依赖路径中同时包含包名和版本号,满足 immutablePaths 使用的条件
|
|
172
|
+
// ref: smallfish
|
|
173
|
+
if ( /*isTnpm*/require('@umijs/utils/package').__npminstall_done) {
|
|
174
|
+
config.snapshot({
|
|
175
|
+
immutablePaths: [
|
|
176
|
+
opts.cache.absNodeModulesPath || (0, path_1.join)(opts.cwd, 'node_modules'),
|
|
177
|
+
],
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
config.infrastructureLogging(Object.assign({ level: 'error' }, (process.env.WEBPACK_FS_CACHE_DEBUG
|
|
181
|
+
? {
|
|
182
|
+
debug: /webpack\.cache/,
|
|
183
|
+
}
|
|
184
|
+
: {})));
|
|
185
|
+
}
|
|
153
186
|
// analyzer
|
|
154
187
|
if (opts.analyze) {
|
|
155
188
|
yield (0, bundleAnalyzerPlugin_1.addBundleAnalyzerPlugin)(applyOpts);
|
package/dist/config/cssRules.js
CHANGED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import Config from '@umijs/bundler-webpack/compiled/webpack-5-chain';
|
|
2
|
+
import { Env, IConfig } from '../types';
|
|
3
|
+
interface IOpts {
|
|
4
|
+
name?: string;
|
|
5
|
+
config: Config;
|
|
6
|
+
userConfig: IConfig;
|
|
7
|
+
cwd: string;
|
|
8
|
+
env: Env;
|
|
9
|
+
}
|
|
10
|
+
export declare function addForkTSCheckerPlugin(opts: IOpts): Promise<void>;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,34 @@
|
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.addForkTSCheckerPlugin = void 0;
|
|
16
|
+
// @ts-ignore
|
|
17
|
+
const fork_ts_checker_webpack_plugin_1 = __importDefault(require("@umijs/bundler-webpack/compiled/fork-ts-checker-webpack-plugin"));
|
|
18
|
+
function addForkTSCheckerPlugin(opts) {
|
|
19
|
+
var _a;
|
|
20
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
21
|
+
const { config, userConfig } = opts;
|
|
22
|
+
if (userConfig.forkTSChecker) {
|
|
23
|
+
// use user's typescript
|
|
24
|
+
if ((_a = userConfig.forkTSChecker.typescript) === null || _a === void 0 ? void 0 : _a.enable) {
|
|
25
|
+
userConfig.forkTSChecker.typescript.typescriptPath =
|
|
26
|
+
require.resolve('typescript');
|
|
27
|
+
}
|
|
28
|
+
config
|
|
29
|
+
.plugin('fork-ts-checker-plugin')
|
|
30
|
+
.use(fork_ts_checker_webpack_plugin_1.default, [userConfig.forkTSChecker]);
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
exports.addForkTSCheckerPlugin = addForkTSCheckerPlugin;
|
|
@@ -12,6 +12,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.addHarmonyLinkingErrorPlugin = void 0;
|
|
13
13
|
// ref: https://github.com/webpack/webpack/blob/ccecc17c01af96edddb931a76e7a3b21ef2969d8/lib/dependencies/HarmonyImportDependency.js#L164
|
|
14
14
|
const LINKING_ERROR_TAG = 'was not found in';
|
|
15
|
+
// build 时会出现 css modules 的引用警告,但这应该是需要忽略的
|
|
16
|
+
const CSS_NO_EXPORTS = /\.(css|sass|scss|styl|less)' \(module has no exports\)/;
|
|
15
17
|
class HarmonyLinkingErrorPlugin {
|
|
16
18
|
apply(compiler) {
|
|
17
19
|
compiler.hooks.afterCompile.tap('HarmonyLinkingErrorPlugin', (compilation) => {
|
|
@@ -21,7 +23,8 @@ class HarmonyLinkingErrorPlugin {
|
|
|
21
23
|
const harmonyLinkingErrors = compilation.warnings.filter((w) => {
|
|
22
24
|
return (w.name === 'ModuleDependencyWarning' &&
|
|
23
25
|
!w.module.resource.includes('node_modules') &&
|
|
24
|
-
w.message.includes(LINKING_ERROR_TAG)
|
|
26
|
+
w.message.includes(LINKING_ERROR_TAG) &&
|
|
27
|
+
!CSS_NO_EXPORTS.test(w.message));
|
|
25
28
|
});
|
|
26
29
|
if (!harmonyLinkingErrors.length) {
|
|
27
30
|
return;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import Config from '@umijs/bundler-webpack/compiled/webpack-5-chain';
|
|
2
|
+
import { Env, IConfig } from '../types';
|
|
3
|
+
interface IOpts {
|
|
4
|
+
name?: string;
|
|
5
|
+
config: Config;
|
|
6
|
+
userConfig: IConfig;
|
|
7
|
+
cwd: string;
|
|
8
|
+
env: Env;
|
|
9
|
+
}
|
|
10
|
+
export declare function addManifestPlugin(opts: IOpts): Promise<void>;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.addManifestPlugin = void 0;
|
|
13
|
+
// @ts-ignore
|
|
14
|
+
const webpack_manifest_plugin_1 = require("@umijs/bundler-webpack/compiled/webpack-manifest-plugin");
|
|
15
|
+
function addManifestPlugin(opts) {
|
|
16
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
17
|
+
const { config, userConfig } = opts;
|
|
18
|
+
if (userConfig.manifest) {
|
|
19
|
+
config.plugin('manifest-plugin').use(webpack_manifest_plugin_1.WebpackManifestPlugin, [
|
|
20
|
+
Object.assign({ fileName: 'asset-manifest.json' }, userConfig.manifest),
|
|
21
|
+
]);
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
exports.addManifestPlugin = addManifestPlugin;
|
|
@@ -15,11 +15,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
exports.addMiniCSSExtractPlugin = void 0;
|
|
16
16
|
// @ts-ignore
|
|
17
17
|
const mini_css_extract_plugin_1 = __importDefault(require("@umijs/bundler-webpack/compiled/mini-css-extract-plugin"));
|
|
18
|
-
const types_1 = require("../types");
|
|
19
18
|
function addMiniCSSExtractPlugin(opts) {
|
|
20
19
|
return __awaiter(this, void 0, void 0, function* () {
|
|
21
|
-
const { config, userConfig,
|
|
22
|
-
const hash =
|
|
20
|
+
const { config, userConfig, useHash } = opts;
|
|
21
|
+
const hash = useHash ? '.[contenthash:8]' : '';
|
|
23
22
|
if (!userConfig.styleLoader) {
|
|
24
23
|
config.plugin('mini-css-extract-plugin').use(mini_css_extract_plugin_1.default, [
|
|
25
24
|
{
|
package/dist/dev.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { IOpts as IConfigOpts } from './config/config';
|
|
1
2
|
import { IConfig } from './types';
|
|
2
|
-
|
|
3
|
+
declare type IOpts = {
|
|
3
4
|
afterMiddlewares?: any[];
|
|
4
5
|
beforeMiddlewares?: any[];
|
|
5
6
|
onDevCompileDone?: Function;
|
|
@@ -14,6 +15,6 @@ interface IOpts {
|
|
|
14
15
|
cwd: string;
|
|
15
16
|
config: IConfig;
|
|
16
17
|
entry: Record<string, string>;
|
|
17
|
-
}
|
|
18
|
+
} & Pick<IConfigOpts, 'cache'>;
|
|
18
19
|
export declare function dev(opts: IOpts): Promise<void>;
|
|
19
20
|
export {};
|
package/dist/dev.js
CHANGED
|
@@ -14,14 +14,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.dev = void 0;
|
|
16
16
|
const mfsu_1 = require("@umijs/mfsu");
|
|
17
|
+
const path_1 = require("path");
|
|
17
18
|
const webpack_1 = __importDefault(require("../compiled/webpack"));
|
|
18
19
|
const config_1 = require("./config/config");
|
|
19
20
|
const constants_1 = require("./constants");
|
|
20
21
|
const server_1 = require("./server/server");
|
|
21
22
|
const types_1 = require("./types");
|
|
22
23
|
function dev(opts) {
|
|
23
|
-
var _a, _b, _c;
|
|
24
|
-
var
|
|
24
|
+
var _a, _b, _c, _d;
|
|
25
|
+
var _e;
|
|
25
26
|
return __awaiter(this, void 0, void 0, function* () {
|
|
26
27
|
const enableMFSU = opts.config.mfsu !== false;
|
|
27
28
|
let mfsu = null;
|
|
@@ -54,6 +55,8 @@ function dev(opts) {
|
|
|
54
55
|
modifyWebpackConfig: opts.modifyWebpackConfig,
|
|
55
56
|
hmr: true,
|
|
56
57
|
analyze: process.env.ANALYZE,
|
|
58
|
+
// disable cache since it's conflict with mfsu
|
|
59
|
+
// cache: opts.cache,
|
|
57
60
|
});
|
|
58
61
|
const depConfig = yield (0, config_1.getConfig)({
|
|
59
62
|
cwd: opts.cwd,
|
|
@@ -63,8 +66,12 @@ function dev(opts) {
|
|
|
63
66
|
hash: true,
|
|
64
67
|
staticPathPrefix: mfsu_1.MF_DEP_PREFIX,
|
|
65
68
|
name: constants_1.MFSU_NAME,
|
|
69
|
+
cache: {
|
|
70
|
+
buildDependencies: (_d = opts.cache) === null || _d === void 0 ? void 0 : _d.buildDependencies,
|
|
71
|
+
cacheDirectory: (0, path_1.join)(opts.cwd, 'node_modules', '.cache', 'mfsu-deps'),
|
|
72
|
+
},
|
|
66
73
|
});
|
|
67
|
-
(
|
|
74
|
+
(_e = webpackConfig.resolve).alias || (_e.alias = {});
|
|
68
75
|
// TODO: REMOVE ME
|
|
69
76
|
['@umijs/utils/compiled/strip-ansi', 'react-error-overlay'].forEach((dep) => {
|
|
70
77
|
// @ts-ignore
|
package/dist/schema.js
CHANGED
|
@@ -24,6 +24,7 @@ function getSchemas() {
|
|
|
24
24
|
return {
|
|
25
25
|
alias: (Joi) => Joi.object(),
|
|
26
26
|
autoCSSModules: (Joi) => Joi.boolean(),
|
|
27
|
+
autoprefixer: (Joi) => Joi.object(),
|
|
27
28
|
chainWebpack: (Joi) => Joi.function(),
|
|
28
29
|
copy: (Joi) => Joi.array().items(Joi.alternatives().try(Joi.object({
|
|
29
30
|
from: Joi.string(),
|
|
@@ -36,20 +37,19 @@ function getSchemas() {
|
|
|
36
37
|
define: (Joi) => Joi.object(),
|
|
37
38
|
depTranspiler: (Joi) => Joi.string().valid(types_1.Transpiler.babel, types_1.Transpiler.esbuild, types_1.Transpiler.swc, types_1.Transpiler.none),
|
|
38
39
|
devtool: (Joi) => Joi.alternatives().try(Joi.string().regex(DEVTOOL_REGEX), Joi.boolean()),
|
|
39
|
-
externals: (Joi) => Joi.alternatives().try(Joi.object().
|
|
40
|
-
Joi.string(),
|
|
41
|
-
Joi.boolean(),
|
|
42
|
-
Joi.object().pattern(/.+/, [Joi.string(), Joi.boolean()]),
|
|
43
|
-
]), Joi.string(), Joi.func().arity(3), Joi.object().regex()),
|
|
40
|
+
externals: (Joi) => Joi.alternatives().try(Joi.object(), Joi.string(), Joi.func()),
|
|
44
41
|
extraBabelPlugins: (Joi) => Joi.alternatives().try(Joi.string(), Joi.array().items(Joi.alternatives().try(Joi.string(), Joi.object()))),
|
|
45
42
|
extraBabelPresets: (Joi) => Joi.alternatives().try(Joi.string(), Joi.array().items(Joi.alternatives().try(Joi.string(), Joi.object()))),
|
|
46
43
|
extraPostCSSPlugins: (Joi) => Joi.array(),
|
|
47
44
|
fastRefresh: (Joi) => Joi.boolean(),
|
|
45
|
+
forkTSChecker: (Joi) => Joi.object(),
|
|
48
46
|
hash: (Joi) => Joi.boolean(),
|
|
49
47
|
ignoreMomentLocale: (Joi) => Joi.boolean(),
|
|
48
|
+
inlineLimit: (Joi) => Joi.number(),
|
|
50
49
|
jsMinifier: (Joi) => Joi.string().valid(types_1.JSMinifier.esbuild, types_1.JSMinifier.swc, types_1.JSMinifier.terser, types_1.JSMinifier.uglifyJs, types_1.JSMinifier.none),
|
|
51
50
|
jsMinifierOptions: (Joi) => Joi.object(),
|
|
52
51
|
lessLoader: (Joi) => Joi.object(),
|
|
52
|
+
manifest: (Joi) => Joi.object(),
|
|
53
53
|
mfsu: (Joi) => Joi.alternatives(Joi.object({
|
|
54
54
|
esbuild: Joi.boolean(),
|
|
55
55
|
mfName: Joi.string(),
|
package/dist/server/server.js
CHANGED
|
@@ -30,8 +30,10 @@ function createServer(opts) {
|
|
|
30
30
|
// basename middleware
|
|
31
31
|
app.use((req, _res, next) => {
|
|
32
32
|
const { url, path } = req;
|
|
33
|
-
const { basename } = userConfig;
|
|
34
|
-
if (
|
|
33
|
+
const { basename, history } = userConfig;
|
|
34
|
+
if ((history === null || history === void 0 ? void 0 : history.type) === 'browser' &&
|
|
35
|
+
basename !== '/' &&
|
|
36
|
+
url.startsWith(basename)) {
|
|
35
37
|
req.url = url.slice(basename.length);
|
|
36
38
|
req.path = path.slice(basename.length);
|
|
37
39
|
}
|
|
@@ -167,7 +169,7 @@ function createServer(opts) {
|
|
|
167
169
|
const port = opts.port || 8000;
|
|
168
170
|
server.listen(port, () => {
|
|
169
171
|
const host = opts.host && opts.host !== '0.0.0.0' ? opts.host : '127.0.0.1';
|
|
170
|
-
utils_1.logger.ready(`App listening at ${utils_1.chalk.green
|
|
172
|
+
utils_1.logger.ready(`App listening at ${utils_1.chalk.green(`http://${host}:${port}`)}`);
|
|
171
173
|
});
|
|
172
174
|
return server;
|
|
173
175
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umijs/bundler-webpack",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.16",
|
|
4
4
|
"description": "@umijs/bundler-webpack",
|
|
5
5
|
"homepage": "https://github.com/umijs/umi-next/tree/master/packages/bundler-webpack#readme",
|
|
6
6
|
"bugs": "https://github.com/umijs/umi-next/issues",
|
|
@@ -34,9 +34,9 @@
|
|
|
34
34
|
"@svgr/plugin-svgo": "^6.1.0",
|
|
35
35
|
"@swc/core": "1.2.117",
|
|
36
36
|
"@types/hapi__joi": "17.1.7",
|
|
37
|
-
"@umijs/babel-preset-umi": "4.0.0-beta.
|
|
38
|
-
"@umijs/mfsu": "4.0.0-beta.
|
|
39
|
-
"@umijs/utils": "4.0.0-beta.
|
|
37
|
+
"@umijs/babel-preset-umi": "4.0.0-beta.16",
|
|
38
|
+
"@umijs/mfsu": "4.0.0-beta.16",
|
|
39
|
+
"@umijs/utils": "4.0.0-beta.16",
|
|
40
40
|
"css-loader": "6.5.1",
|
|
41
41
|
"es5-imcompatible-versions": "^0.1.73",
|
|
42
42
|
"jest-worker": "27.4.2",
|
|
@@ -57,6 +57,7 @@
|
|
|
57
57
|
"css-minimizer-webpack-plugin": "3.1.1",
|
|
58
58
|
"cssnano": "5.0.8",
|
|
59
59
|
"express": "4.17.1",
|
|
60
|
+
"fork-ts-checker-webpack-plugin": "6.5.0",
|
|
60
61
|
"http-proxy-middleware": "2.0.1",
|
|
61
62
|
"less": "4.1.2",
|
|
62
63
|
"less-loader": "10.2.0",
|
|
@@ -78,6 +79,7 @@
|
|
|
78
79
|
"webpack-5-chain": "8.0.0",
|
|
79
80
|
"webpack-bundle-analyzer": "4.5.0",
|
|
80
81
|
"webpack-dev-middleware": "5.2.2",
|
|
82
|
+
"webpack-manifest-plugin": "4.0.2",
|
|
81
83
|
"webpack-sources": "3.2.2",
|
|
82
84
|
"ws": "8.2.3"
|
|
83
85
|
},
|
|
@@ -98,6 +100,7 @@
|
|
|
98
100
|
"compression",
|
|
99
101
|
"connect-history-api-fallback",
|
|
100
102
|
"express",
|
|
103
|
+
"fork-ts-checker-webpack-plugin",
|
|
101
104
|
"http-proxy-middleware",
|
|
102
105
|
"less",
|
|
103
106
|
"less-loader",
|
|
@@ -117,6 +120,7 @@
|
|
|
117
120
|
"webpack-5-chain",
|
|
118
121
|
"webpack-bundle-analyzer",
|
|
119
122
|
"webpack-dev-middleware",
|
|
123
|
+
"webpack-manifest-plugin",
|
|
120
124
|
"webpack-sources",
|
|
121
125
|
"ws",
|
|
122
126
|
"./bundles/webpack/bundle",
|
|
@@ -135,9 +139,11 @@
|
|
|
135
139
|
"tapable": "$$LOCAL",
|
|
136
140
|
"terser": "$$LOCAL",
|
|
137
141
|
"terser-webpack-plugin": "$$LOCAL",
|
|
142
|
+
"typescript": "typescript",
|
|
138
143
|
"uglify-js": "uglify-js",
|
|
139
144
|
"url-loader": "$$LOCAL",
|
|
140
145
|
"webpack": "$$LOCAL",
|
|
146
|
+
"webpack/lib/NormalModule": "../webpack/NormalModule",
|
|
141
147
|
"webpack-5-chain": "$$LOCAL",
|
|
142
148
|
"webpack-sources": "$$LOCAL",
|
|
143
149
|
"ws": "$$LOCAL"
|
|
@@ -165,6 +171,7 @@
|
|
|
165
171
|
"cssnano",
|
|
166
172
|
"compression",
|
|
167
173
|
"connect-history-api-fallback",
|
|
174
|
+
"fork-ts-checker-webpack-plugin",
|
|
168
175
|
"less",
|
|
169
176
|
"less-loader",
|
|
170
177
|
"mini-css-extract-plugin",
|
|
@@ -177,7 +184,8 @@
|
|
|
177
184
|
"svgo-loader",
|
|
178
185
|
"url-loader",
|
|
179
186
|
"webpack-bundle-analyzer",
|
|
180
|
-
"webpack-dev-middleware"
|
|
187
|
+
"webpack-dev-middleware",
|
|
188
|
+
"webpack-manifest-plugin"
|
|
181
189
|
]
|
|
182
190
|
}
|
|
183
191
|
}
|