@umijs/bundler-webpack 4.0.0-rc.9 → 4.0.2
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 +33 -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 +182 -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 +35 -44
- 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.d.ts +1 -2
- 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 +23 -21
- 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,116 +0,0 @@
|
|
|
1
|
-
type FixedSizeArray<T extends number, U> = T extends 0
|
|
2
|
-
? void[]
|
|
3
|
-
: ReadonlyArray<U> & {
|
|
4
|
-
0: U;
|
|
5
|
-
length: T;
|
|
6
|
-
};
|
|
7
|
-
type Measure<T extends number> = T extends 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8
|
|
8
|
-
? T
|
|
9
|
-
: never;
|
|
10
|
-
type Append<T extends any[], U> = {
|
|
11
|
-
0: [U];
|
|
12
|
-
1: [T[0], U];
|
|
13
|
-
2: [T[0], T[1], U];
|
|
14
|
-
3: [T[0], T[1], T[2], U];
|
|
15
|
-
4: [T[0], T[1], T[2], T[3], U];
|
|
16
|
-
5: [T[0], T[1], T[2], T[3], T[4], U];
|
|
17
|
-
6: [T[0], T[1], T[2], T[3], T[4], T[5], U];
|
|
18
|
-
7: [T[0], T[1], T[2], T[3], T[4], T[5], T[6], U];
|
|
19
|
-
8: [T[0], T[1], T[2], T[3], T[4], T[5], T[6], T[7], U];
|
|
20
|
-
}[Measure<T["length"]>];
|
|
21
|
-
type AsArray<T> = T extends any[] ? T : [T];
|
|
22
|
-
|
|
23
|
-
declare class UnsetAdditionalOptions {
|
|
24
|
-
_UnsetAdditionalOptions: true
|
|
25
|
-
}
|
|
26
|
-
type IfSet<X> = X extends UnsetAdditionalOptions ? {} : X;
|
|
27
|
-
|
|
28
|
-
type Callback<E, T> = (error: E | null, result?: T) => void;
|
|
29
|
-
type InnerCallback<E, T> = (error?: E | null | false, result?: T) => void;
|
|
30
|
-
|
|
31
|
-
type FullTap = Tap & {
|
|
32
|
-
type: "sync" | "async" | "promise",
|
|
33
|
-
fn: Function
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
type Tap = TapOptions & {
|
|
37
|
-
name: string;
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
type TapOptions = {
|
|
41
|
-
before?: string;
|
|
42
|
-
stage?: number;
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
interface HookInterceptor<T, R, AdditionalOptions = UnsetAdditionalOptions> {
|
|
46
|
-
name?: string;
|
|
47
|
-
tap?: (tap: FullTap & IfSet<AdditionalOptions>) => void;
|
|
48
|
-
call?: (...args: any[]) => void;
|
|
49
|
-
loop?: (...args: any[]) => void;
|
|
50
|
-
error?: (err: Error) => void;
|
|
51
|
-
result?: (result: R) => void;
|
|
52
|
-
done?: () => void;
|
|
53
|
-
register?: (tap: FullTap & IfSet<AdditionalOptions>) => FullTap & IfSet<AdditionalOptions>;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
type ArgumentNames<T extends any[]> = FixedSizeArray<T["length"], string>;
|
|
57
|
-
|
|
58
|
-
declare class Hook<T, R, AdditionalOptions = UnsetAdditionalOptions> {
|
|
59
|
-
constructor(args?: ArgumentNames<AsArray<T>>, name?: string);
|
|
60
|
-
name: string | undefined;
|
|
61
|
-
taps: FullTap[];
|
|
62
|
-
intercept(interceptor: HookInterceptor<T, R, AdditionalOptions>): void;
|
|
63
|
-
isUsed(): boolean;
|
|
64
|
-
callAsync(...args: Append<AsArray<T>, Callback<Error, R>>): void;
|
|
65
|
-
promise(...args: AsArray<T>): Promise<R>;
|
|
66
|
-
tap(options: string | Tap & IfSet<AdditionalOptions>, fn: (...args: AsArray<T>) => R): void;
|
|
67
|
-
withOptions(options: TapOptions & IfSet<AdditionalOptions>): Omit<this, "call" | "callAsync" | "promise">;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
export class SyncHook<T, R = void, AdditionalOptions = UnsetAdditionalOptions> extends Hook<T, R, AdditionalOptions> {
|
|
71
|
-
call(...args: AsArray<T>): R;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
export class SyncBailHook<T, R, AdditionalOptions = UnsetAdditionalOptions> extends SyncHook<T, R, AdditionalOptions> {}
|
|
75
|
-
export class SyncLoopHook<T, AdditionalOptions = UnsetAdditionalOptions> extends SyncHook<T, void, AdditionalOptions> {}
|
|
76
|
-
export class SyncWaterfallHook<T, AdditionalOptions = UnsetAdditionalOptions> extends SyncHook<T, AsArray<T>[0], AdditionalOptions> {}
|
|
77
|
-
|
|
78
|
-
declare class AsyncHook<T, R, AdditionalOptions = UnsetAdditionalOptions> extends Hook<T, R, AdditionalOptions> {
|
|
79
|
-
tapAsync(
|
|
80
|
-
options: string | Tap & IfSet<AdditionalOptions>,
|
|
81
|
-
fn: (...args: Append<AsArray<T>, InnerCallback<Error, R>>) => void
|
|
82
|
-
): void;
|
|
83
|
-
tapPromise(
|
|
84
|
-
options: string | Tap & IfSet<AdditionalOptions>,
|
|
85
|
-
fn: (...args: AsArray<T>) => Promise<R>
|
|
86
|
-
): void;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
export class AsyncParallelHook<T, AdditionalOptions = UnsetAdditionalOptions> extends AsyncHook<T, void, AdditionalOptions> {}
|
|
90
|
-
export class AsyncParallelBailHook<T, R, AdditionalOptions = UnsetAdditionalOptions> extends AsyncHook<T, R, AdditionalOptions> {}
|
|
91
|
-
export class AsyncSeriesHook<T, AdditionalOptions = UnsetAdditionalOptions> extends AsyncHook<T, void, AdditionalOptions> {}
|
|
92
|
-
export class AsyncSeriesBailHook<T, R, AdditionalOptions = UnsetAdditionalOptions> extends AsyncHook<T, R, AdditionalOptions> {}
|
|
93
|
-
export class AsyncSeriesLoopHook<T, AdditionalOptions = UnsetAdditionalOptions> extends AsyncHook<T, void, AdditionalOptions> {}
|
|
94
|
-
export class AsyncSeriesWaterfallHook<T, AdditionalOptions = UnsetAdditionalOptions> extends AsyncHook<T, AsArray<T>[0], AdditionalOptions> {}
|
|
95
|
-
|
|
96
|
-
type HookFactory<H> = (key: any, hook?: H) => H;
|
|
97
|
-
|
|
98
|
-
interface HookMapInterceptor<H> {
|
|
99
|
-
factory?: HookFactory<H>;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
export class HookMap<H> {
|
|
103
|
-
constructor(factory: HookFactory<H>, name?: string);
|
|
104
|
-
name: string | undefined;
|
|
105
|
-
get(key: any): H | undefined;
|
|
106
|
-
for(key: any): H;
|
|
107
|
-
intercept(interceptor: HookMapInterceptor<H>): void;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
export class MultiHook<H> {
|
|
111
|
-
constructor(hooks: H[], name?: string);
|
|
112
|
-
name: string | undefined;
|
|
113
|
-
tap(options: string | Tap, fn?: Function): void;
|
|
114
|
-
tapAsync(options: string | Tap, fn?: Function): void;
|
|
115
|
-
tapPromise(options: string | Tap, fn?: Function): void;
|
|
116
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { Compilation, Compiler } from '@umijs/bundler-webpack/compiled/webpack';
|
|
2
|
-
interface IOpts {
|
|
3
|
-
sourcemap?: any;
|
|
4
|
-
}
|
|
5
|
-
declare class ESBuildCSSMinifyPlugin {
|
|
6
|
-
options: IOpts;
|
|
7
|
-
constructor(options?: IOpts);
|
|
8
|
-
apply(compiler: Compiler): void;
|
|
9
|
-
transformAssets(compilation: Compilation): Promise<void>;
|
|
10
|
-
}
|
|
11
|
-
export default ESBuildCSSMinifyPlugin;
|
|
@@ -1,63 +0,0 @@
|
|
|
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
|
-
const esbuild_1 = require("@umijs/bundler-utils/compiled/esbuild");
|
|
13
|
-
const webpack_sources_1 = require("@umijs/bundler-webpack/compiled/webpack-sources");
|
|
14
|
-
const version = require('../../package.json');
|
|
15
|
-
const PLUGIN_NAME = 'ESBuildCSSMinifyPlugin';
|
|
16
|
-
const RE_CSS_FILE = /\.css(\?.*)?$/i;
|
|
17
|
-
class ESBuildCSSMinifyPlugin {
|
|
18
|
-
constructor(options = {}) {
|
|
19
|
-
this.options = options;
|
|
20
|
-
}
|
|
21
|
-
apply(compiler) {
|
|
22
|
-
compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
|
|
23
|
-
compilation.hooks.chunkHash.tap(PLUGIN_NAME, (_, hash) => {
|
|
24
|
-
hash.update(JSON.stringify({
|
|
25
|
-
version,
|
|
26
|
-
options: this.options,
|
|
27
|
-
}));
|
|
28
|
-
});
|
|
29
|
-
compilation.hooks.processAssets.tapPromise({
|
|
30
|
-
name: PLUGIN_NAME,
|
|
31
|
-
stage: 400,
|
|
32
|
-
additionalAssets: true,
|
|
33
|
-
}, () => __awaiter(this, void 0, void 0, function* () {
|
|
34
|
-
yield this.transformAssets(compilation);
|
|
35
|
-
}));
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
transformAssets(compilation) {
|
|
39
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
40
|
-
const { options: { devtool }, } = compilation.compiler;
|
|
41
|
-
const sourcemap = this.options.sourcemap === undefined ? !!devtool : this.options.sourcemap;
|
|
42
|
-
const assets = compilation.getAssets().filter((asset) => {
|
|
43
|
-
return !asset.info.minimized && RE_CSS_FILE.test(asset.name);
|
|
44
|
-
});
|
|
45
|
-
yield Promise.all(assets.map((asset) => __awaiter(this, void 0, void 0, function* () {
|
|
46
|
-
const { source, map } = asset.source.sourceAndMap();
|
|
47
|
-
const sourceAsString = source.toString();
|
|
48
|
-
const result = yield (0, esbuild_1.transform)(sourceAsString, {
|
|
49
|
-
loader: 'css',
|
|
50
|
-
sourcemap,
|
|
51
|
-
sourcefile: asset.name,
|
|
52
|
-
minify: true,
|
|
53
|
-
});
|
|
54
|
-
compilation.updateAsset(asset.name,
|
|
55
|
-
// @ts-ignore
|
|
56
|
-
sourcemap
|
|
57
|
-
? new webpack_sources_1.SourceMapSource(result.code, asset.name, result.map, sourceAsString, map, true)
|
|
58
|
-
: new webpack_sources_1.RawSource(result.code), Object.assign(Object.assign({}, asset.info), { minimized: true }));
|
|
59
|
-
})));
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
exports.default = ESBuildCSSMinifyPlugin;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { TransformOptions } from '@parcel/css';
|
|
2
|
-
import type { Compiler } from '../../compiled/webpack/types';
|
|
3
|
-
declare type MinifyPluginOpts = Omit<TransformOptions, 'filename' | 'code' | 'minify'>;
|
|
4
|
-
export declare class ParcelCSSMinifyPlugin {
|
|
5
|
-
private readonly options;
|
|
6
|
-
constructor(opts?: MinifyPluginOpts);
|
|
7
|
-
apply(compiler: Compiler): void;
|
|
8
|
-
private transformAssets;
|
|
9
|
-
}
|
|
10
|
-
export {};
|
|
@@ -1,75 +0,0 @@
|
|
|
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.ParcelCSSMinifyPlugin = void 0;
|
|
13
|
-
const utils_1 = require("@umijs/utils");
|
|
14
|
-
const buffer_1 = require("buffer");
|
|
15
|
-
const path_1 = require("path");
|
|
16
|
-
const webpack_sources_1 = require("../../compiled/webpack-sources");
|
|
17
|
-
const pkgPath = (0, path_1.join)(__dirname, '../../package.json');
|
|
18
|
-
const pkg = require(pkgPath);
|
|
19
|
-
const PLUGIN_NAME = 'parcel-css-minify-plugin';
|
|
20
|
-
const CSS_FILE_REG = /\.css(?:\?.*)?$/i;
|
|
21
|
-
class ParcelCSSMinifyPlugin {
|
|
22
|
-
constructor(opts = {}) {
|
|
23
|
-
this.options = opts;
|
|
24
|
-
}
|
|
25
|
-
apply(compiler) {
|
|
26
|
-
const meta = JSON.stringify({
|
|
27
|
-
name: pkg.name,
|
|
28
|
-
version: pkg.version,
|
|
29
|
-
options: this.options,
|
|
30
|
-
});
|
|
31
|
-
compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
|
|
32
|
-
compilation.hooks.chunkHash.tap(PLUGIN_NAME, (_, hash) => hash.update(meta));
|
|
33
|
-
compilation.hooks.processAssets.tapPromise({
|
|
34
|
-
name: PLUGIN_NAME,
|
|
35
|
-
// @ts-ignore
|
|
36
|
-
stage: compilation.constructor.PROCESS_ASSETS_STAGE_OPTIMIZE_SIZE,
|
|
37
|
-
additionalAssets: true,
|
|
38
|
-
}, () => __awaiter(this, void 0, void 0, function* () { return yield this.transformAssets(compilation); }));
|
|
39
|
-
compilation.hooks.statsPrinter.tap(PLUGIN_NAME, (statsPrinter) => {
|
|
40
|
-
statsPrinter.hooks.print
|
|
41
|
-
.for('asset.info.minimized')
|
|
42
|
-
// @ts-ignore
|
|
43
|
-
.tap(PLUGIN_NAME, (minimized, { green, formatFlag }) => {
|
|
44
|
-
// @ts-ignore
|
|
45
|
-
return minimized ? green(formatFlag('minimized')) : undefined;
|
|
46
|
-
});
|
|
47
|
-
});
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
transformAssets(compilation) {
|
|
51
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
52
|
-
const { options: { devtool }, } = compilation.compiler;
|
|
53
|
-
const sourcemap = this.options.sourceMap === undefined
|
|
54
|
-
? (devtool && devtool.includes('source-map'))
|
|
55
|
-
: this.options.sourceMap;
|
|
56
|
-
const assets = compilation.getAssets().filter((asset) => {
|
|
57
|
-
return !asset.info.minimized && CSS_FILE_REG.test(asset.name);
|
|
58
|
-
});
|
|
59
|
-
yield Promise.all(assets.map((asset) => __awaiter(this, void 0, void 0, function* () {
|
|
60
|
-
const { source, map } = asset.source.sourceAndMap();
|
|
61
|
-
const sourceAsString = source.toString();
|
|
62
|
-
const code = typeof source === 'string' ? buffer_1.Buffer.from(source) : source;
|
|
63
|
-
const { transform } = (0, utils_1.importLazy)('@parcel/css');
|
|
64
|
-
const result = yield transform(Object.assign({ filename: asset.name, code, minify: true, sourceMap: sourcemap }, this.options));
|
|
65
|
-
const codeString = result.code.toString();
|
|
66
|
-
compilation.updateAsset(asset.name,
|
|
67
|
-
// @ts-ignore
|
|
68
|
-
sourcemap
|
|
69
|
-
? new webpack_sources_1.SourceMapSource(codeString, asset.name, JSON.parse(result.map.toString()), sourceAsString, map, true)
|
|
70
|
-
: new webpack_sources_1.RawSource(codeString), Object.assign(Object.assign({}, asset.info), { minimized: true }));
|
|
71
|
-
})));
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
exports.ParcelCSSMinifyPlugin = ParcelCSSMinifyPlugin;
|