@wevu/compiler 6.15.8 → 6.15.10
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.d.mts +15 -0
- package/dist/index.mjs +52 -13
- package/package.json +4 -3
package/dist/index.d.mts
CHANGED
|
@@ -99,6 +99,17 @@ interface WevuDefaults {
|
|
|
99
99
|
component?: Record<string, any>;
|
|
100
100
|
}
|
|
101
101
|
//#endregion
|
|
102
|
+
//#region src/utils/sourcemap.d.ts
|
|
103
|
+
interface EncodedSourceMapLike {
|
|
104
|
+
version: number | string;
|
|
105
|
+
file?: string;
|
|
106
|
+
names: string[];
|
|
107
|
+
sourceRoot?: string;
|
|
108
|
+
sources: string[];
|
|
109
|
+
sourcesContent?: Array<string | null>;
|
|
110
|
+
mappings: string;
|
|
111
|
+
}
|
|
112
|
+
//#endregion
|
|
102
113
|
//#region src/plugins/utils/vueSfcBlockSrc.d.ts
|
|
103
114
|
/**
|
|
104
115
|
* 解析 SFC block `src` 的配置。
|
|
@@ -377,6 +388,7 @@ declare function compileVueTemplateToWxml(template: string, filename: string, op
|
|
|
377
388
|
*/
|
|
378
389
|
interface VueTransformResult {
|
|
379
390
|
script?: string;
|
|
391
|
+
scriptMap?: EncodedSourceMapLike | null;
|
|
380
392
|
template?: string;
|
|
381
393
|
style?: string;
|
|
382
394
|
config?: string;
|
|
@@ -616,6 +628,7 @@ declare function generateScopedId(filename: string): string;
|
|
|
616
628
|
interface TransformResult {
|
|
617
629
|
code: string;
|
|
618
630
|
transformed: boolean;
|
|
631
|
+
map?: EncodedSourceMapLike | null;
|
|
619
632
|
}
|
|
620
633
|
interface TransformScriptOptions {
|
|
621
634
|
/**
|
|
@@ -775,6 +788,7 @@ declare function injectWevuPageFeaturesInJs(source: string, options?: {
|
|
|
775
788
|
}): {
|
|
776
789
|
code: string;
|
|
777
790
|
transformed: boolean;
|
|
791
|
+
map?: EncodedSourceMapLike | null;
|
|
778
792
|
};
|
|
779
793
|
/**
|
|
780
794
|
* 在 JS 源码中注入 wevu 页面特性(支持跨模块解析)。
|
|
@@ -786,6 +800,7 @@ declare function injectWevuPageFeaturesInJsWithResolver(source: string, options:
|
|
|
786
800
|
}): Promise<{
|
|
787
801
|
code: string;
|
|
788
802
|
transformed: boolean;
|
|
803
|
+
map?: EncodedSourceMapLike | null;
|
|
789
804
|
}>;
|
|
790
805
|
//#endregion
|
|
791
806
|
//#region src/plugins/wevu/pageFeatures/matcher.d.ts
|
package/dist/index.mjs
CHANGED
|
@@ -19,6 +19,7 @@ import { fileURLToPath } from "node:url";
|
|
|
19
19
|
import { parse as parse$1 } from "@vue/compiler-dom";
|
|
20
20
|
import { parse as parse$2 } from "comment-json";
|
|
21
21
|
import vm from "node:vm";
|
|
22
|
+
import remapping from "@jridgewell/remapping";
|
|
22
23
|
//#region src/auto-import-components/builtin.auto.ts
|
|
23
24
|
const components = [
|
|
24
25
|
"wxs",
|
|
@@ -1608,9 +1609,15 @@ function injectWevuPageFeaturesInJs(source, options) {
|
|
|
1608
1609
|
code: source,
|
|
1609
1610
|
transformed: false
|
|
1610
1611
|
};
|
|
1612
|
+
const generated = generate(ast, {
|
|
1613
|
+
retainLines: true,
|
|
1614
|
+
sourceMaps: true,
|
|
1615
|
+
sourceFileName: "inline.js"
|
|
1616
|
+
}, source);
|
|
1611
1617
|
return {
|
|
1612
|
-
code:
|
|
1613
|
-
transformed: true
|
|
1618
|
+
code: generated.code,
|
|
1619
|
+
transformed: true,
|
|
1620
|
+
map: generated.map
|
|
1614
1621
|
};
|
|
1615
1622
|
}
|
|
1616
1623
|
/**
|
|
@@ -1648,9 +1655,15 @@ async function injectWevuPageFeaturesInJsWithResolver(source, options) {
|
|
|
1648
1655
|
code: source,
|
|
1649
1656
|
transformed: false
|
|
1650
1657
|
};
|
|
1658
|
+
const generated = generate(ast, {
|
|
1659
|
+
retainLines: true,
|
|
1660
|
+
sourceMaps: true,
|
|
1661
|
+
sourceFileName: "inline.js"
|
|
1662
|
+
}, source);
|
|
1651
1663
|
return {
|
|
1652
|
-
code:
|
|
1653
|
-
transformed: true
|
|
1664
|
+
code: generated.code,
|
|
1665
|
+
transformed: true,
|
|
1666
|
+
map: generated.map
|
|
1654
1667
|
};
|
|
1655
1668
|
}
|
|
1656
1669
|
//#endregion
|
|
@@ -2957,8 +2970,14 @@ function transformScript(source, options) {
|
|
|
2957
2970
|
code: source,
|
|
2958
2971
|
transformed: false
|
|
2959
2972
|
};
|
|
2973
|
+
const generated = generate(ast, {
|
|
2974
|
+
retainLines: true,
|
|
2975
|
+
sourceMaps: true,
|
|
2976
|
+
sourceFileName: "inline.ts"
|
|
2977
|
+
}, source);
|
|
2960
2978
|
return {
|
|
2961
|
-
code:
|
|
2979
|
+
code: generated.code,
|
|
2980
|
+
map: generated.map,
|
|
2962
2981
|
transformed: state.transformed
|
|
2963
2982
|
};
|
|
2964
2983
|
}
|
|
@@ -7509,6 +7528,17 @@ async function parseVueFile(source, filename, options) {
|
|
|
7509
7528
|
};
|
|
7510
7529
|
}
|
|
7511
7530
|
//#endregion
|
|
7531
|
+
//#region src/utils/sourcemap.ts
|
|
7532
|
+
function isEncodedSourceMapLike(value) {
|
|
7533
|
+
return Boolean(value && typeof value === "object" && "version" in value && "mappings" in value && "names" in value && "sources" in value);
|
|
7534
|
+
}
|
|
7535
|
+
function composeSourceMaps(transformedMap, originalMap) {
|
|
7536
|
+
if (isEncodedSourceMapLike(transformedMap) && isEncodedSourceMapLike(originalMap)) return remapping([transformedMap, originalMap], () => null);
|
|
7537
|
+
if (isEncodedSourceMapLike(transformedMap)) return transformedMap;
|
|
7538
|
+
if (isEncodedSourceMapLike(originalMap)) return originalMap;
|
|
7539
|
+
return null;
|
|
7540
|
+
}
|
|
7541
|
+
//#endregion
|
|
7512
7542
|
//#region src/plugins/vue/transform/compileVueFile/script.ts
|
|
7513
7543
|
const TYPE_ONLY_DEFINE_PROPS_RE = /\bdefineProps\s*</;
|
|
7514
7544
|
function collectTemplateComponentNames(template, filename, warn) {
|
|
@@ -7572,16 +7602,19 @@ async function compileScriptPhase(descriptor, descriptorForCompile, filename, op
|
|
|
7572
7602
|
}
|
|
7573
7603
|
}
|
|
7574
7604
|
let scriptCode;
|
|
7605
|
+
let scriptMap = null;
|
|
7575
7606
|
if (descriptor.script || descriptor.scriptSetup) {
|
|
7576
|
-
|
|
7607
|
+
const scriptCompiled = compileScript(descriptorForCompile, {
|
|
7577
7608
|
id: filename,
|
|
7578
7609
|
isProd: false
|
|
7579
|
-
})
|
|
7610
|
+
});
|
|
7611
|
+
scriptCode = scriptCompiled.content;
|
|
7612
|
+
scriptMap = scriptCompiled.map && typeof scriptCompiled.map === "object" ? scriptCompiled.map : null;
|
|
7580
7613
|
if (scriptCode.includes("defineAppJson") || scriptCode.includes("definePageJson") || scriptCode.includes("defineComponentJson")) scriptCode = stripJsonMacroCallsFromCode(scriptCode, filename);
|
|
7581
7614
|
if (!isAppFile && !scriptCode.includes("export default")) scriptCode += "\nexport default {}";
|
|
7582
7615
|
} else scriptCode = "export default {}";
|
|
7583
|
-
if (scriptCode)
|
|
7584
|
-
|
|
7616
|
+
if (scriptCode) {
|
|
7617
|
+
const transformed = transformScript(scriptCode, {
|
|
7585
7618
|
skipComponentTransform: isAppFile,
|
|
7586
7619
|
isApp: isAppFile,
|
|
7587
7620
|
isPage: options?.isPage === true,
|
|
@@ -7594,12 +7627,17 @@ async function compileScriptPhase(descriptor, descriptorForCompile, filename, op
|
|
|
7594
7627
|
layoutHosts: templateCompiled?.layoutHosts,
|
|
7595
7628
|
inlineExpressions: templateCompiled?.inlineExpressions,
|
|
7596
7629
|
relaxStructuredTypeOnlyProps
|
|
7597
|
-
})
|
|
7598
|
-
|
|
7599
|
-
|
|
7600
|
-
|
|
7630
|
+
});
|
|
7631
|
+
return {
|
|
7632
|
+
script: transformed.code,
|
|
7633
|
+
scriptMap: composeSourceMaps(transformed.map ?? null, scriptMap),
|
|
7634
|
+
autoUsingComponentsMap,
|
|
7635
|
+
autoComponentMeta
|
|
7636
|
+
};
|
|
7637
|
+
}
|
|
7601
7638
|
return {
|
|
7602
7639
|
script: scriptCode,
|
|
7640
|
+
scriptMap: null,
|
|
7603
7641
|
autoUsingComponentsMap,
|
|
7604
7642
|
autoComponentMeta
|
|
7605
7643
|
};
|
|
@@ -7664,6 +7702,7 @@ async function compileVueFile(source, filename, options) {
|
|
|
7664
7702
|
const templateCompiled = compileTemplatePhase(parsed.descriptor, filename, options?.template, result);
|
|
7665
7703
|
const scriptPhase = await compileScriptPhase(parsed.descriptor, parsed.descriptorForCompile, filename, options, autoUsingComponents, templateCompiled, parsed.isAppFile);
|
|
7666
7704
|
result.script = scriptPhase.script;
|
|
7705
|
+
result.scriptMap = scriptPhase.scriptMap;
|
|
7667
7706
|
compileStylePhase(parsed.descriptor, filename, result);
|
|
7668
7707
|
await compileConfigPhase({
|
|
7669
7708
|
descriptor: parsed.descriptor,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wevu/compiler",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "6.15.
|
|
4
|
+
"version": "6.15.10",
|
|
5
5
|
"description": "wevu 编译器基础包,面向小程序模板的编译与转换",
|
|
6
6
|
"author": "ice breaker <1324318532@qq.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -41,6 +41,7 @@
|
|
|
41
41
|
"dist"
|
|
42
42
|
],
|
|
43
43
|
"dependencies": {
|
|
44
|
+
"@jridgewell/remapping": "^2.3.5",
|
|
44
45
|
"@vue/compiler-core": "^3.5.32",
|
|
45
46
|
"@vue/compiler-dom": "^3.5.32",
|
|
46
47
|
"comment-json": "^5.0.0",
|
|
@@ -51,8 +52,8 @@
|
|
|
51
52
|
"vue": "^3.5.32",
|
|
52
53
|
"@weapp-core/constants": "^0.1.1",
|
|
53
54
|
"@weapp-core/shared": "3.0.4",
|
|
54
|
-
"@weapp-vite/ast": "6.15.
|
|
55
|
-
"rolldown-require": "2.0.
|
|
55
|
+
"@weapp-vite/ast": "6.15.10",
|
|
56
|
+
"rolldown-require": "2.0.14"
|
|
56
57
|
},
|
|
57
58
|
"publishConfig": {
|
|
58
59
|
"access": "public",
|