@shuvi/toolpack 1.0.55 → 1.0.56
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/lib/babel/plugins/auto-css-modules.d.ts +1 -1
- package/lib/babel/plugins/auto-css-modules.js +1 -1
- package/lib/babel/plugins/dynamic-plugin.js +1 -1
- package/lib/babel/plugins/jsx-pragma.js +1 -1
- package/lib/babel/plugins/optimize-hook-destructuring.js +1 -1
- package/lib/babel/preset.d.ts +2 -2
- package/lib/utils/bundleRequire.d.ts +3 -3
- package/lib/utils/bundleRequire.js +5 -5
- package/lib/webpack/config/base.d.ts +1 -1
- package/lib/webpack/config/base.js +3 -3
- package/lib/webpack/config/browser.js +1 -2
- package/lib/webpack/config/node.js +1 -2
- package/lib/webpack/config/parts/external.js +1 -2
- package/lib/webpack/config/parts/helpers.d.ts +1 -1
- package/lib/webpack/config/parts/helpers.js +3 -3
- package/lib/webpack/config/parts/resolve.js +1 -2
- package/lib/webpack/config/parts/style.js +1 -2
- package/lib/webpack/dynamic-dll/bundler/index.d.ts +2 -2
- package/lib/webpack/dynamic-dll/bundler/index.js +2 -2
- package/lib/webpack/dynamic-dll/bundler/webpack-config.d.ts +1 -1
- package/lib/webpack/dynamic-dll/bundler/webpack-config.js +2 -3
- package/lib/webpack/dynamic-dll/constants.d.ts +1 -1
- package/lib/webpack/dynamic-dll/dep/getCJSExports.js +1 -2
- package/lib/webpack/dynamic-dll/dep/getExposeFromContent.js +1 -2
- package/lib/webpack/dynamic-dll/dep/getModuleExports.js +3 -4
- package/lib/webpack/dynamic-dll/index.d.ts +1 -1
- package/lib/webpack/dynamic-dll/metadata.js +4 -5
- package/lib/webpack/dynamic-dll/moduleCollector.js +1 -2
- package/lib/webpack/dynamic-dll/plugin/dynamic-dll-plugin.d.ts +1 -3
- package/lib/webpack/dynamic-dll/utils.js +6 -6
- package/lib/webpack/index.js +1 -2
- package/lib/webpack/loaders/async-import-loader.d.ts +1 -1
- package/lib/webpack/loaders/lightningcss-loader/index.d.ts +0 -1
- package/lib/webpack/loaders/lightningcss-loader/index.js +2 -2
- package/lib/webpack/loaders/lightningcss-loader/utils.js +14 -15
- package/lib/webpack/loaders/route-component-loader.d.ts +1 -1
- package/lib/webpack/loaders/shuvi-swc-loader/getLoaderSWCOptions.d.ts +13 -13
- package/lib/webpack/loaders/shuvi-swc-loader/getLoaderSWCOptions.js +2 -3
- package/lib/webpack/loaders/shuvi-swc-loader/index.js +1 -1
- package/lib/webpack/plugins/jsconfig-paths-plugin.d.ts +1 -1
- package/lib/webpack/plugins/jsconfig-paths-plugin.js +8 -9
- package/lib/webpack/plugins/module-replace-plugin/plugin.d.ts +1 -1
- package/lib/webpack/plugins/module-replace-plugin/plugin.js +3 -3
- package/lib/webpack/types.d.ts +2 -2
- package/lib/webpack/webpack.d.ts +1 -1
- package/package.json +5 -5
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// Based on https://github.com/umijs/umi/blob/83301f25a420daff69ca51a179134c6b1612f5b6/packages/babel-plugin-auto-css-modules/src/index.ts
|
|
3
3
|
// License: https://github.com/umijs/umi/blob/83301f25a420daff69ca51a179134c6b1612f5b6/LICENSE
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.default = default_1;
|
|
5
6
|
const path_1 = require("path");
|
|
6
7
|
const CSS_EXTNAMES = ['.css', '.less', '.sass', '.scss'];
|
|
7
8
|
function default_1() {
|
|
@@ -21,4 +22,3 @@ function default_1() {
|
|
|
21
22
|
},
|
|
22
23
|
};
|
|
23
24
|
}
|
|
24
|
-
exports.default = default_1;
|
|
@@ -23,6 +23,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWAR
|
|
|
23
23
|
// This file is https://github.com/jamiebuilds/react-loadable/blob/master/src/babel.js
|
|
24
24
|
// Modified to also look for `shuvi/dynamic`
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.default = default_1;
|
|
26
27
|
function default_1({ types: t }) {
|
|
27
28
|
return {
|
|
28
29
|
visitor: {
|
|
@@ -102,4 +103,3 @@ function default_1({ types: t }) {
|
|
|
102
103
|
}
|
|
103
104
|
};
|
|
104
105
|
}
|
|
105
|
-
exports.default = default_1;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = default_1;
|
|
3
4
|
function default_1({ types: t, }) {
|
|
4
5
|
return {
|
|
5
6
|
inherits: require('babel-plugin-syntax-jsx'),
|
|
@@ -74,4 +75,3 @@ function default_1({ types: t, }) {
|
|
|
74
75
|
},
|
|
75
76
|
};
|
|
76
77
|
}
|
|
77
|
-
exports.default = default_1;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// Based on https://github.com/zeit/next.js
|
|
3
3
|
// License: https://github.com/zeit/next.js/blob/977bf8d9ebd2845241b8689317f36e4e487f39d0/license.md
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.default = default_1;
|
|
5
6
|
// matches any hook-like (the default)
|
|
6
7
|
const isHook = /^use[A-Z]/;
|
|
7
8
|
// matches only built-in hooks provided by React et al
|
|
@@ -56,4 +57,3 @@ function default_1({ types: t }) {
|
|
|
56
57
|
}
|
|
57
58
|
};
|
|
58
59
|
}
|
|
59
|
-
exports.default = default_1;
|
package/lib/babel/preset.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { PluginItem } from '@babel/core';
|
|
2
|
-
export
|
|
2
|
+
export type PresetOptions = {
|
|
3
3
|
'preset-env'?: any;
|
|
4
4
|
'preset-react'?: any;
|
|
5
5
|
'transform-runtime'?: any;
|
|
6
6
|
};
|
|
7
|
-
|
|
7
|
+
type BabelPreset = {
|
|
8
8
|
presets?: PluginItem[] | null;
|
|
9
9
|
plugins?: PluginItem[] | null;
|
|
10
10
|
sourceType?: 'script' | 'module' | 'unambiguous';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BuildOptions, Plugin as EsbuildPlugin } from 'esbuild';
|
|
2
2
|
export declare const PATH_SEG_RE: RegExp;
|
|
3
3
|
export declare const JS_EXT_RE: RegExp;
|
|
4
|
-
export
|
|
4
|
+
export type GetOutputFile = (filepath: string) => string;
|
|
5
5
|
export interface Options {
|
|
6
6
|
cwd?: string;
|
|
7
7
|
/**
|
|
@@ -26,8 +26,8 @@ export declare const match: (id: string, patterns?: (string | RegExp)[]) => bool
|
|
|
26
26
|
* An esbuild plugin to mark node_modules as external
|
|
27
27
|
*/
|
|
28
28
|
export declare const externalPlugin: ({ external, notExternal }?: {
|
|
29
|
-
external?: (string | RegExp)[]
|
|
30
|
-
notExternal?: (string | RegExp)[]
|
|
29
|
+
external?: (string | RegExp)[];
|
|
30
|
+
notExternal?: (string | RegExp)[];
|
|
31
31
|
}) => EsbuildPlugin;
|
|
32
32
|
export declare const replaceDirnamePlugin: () => EsbuildPlugin;
|
|
33
33
|
export declare function bundleRequire(filepath: string, options?: Options): Promise<any>;
|
|
@@ -33,7 +33,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
33
33
|
});
|
|
34
34
|
};
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.
|
|
36
|
+
exports.replaceDirnamePlugin = exports.externalPlugin = exports.match = exports.JS_EXT_RE = exports.PATH_SEG_RE = void 0;
|
|
37
|
+
exports.bundleRequire = bundleRequire;
|
|
37
38
|
const fs_1 = require("fs");
|
|
38
39
|
const path = __importStar(require("path"));
|
|
39
40
|
const esbuild_1 = require("esbuild");
|
|
@@ -107,9 +108,9 @@ const replaceDirnamePlugin = () => {
|
|
|
107
108
|
};
|
|
108
109
|
};
|
|
109
110
|
exports.replaceDirnamePlugin = replaceDirnamePlugin;
|
|
110
|
-
function bundleRequire(
|
|
111
|
-
|
|
112
|
-
|
|
111
|
+
function bundleRequire(filepath_1) {
|
|
112
|
+
return __awaiter(this, arguments, void 0, function* (filepath, options = {}) {
|
|
113
|
+
var _a, _b;
|
|
113
114
|
if (!exports.JS_EXT_RE.test(filepath)) {
|
|
114
115
|
throw new Error(`${filepath} is not a valid JS file`);
|
|
115
116
|
}
|
|
@@ -140,4 +141,3 @@ function bundleRequire(filepath, options = {}) {
|
|
|
140
141
|
return extractResult(result);
|
|
141
142
|
});
|
|
142
143
|
}
|
|
143
|
-
exports.bundleRequire = bundleRequire;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import WebpackChain from 'webpack-chain';
|
|
2
2
|
import { CompilerOptions } from '../loaders/shuvi-swc-loader';
|
|
3
|
-
|
|
3
|
+
type TsCompilerOptions = import('typescript').CompilerOptions;
|
|
4
4
|
export interface BaseOptions {
|
|
5
5
|
dev: boolean;
|
|
6
6
|
name: string;
|
|
@@ -26,7 +26,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.
|
|
29
|
+
exports.WebpackChain = void 0;
|
|
30
|
+
exports.getDefineEnv = getDefineEnv;
|
|
31
|
+
exports.baseWebpackChain = baseWebpackChain;
|
|
30
32
|
const webpack_chain_1 = __importDefault(require("webpack-chain"));
|
|
31
33
|
exports.WebpackChain = webpack_chain_1.default;
|
|
32
34
|
const webpack_bundle_analyzer_1 = require("webpack-bundle-analyzer");
|
|
@@ -71,7 +73,6 @@ function getDefineEnv(env) {
|
|
|
71
73
|
return Object.assign(Object.assign({}, acc), { [`process.env.${key}`]: JSON.stringify(env[key]) });
|
|
72
74
|
}, {}));
|
|
73
75
|
}
|
|
74
|
-
exports.getDefineEnv = getDefineEnv;
|
|
75
76
|
/** remove 'shuvi/' of the target name */
|
|
76
77
|
const getSimplifiedTargetName = (targetName) => targetName.replace(/^shuvi\//, '');
|
|
77
78
|
function baseWebpackChain({ dev, outputDir, lightningCss, compiler, projectRoot, include, jsConfig, name, publicPath = '/', env = {}, cacheDir, analyze }) {
|
|
@@ -268,7 +269,6 @@ function baseWebpackChain({ dev, outputDir, lightningCss, compiler, projectRoot,
|
|
|
268
269
|
}
|
|
269
270
|
return config;
|
|
270
271
|
}
|
|
271
|
-
exports.baseWebpackChain = baseWebpackChain;
|
|
272
272
|
function isValidBase64DataURL(input) {
|
|
273
273
|
// Check if input starts with the data URI scheme
|
|
274
274
|
if (!input.startsWith('data:')) {
|
|
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.createBrowserWebpackChain =
|
|
29
|
+
exports.createBrowserWebpackChain = createBrowserWebpackChain;
|
|
30
30
|
const crypto = __importStar(require("crypto"));
|
|
31
31
|
const webpack_1 = __importDefault(require("webpack"));
|
|
32
32
|
const path = __importStar(require("path"));
|
|
@@ -212,4 +212,3 @@ function createBrowserWebpackChain(options) {
|
|
|
212
212
|
chunkFilename: 'static/css/[contenthash:8].chunk.css'
|
|
213
213
|
});
|
|
214
214
|
}
|
|
215
|
-
exports.createBrowserWebpackChain = createBrowserWebpackChain;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createNodeWebpackChain =
|
|
3
|
+
exports.createNodeWebpackChain = createNodeWebpackChain;
|
|
4
4
|
const base_1 = require("./base");
|
|
5
5
|
const external_1 = require("./parts/external");
|
|
6
6
|
const style_1 = require("./parts/style");
|
|
@@ -45,4 +45,3 @@ function createNodeWebpackChain(options) {
|
|
|
45
45
|
chunkFilename: 'static/css/[contenthash:8].chunk.css'
|
|
46
46
|
});
|
|
47
47
|
}
|
|
48
|
-
exports.createNodeWebpackChain = createNodeWebpackChain;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.nodeExternals =
|
|
3
|
+
exports.nodeExternals = nodeExternals;
|
|
4
4
|
function match(value, tests) {
|
|
5
5
|
let matched = false;
|
|
6
6
|
for (let index = 0; index < tests.length; index++) {
|
|
@@ -85,4 +85,3 @@ function nodeExternals({ projectRoot, include }) {
|
|
|
85
85
|
};
|
|
86
86
|
return nodeExternal;
|
|
87
87
|
}
|
|
88
|
-
exports.nodeExternals = nodeExternals;
|
|
@@ -2,7 +2,7 @@ import { WebpackChain } from '../base';
|
|
|
2
2
|
import { ExternalsFunction } from '../../types';
|
|
3
3
|
export declare const checkWebpackExternals: (webpackChain: WebpackChain) => void;
|
|
4
4
|
export declare const addExternals: (webpackChain: WebpackChain, externalFn: ExternalsFunction) => void;
|
|
5
|
-
export declare function shouldUseRelativeAssetPaths(publicPath: string):
|
|
5
|
+
export declare function shouldUseRelativeAssetPaths(publicPath: string): publicPath is "./";
|
|
6
6
|
export declare function splitChunksFilter(chunk: any): boolean;
|
|
7
7
|
export declare const commonChunkFilename: ({ dev }: {
|
|
8
8
|
dev: boolean;
|
|
@@ -3,7 +3,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getDefaultSplitChunksConfig = exports.defaultCacheGroups = exports.NODE_MODULES_REGEXP = exports.commonChunkFilename = exports.
|
|
6
|
+
exports.getDefaultSplitChunksConfig = exports.defaultCacheGroups = exports.NODE_MODULES_REGEXP = exports.commonChunkFilename = exports.addExternals = exports.checkWebpackExternals = void 0;
|
|
7
|
+
exports.shouldUseRelativeAssetPaths = shouldUseRelativeAssetPaths;
|
|
8
|
+
exports.splitChunksFilter = splitChunksFilter;
|
|
7
9
|
const invariant_1 = __importDefault(require("@shuvi/utils/invariant"));
|
|
8
10
|
const externalsFunctionMap = new WeakMap();
|
|
9
11
|
const checkWebpackExternals = (webpackChain) => {
|
|
@@ -62,14 +64,12 @@ exports.addExternals = addExternals;
|
|
|
62
64
|
function shouldUseRelativeAssetPaths(publicPath) {
|
|
63
65
|
return publicPath === './';
|
|
64
66
|
}
|
|
65
|
-
exports.shouldUseRelativeAssetPaths = shouldUseRelativeAssetPaths;
|
|
66
67
|
function splitChunksFilter(chunk) {
|
|
67
68
|
const excludes = {
|
|
68
69
|
// 'static/polyfill': true
|
|
69
70
|
};
|
|
70
71
|
return excludes[chunk.name] !== true;
|
|
71
72
|
}
|
|
72
|
-
exports.splitChunksFilter = splitChunksFilter;
|
|
73
73
|
const commonChunkFilename = ({ dev }) => {
|
|
74
74
|
return `static/common/${dev ? '[name]' : '[name].[contenthash:8]'}.js`;
|
|
75
75
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.resolvePreferTarget =
|
|
3
|
+
exports.resolvePreferTarget = resolvePreferTarget;
|
|
4
4
|
function resolvePreferTarget(target, extensions) {
|
|
5
5
|
return extensions.reduce((res, ext) => {
|
|
6
6
|
res.push(`.${target}${ext}`);
|
|
@@ -8,4 +8,3 @@ function resolvePreferTarget(target, extensions) {
|
|
|
8
8
|
return res;
|
|
9
9
|
}, []);
|
|
10
10
|
}
|
|
11
|
-
exports.resolvePreferTarget = resolvePreferTarget;
|
|
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.withStyle =
|
|
29
|
+
exports.withStyle = withStyle;
|
|
30
30
|
const constants_1 = require("@shuvi/shared/constants");
|
|
31
31
|
const Rule_1 = __importDefault(require("webpack-chain/src/Rule"));
|
|
32
32
|
const mini_css_extract_plugin_1 = __importDefault(require("mini-css-extract-plugin"));
|
|
@@ -288,4 +288,3 @@ function withStyle(chain, { extractCss, sourceMap, ssr, publicPath, lightningCss
|
|
|
288
288
|
}).after('scss-module'));
|
|
289
289
|
return chain;
|
|
290
290
|
}
|
|
291
|
-
exports.withStyle = withStyle;
|
|
@@ -9,8 +9,8 @@ export interface BuildOptions {
|
|
|
9
9
|
esmFullSpecific?: Boolean;
|
|
10
10
|
force?: boolean;
|
|
11
11
|
}
|
|
12
|
-
export
|
|
13
|
-
|
|
12
|
+
export type ShareConfig = Record<string, any>;
|
|
13
|
+
type OnBuildComplete = (error?: null | Error) => void;
|
|
14
14
|
export declare class Bundler {
|
|
15
15
|
private _nextBuild;
|
|
16
16
|
private _completeFns;
|
|
@@ -55,8 +55,8 @@ function getWebpackConfig({ deps, entry, outputDir, shared, externals, esmFullSp
|
|
|
55
55
|
});
|
|
56
56
|
return chain.toConfig();
|
|
57
57
|
}
|
|
58
|
-
function buildDeps(
|
|
59
|
-
return __awaiter(this,
|
|
58
|
+
function buildDeps(_a) {
|
|
59
|
+
return __awaiter(this, arguments, void 0, function* ({ deps, dir }) {
|
|
60
60
|
(0, fs_extra_1.mkdirpSync)(dir);
|
|
61
61
|
// expose files
|
|
62
62
|
yield Promise.all(deps.map((dep) => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getConfig =
|
|
6
|
+
exports.getConfig = getConfig;
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
8
|
const webpack_1 = __importDefault(require("webpack"));
|
|
9
9
|
const webpack_chain_1 = __importDefault(require("webpack-chain"));
|
|
@@ -71,7 +71,7 @@ function getConfig({ name, entry, filename, outputDir, publicPath, shared, exter
|
|
|
71
71
|
.use('esbuild-loader')
|
|
72
72
|
.loader(require.resolve('esbuild-loader'))
|
|
73
73
|
.options({
|
|
74
|
-
loader: 'jsx',
|
|
74
|
+
loader: 'jsx', // Remove this if you're not using JSX
|
|
75
75
|
target: 'es2015' // Syntax to compile to (see options below for possible values)
|
|
76
76
|
});
|
|
77
77
|
const DLL_VERSION = require('../../../../package.json').version;
|
|
@@ -113,4 +113,3 @@ function getConfig({ name, entry, filename, outputDir, publicPath, shared, exter
|
|
|
113
113
|
config.externals(externals);
|
|
114
114
|
return config;
|
|
115
115
|
}
|
|
116
|
-
exports.getConfig = getConfig;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export declare const NAME = "dll";
|
|
2
2
|
export declare const MF_VA_PREFIX = "vf_";
|
|
3
|
-
export declare const DEFAULT_PUBLIC_PATH
|
|
3
|
+
export declare const DEFAULT_PUBLIC_PATH = "/__dll/";
|
|
4
4
|
export declare const DLL_FILENAME = "dll.js";
|
|
5
5
|
export declare const METADATA_FILENAME = "_metadata.json";
|
|
6
6
|
export declare const UPDATE_FILENAME = "_update.json";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getCJSExports =
|
|
3
|
+
exports.getCJSExports = getCJSExports;
|
|
4
4
|
function getCJSExports({ content }) {
|
|
5
5
|
return matchAll(/Object\.defineProperty\(\s*exports\s*\,\s*[\"|\'](\w+)[\"|\']/g, content)
|
|
6
6
|
.concat(
|
|
@@ -47,7 +47,6 @@ function getCJSExports({ content }) {
|
|
|
47
47
|
}))
|
|
48
48
|
.map(result => result[1]);
|
|
49
49
|
}
|
|
50
|
-
exports.getCJSExports = getCJSExports;
|
|
51
50
|
function matchAll(regexp, str) {
|
|
52
51
|
const result = [];
|
|
53
52
|
let match;
|
|
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.getExposeFromContent =
|
|
15
|
+
exports.getExposeFromContent = getExposeFromContent;
|
|
16
16
|
const assert_1 = __importDefault(require("assert"));
|
|
17
17
|
const fs_extra_1 = require("fs-extra");
|
|
18
18
|
const path_1 = require("path");
|
|
@@ -73,7 +73,6 @@ export default _;`.trim();
|
|
|
73
73
|
}
|
|
74
74
|
});
|
|
75
75
|
}
|
|
76
|
-
exports.getExposeFromContent = getExposeFromContent;
|
|
77
76
|
function hasNonDefaultExports(exports) {
|
|
78
77
|
return (exports.filter((exp) => !['__esModule', 'default'].includes(exp))
|
|
79
78
|
.length > 0);
|
|
@@ -9,14 +9,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.getModuleExports =
|
|
12
|
+
exports.getModuleExports = getModuleExports;
|
|
13
13
|
// @ts-ignore: es-module-lexer misconfigure its package.exports
|
|
14
14
|
const es_module_lexer_1 = require("es-module-lexer");
|
|
15
15
|
const esbuild_1 = require("esbuild");
|
|
16
16
|
const path_1 = require("path");
|
|
17
17
|
const getCJSExports_1 = require("./getCJSExports");
|
|
18
|
-
function getModuleExports(
|
|
19
|
-
return __awaiter(this,
|
|
18
|
+
function getModuleExports(_a) {
|
|
19
|
+
return __awaiter(this, arguments, void 0, function* ({ content, libraryPath }) {
|
|
20
20
|
// Support tsx and jsx
|
|
21
21
|
if (/\.(tsx|jsx)$/.test(libraryPath)) {
|
|
22
22
|
content = (yield (0, esbuild_1.transform)(content, {
|
|
@@ -43,4 +43,3 @@ function getModuleExports({ content, libraryPath }) {
|
|
|
43
43
|
};
|
|
44
44
|
});
|
|
45
45
|
}
|
|
46
|
-
exports.getModuleExports = getModuleExports;
|
|
@@ -3,7 +3,7 @@ import type * as webpackType from 'webpack';
|
|
|
3
3
|
import type { Configuration } from 'webpack';
|
|
4
4
|
import type WebpackChain from 'webpack-chain';
|
|
5
5
|
import { ShareConfig } from './bundler';
|
|
6
|
-
|
|
6
|
+
type IResolveWebpackModule = <T extends string>(path: T) => T extends `webpack` ? typeof webpackType : T extends `webpack/${infer R}` ? any : never;
|
|
7
7
|
interface IOpts {
|
|
8
8
|
cwd?: string;
|
|
9
9
|
rootDir: string;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.getMetadata = getMetadata;
|
|
4
|
+
exports.writeMetadata = writeMetadata;
|
|
5
|
+
exports.getUpdate = getUpdate;
|
|
6
|
+
exports.writeUpdate = writeUpdate;
|
|
4
7
|
const path_1 = require("path");
|
|
5
8
|
const fs_extra_1 = require("fs-extra");
|
|
6
9
|
const constants_1 = require("./constants");
|
|
@@ -31,14 +34,12 @@ function getMetadata(root) {
|
|
|
31
34
|
}
|
|
32
35
|
return (0, fs_extra_1.readJSONSync)(file);
|
|
33
36
|
}
|
|
34
|
-
exports.getMetadata = getMetadata;
|
|
35
37
|
function writeMetadata(root, content) {
|
|
36
38
|
(0, fs_extra_1.writeJSONSync)((0, path_1.join)(root, constants_1.METADATA_FILENAME), content, {
|
|
37
39
|
spaces: 2
|
|
38
40
|
});
|
|
39
41
|
lastMetadata = content;
|
|
40
42
|
}
|
|
41
|
-
exports.writeMetadata = writeMetadata;
|
|
42
43
|
function getUpdate(root) {
|
|
43
44
|
const file = (0, path_1.join)((0, utils_1.getDllDir)(root), constants_1.UPDATE_FILENAME);
|
|
44
45
|
if (!(0, fs_extra_1.existsSync)(file)) {
|
|
@@ -48,7 +49,6 @@ function getUpdate(root) {
|
|
|
48
49
|
}
|
|
49
50
|
return (0, fs_extra_1.readJSONSync)(file);
|
|
50
51
|
}
|
|
51
|
-
exports.getUpdate = getUpdate;
|
|
52
52
|
function writeUpdate(root, updateModules) {
|
|
53
53
|
if (!lastMetadata) {
|
|
54
54
|
return;
|
|
@@ -59,4 +59,3 @@ function writeUpdate(root, updateModules) {
|
|
|
59
59
|
spaces: 2
|
|
60
60
|
});
|
|
61
61
|
}
|
|
62
|
-
exports.writeUpdate = writeUpdate;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getModuleCollector =
|
|
3
|
+
exports.getModuleCollector = getModuleCollector;
|
|
4
4
|
const NODE_MODULES = /node_modules/;
|
|
5
5
|
class ModuleCollector {
|
|
6
6
|
constructor(options) {
|
|
@@ -61,4 +61,3 @@ function getModuleCollector(options) {
|
|
|
61
61
|
exclude: options.exclude
|
|
62
62
|
});
|
|
63
63
|
}
|
|
64
|
-
exports.getModuleCollector = getModuleCollector;
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/// <reference types="webpack-env" />
|
|
3
1
|
import type { Compiler } from 'webpack';
|
|
4
2
|
import { ModuleCollectorOptions, ModuleSnapshot } from '../moduleCollector';
|
|
5
|
-
export
|
|
3
|
+
export type SnapshotListener = (snapshot: ModuleSnapshot) => void;
|
|
6
4
|
export interface DynamicDLLPluginOptions {
|
|
7
5
|
resolveWebpackModule: (s: string) => ReturnType<typeof require>;
|
|
8
6
|
dllName: string;
|
|
@@ -3,27 +3,27 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.version = void 0;
|
|
7
|
+
exports.isString = isString;
|
|
8
|
+
exports.isArray = isArray;
|
|
9
|
+
exports.getDepsDir = getDepsDir;
|
|
10
|
+
exports.getDllDir = getDllDir;
|
|
11
|
+
exports.getDllPendingDir = getDllPendingDir;
|
|
7
12
|
const path_1 = __importDefault(require("path"));
|
|
8
13
|
const pkg = require(path_1.default.resolve(__dirname, '../../..', 'package.json'));
|
|
9
14
|
exports.version = pkg.version;
|
|
10
15
|
function isString(val) {
|
|
11
16
|
return typeof val === 'string';
|
|
12
17
|
}
|
|
13
|
-
exports.isString = isString;
|
|
14
18
|
function isArray(val) {
|
|
15
19
|
return Array.isArray(val);
|
|
16
20
|
}
|
|
17
|
-
exports.isArray = isArray;
|
|
18
21
|
function getDepsDir(dir) {
|
|
19
22
|
return path_1.default.join(dir, 'deps');
|
|
20
23
|
}
|
|
21
|
-
exports.getDepsDir = getDepsDir;
|
|
22
24
|
function getDllDir(dir) {
|
|
23
25
|
return path_1.default.join(dir, 'current');
|
|
24
26
|
}
|
|
25
|
-
exports.getDllDir = getDllDir;
|
|
26
27
|
function getDllPendingDir(dir) {
|
|
27
28
|
return path_1.default.join(dir, 'pending');
|
|
28
29
|
}
|
|
29
|
-
exports.getDllPendingDir = getDllPendingDir;
|
package/lib/webpack/index.js
CHANGED
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.resolveWebpackModule =
|
|
17
|
+
exports.resolveWebpackModule = resolveWebpackModule;
|
|
18
18
|
const path_1 = require("path");
|
|
19
19
|
const webpackResolveContext = (0, path_1.join)((0, path_1.dirname)(require.resolve('webpack/package.json')), '../');
|
|
20
20
|
__exportStar(require("./webpack"), exports);
|
|
@@ -27,4 +27,3 @@ function resolveWebpackModule(path) {
|
|
|
27
27
|
}
|
|
28
28
|
return require(`${webpackResolveContext}/${path}`);
|
|
29
29
|
}
|
|
30
|
-
exports.resolveWebpackModule = resolveWebpackModule;
|
|
@@ -36,6 +36,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
36
36
|
};
|
|
37
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
38
|
exports.raw = void 0;
|
|
39
|
+
exports.default = loader;
|
|
39
40
|
const path = __importStar(require("path"));
|
|
40
41
|
const browserslist_1 = __importDefault(require("browserslist"));
|
|
41
42
|
const lightningcss_1 = require("lightningcss");
|
|
@@ -176,7 +177,7 @@ function loader(content, map) {
|
|
|
176
177
|
}
|
|
177
178
|
lightningApis.push({
|
|
178
179
|
importName,
|
|
179
|
-
layer: undefined,
|
|
180
|
+
layer: undefined, // not support
|
|
180
181
|
supports,
|
|
181
182
|
media,
|
|
182
183
|
index
|
|
@@ -366,6 +367,5 @@ function loader(content, map) {
|
|
|
366
367
|
}
|
|
367
368
|
});
|
|
368
369
|
}
|
|
369
|
-
exports.default = loader;
|
|
370
370
|
// accept Buffers instead of strings
|
|
371
371
|
exports.raw = true;
|
|
@@ -12,7 +12,20 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.
|
|
15
|
+
exports.normalizeOptions = normalizeOptions;
|
|
16
|
+
exports.getCssModuleOptions = getCssModuleOptions;
|
|
17
|
+
exports.normalizeUrl = normalizeUrl;
|
|
18
|
+
exports.requestify = requestify;
|
|
19
|
+
exports.normalizeSourceMap = normalizeSourceMap;
|
|
20
|
+
exports.getPreRequester = getPreRequester;
|
|
21
|
+
exports.getImportCode = getImportCode;
|
|
22
|
+
exports.getLightningCssModuleCode = getLightningCssModuleCode;
|
|
23
|
+
exports.getExportCode = getExportCode;
|
|
24
|
+
exports.resolveRequests = resolveRequests;
|
|
25
|
+
exports.isURLRequestable = isURLRequestable;
|
|
26
|
+
exports.combineRequests = combineRequests;
|
|
27
|
+
exports.stringifyRequest = stringifyRequest;
|
|
28
|
+
exports.isDataUrl = isDataUrl;
|
|
16
29
|
/*
|
|
17
30
|
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
18
31
|
Author Tobias Koppers @sokra
|
|
@@ -57,7 +70,6 @@ function stringifyRequest(loaderContext, request) {
|
|
|
57
70
|
})
|
|
58
71
|
.join('!'));
|
|
59
72
|
}
|
|
60
|
-
exports.stringifyRequest = stringifyRequest;
|
|
61
73
|
// We can't use path.win32.isAbsolute because it also matches paths starting with a forward slash
|
|
62
74
|
const IS_NATIVE_WIN32_PATH = /^[a-z]:[/\\]|^\\\\/i;
|
|
63
75
|
const IS_MODULE_REQUEST = /^[^?]*~/;
|
|
@@ -352,7 +364,6 @@ function isDataUrl(url) {
|
|
|
352
364
|
}
|
|
353
365
|
return false;
|
|
354
366
|
}
|
|
355
|
-
exports.isDataUrl = isDataUrl;
|
|
356
367
|
const NATIVE_WIN32_PATH = /^[A-Z]:[/\\]|^\\\\/i;
|
|
357
368
|
function normalizeUrl(url, isStringValue) {
|
|
358
369
|
let normalizedUrl = url
|
|
@@ -383,7 +394,6 @@ function normalizeUrl(url, isStringValue) {
|
|
|
383
394
|
}
|
|
384
395
|
return normalizedUrl;
|
|
385
396
|
}
|
|
386
|
-
exports.normalizeUrl = normalizeUrl;
|
|
387
397
|
function requestify(url, rootContext, needToResolveURL = true) {
|
|
388
398
|
if (needToResolveURL) {
|
|
389
399
|
if (/^file:/i.test(url)) {
|
|
@@ -402,7 +412,6 @@ function requestify(url, rootContext, needToResolveURL = true) {
|
|
|
402
412
|
}
|
|
403
413
|
return url;
|
|
404
414
|
}
|
|
405
|
-
exports.requestify = requestify;
|
|
406
415
|
function getValidLocalName(localName, exportLocalsConvention) {
|
|
407
416
|
const result = exportLocalsConvention(localName);
|
|
408
417
|
return Array.isArray(result) ? result[0] : result;
|
|
@@ -534,7 +543,6 @@ function normalizeOptions(rawOptions, loaderContext) {
|
|
|
534
543
|
exportType
|
|
535
544
|
};
|
|
536
545
|
}
|
|
537
|
-
exports.normalizeOptions = normalizeOptions;
|
|
538
546
|
function getCssModuleOptions(options) {
|
|
539
547
|
if (typeof options.modules === 'object') {
|
|
540
548
|
const modules = options.modules;
|
|
@@ -547,7 +555,6 @@ function getCssModuleOptions(options) {
|
|
|
547
555
|
}
|
|
548
556
|
return Boolean(options.modules);
|
|
549
557
|
}
|
|
550
|
-
exports.getCssModuleOptions = getCssModuleOptions;
|
|
551
558
|
const ABSOLUTE_SCHEME = /^[a-z0-9+\-.]+:/i;
|
|
552
559
|
function getURLType(source) {
|
|
553
560
|
if (source[0] === '/') {
|
|
@@ -592,7 +599,6 @@ function normalizeSourceMap(map, resourcePath) {
|
|
|
592
599
|
}
|
|
593
600
|
return newMap;
|
|
594
601
|
}
|
|
595
|
-
exports.normalizeSourceMap = normalizeSourceMap;
|
|
596
602
|
function getPreRequester({ loaders, loaderIndex }) {
|
|
597
603
|
const cache = Object.create(null);
|
|
598
604
|
return number => {
|
|
@@ -612,7 +618,6 @@ function getPreRequester({ loaders, loaderIndex }) {
|
|
|
612
618
|
return cache[number];
|
|
613
619
|
};
|
|
614
620
|
}
|
|
615
|
-
exports.getPreRequester = getPreRequester;
|
|
616
621
|
function getImportCode(imports, options) {
|
|
617
622
|
let code = '';
|
|
618
623
|
for (const item of imports) {
|
|
@@ -634,7 +639,6 @@ function getImportCode(imports, options) {
|
|
|
634
639
|
}
|
|
635
640
|
return code ? `// Imports\n${code}` : '';
|
|
636
641
|
}
|
|
637
|
-
exports.getImportCode = getImportCode;
|
|
638
642
|
function normalizeLightningCssSourceMapForRuntime(map, loaderContext) {
|
|
639
643
|
let resultMap = null;
|
|
640
644
|
if (map instanceof Buffer) {
|
|
@@ -741,7 +745,6 @@ function getLightningCssModuleCode(result, api, replacements, options, loaderCon
|
|
|
741
745
|
// 5 - layer
|
|
742
746
|
return `${beforeCode}// Module\n___CSS_LOADER_EXPORT___.push([module.id, ${code}, ""${sourceMapValue}]);\n`;
|
|
743
747
|
}
|
|
744
|
-
exports.getLightningCssModuleCode = getLightningCssModuleCode;
|
|
745
748
|
function dashesCamelCase(str) {
|
|
746
749
|
return str.replace(/-+(\w)/g, (match, firstLetter) => firstLetter.toUpperCase());
|
|
747
750
|
}
|
|
@@ -821,7 +824,6 @@ function getExportCode(exports, replacements, icssPluginUsed, options) {
|
|
|
821
824
|
code += `${options.esModule ? 'export default' : 'module.exports ='} ${finalExport};\n`;
|
|
822
825
|
return code;
|
|
823
826
|
}
|
|
824
|
-
exports.getExportCode = getExportCode;
|
|
825
827
|
function resolveRequests(resolve, context, possibleRequests) {
|
|
826
828
|
return __awaiter(this, void 0, void 0, function* () {
|
|
827
829
|
return resolve(context, possibleRequests[0])
|
|
@@ -835,7 +837,6 @@ function resolveRequests(resolve, context, possibleRequests) {
|
|
|
835
837
|
});
|
|
836
838
|
});
|
|
837
839
|
}
|
|
838
|
-
exports.resolveRequests = resolveRequests;
|
|
839
840
|
function isURLRequestable(url, options = {}) {
|
|
840
841
|
// Protocol-relative URLs
|
|
841
842
|
if (/^\/\//.test(url)) {
|
|
@@ -868,11 +869,9 @@ function isURLRequestable(url, options = {}) {
|
|
|
868
869
|
}
|
|
869
870
|
return { requestable: true, needResolve: true };
|
|
870
871
|
}
|
|
871
|
-
exports.isURLRequestable = isURLRequestable;
|
|
872
872
|
function combineRequests(preRequest, url) {
|
|
873
873
|
const idx = url.indexOf('!=!');
|
|
874
874
|
return idx !== -1
|
|
875
875
|
? url.slice(0, idx + 3) + preRequest + url.slice(idx + 3)
|
|
876
876
|
: preRequest + url;
|
|
877
877
|
}
|
|
878
|
-
exports.combineRequests = combineRequests;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
type Obj = Record<string, any>;
|
|
2
2
|
export interface CompilerOptions {
|
|
3
3
|
removeConsole?: boolean;
|
|
4
4
|
useDefineForClassFields?: boolean;
|
|
@@ -34,7 +34,7 @@ export interface CompilerOptions {
|
|
|
34
34
|
}>;
|
|
35
35
|
swcPlugins?: [name: string, option: any][];
|
|
36
36
|
}
|
|
37
|
-
export
|
|
37
|
+
export type SWCLoaderOptions = {
|
|
38
38
|
filename: string;
|
|
39
39
|
isServer: boolean;
|
|
40
40
|
isPageFile: boolean;
|
|
@@ -110,20 +110,20 @@ export default function getLoaderSWCOptions({ filename, development, isServer, m
|
|
|
110
110
|
reactRemoveProperties: boolean | undefined;
|
|
111
111
|
modularizeImports: Record<string, {
|
|
112
112
|
transform: string;
|
|
113
|
-
preventFullImport?: boolean
|
|
114
|
-
skipDefaultConversion?: boolean
|
|
113
|
+
preventFullImport?: boolean;
|
|
114
|
+
skipDefaultConversion?: boolean;
|
|
115
115
|
}> | undefined;
|
|
116
116
|
styledComponents: {
|
|
117
117
|
displayName: boolean;
|
|
118
|
-
topLevelImportPaths?: string[]
|
|
119
|
-
ssr?: boolean
|
|
120
|
-
fileName?: boolean
|
|
121
|
-
meaninglessFileNames?: string[]
|
|
122
|
-
minify?: boolean
|
|
123
|
-
transpileTemplateLiterals?: boolean
|
|
124
|
-
namespace?: string
|
|
125
|
-
pure?: boolean
|
|
126
|
-
cssProp?: boolean
|
|
118
|
+
topLevelImportPaths?: string[];
|
|
119
|
+
ssr?: boolean;
|
|
120
|
+
fileName?: boolean;
|
|
121
|
+
meaninglessFileNames?: string[];
|
|
122
|
+
minify?: boolean;
|
|
123
|
+
transpileTemplateLiterals?: boolean;
|
|
124
|
+
namespace?: string;
|
|
125
|
+
pure?: boolean;
|
|
126
|
+
cssProp?: boolean;
|
|
127
127
|
} | null;
|
|
128
128
|
emotion: {
|
|
129
129
|
enabled: boolean;
|
|
@@ -11,7 +11,8 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
11
11
|
return t;
|
|
12
12
|
};
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.getParserOptions =
|
|
14
|
+
exports.getParserOptions = getParserOptions;
|
|
15
|
+
exports.default = getLoaderSWCOptions;
|
|
15
16
|
function getParserOptions(_a) {
|
|
16
17
|
var { filename, compiler } = _a, rest = __rest(_a, ["filename", "compiler"]);
|
|
17
18
|
const isTSFile = filename.endsWith('.ts');
|
|
@@ -21,7 +22,6 @@ function getParserOptions(_a) {
|
|
|
21
22
|
// Exclude regular TypeScript files from React transformation to prevent e.g. generic parameters and angle-bracket type assertion from being interpreted as JSX tags.
|
|
22
23
|
[isTypeScript ? 'tsx' : 'jsx']: !isTSFile, importAssertions: true });
|
|
23
24
|
}
|
|
24
|
-
exports.getParserOptions = getParserOptions;
|
|
25
25
|
function getBaseSWCOptions({ filename, isPageFile, pagePickLoader, minify, development, hasReactRefresh, isServer, compiler, swcCacheDir }) {
|
|
26
26
|
var _a, _b;
|
|
27
27
|
const parserConfig = getParserOptions({ filename, compiler });
|
|
@@ -162,4 +162,3 @@ function getLoaderSWCOptions({ filename, development, isServer, minify, isPageFi
|
|
|
162
162
|
}
|
|
163
163
|
return baseOptions;
|
|
164
164
|
}
|
|
165
|
-
exports.default = getLoaderSWCOptions;
|
|
@@ -13,6 +13,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.raw = void 0;
|
|
16
|
+
exports.default = swcLoader;
|
|
16
17
|
const querystring_1 = __importDefault(require("querystring"));
|
|
17
18
|
const constants_1 = require("@shuvi/shared/constants");
|
|
18
19
|
const compiler_1 = require("@shuvi/compiler");
|
|
@@ -79,6 +80,5 @@ function swcLoader(inputSource, inputSourceMap) {
|
|
|
79
80
|
callback && callback(err);
|
|
80
81
|
});
|
|
81
82
|
}
|
|
82
|
-
exports.default = swcLoader;
|
|
83
83
|
// accept Buffers instead of strings
|
|
84
84
|
exports.raw = true;
|
|
@@ -27,7 +27,7 @@ export declare function isString(text: unknown): text is string;
|
|
|
27
27
|
*/
|
|
28
28
|
export declare function matchedText(pattern: Pattern, candidate: string): string;
|
|
29
29
|
export declare function patternText({ prefix, suffix }: Pattern): string;
|
|
30
|
-
|
|
30
|
+
type Paths = {
|
|
31
31
|
[match: string]: string[];
|
|
32
32
|
};
|
|
33
33
|
/**
|
|
@@ -23,7 +23,14 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.
|
|
26
|
+
exports.hasZeroOrOneAsteriskCharacter = hasZeroOrOneAsteriskCharacter;
|
|
27
|
+
exports.pathIsRelative = pathIsRelative;
|
|
28
|
+
exports.tryParsePattern = tryParsePattern;
|
|
29
|
+
exports.findBestPatternMatch = findBestPatternMatch;
|
|
30
|
+
exports.matchPatternOrExact = matchPatternOrExact;
|
|
31
|
+
exports.isString = isString;
|
|
32
|
+
exports.matchedText = matchedText;
|
|
33
|
+
exports.patternText = patternText;
|
|
27
34
|
/**
|
|
28
35
|
* This webpack resolver is largely based on TypeScript's "paths" handling
|
|
29
36
|
* The TypeScript license can be found here:
|
|
@@ -46,14 +53,12 @@ function hasZeroOrOneAsteriskCharacter(str) {
|
|
|
46
53
|
}
|
|
47
54
|
return true;
|
|
48
55
|
}
|
|
49
|
-
exports.hasZeroOrOneAsteriskCharacter = hasZeroOrOneAsteriskCharacter;
|
|
50
56
|
/**
|
|
51
57
|
* Determines whether a path starts with a relative path component (i.e. `.` or `..`).
|
|
52
58
|
*/
|
|
53
59
|
function pathIsRelative(testPath) {
|
|
54
60
|
return /^\.\.?($|[\\/])/.test(testPath);
|
|
55
61
|
}
|
|
56
|
-
exports.pathIsRelative = pathIsRelative;
|
|
57
62
|
function tryParsePattern(pattern) {
|
|
58
63
|
// This should be verified outside of here and a proper error thrown.
|
|
59
64
|
const indexOfStar = pattern.indexOf('*');
|
|
@@ -64,7 +69,6 @@ function tryParsePattern(pattern) {
|
|
|
64
69
|
suffix: pattern.slice(indexOfStar + 1)
|
|
65
70
|
};
|
|
66
71
|
}
|
|
67
|
-
exports.tryParsePattern = tryParsePattern;
|
|
68
72
|
function isPatternMatch({ prefix, suffix }, candidate) {
|
|
69
73
|
return (candidate.length >= prefix.length + suffix.length &&
|
|
70
74
|
candidate.startsWith(prefix) &&
|
|
@@ -85,7 +89,6 @@ function findBestPatternMatch(values, getPattern, candidate) {
|
|
|
85
89
|
}
|
|
86
90
|
return matchedValue;
|
|
87
91
|
}
|
|
88
|
-
exports.findBestPatternMatch = findBestPatternMatch;
|
|
89
92
|
/**
|
|
90
93
|
* patternStrings contains both pattern strings (containing "*") and regular strings.
|
|
91
94
|
* Return an exact match if possible, or a pattern match, or undefined.
|
|
@@ -107,14 +110,12 @@ function matchPatternOrExact(patternStrings, candidate) {
|
|
|
107
110
|
}
|
|
108
111
|
return findBestPatternMatch(patterns, _ => _, candidate);
|
|
109
112
|
}
|
|
110
|
-
exports.matchPatternOrExact = matchPatternOrExact;
|
|
111
113
|
/**
|
|
112
114
|
* Tests whether a value is string
|
|
113
115
|
*/
|
|
114
116
|
function isString(text) {
|
|
115
117
|
return typeof text === 'string';
|
|
116
118
|
}
|
|
117
|
-
exports.isString = isString;
|
|
118
119
|
/**
|
|
119
120
|
* Given that candidate matches pattern, returns the text matching the '*'.
|
|
120
121
|
* E.g.: matchedText(tryParsePattern("foo*baz"), "foobarbaz") === "bar"
|
|
@@ -122,11 +123,9 @@ exports.isString = isString;
|
|
|
122
123
|
function matchedText(pattern, candidate) {
|
|
123
124
|
return candidate.substring(pattern.prefix.length, candidate.length - pattern.suffix.length);
|
|
124
125
|
}
|
|
125
|
-
exports.matchedText = matchedText;
|
|
126
126
|
function patternText({ prefix, suffix }) {
|
|
127
127
|
return `${prefix}*${suffix}`;
|
|
128
128
|
}
|
|
129
|
-
exports.patternText = patternText;
|
|
130
129
|
/**
|
|
131
130
|
* Calls the iterator function for each entry of the array
|
|
132
131
|
* until the first result or error is reached
|
|
@@ -59,9 +59,6 @@ function getKnownModules(id) {
|
|
|
59
59
|
// }
|
|
60
60
|
// }
|
|
61
61
|
class ModuleReplacePlugin {
|
|
62
|
-
constructor(options) {
|
|
63
|
-
this._options = Object.assign({ modules: [] }, options);
|
|
64
|
-
}
|
|
65
62
|
static restoreModule(id) {
|
|
66
63
|
const moduleInfos = getKnownModules(id).filter(m => m.action === ModuleAction.REPLACE);
|
|
67
64
|
if (moduleInfos.length < 1) {
|
|
@@ -89,6 +86,9 @@ class ModuleReplacePlugin {
|
|
|
89
86
|
moduleInfo.action = ModuleAction.REPLACE;
|
|
90
87
|
});
|
|
91
88
|
}
|
|
89
|
+
constructor(options) {
|
|
90
|
+
this._options = Object.assign({ modules: [] }, options);
|
|
91
|
+
}
|
|
92
92
|
apply(compiler) {
|
|
93
93
|
var _a;
|
|
94
94
|
const { modules } = this._options;
|
package/lib/webpack/types.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export interface IModule {
|
|
|
7
7
|
files: string[];
|
|
8
8
|
children: IModuleItem[];
|
|
9
9
|
}
|
|
10
|
-
export
|
|
10
|
+
export type IAssetMap = {
|
|
11
11
|
js: string[];
|
|
12
12
|
css?: string[];
|
|
13
13
|
} & {
|
|
@@ -32,7 +32,7 @@ export interface IManifest {
|
|
|
32
32
|
[s: string]: IModule;
|
|
33
33
|
};
|
|
34
34
|
}
|
|
35
|
-
export
|
|
35
|
+
export type ExternalsFunction = (data: {
|
|
36
36
|
context: string;
|
|
37
37
|
request: string;
|
|
38
38
|
}, callback: (err: Error | null, result: string | undefined) => void) => void;
|
package/lib/webpack/webpack.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import webpack, { Compilation } from 'webpack';
|
|
2
2
|
export { WebpackChain } from './config';
|
|
3
3
|
export { DynamicDll } from './dynamic-dll';
|
|
4
|
-
|
|
4
|
+
type ChunkGroup = Compilation['chunkGroups'][0];
|
|
5
5
|
export { webpack, ChunkGroup };
|
|
6
6
|
/**
|
|
7
7
|
* re-export for shuvi plugin
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shuvi/toolpack",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.56",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/shuvijs/shuvi.git",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"node": ">= 16.0.0"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@shuvi/compiler": "1.0.
|
|
23
|
+
"@shuvi/compiler": "1.0.56",
|
|
24
24
|
"@babel/core": "7.12.10",
|
|
25
25
|
"@babel/plugin-proposal-class-properties": "7.12.1",
|
|
26
26
|
"@babel/plugin-proposal-nullish-coalescing-operator": "7.10.1",
|
|
@@ -35,8 +35,8 @@
|
|
|
35
35
|
"@babel/preset-typescript": "7.12.7",
|
|
36
36
|
"@babel/runtime": "7.12.5",
|
|
37
37
|
"lightningcss": "1.19.0",
|
|
38
|
-
"@shuvi/shared": "1.0.
|
|
39
|
-
"@shuvi/utils": "1.0.
|
|
38
|
+
"@shuvi/shared": "1.0.56",
|
|
39
|
+
"@shuvi/utils": "1.0.56",
|
|
40
40
|
"babel-loader": "8.2.2",
|
|
41
41
|
"babel-plugin-syntax-jsx": "6.18.0",
|
|
42
42
|
"babel-plugin-transform-define": "2.0.0",
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"stream-browserify": "3.0.0",
|
|
69
69
|
"style-loader": "2.0.0",
|
|
70
70
|
"terser-webpack-plugin": "5.2.5",
|
|
71
|
-
"typescript": "
|
|
71
|
+
"typescript": "5.5.2",
|
|
72
72
|
"vm-browserify": "1.1.2",
|
|
73
73
|
"webpack": "5.73.0",
|
|
74
74
|
"webpack-bundle-analyzer": "4.3.0",
|