@code-inspector/webpack 1.3.0 → 1.3.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/README.md +6 -1
- package/dist/index.mjs +89 -88
- package/dist/index.umd.js +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -391,4 +391,9 @@ For Chinese users, you can join the QQ group `769748484` or add the author's Wei
|
|
|
391
391
|
|
|
392
392
|
## 💖 Sponsor
|
|
393
393
|
|
|
394
|
-
Sponsoring this project can help the author create better. If you are willing,
|
|
394
|
+
Sponsoring this project can help the author create better. If you are willing, you can sponsor me through Alipay or WeChatPay:
|
|
395
|
+
|
|
396
|
+
<div style="display: flex; column-gap: 16px; row-gap: 16px; flex-wrap: wrap;">
|
|
397
|
+
<img src="https://cdn.jsdelivr.net/gh/zh-lx/static-img/code-inspector/wxpay.jpg" width="200" height="272" />
|
|
398
|
+
<img src="https://cdn.jsdelivr.net/gh/zh-lx/static-img/code-inspector/alipay.jpg" width="180" height="272" />
|
|
399
|
+
</div>
|
package/dist/index.mjs
CHANGED
|
@@ -1,167 +1,168 @@
|
|
|
1
1
|
var L = Object.defineProperty, N = Object.defineProperties;
|
|
2
2
|
var O = Object.getOwnPropertyDescriptors;
|
|
3
|
-
var
|
|
3
|
+
var C = Object.getOwnPropertySymbols;
|
|
4
4
|
var S = Object.prototype.hasOwnProperty, z = Object.prototype.propertyIsEnumerable;
|
|
5
|
-
var
|
|
6
|
-
for (var
|
|
7
|
-
S.call(t,
|
|
8
|
-
if (
|
|
9
|
-
for (var
|
|
10
|
-
z.call(t,
|
|
11
|
-
return
|
|
12
|
-
}, v = (
|
|
13
|
-
var
|
|
14
|
-
var
|
|
5
|
+
var W = (s, t, e) => t in s ? L(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e, d = (s, t) => {
|
|
6
|
+
for (var e in t || (t = {}))
|
|
7
|
+
S.call(t, e) && W(s, e, t[e]);
|
|
8
|
+
if (C)
|
|
9
|
+
for (var e of C(t))
|
|
10
|
+
z.call(t, e) && W(s, e, t[e]);
|
|
11
|
+
return s;
|
|
12
|
+
}, v = (s, t) => N(s, O(t));
|
|
13
|
+
var c = (s, t, e) => new Promise((n, a) => {
|
|
14
|
+
var r = (o) => {
|
|
15
15
|
try {
|
|
16
|
-
|
|
16
|
+
i(e.next(o));
|
|
17
17
|
} catch (f) {
|
|
18
|
-
|
|
18
|
+
a(f);
|
|
19
19
|
}
|
|
20
|
-
},
|
|
20
|
+
}, u = (o) => {
|
|
21
21
|
try {
|
|
22
|
-
|
|
22
|
+
i(e.throw(o));
|
|
23
23
|
} catch (f) {
|
|
24
|
-
|
|
24
|
+
a(f);
|
|
25
25
|
}
|
|
26
|
-
},
|
|
27
|
-
|
|
26
|
+
}, i = (o) => o.done ? n(o.value) : Promise.resolve(o.value).then(r, u);
|
|
27
|
+
i((e = e.apply(s, t)).next());
|
|
28
28
|
});
|
|
29
|
-
import { normalizePath as
|
|
30
|
-
import
|
|
31
|
-
function
|
|
32
|
-
return
|
|
33
|
-
if (!
|
|
29
|
+
import { normalizePath as _, fileURLToPath as I, isDev as R, getProjectRecord as F, isNextjsProject as H, getCodeWithWebComponent as Q } from "@code-inspector/core";
|
|
30
|
+
import j, { dirname as U } from "path";
|
|
31
|
+
function V(s, t) {
|
|
32
|
+
return c(this, null, function* () {
|
|
33
|
+
if (!s || !t)
|
|
34
34
|
return [];
|
|
35
|
-
const
|
|
35
|
+
const e = typeof s == "function" ? yield s() : s;
|
|
36
36
|
let n = [];
|
|
37
|
-
if (typeof
|
|
38
|
-
for (const
|
|
39
|
-
const
|
|
40
|
-
|
|
37
|
+
if (typeof e == "object" && !Array.isArray(e))
|
|
38
|
+
for (const a in e) {
|
|
39
|
+
const r = e[a], u = r.import || r;
|
|
40
|
+
$(n, u, t);
|
|
41
41
|
}
|
|
42
42
|
else
|
|
43
|
-
|
|
44
|
-
return n.filter((
|
|
43
|
+
$(n, e, t);
|
|
44
|
+
return n.filter((a) => !!a);
|
|
45
45
|
});
|
|
46
46
|
}
|
|
47
|
-
function
|
|
48
|
-
typeof t == "string" ?
|
|
49
|
-
...t.map((n) =>
|
|
47
|
+
function $(s, t, e) {
|
|
48
|
+
typeof t == "string" ? s.push(w(t, e)) : Array.isArray(t) && s.push(
|
|
49
|
+
...t.map((n) => w(n, e))
|
|
50
50
|
);
|
|
51
51
|
}
|
|
52
|
-
function
|
|
53
|
-
return
|
|
52
|
+
function w(s, t) {
|
|
53
|
+
return j.isAbsolute(s) ? _(s) : s.startsWith(".") ? j.resolve(t, _(s)) : "";
|
|
54
54
|
}
|
|
55
|
-
let
|
|
56
|
-
typeof __dirname != "undefined" ?
|
|
57
|
-
let
|
|
58
|
-
const
|
|
59
|
-
var
|
|
60
|
-
if (!
|
|
55
|
+
let p = "";
|
|
56
|
+
typeof __dirname != "undefined" ? p = __dirname : p = U(I(import.meta.url));
|
|
57
|
+
let P = !0;
|
|
58
|
+
const q = (s, t) => {
|
|
59
|
+
var r, u;
|
|
60
|
+
if (!P)
|
|
61
61
|
return;
|
|
62
|
-
|
|
63
|
-
const
|
|
62
|
+
P = !1;
|
|
63
|
+
const e = (t == null ? void 0 : t.compiler) || t, n = (r = e == null ? void 0 : e.options) == null ? void 0 : r.module;
|
|
64
64
|
((n == null ? void 0 : n.rules) || (n == null ? void 0 : n.loaders) || []).push(
|
|
65
|
-
|
|
66
|
-
test: (
|
|
65
|
+
d({
|
|
66
|
+
test: (u = s.match) != null ? u : /\.html$/,
|
|
67
67
|
resourceQuery: /vue/,
|
|
68
68
|
use: [
|
|
69
69
|
{
|
|
70
|
-
loader:
|
|
71
|
-
options:
|
|
70
|
+
loader: j.resolve(p, "./loader.js"),
|
|
71
|
+
options: s
|
|
72
72
|
}
|
|
73
73
|
]
|
|
74
|
-
},
|
|
75
|
-
|
|
74
|
+
}, s.enforcePre === !1 ? {} : { enforce: "pre" }),
|
|
75
|
+
d({
|
|
76
76
|
test: /\.(vue|jsx|tsx|js|ts|mjs|mts|svelte)$/,
|
|
77
77
|
use: [
|
|
78
78
|
{
|
|
79
|
-
loader:
|
|
80
|
-
options:
|
|
79
|
+
loader: j.resolve(p, "./loader.js"),
|
|
80
|
+
options: s
|
|
81
81
|
}
|
|
82
82
|
]
|
|
83
|
-
},
|
|
84
|
-
v(
|
|
83
|
+
}, s.enforcePre === !1 ? {} : { enforce: "pre" }),
|
|
84
|
+
v(d({}, s.injectTo ? { resource: s.injectTo } : {
|
|
85
85
|
test: /\.(jsx|tsx|js|ts|mjs|mts)$/,
|
|
86
86
|
exclude: /node_modules/
|
|
87
87
|
}), {
|
|
88
88
|
use: [
|
|
89
89
|
{
|
|
90
|
-
loader:
|
|
91
|
-
options:
|
|
90
|
+
loader: j.resolve(p, "./inject-loader.js"),
|
|
91
|
+
options: s
|
|
92
92
|
}
|
|
93
93
|
],
|
|
94
94
|
enforce: H() ? "pre" : "post"
|
|
95
95
|
})
|
|
96
96
|
);
|
|
97
97
|
};
|
|
98
|
-
function
|
|
98
|
+
function D(s, t, e) {
|
|
99
99
|
return Q({
|
|
100
|
-
options: v(
|
|
100
|
+
options: v(d({}, s), { importClient: "code" }),
|
|
101
101
|
file: "main.js",
|
|
102
102
|
code: "",
|
|
103
103
|
record: t,
|
|
104
|
-
inject: !0
|
|
104
|
+
inject: !0,
|
|
105
|
+
server: e
|
|
105
106
|
});
|
|
106
107
|
}
|
|
107
|
-
function
|
|
108
|
-
return
|
|
109
|
-
options:
|
|
108
|
+
function B(n) {
|
|
109
|
+
return c(this, arguments, function* ({
|
|
110
|
+
options: s,
|
|
110
111
|
record: t,
|
|
111
|
-
assets:
|
|
112
|
+
assets: e
|
|
112
113
|
}) {
|
|
113
|
-
const
|
|
114
|
-
if (
|
|
115
|
-
const
|
|
116
|
-
|
|
114
|
+
const a = Object.keys(e).filter((r) => /\.html$/.test(r));
|
|
115
|
+
if (a.length) {
|
|
116
|
+
const r = yield D(s, t);
|
|
117
|
+
a.forEach((u) => {
|
|
117
118
|
var o, f;
|
|
118
|
-
const
|
|
119
|
-
if (typeof
|
|
120
|
-
const
|
|
119
|
+
const i = (f = (o = e[u]) == null ? void 0 : o.source) == null ? void 0 : f.call(o);
|
|
120
|
+
if (typeof i == "string") {
|
|
121
|
+
const h = i.replace(
|
|
121
122
|
"<head>",
|
|
122
|
-
'<head><script type="module">\n'.concat(
|
|
123
|
+
'<head><script type="module">\n'.concat(r, "\n<\/script>")
|
|
123
124
|
);
|
|
124
|
-
|
|
125
|
-
source: () =>
|
|
126
|
-
size: () =>
|
|
125
|
+
e[u] = {
|
|
126
|
+
source: () => h,
|
|
127
|
+
size: () => h.length
|
|
127
128
|
};
|
|
128
129
|
}
|
|
129
130
|
});
|
|
130
131
|
}
|
|
131
132
|
});
|
|
132
133
|
}
|
|
133
|
-
class
|
|
134
|
+
class M {
|
|
134
135
|
constructor(t) {
|
|
135
136
|
this.options = t;
|
|
136
137
|
}
|
|
137
138
|
apply(t) {
|
|
138
|
-
return
|
|
139
|
-
var
|
|
140
|
-
if (
|
|
139
|
+
return c(this, null, function* () {
|
|
140
|
+
var a, r, u, i, o, f, h, b, k, A, y, x;
|
|
141
|
+
if (P = !0, this.options.close || !R(
|
|
141
142
|
this.options.dev,
|
|
142
|
-
((
|
|
143
|
+
((a = t == null ? void 0 : t.options) == null ? void 0 : a.mode) === "development" || process.env.NODE_ENV === "development"
|
|
143
144
|
))
|
|
144
145
|
return;
|
|
145
|
-
const
|
|
146
|
+
const e = {
|
|
146
147
|
port: 0,
|
|
147
148
|
entry: "",
|
|
148
149
|
output: this.options.output,
|
|
149
|
-
inputs:
|
|
150
|
+
inputs: V(
|
|
150
151
|
(r = t == null ? void 0 : t.options) == null ? void 0 : r.entry,
|
|
151
|
-
(
|
|
152
|
+
(u = t == null ? void 0 : t.options) == null ? void 0 : u.context
|
|
152
153
|
),
|
|
153
154
|
envDir: (i = t == null ? void 0 : t.options) == null ? void 0 : i.context,
|
|
154
|
-
root: (
|
|
155
|
-
};
|
|
156
|
-
if ((
|
|
155
|
+
root: (o = t == null ? void 0 : t.options) == null ? void 0 : o.context
|
|
156
|
+
}, n = ((f = t == null ? void 0 : t.options) == null ? void 0 : f.cache) || ((b = (h = t == null ? void 0 : t.options) == null ? void 0 : h.experiments) == null ? void 0 : b.cache);
|
|
157
|
+
if ((n == null ? void 0 : n.type) === "filesystem" && (this.options.cache ? (e.port = this.options.port || ((k = F(e)) == null ? void 0 : k.previousPort), D(this.options, e, !0)) : n.version = "code-inspector-".concat(Date.now())), q(v(d({}, this.options), { record: e }), t), (A = t == null ? void 0 : t.hooks) != null && A.emit && !((x = (y = this.options.skipSnippets) == null ? void 0 : y.includes) != null && x.call(y, "htmlScript"))) {
|
|
157
158
|
const E = this.options;
|
|
158
159
|
t.hooks.emit.tapAsync(
|
|
159
160
|
"WebpackCodeInspectorPlugin",
|
|
160
|
-
(g, T) =>
|
|
161
|
+
(g, T) => c(this, null, function* () {
|
|
161
162
|
let l = {};
|
|
162
|
-
g.getAssets ? l = yield g.getAssets() : l = g.assets, yield
|
|
163
|
+
g.getAssets ? l = yield g.getAssets() : l = g.assets, yield B({
|
|
163
164
|
options: E,
|
|
164
|
-
record:
|
|
165
|
+
record: e,
|
|
165
166
|
assets: l
|
|
166
167
|
}), T();
|
|
167
168
|
})
|
|
@@ -171,5 +172,5 @@ class K {
|
|
|
171
172
|
}
|
|
172
173
|
}
|
|
173
174
|
export {
|
|
174
|
-
|
|
175
|
+
M as default
|
|
175
176
|
};
|
package/dist/index.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(n
|
|
1
|
+
(function(s,n){typeof exports=="object"&&typeof module!="undefined"?module.exports=n(require("@code-inspector/core"),require("path")):typeof define=="function"&&define.amd?define(["@code-inspector/core","path"],n):(s=typeof globalThis!="undefined"?globalThis:s||self,s.WebpackCodeInspectorPlugin=n(s.core,s.path))})(this,function(s,n){"use strict";var q=Object.defineProperty,z=Object.defineProperties;var N=Object.getOwnPropertyDescriptors;var L=Object.getOwnPropertySymbols;var O=Object.prototype.hasOwnProperty,F=Object.prototype.propertyIsEnumerable;var R=(s,n,r)=>n in s?q(s,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):s[n]=r,j=(s,n)=>{for(var r in n||(n={}))O.call(n,r)&&R(s,r,n[r]);if(L)for(var r of L(n))F.call(n,r)&&R(s,r,n[r]);return s},C=(s,n)=>z(s,N(n));var b=(s,n,r)=>new Promise((A,l)=>{var k=a=>{try{h(r.next(a))}catch(y){l(y)}},c=a=>{try{h(r.throw(a))}catch(y){l(y)}},h=a=>a.done?A(a.value):Promise.resolve(a.value).then(k,c);h((r=r.apply(s,n)).next())});var r=typeof document!="undefined"?document.currentScript:null;function A(t,e){return b(this,null,function*(){if(!t||!e)return[];const o=typeof t=="function"?yield t():t;let u=[];if(typeof o=="object"&&!Array.isArray(o))for(const f in o){const i=o[f],d=i.import||i;l(u,d,e)}else l(u,o,e);return u.filter(f=>!!f)})}function l(t,e,o){typeof e=="string"?t.push(k(e,o)):Array.isArray(e)&&t.push(...e.map(u=>k(u,o)))}function k(t,e){return n.isAbsolute(t)?s.normalizePath(t):t.startsWith(".")?n.resolve(e,s.normalizePath(t)):""}let c="";typeof __dirname!="undefined"?c=__dirname:c=n.dirname(s.fileURLToPath(typeof document=="undefined"&&typeof location=="undefined"?require("url").pathToFileURL(__filename).href:typeof document=="undefined"?location.href:r&&r.src||new URL("index.umd.js",document.baseURI).href));let h=!0;const a=(t,e)=>{var i,d;if(!h)return;h=!1;const o=(e==null?void 0:e.compiler)||e,u=(i=o==null?void 0:o.options)==null?void 0:i.module;((u==null?void 0:u.rules)||(u==null?void 0:u.loaders)||[]).push(j({test:(d=t.match)!=null?d:/\.html$/,resourceQuery:/vue/,use:[{loader:n.resolve(c,"./loader.js"),options:t}]},t.enforcePre===!1?{}:{enforce:"pre"}),j({test:/\.(vue|jsx|tsx|js|ts|mjs|mts|svelte)$/,use:[{loader:n.resolve(c,"./loader.js"),options:t}]},t.enforcePre===!1?{}:{enforce:"pre"}),C(j({},t.injectTo?{resource:t.injectTo}:{test:/\.(jsx|tsx|js|ts|mjs|mts)$/,exclude:/node_modules/}),{use:[{loader:n.resolve(c,"./inject-loader.js"),options:t}],enforce:s.isNextjsProject()?"pre":"post"}))};function y(t,e,o){return s.getCodeWithWebComponent({options:C(j({},t),{importClient:"code"}),file:"main.js",code:"",record:e,inject:!0,server:o})}function S(u){return b(this,arguments,function*({options:t,record:e,assets:o}){const f=Object.keys(o).filter(i=>/\.html$/.test(i));if(f.length){const i=yield y(t,e);f.forEach(d=>{var p,P;const v=(P=(p=o[d])==null?void 0:p.source)==null?void 0:P.call(p);if(typeof v=="string"){const g=v.replace("<head>",'<head><script type="module">\n'.concat(i,"\n<\/script>"));o[d]={source:()=>g,size:()=>g.length}}})}})}class E{constructor(e){this.options=e}apply(e){return b(this,null,function*(){var f,i,d,v,p,P,g,W,w,$,x,D;if(h=!0,this.options.close||!s.isDev(this.options.dev,((f=e==null?void 0:e.options)==null?void 0:f.mode)==="development"||process.env.NODE_ENV==="development"))return;const o={port:0,entry:"",output:this.options.output,inputs:A((i=e==null?void 0:e.options)==null?void 0:i.entry,(d=e==null?void 0:e.options)==null?void 0:d.context),envDir:(v=e==null?void 0:e.options)==null?void 0:v.context,root:(p=e==null?void 0:e.options)==null?void 0:p.context},u=((P=e==null?void 0:e.options)==null?void 0:P.cache)||((W=(g=e==null?void 0:e.options)==null?void 0:g.experiments)==null?void 0:W.cache);if((u==null?void 0:u.type)==="filesystem"&&(this.options.cache?(o.port=this.options.port||((w=s.getProjectRecord(o))==null?void 0:w.previousPort),y(this.options,o,!0)):u.version="code-inspector-".concat(Date.now())),a(C(j({},this.options),{record:o}),e),($=e==null?void 0:e.hooks)!=null&&$.emit&&!((D=(x=this.options.skipSnippets)==null?void 0:x.includes)!=null&&D.call(x,"htmlScript"))){const I=this.options;e.hooks.emit.tapAsync("WebpackCodeInspectorPlugin",(_,U)=>b(this,null,function*(){let T={};_.getAssets?T=yield _.getAssets():T=_.assets,yield S({options:I,record:o,assets:T}),U()}))}})}}return E});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@code-inspector/webpack",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.2",
|
|
4
4
|
"main": "./dist/index.umd.js",
|
|
5
5
|
"module": "./dist/index.mjs",
|
|
6
6
|
"typings": "./types/index.d.ts",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"url": "https://github.com/zh-lx/code-inspector/issues"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@code-inspector/core": "1.3.
|
|
43
|
+
"@code-inspector/core": "1.3.2"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@types/node": "^20.3.3",
|