@rsdoctor/core 2.0.0-alpha.1 → 2.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/26.js +26174 -0
- package/dist/630.js +1280 -0
- package/dist/630.js.LICENSE.txt +7 -0
- package/dist/build-utils/build/chunks/assetsModules.d.ts +7 -1
- package/dist/build-utils/build/loader/probeLoader.d.ts +7 -2
- package/dist/build-utils/build/server.d.ts +1 -2
- package/dist/build-utils/build/utils/parseBundle.d.ts +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.js +1908 -7
- package/dist/inner-plugins/constants.d.ts +1 -1
- package/dist/inner-plugins/plugins/base.d.ts +2 -2
- package/dist/inner-plugins/plugins/errors.d.ts +1 -0
- package/dist/inner-plugins/plugins/plugins.d.ts +1 -1
- package/dist/inner-plugins/plugins/summary.d.ts +3 -2
- package/dist/inner-plugins/utils/sdk.d.ts +2 -1
- package/dist/logger.d.ts +2 -2
- package/dist/probe-loader.js +2 -0
- package/dist/proxy-loader.d.ts +1 -0
- package/dist/proxy-loader.js +48 -0
- package/dist/rslib-runtime.js +28 -0
- package/dist/rspack-plugin/constants.d.ts +1 -1
- package/dist/rspack-plugin/multiple.d.ts +5 -3
- package/dist/rspack-plugin/plugin.d.ts +43 -17
- package/dist/rspack-plugin/session.d.ts +20 -0
- package/dist/rules/rules/ecma-version-check/htmlParserStub.d.ts +3 -0
- package/dist/rules/rules/ecma-version-check/types.d.ts +13 -2
- package/dist/sdk/multiple/controller.d.ts +13 -2
- package/dist/sdk/multiple/primary.d.ts +12 -4
- package/dist/sdk/server/apis/base.d.ts +1 -1
- package/dist/sdk/server/socket/api.d.ts +1 -1
- package/dist/sdk/utils/date.d.ts +1 -0
- package/dist/types/loader.d.ts +1 -1
- package/package.json +23 -117
- package/dist/build-utils/build/chunks/assetsModules.js +0 -9
- package/dist/build-utils/build/chunks/index.js +0 -3
- package/dist/build-utils/build/chunks/rspack/transform.js +0 -44
- package/dist/build-utils/build/envinfo.js +0 -60
- package/dist/build-utils/build/file/cache.js +0 -24
- package/dist/build-utils/build/file/index.js +0 -5
- package/dist/build-utils/build/file/sharding.js +0 -38
- package/dist/build-utils/build/index.js +0 -12
- package/dist/build-utils/build/json.js +0 -67
- package/dist/build-utils/build/loader/index.js +0 -3
- package/dist/build-utils/build/loader/probeLoader.js +0 -44
- package/dist/build-utils/build/loader/probeLoaderPlugin.js +0 -32
- package/dist/build-utils/build/module-graph/index.js +0 -2
- package/dist/build-utils/build/module-graph/parser.js +0 -13
- package/dist/build-utils/build/module-graph/rspack/transform.js +0 -111
- package/dist/build-utils/build/module-graph/utils.js +0 -60
- package/dist/build-utils/build/process.js +0 -18
- package/dist/build-utils/build/server.js +0 -107
- package/dist/build-utils/build/utils/index.js +0 -4
- package/dist/build-utils/build/utils/loader.js +0 -267
- package/dist/build-utils/build/utils/parseBundle.js +0 -238
- package/dist/build-utils/build/utils/plugin.js +0 -21
- package/dist/build-utils/index.js +0 -13
- package/dist/collection.d.ts +0 -1
- package/dist/collection.js +0 -2
- package/dist/common/file.js +0 -8
- package/dist/common/global-config.js +0 -33
- package/dist/common/index.d.ts +0 -4
- package/dist/common/index.js +0 -6
- package/dist/common-browser.d.ts +0 -1
- package/dist/common-browser.js +0 -2
- package/dist/error/error.js +0 -143
- package/dist/error/index.js +0 -3
- package/dist/error/transform.js +0 -138
- package/dist/error/utils.js +0 -23
- package/dist/graph/index.d.ts +0 -1
- package/dist/graph/index.js +0 -2
- package/dist/inner-plugins/constants.js +0 -19
- package/dist/inner-plugins/index.js +0 -3
- package/dist/inner-plugins/loaders/proxy.js +0 -65
- package/dist/inner-plugins/plugins/base.js +0 -20
- package/dist/inner-plugins/plugins/bundle.js +0 -63
- package/dist/inner-plugins/plugins/ensureModulesChunkGraph.js +0 -74
- package/dist/inner-plugins/plugins/errors.js +0 -65
- package/dist/inner-plugins/plugins/index.js +0 -11
- package/dist/inner-plugins/plugins/loader.js +0 -108
- package/dist/inner-plugins/plugins/plugins.js +0 -40
- package/dist/inner-plugins/plugins/progress.js +0 -35
- package/dist/inner-plugins/plugins/resolver.js +0 -57
- package/dist/inner-plugins/plugins/rspack.js +0 -99
- package/dist/inner-plugins/plugins/rules.js +0 -64
- package/dist/inner-plugins/plugins/sourcemapTool.js +0 -230
- package/dist/inner-plugins/plugins/summary.js +0 -92
- package/dist/inner-plugins/utils/circleDetect.js +0 -16
- package/dist/inner-plugins/utils/config.js +0 -141
- package/dist/inner-plugins/utils/index.js +0 -8
- package/dist/inner-plugins/utils/loader.js +0 -134
- package/dist/inner-plugins/utils/normalize-config.js +0 -77
- package/dist/inner-plugins/utils/openBrowser.js +0 -55
- package/dist/inner-plugins/utils/plugin-common.js +0 -94
- package/dist/inner-plugins/utils/plugin.js +0 -70
- package/dist/inner-plugins/utils/sdk.js +0 -19
- package/dist/logger.js +0 -51
- package/dist/rspack-plugin/constants.js +0 -23
- package/dist/rspack-plugin/index.js +0 -3
- package/dist/rspack-plugin/multiple.js +0 -39
- package/dist/rspack-plugin/plugin.js +0 -133
- package/dist/rule-utils/document/document.js +0 -46
- package/dist/rule-utils/document/index.js +0 -4
- package/dist/rule-utils/document/server.js +0 -13
- package/dist/rule-utils/document/types.js +0 -1
- package/dist/rule-utils/index.js +0 -3
- package/dist/rule-utils/parser/asserts.js +0 -105
- package/dist/rule-utils/parser/index.js +0 -5
- package/dist/rule-utils/parser/parser.js +0 -24
- package/dist/rule-utils/parser/types.js +0 -8
- package/dist/rule-utils/parser/utils.js +0 -106
- package/dist/rules/index.js +0 -4
- package/dist/rules/linter.js +0 -36
- package/dist/rules/rule.js +0 -101
- package/dist/rules/rules/cjs-require/index.js +0 -50
- package/dist/rules/rules/cjs-require/types.js +0 -1
- package/dist/rules/rules/cross-chunks-package/index.js +0 -41
- package/dist/rules/rules/cross-chunks-package/types.js +0 -1
- package/dist/rules/rules/cross-chunks-package/utils.js +0 -7
- package/dist/rules/rules/default-import-check/index.js +0 -83
- package/dist/rules/rules/default-import-check/types.js +0 -1
- package/dist/rules/rules/default-import-check/utils.js +0 -52
- package/dist/rules/rules/duplicate-package/index.js +0 -39
- package/dist/rules/rules/duplicate-package/types.js +0 -24
- package/dist/rules/rules/duplicate-package/utils.js +0 -38
- package/dist/rules/rules/ecma-version-check/index.js +0 -53
- package/dist/rules/rules/ecma-version-check/types.js +0 -1
- package/dist/rules/rules/ecma-version-check/utils.js +0 -6
- package/dist/rules/rules/esm-resolved-to-cjs/index.js +0 -193
- package/dist/rules/rules/esm-resolved-to-cjs/types.js +0 -1
- package/dist/rules/rules/index.js +0 -22
- package/dist/rules/rules/loader-performance-optimization/index.js +0 -86
- package/dist/rules/rules/loader-performance-optimization/types.js +0 -1
- package/dist/rules/rules/loader-performance-optimization/utils.js +0 -10
- package/dist/rules/rules/module-mixed-chunks/index.js +0 -52
- package/dist/rules/rules/module-mixed-chunks/types.js +0 -1
- package/dist/rules/rules/side-effects-only-imports/index.js +0 -81
- package/dist/rules/rules/side-effects-only-imports/types.js +0 -1
- package/dist/rules/utils.js +0 -10
- package/dist/sdk/index.js +0 -3
- package/dist/sdk/multiple/controller.js +0 -42
- package/dist/sdk/multiple/index.js +0 -3
- package/dist/sdk/multiple/primary.js +0 -64
- package/dist/sdk/multiple/server.js +0 -14
- package/dist/sdk/sdk/core.js +0 -163
- package/dist/sdk/sdk/index.js +0 -435
- package/dist/sdk/sdk/types.js +0 -1
- package/dist/sdk/server/apis/alerts.js +0 -30
- package/dist/sdk/server/apis/base.js +0 -22
- package/dist/sdk/server/apis/bundle-diff.js +0 -51
- package/dist/sdk/server/apis/data.js +0 -44
- package/dist/sdk/server/apis/fs.js +0 -28
- package/dist/sdk/server/apis/graph.js +0 -116
- package/dist/sdk/server/apis/index.js +0 -11
- package/dist/sdk/server/apis/loader.js +0 -120
- package/dist/sdk/server/apis/plugin.js +0 -39
- package/dist/sdk/server/apis/project.js +0 -59
- package/dist/sdk/server/apis/renderer.js +0 -33
- package/dist/sdk/server/apis/resolver.js +0 -38
- package/dist/sdk/server/client.js +0 -8
- package/dist/sdk/server/fakeServer.js +0 -12
- package/dist/sdk/server/index.js +0 -292
- package/dist/sdk/server/json-body.js +0 -150
- package/dist/sdk/server/router.js +0 -83
- package/dist/sdk/server/security.js +0 -47
- package/dist/sdk/server/socket/api.js +0 -22
- package/dist/sdk/server/socket/index.js +0 -166
- package/dist/sdk/server/utils.js +0 -19
- package/dist/sdk/utils/base.js +0 -22
- package/dist/sdk/utils/constant.js +0 -4
- package/dist/sdk/utils/index.js +0 -4
- package/dist/sdk/utils/openBrowser.js +0 -53
- package/dist/sdk/utils/upload.js +0 -6
- package/dist/sdk.js +0 -2
- package/dist/types/index.js +0 -4
- package/dist/types/loader.js +0 -1
- package/dist/types/plugin.js +0 -1
- package/dist/types/rules.js +0 -1
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import "node:module";
|
|
2
|
-
import { Manifest } from "@rsdoctor/shared/types";
|
|
3
|
-
import { Loader } from "../../common/index.js";
|
|
4
|
-
import { isEqual, omit } from "../../collection.js";
|
|
5
|
-
import { interceptLoader } from "../utils/index.js";
|
|
6
|
-
import { InternalBasePlugin } from "./base.js";
|
|
7
|
-
import { time, timeEnd } from "../../logger.js";
|
|
8
|
-
import { fileURLToPath } from "url";
|
|
9
|
-
import { safeCloneDeep } from "../utils/plugin-common.js";
|
|
10
|
-
class InternalLoaderPlugin extends InternalBasePlugin {
|
|
11
|
-
apply(compiler) {
|
|
12
|
-
time('InternalLoaderPlugin.apply');
|
|
13
|
-
try {
|
|
14
|
-
compiler.hooks.afterPlugins.tap(this.tapPostOptions, this.afterPlugins.bind(this, compiler));
|
|
15
|
-
compiler.hooks.compilation.tap(this.tapPreOptions, (compilation)=>this.compilation(compiler, compilation));
|
|
16
|
-
} finally{
|
|
17
|
-
timeEnd('InternalLoaderPlugin.apply');
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
compilation(compiler, compilation) {
|
|
21
|
-
time('InternalLoaderPlugin.compilation');
|
|
22
|
-
try {
|
|
23
|
-
if (compiler.isChild()) return;
|
|
24
|
-
const wrapper = (callback)=>(loaderContext, module)=>{
|
|
25
|
-
const proxyLoaders = module?.loaders || loaderContext?.loaders || [];
|
|
26
|
-
const originLoaders = proxyLoaders.map((loader)=>{
|
|
27
|
-
const rawOptions = loader.options;
|
|
28
|
-
const opts = 'object' == typeof rawOptions && null !== rawOptions ? rawOptions : {};
|
|
29
|
-
if (opts[Loader.LoaderInternalPropertyName]) return {
|
|
30
|
-
...loader,
|
|
31
|
-
loader: opts[Loader.LoaderInternalPropertyName].loader,
|
|
32
|
-
options: omit(opts, Loader.LoaderInternalPropertyName)
|
|
33
|
-
};
|
|
34
|
-
return loader;
|
|
35
|
-
});
|
|
36
|
-
const newLoaders = safeCloneDeep(originLoaders);
|
|
37
|
-
if ('object' == typeof compiler.options.cache && 'version' in compiler.options.cache && 'string' == typeof compiler.options.cache.version && compiler.options.cache.version.indexOf('next/dist/build') > -1) callback(loaderContext, module || {});
|
|
38
|
-
else {
|
|
39
|
-
const proxyModule = new Proxy(module || {}, {
|
|
40
|
-
get (target, p, receiver) {
|
|
41
|
-
if ('loaders' === p) return newLoaders;
|
|
42
|
-
return Reflect.get(target, p, receiver);
|
|
43
|
-
},
|
|
44
|
-
set (target, p, newValue, receiver) {
|
|
45
|
-
const _newValue = safeCloneDeep(newValue);
|
|
46
|
-
if ('loaders' === p) {
|
|
47
|
-
if (Array.isArray(_newValue)) {
|
|
48
|
-
newLoaders.length = 0;
|
|
49
|
-
_newValue.forEach((e)=>{
|
|
50
|
-
newLoaders.push(e);
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
return Reflect.set(target, p, _newValue, receiver);
|
|
55
|
-
},
|
|
56
|
-
deleteProperty (target, p) {
|
|
57
|
-
return Reflect.deleteProperty(target, p);
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
callback(loaderContext, proxyModule);
|
|
61
|
-
}
|
|
62
|
-
if (!isEqual(originLoaders, newLoaders)) {
|
|
63
|
-
const rules = this.getInterceptRules(compiler, newLoaders.map((e)=>({
|
|
64
|
-
loader: e.loader,
|
|
65
|
-
options: e.options ?? void 0
|
|
66
|
-
})));
|
|
67
|
-
module.loaders = rules.map((e, i)=>({
|
|
68
|
-
...newLoaders[i],
|
|
69
|
-
loader: e.loader,
|
|
70
|
-
options: e.options
|
|
71
|
-
}));
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
const interceptor = {
|
|
75
|
-
register (tap) {
|
|
76
|
-
const originFn = tap.fn;
|
|
77
|
-
if ('function' == typeof originFn) tap.fn = wrapper(originFn);
|
|
78
|
-
return tap;
|
|
79
|
-
}
|
|
80
|
-
};
|
|
81
|
-
compiler.webpack.NormalModule.getCompilationHooks(compilation).loader.intercept(interceptor);
|
|
82
|
-
} finally{
|
|
83
|
-
timeEnd('InternalLoaderPlugin.compilation');
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
getInterceptRules(compiler, rules) {
|
|
87
|
-
return interceptLoader(rules, this.internalLoaderPath, {
|
|
88
|
-
cwd: compiler.context || process.cwd(),
|
|
89
|
-
host: this.sdk.server.origin,
|
|
90
|
-
skipLoaders: this.options.loaderInterceptorOptions.skipLoaders
|
|
91
|
-
}, compiler.resolverFactory.get('loader', compiler.options.resolveLoader), this.sdk.root);
|
|
92
|
-
}
|
|
93
|
-
constructor(...args){
|
|
94
|
-
super(...args), this.name = 'loader', this.internalLoaderPath = fileURLToPath(new URL('../loaders/proxy.js', import.meta.url)), this.afterPlugins = (compiler)=>{
|
|
95
|
-
time('InternalLoaderPlugin.afterPlugins');
|
|
96
|
-
try {
|
|
97
|
-
if (compiler.isChild()) return;
|
|
98
|
-
compiler.options.module.rules = this.getInterceptRules(compiler, compiler.options.module.rules);
|
|
99
|
-
this.sdk.addClientRoutes([
|
|
100
|
-
Manifest.RsdoctorManifestClientRoutes.Loaders
|
|
101
|
-
]);
|
|
102
|
-
} finally{
|
|
103
|
-
timeEnd('InternalLoaderPlugin.afterPlugins');
|
|
104
|
-
}
|
|
105
|
-
};
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
export { InternalLoaderPlugin };
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import "node:module";
|
|
2
|
-
import { Manifest } from "@rsdoctor/shared/types";
|
|
3
|
-
import { Utils } from "../../build-utils/build/index.js";
|
|
4
|
-
import { interceptPluginHook } from "../utils/index.js";
|
|
5
|
-
import { InternalBasePlugin } from "./base.js";
|
|
6
|
-
import { time, timeEnd } from "../../logger.js";
|
|
7
|
-
class InternalPluginsPlugin extends InternalBasePlugin {
|
|
8
|
-
apply(compiler) {
|
|
9
|
-
time('InternalPluginsPlugin.apply');
|
|
10
|
-
try {
|
|
11
|
-
compiler.hooks.afterPlugins.tap(this.tapPostOptions, this.afterPlugins.bind(this, compiler));
|
|
12
|
-
compiler.hooks.compilation.tap(this.tapPostOptions, this.compilation);
|
|
13
|
-
} finally{
|
|
14
|
-
timeEnd('InternalPluginsPlugin.apply');
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
constructor(...args){
|
|
18
|
-
super(...args), this.name = 'plugins', this.afterPlugins = (compiler)=>{
|
|
19
|
-
time('InternalPluginsPlugin.afterPlugins');
|
|
20
|
-
try {
|
|
21
|
-
if (compiler.isChild()) return;
|
|
22
|
-
Utils.interceptCompilerHooks(compiler, (name, hook)=>interceptPluginHook(this.sdk, name, hook));
|
|
23
|
-
this.sdk.addClientRoutes([
|
|
24
|
-
Manifest.RsdoctorManifestClientRoutes.Plugins
|
|
25
|
-
]);
|
|
26
|
-
} finally{
|
|
27
|
-
timeEnd('InternalPluginsPlugin.afterPlugins');
|
|
28
|
-
}
|
|
29
|
-
}, this.compilation = (compilation)=>{
|
|
30
|
-
time('InternalPluginsPlugin.compilation');
|
|
31
|
-
try {
|
|
32
|
-
if (compilation.compiler.isChild()) return;
|
|
33
|
-
Utils.interceptCompilationHooks(compilation, (name, hook)=>interceptPluginHook(this.sdk, name, hook));
|
|
34
|
-
} finally{
|
|
35
|
-
timeEnd('InternalPluginsPlugin.compilation');
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
export { InternalPluginsPlugin };
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import "node:module";
|
|
2
|
-
import { SDK } from "@rsdoctor/shared/types";
|
|
3
|
-
import { InternalBasePlugin } from "./base.js";
|
|
4
|
-
import { logger } from "../../logger.js";
|
|
5
|
-
class InternalProgressPlugin extends InternalBasePlugin {
|
|
6
|
-
apply(compiler) {
|
|
7
|
-
const { sdk, currentProgress } = this;
|
|
8
|
-
if (compiler.webpack && compiler.webpack.ProgressPlugin) {
|
|
9
|
-
const progress = new compiler.webpack.ProgressPlugin((percentage, msg)=>{
|
|
10
|
-
currentProgress.percentage = percentage;
|
|
11
|
-
currentProgress.message = msg || '';
|
|
12
|
-
const api = SDK.ServerAPI.APIExtends.GetCompileProgress;
|
|
13
|
-
try {
|
|
14
|
-
sdk.server.sendAPIDataToClient(api, {
|
|
15
|
-
req: {
|
|
16
|
-
api,
|
|
17
|
-
body: void 0
|
|
18
|
-
},
|
|
19
|
-
res: currentProgress
|
|
20
|
-
});
|
|
21
|
-
} catch (e) {
|
|
22
|
-
logger.debug(e);
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
progress.apply(compiler);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
constructor(...args){
|
|
29
|
-
super(...args), this.name = 'progress', this.currentProgress = {
|
|
30
|
-
percentage: 100,
|
|
31
|
-
message: ''
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
export { InternalProgressPlugin };
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import "node:module";
|
|
2
|
-
import { Manifest } from "@rsdoctor/shared/types";
|
|
3
|
-
import { Time } from "../../common/index.js";
|
|
4
|
-
import { InternalBasePlugin } from "./base.js";
|
|
5
|
-
class InternalResolverPlugin extends InternalBasePlugin {
|
|
6
|
-
apply(compiler) {
|
|
7
|
-
this.scheduler.ensureModulesChunksGraphApplied(compiler);
|
|
8
|
-
compiler.hooks.normalModuleFactory.tap(this.tapPostOptions, this.handleNormalModuleFactory);
|
|
9
|
-
this.sdk.addClientRoutes([
|
|
10
|
-
Manifest.RsdoctorManifestClientRoutes.ModuleResolve
|
|
11
|
-
]);
|
|
12
|
-
}
|
|
13
|
-
constructor(...args){
|
|
14
|
-
super(...args), this.name = 'resolver', this.resolveDataMap = new Map(), this.handleNormalModuleFactory = (normalModuleFactory)=>{
|
|
15
|
-
normalModuleFactory.hooks.beforeResolve.tap(this.tapPostOptions, (resolveData)=>{
|
|
16
|
-
if (!resolveData) return;
|
|
17
|
-
const issuer = resolveData.contextInfo?.issuer || resolveData.context || '';
|
|
18
|
-
const request = resolveData.request;
|
|
19
|
-
if (issuer && request) {
|
|
20
|
-
const key = `${issuer}::${request}`;
|
|
21
|
-
this.resolveDataMap.set(key, {
|
|
22
|
-
startAt: Date.now(),
|
|
23
|
-
startHRTime: process.hrtime(),
|
|
24
|
-
request
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
normalModuleFactory.hooks.afterResolve.tap(this.tapPostOptions, (resolveData)=>{
|
|
29
|
-
if (!resolveData) return;
|
|
30
|
-
const issuer = resolveData.contextInfo?.issuer || resolveData.context || '';
|
|
31
|
-
const request = resolveData.request;
|
|
32
|
-
const result = resolveData.createData?.resource || resolveData.resourceResolveData?.path;
|
|
33
|
-
if (issuer && request) {
|
|
34
|
-
const key = `${issuer}::${request}`;
|
|
35
|
-
const startData = this.resolveDataMap.get(key);
|
|
36
|
-
if (startData) {
|
|
37
|
-
const data = {
|
|
38
|
-
isEntry: Boolean(issuer),
|
|
39
|
-
issuerPath: issuer,
|
|
40
|
-
request: startData.request,
|
|
41
|
-
startAt: startData.startAt,
|
|
42
|
-
endAt: Time.getCurrentTimestamp(startData.startAt, startData.startHRTime),
|
|
43
|
-
result: result || '',
|
|
44
|
-
pid: process.pid,
|
|
45
|
-
ppid: process.ppid
|
|
46
|
-
};
|
|
47
|
-
this.sdk.reportResolver([
|
|
48
|
-
data
|
|
49
|
-
]);
|
|
50
|
-
this.resolveDataMap.delete(key);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
export { InternalResolverPlugin };
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import "node:module";
|
|
2
|
-
import { ChunkGraph } from "../../graph/index.js";
|
|
3
|
-
import { Chunks, ModuleGraph } from "../../build-utils/build/index.js";
|
|
4
|
-
import { internalPluginTapPreOptions } from "../constants.js";
|
|
5
|
-
import { logger } from "../../logger.js";
|
|
6
|
-
function getRspackNativePlugin(compiler) {
|
|
7
|
-
const RsdoctorRspackPlugin = compiler.webpack.experiments?.RsdoctorPlugin;
|
|
8
|
-
if (!RsdoctorRspackPlugin) throw new Error('[RsdoctorRspackPlugin] The current Rspack version does not provide experiments.RsdoctorPlugin. Please upgrade Rspack.');
|
|
9
|
-
return RsdoctorRspackPlugin;
|
|
10
|
-
}
|
|
11
|
-
function applyRspackNativePlugin(compiler, plugin, RsdoctorRspackPlugin) {
|
|
12
|
-
const state = {
|
|
13
|
-
chunkGraph: false,
|
|
14
|
-
moduleGraph: false
|
|
15
|
-
};
|
|
16
|
-
logger.debug('[RspackNativePlugin] Apply hooks');
|
|
17
|
-
compiler.hooks.compilation.tap('RsdoctorRspackPlugin', (compilation)=>{
|
|
18
|
-
state.chunkGraph = false;
|
|
19
|
-
state.moduleGraph = false;
|
|
20
|
-
const hooks = RsdoctorRspackPlugin.getCompilationHooks(compilation);
|
|
21
|
-
const cached = {};
|
|
22
|
-
const dependOn = {
|
|
23
|
-
chunkGraphData: [],
|
|
24
|
-
moduleGraphData: [
|
|
25
|
-
'chunkGraphData'
|
|
26
|
-
],
|
|
27
|
-
assetPatchData: [
|
|
28
|
-
'chunkGraphData'
|
|
29
|
-
],
|
|
30
|
-
moduleIdsPatchData: [
|
|
31
|
-
'moduleGraphData'
|
|
32
|
-
],
|
|
33
|
-
moduleSourcesPatchData: [
|
|
34
|
-
'moduleGraphData'
|
|
35
|
-
]
|
|
36
|
-
};
|
|
37
|
-
const consumer = {
|
|
38
|
-
chunkGraphData: (data)=>{
|
|
39
|
-
plugin.chunkGraph = new ChunkGraph();
|
|
40
|
-
Chunks.patchNativeChunkGraph(plugin.chunkGraph, data);
|
|
41
|
-
state.chunkGraph = true;
|
|
42
|
-
},
|
|
43
|
-
moduleGraphData: (data)=>{
|
|
44
|
-
ModuleGraph.patchNativeModuleGraph(plugin.modulesGraph, plugin.chunkGraph, data);
|
|
45
|
-
state.moduleGraph = true;
|
|
46
|
-
},
|
|
47
|
-
moduleIdsPatchData: (data)=>{
|
|
48
|
-
ModuleGraph.patchNativeModuleIds(plugin.modulesGraph, data);
|
|
49
|
-
},
|
|
50
|
-
moduleSourcesPatchData: (data)=>{
|
|
51
|
-
ModuleGraph.patchNativeModuleSources(plugin.modulesGraph, data);
|
|
52
|
-
if (plugin.options.features.treeShaking) ModuleGraph.extractSideEffectCodes(plugin.modulesGraph);
|
|
53
|
-
},
|
|
54
|
-
assetPatchData: (data)=>{
|
|
55
|
-
Chunks.patchNativeAssets(plugin.chunkGraph, data);
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
const tryConsumeData = (key, data)=>{
|
|
59
|
-
if (true === cached[key]) return;
|
|
60
|
-
cached[key] = data;
|
|
61
|
-
while(true){
|
|
62
|
-
let hasConsumed = false;
|
|
63
|
-
for (const [_task, deps] of Object.entries(dependOn)){
|
|
64
|
-
const task = _task;
|
|
65
|
-
if (true === cached[task] || void 0 === cached[task]) continue;
|
|
66
|
-
const prepared = deps.every((dep)=>true === cached[dep]);
|
|
67
|
-
if (prepared) {
|
|
68
|
-
consumer[task](cached[task]);
|
|
69
|
-
cached[task] = true;
|
|
70
|
-
hasConsumed = true;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
if (!hasConsumed) break;
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
hooks.chunkGraph.tap(internalPluginTapPreOptions('nativeChunkGraph'), (rawChunkGraph)=>{
|
|
77
|
-
logger.debug('[RspackNativePlugin] Called chunkGraph hook');
|
|
78
|
-
tryConsumeData('chunkGraphData', rawChunkGraph);
|
|
79
|
-
});
|
|
80
|
-
hooks.moduleGraph.tap(internalPluginTapPreOptions('nativeModuleGraph'), (rawModuleGraph)=>{
|
|
81
|
-
logger.debug('[RspackNativePlugin] Called moduleGraph hook');
|
|
82
|
-
tryConsumeData('moduleGraphData', rawModuleGraph);
|
|
83
|
-
});
|
|
84
|
-
hooks.moduleIds.tap(internalPluginTapPreOptions('nativeSourcePatch'), (rawModuleIdsPatch)=>{
|
|
85
|
-
logger.debug('[RspackNativePlugin] Called moduleIds hook');
|
|
86
|
-
tryConsumeData('moduleIdsPatchData', rawModuleIdsPatch);
|
|
87
|
-
});
|
|
88
|
-
hooks.moduleSources.tap(internalPluginTapPreOptions('nativeModuleSourcesPatch'), (rawModuleSourcesPatch)=>{
|
|
89
|
-
logger.debug('[RspackNativePlugin] Called moduleSources hook');
|
|
90
|
-
tryConsumeData('moduleSourcesPatchData', rawModuleSourcesPatch);
|
|
91
|
-
});
|
|
92
|
-
hooks.assets.tap(internalPluginTapPreOptions('nativeAssetPatch'), (rawAssetPatch)=>{
|
|
93
|
-
logger.debug('[RspackNativePlugin] Called assets hook');
|
|
94
|
-
tryConsumeData('assetPatchData', rawAssetPatch);
|
|
95
|
-
});
|
|
96
|
-
});
|
|
97
|
-
return state;
|
|
98
|
-
}
|
|
99
|
-
export { applyRspackNativePlugin, getRspackNativePlugin };
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import "node:module";
|
|
2
|
-
import { InternalBasePlugin } from "./base.js";
|
|
3
|
-
import { Linter } from "../../rules/index.js";
|
|
4
|
-
import { DevToolError } from "../../error/index.js";
|
|
5
|
-
import { pull } from "../../collection.js";
|
|
6
|
-
import { time, timeEnd } from "../../logger.js";
|
|
7
|
-
class InternalRulesPlugin extends InternalBasePlugin {
|
|
8
|
-
apply(compiler) {
|
|
9
|
-
time('InternalRulesPlugin.apply');
|
|
10
|
-
try {
|
|
11
|
-
compiler.hooks.done.tapPromise(this.tapPreOptions, this.done);
|
|
12
|
-
} finally{
|
|
13
|
-
timeEnd('InternalRulesPlugin.apply');
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
async lint(compilation) {
|
|
17
|
-
time('InternalRulesPlugin.lint');
|
|
18
|
-
try {
|
|
19
|
-
const options = this.options ?? {};
|
|
20
|
-
const linter = new Linter(options.linter);
|
|
21
|
-
const result = await linter.validate(this.sdk.getRuleContext({}));
|
|
22
|
-
const validateErrors = result.errors.map((err)=>DevToolError.from(err, {
|
|
23
|
-
detail: err.detail,
|
|
24
|
-
controller: {
|
|
25
|
-
noColor: true
|
|
26
|
-
}
|
|
27
|
-
}));
|
|
28
|
-
const errors = validateErrors.filter((item)=>'Error' === item.level);
|
|
29
|
-
const warnings = validateErrors.filter((item)=>'Warn' === item.level);
|
|
30
|
-
const toRspackError = (err)=>err.toError();
|
|
31
|
-
result.replace.forEach((item)=>{
|
|
32
|
-
if (Array.isArray(compilation.errors) && compilation.errors.includes(item)) pull(compilation.errors, item);
|
|
33
|
-
if (Array.isArray(compilation.warnings) && compilation.warnings.includes(item)) pull(compilation.warnings, item);
|
|
34
|
-
});
|
|
35
|
-
if (Array.isArray(compilation.errors)) errors.forEach((err)=>{
|
|
36
|
-
compilation.errors.push(toRspackError(err));
|
|
37
|
-
});
|
|
38
|
-
if (Array.isArray(compilation.warnings)) warnings.forEach((err)=>{
|
|
39
|
-
compilation.warnings.push(toRspackError(err));
|
|
40
|
-
});
|
|
41
|
-
this.sdk.reportError(validateErrors);
|
|
42
|
-
await linter.afterValidate({
|
|
43
|
-
data: this.sdk.getRuleContext({}),
|
|
44
|
-
validateResult: result,
|
|
45
|
-
hooks: {
|
|
46
|
-
afterSaveManifest: this.sdk.hooks.afterSaveManifest
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
} finally{
|
|
50
|
-
timeEnd('InternalRulesPlugin.lint');
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
constructor(...args){
|
|
54
|
-
super(...args), this.name = 'rules', this.done = async (stats)=>{
|
|
55
|
-
time('InternalRulesPlugin.done');
|
|
56
|
-
try {
|
|
57
|
-
await this.lint(stats.compilation);
|
|
58
|
-
} finally{
|
|
59
|
-
timeEnd('InternalRulesPlugin.done');
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
export { InternalRulesPlugin };
|
|
@@ -1,230 +0,0 @@
|
|
|
1
|
-
import "node:module";
|
|
2
|
-
import { Graph } from "../../common/index.js";
|
|
3
|
-
import { logger, time, timeEnd } from "../../logger.js";
|
|
4
|
-
import { dirname, isAbsolute, resolve } from "path";
|
|
5
|
-
import { SourceMapConsumer } from "source-map";
|
|
6
|
-
const UNASSIGNED = '[unassigned]';
|
|
7
|
-
function bindContextCache(context, namespace, cache, sourceMapDir, sourceRoot) {
|
|
8
|
-
cache = cache || new Map();
|
|
9
|
-
return (source, sourceMapFilenameRegex)=>{
|
|
10
|
-
if (cache.has(source)) return cache.get(source);
|
|
11
|
-
let resolved = UNASSIGNED;
|
|
12
|
-
if (source.startsWith('file://')) resolved = resolve(context, source.replace(/^file:\/\//, ''));
|
|
13
|
-
else if (source.startsWith('webpack://')) if (sourceMapFilenameRegex) {
|
|
14
|
-
const match = source.match(sourceMapFilenameRegex);
|
|
15
|
-
const filePath = match?.[1];
|
|
16
|
-
const hasNamespace = namespace && source.startsWith(`webpack://${namespace}`) || namespace && source.startsWith(`file://${namespace}`);
|
|
17
|
-
const baseDir = hasNamespace ? process.cwd() : context;
|
|
18
|
-
resolved = filePath ? resolve(baseDir, `./${filePath}`) : UNASSIGNED;
|
|
19
|
-
} else resolved = UNASSIGNED;
|
|
20
|
-
else if (isAbsolute(source)) resolved = source;
|
|
21
|
-
else {
|
|
22
|
-
let baseDir = context;
|
|
23
|
-
if (sourceRoot) baseDir = isAbsolute(sourceRoot) ? sourceRoot : sourceMapDir ? resolve(sourceMapDir, sourceRoot) : resolve(context, sourceRoot);
|
|
24
|
-
else if (sourceMapDir) baseDir = sourceMapDir;
|
|
25
|
-
resolved = resolve(baseDir, source);
|
|
26
|
-
}
|
|
27
|
-
cache.set(source, resolved);
|
|
28
|
-
return resolved;
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
async function collectSourceMaps(map, assetLinesCodeList, _compilation, _this, sourceMapFilenameRegex, namespace, skipSources, sourceMapPath) {
|
|
32
|
-
if (map) {
|
|
33
|
-
const consumer = await new SourceMapConsumer(map);
|
|
34
|
-
let sourceMapDir;
|
|
35
|
-
if (sourceMapPath) sourceMapDir = dirname(sourceMapPath);
|
|
36
|
-
else if (_compilation.options.output?.path) sourceMapDir = 'string' == typeof _compilation.options.output.path ? _compilation.options.output.path : void 0;
|
|
37
|
-
const sourceRoot = map.sourceRoot;
|
|
38
|
-
const getRealSourcePath = bindContextCache(_this.sdk.root || process.cwd(), namespace, _this._realSourcePathCache, sourceMapDir, sourceRoot ?? void 0);
|
|
39
|
-
const lineMappings = new Map();
|
|
40
|
-
consumer._absoluteSources = consumer._sources;
|
|
41
|
-
consumer.eachMapping((m)=>{
|
|
42
|
-
if (!lineMappings.has(m.generatedLine)) lineMappings.set(m.generatedLine, []);
|
|
43
|
-
lineMappings.get(m.generatedLine).push(m);
|
|
44
|
-
});
|
|
45
|
-
for (const [lineNum, mappings] of lineMappings.entries()){
|
|
46
|
-
mappings.sort((a, b)=>a.generatedColumn - b.generatedColumn);
|
|
47
|
-
const lineIdx = lineNum - 1;
|
|
48
|
-
if (lineIdx < 0 || lineIdx >= assetLinesCodeList.length) continue;
|
|
49
|
-
const line = assetLinesCodeList[lineIdx];
|
|
50
|
-
for(let i = 0; i < mappings.length; i++){
|
|
51
|
-
const m = mappings[i];
|
|
52
|
-
if (!m.source) continue;
|
|
53
|
-
let realSource = m.source;
|
|
54
|
-
if (realSource.includes('!')) {
|
|
55
|
-
const parts = realSource.split('!');
|
|
56
|
-
for(let j = parts.length - 1; j >= 0; j--){
|
|
57
|
-
const part = parts[j];
|
|
58
|
-
if (!part) continue;
|
|
59
|
-
const cleanPart = part.split('??')[0];
|
|
60
|
-
if (!cleanPart.startsWith('builtin:')) {
|
|
61
|
-
if (cleanPart.startsWith('/') || cleanPart.includes('\\')) {
|
|
62
|
-
realSource = cleanPart;
|
|
63
|
-
break;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
if (realSource === m.source) {
|
|
68
|
-
const lastPart = parts[parts.length - 1];
|
|
69
|
-
realSource = lastPart ? lastPart.split('??')[0] : lastPart;
|
|
70
|
-
}
|
|
71
|
-
} else if (realSource.includes('??')) realSource = realSource.split('??')[0];
|
|
72
|
-
if (realSource) {
|
|
73
|
-
if ((realSource.startsWith('webpack://') || realSource.startsWith('file://')) && sourceMapFilenameRegex) realSource = getRealSourcePath(realSource, sourceMapFilenameRegex);
|
|
74
|
-
else if (!isAbsolute(realSource)) realSource = getRealSourcePath(realSource, sourceMapFilenameRegex);
|
|
75
|
-
}
|
|
76
|
-
if (!realSource || realSource === UNASSIGNED) continue;
|
|
77
|
-
if (skipSources && skipSources.has(realSource)) continue;
|
|
78
|
-
const next = mappings[i + 1];
|
|
79
|
-
const start = m.generatedColumn;
|
|
80
|
-
const end = next ? next.generatedColumn : line.length;
|
|
81
|
-
const codeSegment = line.slice(start, end);
|
|
82
|
-
const prev = _this.sourceMapSets.get(realSource) || '';
|
|
83
|
-
_this.sourceMapSets.set(realSource, prev.concat(codeSegment));
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
async function handleAfterEmitAssets(compilation, _this, sourceMapFilenameRegex, namespace) {
|
|
89
|
-
if ('rspack' in compilation.compiler) {
|
|
90
|
-
_this.sourceMapSets = new Map();
|
|
91
|
-
if (_this.assetsWithoutSourceMap) _this.assetsWithoutSourceMap.clear();
|
|
92
|
-
else _this.assetsWithoutSourceMap = new Set();
|
|
93
|
-
time('ensureModulesChunkGraph.afterEmit.start');
|
|
94
|
-
const assets = [
|
|
95
|
-
...compilation.getAssets()
|
|
96
|
-
];
|
|
97
|
-
const skipSources = new Set();
|
|
98
|
-
for (const asset of assets){
|
|
99
|
-
const { assetLinesCodeList, map: mapFromAsset, assetName } = parseAsset(asset, assets, 'js/css');
|
|
100
|
-
let map = mapFromAsset;
|
|
101
|
-
let sourceMapPath;
|
|
102
|
-
if (map) {
|
|
103
|
-
const outputPath = compilation.options.output?.path;
|
|
104
|
-
if (outputPath && 'string' == typeof outputPath && assetName) {
|
|
105
|
-
const mapFileName = assetName.endsWith('.map') ? assetName : `${assetName}.map`;
|
|
106
|
-
sourceMapPath = resolve(outputPath, mapFileName);
|
|
107
|
-
}
|
|
108
|
-
} else {
|
|
109
|
-
const sourceMapFile = asset.info.related?.sourceMap;
|
|
110
|
-
const sourceMapFileAssetName = sourceMapFile?.replace(/(\.[^.]+)(\.[^.]+)?$/, '$1');
|
|
111
|
-
if (sourceMapFile) {
|
|
112
|
-
let sourceMapAsset = assets.find((asset)=>asset.name === sourceMapFile);
|
|
113
|
-
if (!sourceMapAsset && sourceMapFileAssetName) {
|
|
114
|
-
const baseNameWithoutHash = Graph.formatAssetName(sourceMapFileAssetName, 'string' == typeof compilation.options.output.filename ? compilation.options.output.filename : void 0);
|
|
115
|
-
sourceMapAsset = assets.find((asset)=>{
|
|
116
|
-
const assetBaseName = Graph.formatAssetName(asset.name, 'string' == typeof compilation.options.output.filename ? compilation.options.output.filename : void 0);
|
|
117
|
-
return assetBaseName.includes(baseNameWithoutHash) && asset.name.endsWith('.map');
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
if (sourceMapAsset) {
|
|
121
|
-
map = JSON.parse(sourceMapAsset.source.source().toString());
|
|
122
|
-
const outputPath = compilation.options.output?.path;
|
|
123
|
-
if (outputPath && 'string' == typeof outputPath) sourceMapPath = resolve(outputPath, sourceMapAsset.name);
|
|
124
|
-
}
|
|
125
|
-
} else {
|
|
126
|
-
if (assetName && 'string' == typeof assetName && (assetName.endsWith('.js') || assetName.endsWith('.bundle') || assetName.endsWith('.css'))) _this.assetsWithoutSourceMap.add(assetName);
|
|
127
|
-
continue;
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
try {
|
|
131
|
-
await collectSourceMaps(map, assetLinesCodeList, compilation, _this, sourceMapFilenameRegex, namespace, skipSources, sourceMapPath);
|
|
132
|
-
} catch (e) {
|
|
133
|
-
logger.debug(e);
|
|
134
|
-
}
|
|
135
|
-
_this.sourceMapSets.forEach((_value, key)=>{
|
|
136
|
-
if (!skipSources.has(key)) skipSources.add(key);
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
timeEnd('ensureModulesChunkGraph.afterEmit.start');
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
async function handleEmitAssets(options) {
|
|
143
|
-
const { compilation, pluginInstance, sourceMapFilenameRegex, namespace } = options;
|
|
144
|
-
if (!('rspack' in compilation.compiler)) {
|
|
145
|
-
pluginInstance.sourceMapSets = new Map();
|
|
146
|
-
time('ensureModulesChunkGraph.afterEmit.start');
|
|
147
|
-
const assets = Object.values(compilation.getAssets()).map((asset, index)=>({
|
|
148
|
-
name: index.toString(),
|
|
149
|
-
source: asset,
|
|
150
|
-
info: asset.info || {}
|
|
151
|
-
}));
|
|
152
|
-
for (const asset of assets){
|
|
153
|
-
const { assetLinesCodeList, map, assetName } = parseAsset(asset, assets, 'map');
|
|
154
|
-
if (!map) continue;
|
|
155
|
-
let sourceMapPath;
|
|
156
|
-
const outputPath = compilation.options.output?.path;
|
|
157
|
-
if (outputPath && 'string' == typeof outputPath && 'string' == typeof assetName) {
|
|
158
|
-
const mapFileName = assetName.endsWith('.map') ? assetName : `${assetName}.map`;
|
|
159
|
-
sourceMapPath = resolve(outputPath, mapFileName);
|
|
160
|
-
}
|
|
161
|
-
try {
|
|
162
|
-
await collectSourceMaps(map, assetLinesCodeList, compilation, pluginInstance, sourceMapFilenameRegex, namespace, void 0, sourceMapPath);
|
|
163
|
-
} catch (e) {
|
|
164
|
-
logger.debug(e);
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
timeEnd('ensureModulesChunkGraph.afterEmit.start');
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
function parseAsset(asset, assets, type) {
|
|
171
|
-
const assetName = asset.source?.name || asset.name;
|
|
172
|
-
let assetContent = '';
|
|
173
|
-
let assetLinesCodeList = [];
|
|
174
|
-
let map = null;
|
|
175
|
-
try {
|
|
176
|
-
if ('map' === type && 'string' == typeof assetName && assetName.endsWith('.map') && !asset.name.includes('d.ts')) {
|
|
177
|
-
assetContent = asset.source?.source?.source?.() || '';
|
|
178
|
-
if (!assetContent) {
|
|
179
|
-
logger.debug(`Failed to get source content for asset: ${assetName}`);
|
|
180
|
-
return {
|
|
181
|
-
assetName,
|
|
182
|
-
assetContent: '',
|
|
183
|
-
assetLinesCodeList: [],
|
|
184
|
-
map: null
|
|
185
|
-
};
|
|
186
|
-
}
|
|
187
|
-
map = JSON.parse(assetContent);
|
|
188
|
-
if (!map || !map.file) {
|
|
189
|
-
logger.debug(`Failed to get source map file for asset: ${assetName}`);
|
|
190
|
-
return {
|
|
191
|
-
assetName,
|
|
192
|
-
assetContent,
|
|
193
|
-
assetLinesCodeList: [],
|
|
194
|
-
map: null
|
|
195
|
-
};
|
|
196
|
-
}
|
|
197
|
-
const bundledAsset = assets.find((asset2)=>asset2.source?.name === map?.file);
|
|
198
|
-
const bundledCode = bundledAsset?.source?.source?.source?.() || '';
|
|
199
|
-
if (!bundledCode) {
|
|
200
|
-
logger.debug(`Failed to get bundled code for asset: ${map.file}`);
|
|
201
|
-
return {
|
|
202
|
-
assetName,
|
|
203
|
-
assetContent,
|
|
204
|
-
assetLinesCodeList: [],
|
|
205
|
-
map
|
|
206
|
-
};
|
|
207
|
-
}
|
|
208
|
-
assetLinesCodeList = bundledCode.split(/\r?\n/);
|
|
209
|
-
} else if ('js/css' === type && (assetName.endsWith('.js') || assetName.endsWith('.bundle') || assetName.endsWith('.css'))) {
|
|
210
|
-
assetContent = asset.source?.source?.() || '';
|
|
211
|
-
assetLinesCodeList = assetContent.split(/\r?\n/);
|
|
212
|
-
map = asset.source?.sourceAndMap?.()?.map || null;
|
|
213
|
-
}
|
|
214
|
-
} catch (error) {
|
|
215
|
-
logger.debug(`Error parsing asset ${assetName}:`, error);
|
|
216
|
-
return {
|
|
217
|
-
assetName,
|
|
218
|
-
assetContent: '',
|
|
219
|
-
assetLinesCodeList: [],
|
|
220
|
-
map: null
|
|
221
|
-
};
|
|
222
|
-
}
|
|
223
|
-
return {
|
|
224
|
-
assetName,
|
|
225
|
-
assetContent,
|
|
226
|
-
assetLinesCodeList,
|
|
227
|
-
map
|
|
228
|
-
};
|
|
229
|
-
}
|
|
230
|
-
export { UNASSIGNED, bindContextCache, collectSourceMaps, handleAfterEmitAssets, handleEmitAssets };
|