@code-inspector/esbuild 1.4.3 → 1.4.5
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.js +1 -1
- package/dist/index.mjs +37 -37
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var f=(
|
|
1
|
+
"use strict";var f=(a,u,i)=>new Promise((o,c)=>{var p=t=>{try{r(i.next(t))}catch(s){c(s)}},e=t=>{try{r(i.throw(t))}catch(s){c(s)}},r=t=>t.done?o(t.value):Promise.resolve(t.value).then(p,e);r((i=i.apply(a,u)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("@code-inspector/core"),h=require("fs"),y=require("path"),C="@code-inspector/esbuild";function T(a){return{name:C,setup(u){if(a.close||!n.isDev(a.dev,!1))return;const i={port:0,entry:"",output:a.output},{escapeTags:o=[]}=a,c=new Map;u.onLoad({filter:a.match||/\.(jsx|tsx|js|ts|mjs|mts)?$/},p=>f(this,null,function*(){let e=p.path;e=n.getMappingFilePath(e,a.mappings);let r=yield h.promises.readFile(e,"utf8"),t=c.get(e);if(!t||t.originCode!==r){let s=r;if(n.isExcludedFile(e,a))return s;s=yield n.getCodeWithWebComponent({options:a,file:e,code:s,record:i});let l="";if(n.isJsTypeFile(e)?l="jsx":e.endsWith(".svelte")&&(l="svelte"),l)s=yield n.transformCode({content:s,filePath:e,fileType:l,escapeTags:o,pathType:a.pathType});else if(e.endsWith(".vue")){l="vue";const{descriptor:d}=n.parseSFC(s,{sourceMap:!1}),g=yield n.transformCode({content:d.template.content,filePath:e,fileType:l,escapeTags:o,pathType:a.pathType});s=s.replace(d.template.content,g)}const m=y.extname(e).replace(".","");t={originCode:r,output:{contents:s,loader:m}},c.set(e,t)}return t.output}))}}}exports.EsbuildCodeInspectorPlugin=T;
|
package/dist/index.mjs
CHANGED
|
@@ -1,74 +1,74 @@
|
|
|
1
|
-
var f = (
|
|
1
|
+
var f = (s, o, n) => new Promise((p, l) => {
|
|
2
2
|
var c = (t) => {
|
|
3
3
|
try {
|
|
4
4
|
r(n.next(t));
|
|
5
|
-
} catch (
|
|
6
|
-
|
|
5
|
+
} catch (a) {
|
|
6
|
+
l(a);
|
|
7
7
|
}
|
|
8
8
|
}, e = (t) => {
|
|
9
9
|
try {
|
|
10
10
|
r(n.throw(t));
|
|
11
|
-
} catch (
|
|
12
|
-
|
|
11
|
+
} catch (a) {
|
|
12
|
+
l(a);
|
|
13
13
|
}
|
|
14
14
|
}, r = (t) => t.done ? p(t.value) : Promise.resolve(t.value).then(c, e);
|
|
15
|
-
r((n = n.apply(
|
|
15
|
+
r((n = n.apply(s, o)).next());
|
|
16
16
|
});
|
|
17
17
|
import { isDev as g, getMappingFilePath as y, isExcludedFile as C, getCodeWithWebComponent as x, isJsTypeFile as T, transformCode as d, parseSFC as v } from "@code-inspector/core";
|
|
18
|
-
import
|
|
19
|
-
import
|
|
20
|
-
const
|
|
21
|
-
function E(
|
|
18
|
+
import w from "fs";
|
|
19
|
+
import F from "path";
|
|
20
|
+
const j = "@code-inspector/esbuild";
|
|
21
|
+
function E(s) {
|
|
22
22
|
return {
|
|
23
|
-
name:
|
|
23
|
+
name: j,
|
|
24
24
|
setup(o) {
|
|
25
|
-
if (
|
|
25
|
+
if (s.close || !g(s.dev, !1))
|
|
26
26
|
return;
|
|
27
27
|
const n = {
|
|
28
28
|
port: 0,
|
|
29
29
|
entry: "",
|
|
30
|
-
output:
|
|
31
|
-
}, { escapeTags: p = [] } =
|
|
30
|
+
output: s.output
|
|
31
|
+
}, { escapeTags: p = [] } = s, l = /* @__PURE__ */ new Map();
|
|
32
32
|
o.onLoad(
|
|
33
|
-
{ filter:
|
|
33
|
+
{ filter: s.match || /\.(jsx|tsx|js|ts|mjs|mts)?$/ },
|
|
34
34
|
(c) => f(this, null, function* () {
|
|
35
35
|
let e = c.path;
|
|
36
|
-
e = y(e,
|
|
37
|
-
let r = yield
|
|
36
|
+
e = y(e, s.mappings);
|
|
37
|
+
let r = yield w.promises.readFile(e, "utf8"), t = l.get(e);
|
|
38
38
|
if (!t || t.originCode !== r) {
|
|
39
|
-
let
|
|
40
|
-
if (C(e,
|
|
41
|
-
return
|
|
42
|
-
|
|
43
|
-
options:
|
|
39
|
+
let a = r;
|
|
40
|
+
if (C(e, s))
|
|
41
|
+
return a;
|
|
42
|
+
a = yield x({
|
|
43
|
+
options: s,
|
|
44
44
|
file: e,
|
|
45
|
-
code:
|
|
45
|
+
code: a,
|
|
46
46
|
record: n
|
|
47
47
|
});
|
|
48
|
-
let
|
|
49
|
-
if (T(e) ?
|
|
50
|
-
|
|
51
|
-
content:
|
|
48
|
+
let i = "";
|
|
49
|
+
if (T(e) ? i = "jsx" : e.endsWith(".svelte") && (i = "svelte"), i)
|
|
50
|
+
a = yield d({
|
|
51
|
+
content: a,
|
|
52
52
|
filePath: e,
|
|
53
|
-
fileType:
|
|
53
|
+
fileType: i,
|
|
54
54
|
escapeTags: p,
|
|
55
|
-
pathType:
|
|
55
|
+
pathType: s.pathType
|
|
56
56
|
});
|
|
57
57
|
else if (e.endsWith(".vue")) {
|
|
58
|
-
|
|
59
|
-
const { descriptor: u } = v(
|
|
58
|
+
i = "vue";
|
|
59
|
+
const { descriptor: u } = v(a, {
|
|
60
60
|
sourceMap: !1
|
|
61
|
-
}), h = d({
|
|
61
|
+
}), h = yield d({
|
|
62
62
|
content: u.template.content,
|
|
63
63
|
filePath: e,
|
|
64
|
-
fileType:
|
|
64
|
+
fileType: i,
|
|
65
65
|
escapeTags: p,
|
|
66
|
-
pathType:
|
|
66
|
+
pathType: s.pathType
|
|
67
67
|
});
|
|
68
|
-
|
|
68
|
+
a = a.replace(u.template.content, h);
|
|
69
69
|
}
|
|
70
|
-
const m =
|
|
71
|
-
t = { originCode: r, output: { contents:
|
|
70
|
+
const m = F.extname(e).replace(".", "");
|
|
71
|
+
t = { originCode: r, output: { contents: a, loader: m } }, l.set(e, t);
|
|
72
72
|
}
|
|
73
73
|
return t.output;
|
|
74
74
|
})
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@code-inspector/esbuild",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.5",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"module": "./dist/index.mjs",
|
|
6
6
|
"typings": "./types/index.d.ts",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"url": "https://github.com/zh-lx/code-inspector/issues"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@code-inspector/core": "1.4.
|
|
41
|
+
"@code-inspector/core": "1.4.5"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@types/node": "^16.0.1",
|