code-inspector-plugin 1.0.5 → 1.1.1-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/README.md +107 -84
- package/dist/index.js +1 -1
- package/dist/index.mjs +133 -85
- package/package.json +7 -6
- package/types/index.d.ts +1 -6
package/README.md
CHANGED
|
@@ -42,17 +42,16 @@ The following are which compilers, web frameworks and editors we supported now:
|
|
|
42
42
|
✅ rspack / rsbuild<br />
|
|
43
43
|
✅ farm<br />
|
|
44
44
|
✅ esbuild<br />
|
|
45
|
-
✅ turbopack
|
|
46
|
-
✅
|
|
45
|
+
✅ turbopack<br />
|
|
46
|
+
✅ mako<br />
|
|
47
47
|
- The following Web frameworks are currently supported:<br />
|
|
48
|
-
✅ vue2<br />
|
|
49
|
-
✅
|
|
50
|
-
✅ react<br />
|
|
48
|
+
✅ vue2 / vue3 / nuxt<br />
|
|
49
|
+
✅ react / nextjs / umijs<br />
|
|
51
50
|
✅ preact<br />
|
|
52
51
|
✅ solid<br />
|
|
53
52
|
✅ qwik<br />
|
|
54
53
|
✅ svelte<br />
|
|
55
|
-
✅ astro
|
|
54
|
+
✅ astro<br />
|
|
56
55
|
- The following code editors are currently supported:<br />
|
|
57
56
|
[VSCode](https://code.visualstudio.com/) | [Cursor](https://www.cursor.com/) | [Windsurf](https://codeium.com/windsurf) | [WebStorm](https://www.jetbrains.com/webstorm/) | [Atom](https://atom.io/) | [HBuilderX](https://www.dcloud.io/hbuilderx.html) | [PhpStorm](https://www.jetbrains.com/phpstorm/) | [PyCharm](https://www.jetbrains.com/pycharm/) | [IntelliJ IDEA](https://www.jetbrains.com/idea/) | [and Others](https://inspector.fe-dev.cn/en/guide/ide.html)
|
|
58
57
|
|
|
@@ -213,112 +212,136 @@ Please check here for more usage information: [code-inspector-plugin configurati
|
|
|
213
212
|
<details>
|
|
214
213
|
<summary>Click to expand configuration about: <b>nuxt</b></summary>
|
|
215
214
|
|
|
216
|
-
For nuxt3.x :
|
|
215
|
+
- For nuxt3.x :
|
|
217
216
|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
217
|
+
```js
|
|
218
|
+
// nuxt.config.js
|
|
219
|
+
import { codeInspectorPlugin } from 'code-inspector-plugin';
|
|
221
220
|
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
221
|
+
// https://nuxt.com/docs/api/configuration/nuxt-config
|
|
222
|
+
export default defineNuxtConfig({
|
|
223
|
+
vite: {
|
|
224
|
+
plugins: [codeInspectorPlugin({ bundler: 'vite' })],
|
|
225
|
+
},
|
|
226
|
+
});
|
|
227
|
+
```
|
|
229
228
|
|
|
230
|
-
For nuxt2.x :
|
|
229
|
+
- For nuxt2.x :
|
|
231
230
|
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
231
|
+
```js
|
|
232
|
+
// nuxt.config.js
|
|
233
|
+
import { codeInspectorPlugin } from 'code-inspector-plugin';
|
|
235
234
|
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
235
|
+
export default {
|
|
236
|
+
build: {
|
|
237
|
+
extend(config) {
|
|
238
|
+
config.plugins.push(codeInspectorPlugin({ bundler: 'webpack' }));
|
|
239
|
+
return config;
|
|
240
|
+
},
|
|
241
241
|
},
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
```
|
|
242
|
+
};
|
|
243
|
+
```
|
|
245
244
|
|
|
246
245
|
</details>
|
|
247
246
|
|
|
248
247
|
<details>
|
|
249
248
|
<summary>Click to expand configuration about: <b>next.js</b></summary>
|
|
250
249
|
|
|
251
|
-
For next.js(<= 14.x):
|
|
252
|
-
```js
|
|
253
|
-
// next.config.js
|
|
254
|
-
const { codeInspectorPlugin } = require('code-inspector-plugin');
|
|
250
|
+
- For next.js(<= 14.x):
|
|
255
251
|
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
return config;
|
|
260
|
-
},
|
|
261
|
-
};
|
|
252
|
+
```js
|
|
253
|
+
// next.config.js
|
|
254
|
+
const { codeInspectorPlugin } = require('code-inspector-plugin');
|
|
262
255
|
|
|
263
|
-
|
|
264
|
-
|
|
256
|
+
const nextConfig = {
|
|
257
|
+
webpack: (config, { dev, isServer }) => {
|
|
258
|
+
config.plugins.push(codeInspectorPlugin({ bundler: 'webpack' }));
|
|
259
|
+
return config;
|
|
260
|
+
},
|
|
261
|
+
};
|
|
265
262
|
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
import type { NextConfig } from 'next';
|
|
269
|
-
import { codeInspectorPlugin } from 'code-inspector-plugin';
|
|
263
|
+
module.exports = nextConfig;
|
|
264
|
+
```
|
|
270
265
|
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
266
|
+
- For next.js(15.0.x ~ 15.2.x):
|
|
267
|
+
|
|
268
|
+
```js
|
|
269
|
+
import type { NextConfig } from 'next';
|
|
270
|
+
import { codeInspectorPlugin } from 'code-inspector-plugin';
|
|
271
|
+
|
|
272
|
+
const nextConfig: NextConfig = {
|
|
273
|
+
experimental: {
|
|
274
|
+
turbo: {
|
|
275
|
+
rules: codeInspectorPlugin({
|
|
276
|
+
bundler: 'turbopack',
|
|
277
|
+
}),
|
|
278
|
+
},
|
|
277
279
|
},
|
|
278
|
-
}
|
|
279
|
-
};
|
|
280
|
+
};
|
|
280
281
|
|
|
281
|
-
|
|
282
|
-
|
|
282
|
+
export default nextConfig;
|
|
283
|
+
```
|
|
283
284
|
|
|
284
|
-
For next.js(>= 15.3.x):
|
|
285
|
-
```js
|
|
286
|
-
// next.config.js
|
|
287
|
-
import type { NextConfig } from 'next';
|
|
288
|
-
import { codeInspectorPlugin } from 'code-inspector-plugin';
|
|
285
|
+
- For next.js(>= 15.3.x):
|
|
289
286
|
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
}),
|
|
295
|
-
},
|
|
296
|
-
};
|
|
287
|
+
```js
|
|
288
|
+
// next.config.js
|
|
289
|
+
import type { NextConfig } from 'next';
|
|
290
|
+
import { codeInspectorPlugin } from 'code-inspector-plugin';
|
|
297
291
|
|
|
298
|
-
|
|
299
|
-
|
|
292
|
+
const nextConfig: NextConfig = {
|
|
293
|
+
turbopack: {
|
|
294
|
+
rules: codeInspectorPlugin({
|
|
295
|
+
bundler: 'turbopack',
|
|
296
|
+
}),
|
|
297
|
+
},
|
|
298
|
+
};
|
|
299
|
+
|
|
300
|
+
export default nextConfig;
|
|
301
|
+
```
|
|
300
302
|
|
|
301
303
|
</details>
|
|
302
304
|
|
|
303
305
|
<details>
|
|
304
306
|
<summary>Click to expand configuration about: <b>umi.js</b></summary>
|
|
305
307
|
|
|
306
|
-
|
|
307
|
-
// umi.config.js or umirc.js
|
|
308
|
-
import { defineConfig } from '@umijs/max';
|
|
309
|
-
import { codeInspectorPlugin } from 'code-inspector-plugin';
|
|
308
|
+
- With webpack:
|
|
310
309
|
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
)
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
310
|
+
```js
|
|
311
|
+
// umi.config.js or umirc.js
|
|
312
|
+
import { defineConfig } from '@umijs/max';
|
|
313
|
+
import { codeInspectorPlugin } from 'code-inspector-plugin';
|
|
314
|
+
|
|
315
|
+
export default defineConfig({
|
|
316
|
+
chainWebpack(memo) {
|
|
317
|
+
memo.plugin('code-inspector-plugin').use(
|
|
318
|
+
codeInspectorPlugin({
|
|
319
|
+
bundler: 'webpack',
|
|
320
|
+
})
|
|
321
|
+
);
|
|
322
|
+
},
|
|
323
|
+
// other config
|
|
324
|
+
});
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
- With mako:
|
|
328
|
+
|
|
329
|
+
```ts
|
|
330
|
+
// .umirc.ts
|
|
331
|
+
import { defineConfig } from 'umi';
|
|
332
|
+
import { codeInspectorPlugin } from 'code-inspector-plugin';
|
|
333
|
+
|
|
334
|
+
export default defineConfig({
|
|
335
|
+
// other config...
|
|
336
|
+
mako: {
|
|
337
|
+
plugins: [
|
|
338
|
+
codeInspectorPlugin({
|
|
339
|
+
bundler: 'mako',
|
|
340
|
+
}),
|
|
341
|
+
],
|
|
342
|
+
},
|
|
343
|
+
});
|
|
344
|
+
```
|
|
322
345
|
|
|
323
346
|
</details>
|
|
324
347
|
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var x=Object.defineProperty,O=Object.defineProperties;var E=Object.getOwnPropertyDescriptors;var h=Object.getOwnPropertySymbols;var k=Object.prototype.hasOwnProperty,F=Object.prototype.propertyIsEnumerable;var v=(e,t,r)=>t in e?x(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,y=(e,t)=>{for(var r in t||(t={}))k.call(t,r)&&v(e,r,t[r]);if(h)for(var r of h(t))F.call(t,r)&&v(e,r,t[r]);return e},b=(e,t)=>O(e,E(t));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const I=require("@code-inspector/vite"),_=require("@code-inspector/webpack"),i=require("@code-inspector/core"),d=require("path"),D=require("chalk"),S={};var W=(e,t,r)=>new Promise((s,p)=>{var a=n=>{try{l(r.next(n))}catch(o){p(o)}},c=n=>{try{l(r.throw(n))}catch(o){p(o)}},l=n=>n.done?s(n.value):Promise.resolve(n.value).then(a,c);l((r=r.apply(e,t)).next())});const q="@code-inspector/esbuild";function M(e){return{name:q,setup(t){if(e.close||!i.isDev(e.dev,!1))return;const r={port:0,entry:"",output:e.output},{escapeTags:s=[]}=e,p=new Map;t.onLoad({filter:e.match||/\.(jsx|tsx|js|ts|mjs|mts)?$/},a=>W(this,null,function*(){let c=a.path;c=i.getMappingFilePath(c,e.mappings);let l=yield S.promises.readFile(c,"utf8"),n=p.get(c);if(!n||n.originCode!==l){let o=l;if(i.isExcludedFile(c,e))return o;o=yield i.getCodeWithWebComponent({options:e,file:c,code:o,record:r});let u="";if(i.isJsTypeFile(c)?u="jsx":c.endsWith(".svelte")&&(u="svelte"),u)o=i.transformCode({content:o,filePath:c,fileType:u,escapeTags:s,pathType:e.pathType});else if(c.endsWith(".vue")){u="vue";const{descriptor:m}=i.parseSFC(o,{sourceMap:!1}),w=i.transformCode({content:m.template.content,filePath:c,fileType:u,escapeTags:s,pathType:e.pathType});o=o.replace(m.template.content,w)}const C=d.extname(c).replace(".","");n={originCode:l,output:{contents:o,loader:C}},p.set(c,n)}return n.output}))}}}var N=Object.defineProperty,R=Object.defineProperties,L=Object.getOwnPropertyDescriptors,g=Object.getOwnPropertySymbols,U=Object.prototype.hasOwnProperty,V=Object.prototype.propertyIsEnumerable,P=(e,t,r)=>t in e?N(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,f=(e,t)=>{for(var r in t||(t={}))U.call(t,r)&&P(e,r,t[r]);if(g)for(var r of g(t))V.call(t,r)&&P(e,r,t[r]);return e},j=(e,t)=>R(e,L(t));function J(e){const t={port:0,entry:"",output:e.output};return e.close||!i.isDev(e.dev,process.env.NODE_ENV==="development")?{}:{"**/*.{jsx,tsx,js,ts,mjs,mts}":{loaders:[f({loader:"@code-inspector/webpack/dist/loader.js",options:j(f({},e),{record:t})},e.enforcePre===!1?{}:{enforce:"pre"}),{loader:"@code-inspector/webpack/dist/inject-loader.js",options:j(f({},e),{record:t}),enforce:"pre"}]}}}var $=(e,t,r)=>new Promise((s,p)=>{var a=n=>{try{l(r.next(n))}catch(o){p(o)}},c=n=>{try{l(r.throw(n))}catch(o){p(o)}},l=n=>n.done?s(n.value):Promise.resolve(n.value).then(a,c);l((r=r.apply(e,t)).next())});function z(e){const t={port:0,entry:"",output:e.output};return e.close||!i.isDev(e.dev,process.env.NODE_ENV==="development")?{name:"@code-inspector/mako"}:{name:"@code-inspector/mako",enforce:e.enforcePre===!1?"post":"pre",transform:(r,s)=>$(this,null,function*(){if(i.isExcludedFile(s,e)||s.includes("/.umi/"))return;const{escapeTags:p=[],mappings:a,match:c}=e||{};if(c&&!c.test(s))return;const l=yield i.getCodeWithWebComponent({options:e,file:s,code:r,record:t});if(i.isJsTypeFile(s)){const n=d.extname(s).slice(1);let o=i.normalizePath(s);return o=i.getMappingFilePath(o,a),{content:i.transformCode({content:l,filePath:o,fileType:"jsx",escapeTags:p,pathType:e.pathType}),type:n}}})}}function T(e){if(!(e!=null&&e.bundler)){console.log(D.red("Please specify the bundler in the options of code-inspector-plugin."));return}let t=!1;e.needEnvInspector&&(t=!0,i.getEnvVariable("CODE_INSPECTOR",process.cwd())==="true"&&(t=!1));let r="";typeof __dirname!="undefined"?r=__dirname:r=d.dirname(i.fileURLToPath(typeof document=="undefined"?require("url").pathToFileURL(__filename).href:document.currentScript&&document.currentScript.src||new URL("index.js",document.baseURI).href));const s=b(y({},e),{close:t,output:d.resolve(r,"./")});return e.bundler==="webpack"||e.bundler==="rspack"?new _(s):e.bundler==="esbuild"?M(s):e.bundler==="turbopack"?J(s):e.bundler==="mako"?z(s):I.ViteCodeInspectorPlugin(s)}const A=T;exports.CodeInspectorPlugin=T;exports.codeInspectorPlugin=A;
|
package/dist/index.mjs
CHANGED
|
@@ -1,94 +1,89 @@
|
|
|
1
1
|
var I = Object.defineProperty, _ = Object.defineProperties;
|
|
2
2
|
var D = Object.getOwnPropertyDescriptors;
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
3
|
+
var v = Object.getOwnPropertySymbols;
|
|
4
|
+
var F = Object.prototype.hasOwnProperty, N = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var y = (e, t, r) => t in e ? I(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r, b = (e, t) => {
|
|
6
6
|
for (var r in t || (t = {}))
|
|
7
|
-
|
|
8
|
-
if (
|
|
9
|
-
for (var r of
|
|
10
|
-
|
|
7
|
+
F.call(t, r) && y(e, r, t[r]);
|
|
8
|
+
if (v)
|
|
9
|
+
for (var r of v(t))
|
|
10
|
+
N.call(t, r) && y(e, r, t[r]);
|
|
11
11
|
return e;
|
|
12
|
-
},
|
|
13
|
-
import { ViteCodeInspectorPlugin as
|
|
14
|
-
import
|
|
15
|
-
import { isDev as
|
|
16
|
-
import
|
|
17
|
-
import
|
|
18
|
-
const
|
|
19
|
-
var
|
|
20
|
-
var
|
|
12
|
+
}, P = (e, t) => _(e, D(t));
|
|
13
|
+
import { ViteCodeInspectorPlugin as W } from "@code-inspector/vite";
|
|
14
|
+
import V from "@code-inspector/webpack";
|
|
15
|
+
import { isDev as f, getMappingFilePath as w, isExcludedFile as x, getCodeWithWebComponent as O, isJsTypeFile as k, parseSFC as M, transformCode as d, normalizePath as S, getEnvVariable as L, fileURLToPath as R } from "@code-inspector/core";
|
|
16
|
+
import m, { dirname as $ } from "path";
|
|
17
|
+
import z from "chalk";
|
|
18
|
+
const J = {};
|
|
19
|
+
var U = (e, t, r) => new Promise((s, l) => {
|
|
20
|
+
var i = (n) => {
|
|
21
21
|
try {
|
|
22
|
-
|
|
23
|
-
} catch (
|
|
24
|
-
|
|
22
|
+
p(r.next(n));
|
|
23
|
+
} catch (o) {
|
|
24
|
+
l(o);
|
|
25
25
|
}
|
|
26
|
-
},
|
|
26
|
+
}, c = (n) => {
|
|
27
27
|
try {
|
|
28
|
-
|
|
29
|
-
} catch (
|
|
30
|
-
|
|
28
|
+
p(r.throw(n));
|
|
29
|
+
} catch (o) {
|
|
30
|
+
l(o);
|
|
31
31
|
}
|
|
32
|
-
},
|
|
33
|
-
|
|
32
|
+
}, p = (n) => n.done ? s(n.value) : Promise.resolve(n.value).then(i, c);
|
|
33
|
+
p((r = r.apply(e, t)).next());
|
|
34
34
|
});
|
|
35
|
-
const
|
|
36
|
-
function
|
|
35
|
+
const q = "@code-inspector/esbuild";
|
|
36
|
+
function A(e) {
|
|
37
37
|
return {
|
|
38
|
-
name:
|
|
38
|
+
name: q,
|
|
39
39
|
setup(t) {
|
|
40
|
-
if (e.close || !
|
|
40
|
+
if (e.close || !f(e.dev, !1))
|
|
41
41
|
return;
|
|
42
42
|
const r = {
|
|
43
43
|
port: 0,
|
|
44
44
|
entry: "",
|
|
45
45
|
output: e.output
|
|
46
|
-
}, { escapeTags:
|
|
46
|
+
}, { escapeTags: s = [] } = e, l = /* @__PURE__ */ new Map();
|
|
47
47
|
t.onLoad(
|
|
48
48
|
{ filter: e.match || /\.(jsx|tsx|js|ts|mjs|mts)?$/ },
|
|
49
|
-
(
|
|
50
|
-
let
|
|
51
|
-
|
|
52
|
-
let
|
|
53
|
-
if (!n || n.originCode !==
|
|
54
|
-
let
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
o
|
|
59
|
-
), x = g(e.include || [], o);
|
|
60
|
-
if (T && !x)
|
|
61
|
-
return s;
|
|
62
|
-
s = yield V({
|
|
49
|
+
(i) => U(this, null, function* () {
|
|
50
|
+
let c = i.path;
|
|
51
|
+
c = w(c, e.mappings);
|
|
52
|
+
let p = yield J.promises.readFile(c, "utf8"), n = l.get(c);
|
|
53
|
+
if (!n || n.originCode !== p) {
|
|
54
|
+
let o = p;
|
|
55
|
+
if (x(c, e))
|
|
56
|
+
return o;
|
|
57
|
+
o = yield O({
|
|
63
58
|
options: e,
|
|
64
|
-
file:
|
|
65
|
-
code:
|
|
59
|
+
file: c,
|
|
60
|
+
code: o,
|
|
66
61
|
record: r
|
|
67
62
|
});
|
|
68
|
-
let
|
|
69
|
-
if (
|
|
70
|
-
|
|
71
|
-
content:
|
|
72
|
-
filePath:
|
|
73
|
-
fileType:
|
|
74
|
-
escapeTags:
|
|
63
|
+
let a = "";
|
|
64
|
+
if (k(c) ? a = "jsx" : c.endsWith(".svelte") && (a = "svelte"), a)
|
|
65
|
+
o = d({
|
|
66
|
+
content: o,
|
|
67
|
+
filePath: c,
|
|
68
|
+
fileType: a,
|
|
69
|
+
escapeTags: s,
|
|
75
70
|
pathType: e.pathType
|
|
76
71
|
});
|
|
77
|
-
else if (
|
|
78
|
-
|
|
79
|
-
const { descriptor:
|
|
72
|
+
else if (c.endsWith(".vue")) {
|
|
73
|
+
a = "vue";
|
|
74
|
+
const { descriptor: h } = M(o, {
|
|
80
75
|
sourceMap: !1
|
|
81
|
-
}), E =
|
|
82
|
-
content:
|
|
83
|
-
filePath:
|
|
84
|
-
fileType:
|
|
85
|
-
escapeTags:
|
|
76
|
+
}), E = d({
|
|
77
|
+
content: h.template.content,
|
|
78
|
+
filePath: c,
|
|
79
|
+
fileType: a,
|
|
80
|
+
escapeTags: s,
|
|
86
81
|
pathType: e.pathType
|
|
87
82
|
});
|
|
88
|
-
|
|
83
|
+
o = o.replace(h.template.content, E);
|
|
89
84
|
}
|
|
90
|
-
const
|
|
91
|
-
n = { originCode:
|
|
85
|
+
const C = m.extname(c).replace(".", "");
|
|
86
|
+
n = { originCode: p, output: { contents: o, loader: C } }, l.set(c, n);
|
|
92
87
|
}
|
|
93
88
|
return n.output;
|
|
94
89
|
})
|
|
@@ -96,32 +91,32 @@ function G(e) {
|
|
|
96
91
|
}
|
|
97
92
|
};
|
|
98
93
|
}
|
|
99
|
-
var
|
|
94
|
+
var B = Object.defineProperty, G = Object.defineProperties, H = Object.getOwnPropertyDescriptors, g = Object.getOwnPropertySymbols, K = Object.prototype.hasOwnProperty, Q = Object.prototype.propertyIsEnumerable, j = (e, t, r) => t in e ? B(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r, u = (e, t) => {
|
|
100
95
|
for (var r in t || (t = {}))
|
|
101
|
-
|
|
102
|
-
if (
|
|
103
|
-
for (var r of
|
|
104
|
-
|
|
96
|
+
K.call(t, r) && j(e, r, t[r]);
|
|
97
|
+
if (g)
|
|
98
|
+
for (var r of g(t))
|
|
99
|
+
Q.call(t, r) && j(e, r, t[r]);
|
|
105
100
|
return e;
|
|
106
|
-
},
|
|
107
|
-
function
|
|
101
|
+
}, T = (e, t) => G(e, H(t));
|
|
102
|
+
function X(e) {
|
|
108
103
|
const t = {
|
|
109
104
|
port: 0,
|
|
110
105
|
entry: "",
|
|
111
106
|
output: e.output
|
|
112
107
|
};
|
|
113
|
-
return e.close || !
|
|
108
|
+
return e.close || !f(e.dev, process.env.NODE_ENV === "development") ? {} : {
|
|
114
109
|
"**/*.{jsx,tsx,js,ts,mjs,mts}": {
|
|
115
110
|
loaders: [
|
|
116
|
-
|
|
117
|
-
loader: "
|
|
118
|
-
options:
|
|
111
|
+
u({
|
|
112
|
+
loader: "@code-inspector/webpack/dist/loader.js",
|
|
113
|
+
options: T(u({}, e), {
|
|
119
114
|
record: t
|
|
120
115
|
})
|
|
121
116
|
}, e.enforcePre === !1 ? {} : { enforce: "pre" }),
|
|
122
117
|
{
|
|
123
|
-
loader: "
|
|
124
|
-
options:
|
|
118
|
+
loader: "@code-inspector/webpack/dist/inject-loader.js",
|
|
119
|
+
options: T(u({}, e), {
|
|
125
120
|
record: t
|
|
126
121
|
}),
|
|
127
122
|
enforce: "pre"
|
|
@@ -130,27 +125,80 @@ function Z(e) {
|
|
|
130
125
|
}
|
|
131
126
|
};
|
|
132
127
|
}
|
|
128
|
+
var Y = (e, t, r) => new Promise((s, l) => {
|
|
129
|
+
var i = (n) => {
|
|
130
|
+
try {
|
|
131
|
+
p(r.next(n));
|
|
132
|
+
} catch (o) {
|
|
133
|
+
l(o);
|
|
134
|
+
}
|
|
135
|
+
}, c = (n) => {
|
|
136
|
+
try {
|
|
137
|
+
p(r.throw(n));
|
|
138
|
+
} catch (o) {
|
|
139
|
+
l(o);
|
|
140
|
+
}
|
|
141
|
+
}, p = (n) => n.done ? s(n.value) : Promise.resolve(n.value).then(i, c);
|
|
142
|
+
p((r = r.apply(e, t)).next());
|
|
143
|
+
});
|
|
144
|
+
function Z(e) {
|
|
145
|
+
const t = {
|
|
146
|
+
port: 0,
|
|
147
|
+
entry: "",
|
|
148
|
+
output: e.output
|
|
149
|
+
};
|
|
150
|
+
return e.close || !f(e.dev, process.env.NODE_ENV === "development") ? {
|
|
151
|
+
name: "@code-inspector/mako"
|
|
152
|
+
} : {
|
|
153
|
+
name: "@code-inspector/mako",
|
|
154
|
+
enforce: e.enforcePre === !1 ? "post" : "pre",
|
|
155
|
+
transform: (r, s) => Y(this, null, function* () {
|
|
156
|
+
if (x(s, e) || s.includes("/.umi/"))
|
|
157
|
+
return;
|
|
158
|
+
const { escapeTags: l = [], mappings: i, match: c } = e || {};
|
|
159
|
+
if (c && !c.test(s))
|
|
160
|
+
return;
|
|
161
|
+
const p = yield O({
|
|
162
|
+
options: e,
|
|
163
|
+
file: s,
|
|
164
|
+
code: r,
|
|
165
|
+
record: t
|
|
166
|
+
});
|
|
167
|
+
if (k(s)) {
|
|
168
|
+
const n = m.extname(s).slice(1);
|
|
169
|
+
let o = S(s);
|
|
170
|
+
return o = w(o, i), { content: d({
|
|
171
|
+
content: p,
|
|
172
|
+
filePath: o,
|
|
173
|
+
fileType: "jsx",
|
|
174
|
+
escapeTags: l,
|
|
175
|
+
pathType: e.pathType
|
|
176
|
+
}), type: n };
|
|
177
|
+
}
|
|
178
|
+
})
|
|
179
|
+
};
|
|
180
|
+
}
|
|
133
181
|
function ee(e) {
|
|
134
182
|
if (!(e != null && e.bundler)) {
|
|
135
183
|
console.log(
|
|
136
|
-
|
|
184
|
+
z.red(
|
|
137
185
|
"Please specify the bundler in the options of code-inspector-plugin."
|
|
138
186
|
)
|
|
139
187
|
);
|
|
140
188
|
return;
|
|
141
189
|
}
|
|
142
190
|
let t = !1;
|
|
143
|
-
e.needEnvInspector && (t = !0,
|
|
191
|
+
e.needEnvInspector && (t = !0, L("CODE_INSPECTOR", process.cwd()) === "true" && (t = !1));
|
|
144
192
|
let r = "";
|
|
145
|
-
typeof __dirname != "undefined" ? r = __dirname : r =
|
|
146
|
-
const
|
|
193
|
+
typeof __dirname != "undefined" ? r = __dirname : r = $(R(import.meta.url));
|
|
194
|
+
const s = P(b({}, e), {
|
|
147
195
|
close: t,
|
|
148
|
-
output:
|
|
196
|
+
output: m.resolve(r, "./")
|
|
149
197
|
});
|
|
150
|
-
return e.bundler === "webpack" || e.bundler === "rspack" ? new
|
|
198
|
+
return e.bundler === "webpack" || e.bundler === "rspack" ? new V(s) : e.bundler === "esbuild" ? A(s) : e.bundler === "turbopack" ? X(s) : e.bundler === "mako" ? Z(s) : W(s);
|
|
151
199
|
}
|
|
152
|
-
const
|
|
200
|
+
const pe = ee;
|
|
153
201
|
export {
|
|
154
202
|
ee as CodeInspectorPlugin,
|
|
155
|
-
|
|
203
|
+
pe as codeInspectorPlugin
|
|
156
204
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "code-inspector-plugin",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.1-beta.1",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"module": "./dist/index.mjs",
|
|
6
6
|
"typings": "./types/index.d.ts",
|
|
@@ -47,11 +47,12 @@
|
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
49
|
"chalk": "4.1.1",
|
|
50
|
-
"code-inspector
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
50
|
+
"@code-inspector/core": "1.1.1-beta.1",
|
|
51
|
+
"@code-inspector/webpack": "1.1.1-beta.1",
|
|
52
|
+
"@code-inspector/esbuild": "1.1.1-beta.1",
|
|
53
|
+
"@code-inspector/vite": "1.1.1-beta.1",
|
|
54
|
+
"@code-inspector/mako": "1.1.1-beta.1",
|
|
55
|
+
"@code-inspector/turbopack": "1.1.1-beta.1"
|
|
55
56
|
},
|
|
56
57
|
"devDependencies": {
|
|
57
58
|
"@types/node": "^16.0.1",
|
package/types/index.d.ts
CHANGED
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
import { CodeOptions } from 'code-inspector
|
|
1
|
+
import { CodeOptions } from '@code-inspector/core';
|
|
2
2
|
export interface CodeInspectorPluginOptions extends CodeOptions {
|
|
3
|
-
/**
|
|
4
|
-
* @zh 指定项目的打包器
|
|
5
|
-
* @en specify the bundler of the project
|
|
6
|
-
*/
|
|
7
|
-
bundler: 'vite' | 'webpack' | 'rspack' | 'esbuild' | 'turbopack';
|
|
8
3
|
/**
|
|
9
4
|
* @zh 设置为 true 时,仅当 .env.local 文件存在且其包含 CODE_INSPECTOR=true 时插件生效;默认值为 false
|
|
10
5
|
* @en When set the value to true, only if the .env.local file exists and it contains CODE_INSPECTOR=true, the plugin takes effect; The default value is false
|