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