@code-inspector/webpack 1.4.5 → 1.5.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/index.mjs +111 -104
- package/dist/index.umd.js +1 -1
- package/dist/loader.js +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -1,170 +1,177 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
1
|
+
var N = Object.defineProperty, O = Object.defineProperties;
|
|
2
|
+
var R = Object.getOwnPropertyDescriptors;
|
|
3
|
+
var x = Object.getOwnPropertySymbols;
|
|
4
4
|
var S = Object.prototype.hasOwnProperty, z = Object.prototype.propertyIsEnumerable;
|
|
5
|
-
var W = (
|
|
6
|
-
for (var
|
|
7
|
-
S.call(t,
|
|
8
|
-
if (
|
|
9
|
-
for (var
|
|
10
|
-
z.call(t,
|
|
11
|
-
return
|
|
12
|
-
},
|
|
13
|
-
var
|
|
14
|
-
var
|
|
5
|
+
var W = (e, t, s) => t in e ? N(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s, c = (e, t) => {
|
|
6
|
+
for (var s in t || (t = {}))
|
|
7
|
+
S.call(t, s) && W(e, s, t[s]);
|
|
8
|
+
if (x)
|
|
9
|
+
for (var s of x(t))
|
|
10
|
+
z.call(t, s) && W(e, s, t[s]);
|
|
11
|
+
return e;
|
|
12
|
+
}, y = (e, t) => O(e, R(t));
|
|
13
|
+
var h = (e, t, s) => new Promise((o, n) => {
|
|
14
|
+
var a = (r) => {
|
|
15
15
|
try {
|
|
16
|
-
|
|
17
|
-
} catch (
|
|
18
|
-
|
|
16
|
+
f(s.next(r));
|
|
17
|
+
} catch (i) {
|
|
18
|
+
n(i);
|
|
19
19
|
}
|
|
20
|
-
}, u = (
|
|
20
|
+
}, u = (r) => {
|
|
21
21
|
try {
|
|
22
|
-
|
|
23
|
-
} catch (
|
|
24
|
-
|
|
22
|
+
f(s.throw(r));
|
|
23
|
+
} catch (i) {
|
|
24
|
+
n(i);
|
|
25
25
|
}
|
|
26
|
-
},
|
|
27
|
-
|
|
26
|
+
}, f = (r) => r.done ? o(r.value) : Promise.resolve(r.value).then(a, u);
|
|
27
|
+
f((s = s.apply(e, t)).next());
|
|
28
28
|
});
|
|
29
|
-
import { normalizePath as
|
|
30
|
-
import j
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
29
|
+
import { normalizePath as $, isDev as _, getProjectRecord as H, isNextjsProject as Q, getCodeWithWebComponent as U } from "@code-inspector/core";
|
|
30
|
+
import j from "path";
|
|
31
|
+
import { fileURLToPath as V } from "url";
|
|
32
|
+
function q(e, t) {
|
|
33
|
+
return h(this, null, function* () {
|
|
34
|
+
if (!e || !t)
|
|
34
35
|
return [];
|
|
35
|
-
const
|
|
36
|
-
let
|
|
37
|
-
if (typeof
|
|
38
|
-
for (const
|
|
39
|
-
const
|
|
40
|
-
|
|
36
|
+
const s = typeof e == "function" ? yield e() : e;
|
|
37
|
+
let o = [];
|
|
38
|
+
if (typeof s == "object" && !Array.isArray(s))
|
|
39
|
+
for (const n in s) {
|
|
40
|
+
const a = s[n], u = a.import || a;
|
|
41
|
+
w(o, u, t);
|
|
41
42
|
}
|
|
42
43
|
else
|
|
43
|
-
|
|
44
|
-
return
|
|
44
|
+
w(o, s, t);
|
|
45
|
+
return o.filter((n) => !!n);
|
|
45
46
|
});
|
|
46
47
|
}
|
|
47
|
-
function
|
|
48
|
-
typeof t == "string" ?
|
|
49
|
-
...t.map((
|
|
48
|
+
function w(e, t, s) {
|
|
49
|
+
typeof t == "string" ? e.push(D(t, s)) : Array.isArray(t) && e.push(
|
|
50
|
+
...t.map((o) => D(o, s))
|
|
50
51
|
);
|
|
51
52
|
}
|
|
52
|
-
function
|
|
53
|
-
return j.isAbsolute(
|
|
53
|
+
function D(e, t) {
|
|
54
|
+
return j.isAbsolute(e) ? $(e) : e.startsWith(".") ? j.resolve(t, $(e)) : "";
|
|
54
55
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
56
|
+
const L = j.dirname(V(import.meta.url)), P = j.resolve(L, "./loader.js"), E = j.resolve(L, "./inject-loader.js");
|
|
57
|
+
function B(e) {
|
|
58
|
+
return e.some(
|
|
59
|
+
(t) => {
|
|
60
|
+
var s, o;
|
|
61
|
+
return (o = (s = t == null ? void 0 : t.use) == null ? void 0 : s.some) == null ? void 0 : o.call(
|
|
62
|
+
s,
|
|
63
|
+
(n) => (n == null ? void 0 : n.loader) === P || (n == null ? void 0 : n.loader) === E
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
const F = (e, t) => {
|
|
69
|
+
var a, u;
|
|
70
|
+
const s = (t == null ? void 0 : t.compiler) || t, o = (a = s == null ? void 0 : s.options) == null ? void 0 : a.module, n = (o == null ? void 0 : o.rules) || (o == null ? void 0 : o.loaders) || [];
|
|
71
|
+
B(n) || n.push(
|
|
72
|
+
c({
|
|
73
|
+
test: (u = e.match) != null ? u : /\.html$/,
|
|
67
74
|
resourceQuery: /vue/,
|
|
68
75
|
use: [
|
|
69
76
|
{
|
|
70
|
-
loader:
|
|
71
|
-
options:
|
|
77
|
+
loader: P,
|
|
78
|
+
options: e
|
|
72
79
|
}
|
|
73
80
|
]
|
|
74
|
-
},
|
|
75
|
-
|
|
81
|
+
}, e.enforcePre === !1 ? {} : { enforce: "pre" }),
|
|
82
|
+
c({
|
|
76
83
|
test: /\.(vue|jsx|tsx|js|ts|mjs|mts|svelte)$/,
|
|
77
84
|
use: [
|
|
78
85
|
{
|
|
79
|
-
loader:
|
|
80
|
-
options:
|
|
86
|
+
loader: P,
|
|
87
|
+
options: e
|
|
81
88
|
}
|
|
82
89
|
]
|
|
83
|
-
},
|
|
84
|
-
|
|
90
|
+
}, e.enforcePre === !1 ? {} : { enforce: "pre" }),
|
|
91
|
+
y(c({}, e.injectTo ? { resource: e.injectTo } : {
|
|
85
92
|
test: /\.(jsx|tsx|js|ts|mjs|mts)$/,
|
|
86
93
|
exclude: /node_modules/
|
|
87
94
|
}), {
|
|
88
95
|
use: [
|
|
89
96
|
{
|
|
90
|
-
loader:
|
|
91
|
-
options:
|
|
97
|
+
loader: E,
|
|
98
|
+
options: e
|
|
92
99
|
}
|
|
93
100
|
],
|
|
94
|
-
enforce:
|
|
101
|
+
enforce: Q() ? "pre" : "post"
|
|
95
102
|
})
|
|
96
103
|
);
|
|
97
104
|
};
|
|
98
|
-
function
|
|
99
|
-
return
|
|
100
|
-
options:
|
|
105
|
+
function T(e, t, s) {
|
|
106
|
+
return U({
|
|
107
|
+
options: y(c({}, e), { importClient: "code" }),
|
|
101
108
|
file: "main.js",
|
|
102
109
|
code: "",
|
|
103
110
|
record: t,
|
|
104
111
|
inject: !0,
|
|
105
|
-
server:
|
|
112
|
+
server: s
|
|
106
113
|
});
|
|
107
114
|
}
|
|
108
|
-
function
|
|
109
|
-
return
|
|
110
|
-
options:
|
|
115
|
+
function G(o) {
|
|
116
|
+
return h(this, arguments, function* ({
|
|
117
|
+
options: e,
|
|
111
118
|
record: t,
|
|
112
|
-
assets:
|
|
119
|
+
assets: s
|
|
113
120
|
}) {
|
|
114
|
-
const
|
|
115
|
-
if (
|
|
116
|
-
const
|
|
117
|
-
|
|
118
|
-
var
|
|
119
|
-
const
|
|
120
|
-
if (typeof
|
|
121
|
-
const
|
|
121
|
+
const n = Object.keys(s).filter((a) => /\.html$/.test(a));
|
|
122
|
+
if (n.length) {
|
|
123
|
+
const a = yield T(e, t);
|
|
124
|
+
n.forEach((u) => {
|
|
125
|
+
var r, i;
|
|
126
|
+
const f = (i = (r = s[u]) == null ? void 0 : r.source) == null ? void 0 : i.call(r);
|
|
127
|
+
if (typeof f == "string") {
|
|
128
|
+
const d = f.replace(
|
|
122
129
|
"<head>",
|
|
123
|
-
'<head><script type="module">\n'.concat(
|
|
130
|
+
'<head><script type="module">\n'.concat(a, "\n<\/script>")
|
|
124
131
|
);
|
|
125
|
-
|
|
126
|
-
source: () =>
|
|
127
|
-
size: () =>
|
|
132
|
+
s[u] = {
|
|
133
|
+
source: () => d,
|
|
134
|
+
size: () => d.length
|
|
128
135
|
};
|
|
129
136
|
}
|
|
130
137
|
});
|
|
131
138
|
}
|
|
132
139
|
});
|
|
133
140
|
}
|
|
134
|
-
class
|
|
141
|
+
class Y {
|
|
135
142
|
constructor(t) {
|
|
136
143
|
this.options = t;
|
|
137
144
|
}
|
|
138
145
|
apply(t) {
|
|
139
|
-
return
|
|
140
|
-
var
|
|
141
|
-
if (
|
|
146
|
+
return h(this, null, function* () {
|
|
147
|
+
var n, a, u, f, r, i, d, b, k, A, p, C;
|
|
148
|
+
if (this.options.close || !_(
|
|
142
149
|
this.options.dev,
|
|
143
|
-
((
|
|
150
|
+
((n = t == null ? void 0 : t.options) == null ? void 0 : n.mode) === "development" || process.env.NODE_ENV === "development"
|
|
144
151
|
))
|
|
145
152
|
return;
|
|
146
|
-
const
|
|
153
|
+
const s = {
|
|
147
154
|
port: 0,
|
|
148
155
|
entry: "",
|
|
149
156
|
output: this.options.output,
|
|
150
|
-
inputs:
|
|
151
|
-
(
|
|
157
|
+
inputs: q(
|
|
158
|
+
(a = t == null ? void 0 : t.options) == null ? void 0 : a.entry,
|
|
152
159
|
(u = t == null ? void 0 : t.options) == null ? void 0 : u.context
|
|
153
160
|
),
|
|
154
|
-
envDir: (
|
|
155
|
-
root: (
|
|
156
|
-
},
|
|
157
|
-
if ((
|
|
158
|
-
const
|
|
161
|
+
envDir: (f = t == null ? void 0 : t.options) == null ? void 0 : f.context,
|
|
162
|
+
root: (r = t == null ? void 0 : t.options) == null ? void 0 : r.context
|
|
163
|
+
}, o = ((i = t == null ? void 0 : t.options) == null ? void 0 : i.cache) || ((b = (d = t == null ? void 0 : t.options) == null ? void 0 : d.experiments) == null ? void 0 : b.cache);
|
|
164
|
+
if ((o == null ? void 0 : o.type) === "filesystem" && (this.options.cache ? (s.port = this.options.port || ((k = H(s)) == null ? void 0 : k.previousPort), T(this.options, s, !0)) : o.version = "code-inspector-".concat(Date.now())), F(y(c({}, this.options), { record: s }), t), (A = t == null ? void 0 : t.hooks) != null && A.emit && !((C = (p = this.options.skipSnippets) == null ? void 0 : p.includes) != null && C.call(p, "htmlScript"))) {
|
|
165
|
+
const l = this.options;
|
|
159
166
|
t.hooks.emit.tapAsync(
|
|
160
167
|
"WebpackCodeInspectorPlugin",
|
|
161
|
-
(
|
|
162
|
-
let
|
|
163
|
-
|
|
164
|
-
options:
|
|
165
|
-
record:
|
|
166
|
-
assets:
|
|
167
|
-
}),
|
|
168
|
+
(v, I) => h(this, null, function* () {
|
|
169
|
+
let g = {};
|
|
170
|
+
v.getAssets ? g = yield v.getAssets() : g = v.assets, yield G({
|
|
171
|
+
options: l,
|
|
172
|
+
record: s,
|
|
173
|
+
assets: g
|
|
174
|
+
}), I();
|
|
168
175
|
})
|
|
169
176
|
);
|
|
170
177
|
}
|
|
@@ -172,5 +179,5 @@ class M {
|
|
|
172
179
|
}
|
|
173
180
|
}
|
|
174
181
|
export {
|
|
175
|
-
|
|
182
|
+
Y as default
|
|
176
183
|
};
|
package/dist/index.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(n,o){typeof exports=="object"&&typeof module!="undefined"?module.exports=o(require("@code-inspector/core"),require("path"),require("url")):typeof define=="function"&&define.amd?define(["@code-inspector/core","path","url"],o):(n=typeof globalThis!="undefined"?globalThis:n||self,n.WebpackCodeInspectorPlugin=o(n.core,n.path,n.url))})(this,function(n,o,i){"use strict";var O=Object.defineProperty,F=Object.defineProperties;var H=Object.getOwnPropertyDescriptors;var I=Object.getOwnPropertySymbols;var Q=Object.prototype.hasOwnProperty,V=Object.prototype.propertyIsEnumerable;var S=(n,o,i)=>o in n?O(n,o,{enumerable:!0,configurable:!0,writable:!0,value:i}):n[o]=i,y=(n,o)=>{for(var i in o||(o={}))Q.call(o,i)&&S(n,i,o[i]);if(I)for(var i of I(o))V.call(o,i)&&S(n,i,o[i]);return n},A=(n,o)=>F(n,H(o));var g=(n,o,i)=>new Promise((b,C)=>{var k=f=>{try{h(i.next(f))}catch(p){C(p)}},l=f=>{try{h(i.throw(f))}catch(p){C(p)}},h=f=>f.done?b(f.value):Promise.resolve(f.value).then(k,l);h((i=i.apply(n,o)).next())});var b=typeof document!="undefined"?document.currentScript:null;function C(s,e){return g(this,null,function*(){if(!s||!e)return[];const t=typeof s=="function"?yield s():s;let r=[];if(typeof t=="object"&&!Array.isArray(t))for(const u in t){const d=t[u],a=d.import||d;k(r,a,e)}else k(r,t,e);return r.filter(u=>!!u)})}function k(s,e,t){typeof e=="string"?s.push(l(e,t)):Array.isArray(e)&&s.push(...e.map(r=>l(r,t)))}function l(s,e){return o.isAbsolute(s)?n.normalizePath(s):s.startsWith(".")?o.resolve(e,n.normalizePath(s)):""}const h=o.dirname(i.fileURLToPath(typeof document=="undefined"&&typeof location=="undefined"?require("url").pathToFileURL(__filename).href:typeof document=="undefined"?location.href:b&&b.src||new URL("index.umd.js",document.baseURI).href)),f=o.resolve(h,"./loader.js"),p=o.resolve(h,"./inject-loader.js");function _(s){return s.some(e=>{var t,r;return(r=(t=e==null?void 0:e.use)==null?void 0:t.some)==null?void 0:r.call(t,u=>(u==null?void 0:u.loader)===f||(u==null?void 0:u.loader)===p)})}const q=(s,e)=>{var d,a;const t=(e==null?void 0:e.compiler)||e,r=(d=t==null?void 0:t.options)==null?void 0:d.module,u=(r==null?void 0:r.rules)||(r==null?void 0:r.loaders)||[];_(u)||u.push(y({test:(a=s.match)!=null?a:/\.html$/,resourceQuery:/vue/,use:[{loader:f,options:s}]},s.enforcePre===!1?{}:{enforce:"pre"}),y({test:/\.(vue|jsx|tsx|js|ts|mjs|mts|svelte)$/,use:[{loader:f,options:s}]},s.enforcePre===!1?{}:{enforce:"pre"}),A(y({},s.injectTo?{resource:s.injectTo}:{test:/\.(jsx|tsx|js|ts|mjs|mts)$/,exclude:/node_modules/}),{use:[{loader:p,options:s}],enforce:n.isNextjsProject()?"pre":"post"}))};function W(s,e,t){return n.getCodeWithWebComponent({options:A(y({},s),{importClient:"code"}),file:"main.js",code:"",record:e,inject:!0,server:t})}function E(r){return g(this,arguments,function*({options:s,record:e,assets:t}){const u=Object.keys(t).filter(d=>/\.html$/.test(d));if(u.length){const d=yield W(s,e);u.forEach(a=>{var c,v;const j=(v=(c=t[a])==null?void 0:c.source)==null?void 0:v.call(c);if(typeof j=="string"){const P=j.replace("<head>",'<head><script type="module">\n'.concat(d,"\n<\/script>"));t[a]={source:()=>P,size:()=>P.length}}})}})}class U{constructor(e){this.options=e}apply(e){return g(this,null,function*(){var u,d,a,j,c,v,P,w,R,$,x,D;if(this.options.close||!n.isDev(this.options.dev,((u=e==null?void 0:e.options)==null?void 0:u.mode)==="development"||process.env.NODE_ENV==="development"))return;const t={port:0,entry:"",output:this.options.output,inputs:C((d=e==null?void 0:e.options)==null?void 0:d.entry,(a=e==null?void 0:e.options)==null?void 0:a.context),envDir:(j=e==null?void 0:e.options)==null?void 0:j.context,root:(c=e==null?void 0:e.options)==null?void 0:c.context},r=((v=e==null?void 0:e.options)==null?void 0:v.cache)||((w=(P=e==null?void 0:e.options)==null?void 0:P.experiments)==null?void 0:w.cache);if((r==null?void 0:r.type)==="filesystem"&&(this.options.cache?(t.port=this.options.port||((R=n.getProjectRecord(t))==null?void 0:R.previousPort),W(this.options,t,!0)):r.version="code-inspector-".concat(Date.now())),q(A(y({},this.options),{record:t}),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 z=this.options;e.hooks.emit.tapAsync("WebpackCodeInspectorPlugin",(L,N)=>g(this,null,function*(){let T={};L.getAssets?T=yield L.getAssets():T=L.assets,yield E({options:z,record:t,assets:T}),N()}))}})}}return U});
|
package/dist/loader.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var T=(s,e,t)=>new Promise((r,p)=>{var o=i=>{try{c(t.next(i))}catch(n){p(n)}},u=i=>{try{c(t.throw(i))}catch(n){p(n)}},c=i=>i.done?r(i.value):Promise.resolve(i.value).then(o,u);c((t=t.apply(s,e)).next())});const a=require("@code-inspector/core"),x=["isJsx","isTsx","lang.jsx","lang.tsx"];function S(s){return T(this,null,function*(){var f,y,g;this.cacheable&&this.cacheable(!0);let e=a.normalizePath(this.resourcePath),t=new URLSearchParams(((f=this.resource.split("?"))==null?void 0:f[1])||"");const r=this.query;let{escapeTags:p=[],mappings:o}=r
|
|
1
|
+
"use strict";var T=(s,e,t)=>new Promise((r,p)=>{var o=i=>{try{c(t.next(i))}catch(n){p(n)}},u=i=>{try{c(t.throw(i))}catch(n){p(n)}},c=i=>i.done?r(i.value):Promise.resolve(i.value).then(o,u);c((t=t.apply(s,e)).next())});const a=require("@code-inspector/core"),x=["isJsx","isTsx","lang.jsx","lang.tsx"];function S(s){return T(this,null,function*(){var f,y,g;this.cacheable&&this.cacheable(!0);let e=a.normalizePath(this.resourcePath),t=new URLSearchParams(((f=this.resource.split("?"))==null?void 0:f[1])||"");const r=this.query||{};let{escapeTags:p=[],mappings:o}=r;if(a.isExcludedFile(e,r))return s;if(e=a.getMappingFilePath(e,o),a.isJsTypeFile(e)||e.endsWith(".vue")&&x.some(l=>t.get(l)!==null))return yield a.transformCode({content:s,filePath:e,fileType:"jsx",escapeTags:p,pathType:r.pathType});if(e.endsWith(".vue")&&(t.get("lang")==="tsx"||t.get("lang")==="jsx")){const{descriptor:l}=a.parseSFC(s,{sourceMap:!1}),d=[(y=l.script)==null?void 0:y.content,(g=l.scriptSetup)==null?void 0:g.content];for(const h of d){if(!h)continue;const m=yield a.transformCode({content:h,filePath:e,fileType:"jsx",escapeTags:p,pathType:r.pathType});s=s.replace(h,()=>m)}return s}const i=e.endsWith(".vue")&&t.get("type")!=="style"&&t.get("type")!=="script"&&t.get("raw")===null,n=e.endsWith(".html")&&t.get("type")==="template"&&t.has("vue");return i||n?yield a.transformCode({content:s,filePath:e,fileType:"vue",escapeTags:p,pathType:r.pathType}):e.endsWith(".svelte")?yield a.transformCode({content:s,filePath:e,fileType:"svelte",escapeTags:p,pathType:r.pathType}):s})}module.exports=S;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@code-inspector/webpack",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
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.
|
|
43
|
+
"@code-inspector/core": "1.5.0"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@types/node": "^20.3.3",
|