@marko/vite 4.0.1 → 4.0.3
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 +67 -16
- package/package.json +8 -8
package/dist/index.mjs
CHANGED
|
@@ -600,6 +600,7 @@ var browserQuery = "?marko-browser";
|
|
|
600
600
|
var markoExt = ".marko";
|
|
601
601
|
var htmlExt = ".html";
|
|
602
602
|
var resolveOpts = { skipSelf: true };
|
|
603
|
+
var configsByFileSystem = /* @__PURE__ */ new Map();
|
|
603
604
|
var cache = /* @__PURE__ */ new Map();
|
|
604
605
|
var babelCaller = {
|
|
605
606
|
name: "@marko/vite",
|
|
@@ -616,7 +617,8 @@ function markoPlugin(opts = {}) {
|
|
|
616
617
|
let basePathVar;
|
|
617
618
|
let baseConfig;
|
|
618
619
|
let ssrConfig;
|
|
619
|
-
let
|
|
620
|
+
let ssrCjsBuildConfig;
|
|
621
|
+
let ssrCjsServeConfig;
|
|
620
622
|
let domConfig;
|
|
621
623
|
let hydrateConfig;
|
|
622
624
|
const resolveVirtualDependency = (from, dep) => {
|
|
@@ -656,11 +658,18 @@ function markoPlugin(opts = {}) {
|
|
|
656
658
|
enforce: "pre",
|
|
657
659
|
// Must be pre to allow us to resolve assets before vite.
|
|
658
660
|
async config(config, env) {
|
|
661
|
+
let optimize = env.mode === "production";
|
|
662
|
+
if ("MARKO_DEBUG" in process.env) {
|
|
663
|
+
optimize = process.env.MARKO_DEBUG === "false" || process.env.MARKO_DEBUG === "0";
|
|
664
|
+
} else {
|
|
665
|
+
process.env.MARKO_DEBUG = optimize ? "false" : "true";
|
|
666
|
+
}
|
|
659
667
|
compiler ??= await import(opts.compiler || "@marko/compiler");
|
|
660
668
|
runtimeId = opts.runtimeId;
|
|
661
669
|
basePathVar = opts.basePathVar;
|
|
662
670
|
baseConfig = {
|
|
663
671
|
cache,
|
|
672
|
+
optimize,
|
|
664
673
|
runtimeId,
|
|
665
674
|
sourceMaps: true,
|
|
666
675
|
writeVersionComment: false,
|
|
@@ -686,6 +695,12 @@ function markoPlugin(opts = {}) {
|
|
|
686
695
|
resolveVirtualDependency,
|
|
687
696
|
output: "html"
|
|
688
697
|
};
|
|
698
|
+
ssrCjsServeConfig = {
|
|
699
|
+
...ssrConfig,
|
|
700
|
+
ast: true,
|
|
701
|
+
code: false,
|
|
702
|
+
sourceMaps: false
|
|
703
|
+
};
|
|
689
704
|
domConfig = {
|
|
690
705
|
...baseConfig,
|
|
691
706
|
resolveVirtualDependency,
|
|
@@ -789,7 +804,7 @@ function markoPlugin(opts = {}) {
|
|
|
789
804
|
},
|
|
790
805
|
configResolved(config) {
|
|
791
806
|
basePath = config.base;
|
|
792
|
-
|
|
807
|
+
ssrCjsBuildConfig = {
|
|
793
808
|
...ssrConfig,
|
|
794
809
|
//modules: 'cjs'
|
|
795
810
|
babelConfig: {
|
|
@@ -841,6 +856,9 @@ function markoPlugin(opts = {}) {
|
|
|
841
856
|
handleHotUpdate(ctx) {
|
|
842
857
|
compiler.taglib.clearCaches();
|
|
843
858
|
baseConfig.cache.clear();
|
|
859
|
+
for (const [, cache2] of configsByFileSystem) {
|
|
860
|
+
cache2.clear();
|
|
861
|
+
}
|
|
844
862
|
for (const mod of ctx.modules) {
|
|
845
863
|
if (mod.id && virtualFiles.has(mod.id)) {
|
|
846
864
|
virtualFiles.set(mod.id, createDeferredPromise());
|
|
@@ -878,12 +896,12 @@ function markoPlugin(opts = {}) {
|
|
|
878
896
|
if (importeeQuery) {
|
|
879
897
|
importee = importee.slice(0, -importeeQuery.length);
|
|
880
898
|
} else if (!importOpts.scan) {
|
|
881
|
-
if (ssr && linked && importer && (importer !== devEntryFile || normalizePath(importer) !== devEntryFilePosix) && // Vite tries to resolve against an `index.html` in some cases, we ignore it here.
|
|
899
|
+
if (ssr && linked && importer && importer[0] !== "\0" && (importer !== devEntryFile || normalizePath(importer) !== devEntryFilePosix) && // Vite tries to resolve against an `index.html` in some cases, we ignore it here.
|
|
882
900
|
isMarkoFile(importee) && !isMarkoFile(importer.replace(queryReg, ""))) {
|
|
883
901
|
importeeQuery = serverEntryQuery;
|
|
884
902
|
} else if (!ssr && isBuild && importer && isMarkoFile(importee) && this.getModuleInfo(importer)?.isEntry) {
|
|
885
903
|
importeeQuery = browserEntryQuery;
|
|
886
|
-
} else if (linked && !ssr && !importeeQuery && isMarkoFile(importee)) {
|
|
904
|
+
} else if (!isBuild && linked && !ssr && !importeeQuery && isMarkoFile(importee)) {
|
|
887
905
|
importeeQuery = browserQuery;
|
|
888
906
|
}
|
|
889
907
|
}
|
|
@@ -934,6 +952,10 @@ function markoPlugin(opts = {}) {
|
|
|
934
952
|
},
|
|
935
953
|
async transform(source, rawId, ssr) {
|
|
936
954
|
let id = stripVersionAndTimeStamp(rawId);
|
|
955
|
+
const info = isBuild ? this.getModuleInfo(id) : void 0;
|
|
956
|
+
if (info?.meta.arcSourceId) {
|
|
957
|
+
id = info.meta.arcSourceId;
|
|
958
|
+
}
|
|
937
959
|
const isSSR = typeof ssr === "object" ? ssr.ssr : ssr;
|
|
938
960
|
const query = getMarkoQuery(id);
|
|
939
961
|
if (query && !query.startsWith(virtualFileQuery)) {
|
|
@@ -993,20 +1015,22 @@ function markoPlugin(opts = {}) {
|
|
|
993
1015
|
}
|
|
994
1016
|
if (!query && isCJSModule(id)) {
|
|
995
1017
|
if (isBuild) {
|
|
996
|
-
const { code: code2, map: map2 } = await compiler.compile(
|
|
1018
|
+
const { code: code2, map: map2, meta: meta2 } = await compiler.compile(
|
|
997
1019
|
source,
|
|
998
1020
|
id,
|
|
999
|
-
|
|
1021
|
+
getConfigForFileSystem(info, ssrCjsBuildConfig)
|
|
1000
1022
|
);
|
|
1001
|
-
return {
|
|
1023
|
+
return {
|
|
1024
|
+
code: code2,
|
|
1025
|
+
map: map2,
|
|
1026
|
+
meta: { arcSourceCode: source, arcScanIds: meta2.analyzedTags }
|
|
1027
|
+
};
|
|
1002
1028
|
} else {
|
|
1003
|
-
const { ast } = await compiler.compile(
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
sourceMaps: false
|
|
1009
|
-
});
|
|
1029
|
+
const { ast } = await compiler.compile(
|
|
1030
|
+
source,
|
|
1031
|
+
id,
|
|
1032
|
+
ssrCjsServeConfig
|
|
1033
|
+
);
|
|
1010
1034
|
let namedExports = "";
|
|
1011
1035
|
let code2 = `import { createRequire } from "module";
|
|
1012
1036
|
`;
|
|
@@ -1068,7 +1092,10 @@ function markoPlugin(opts = {}) {
|
|
|
1068
1092
|
const compiled = await compiler.compile(
|
|
1069
1093
|
source,
|
|
1070
1094
|
id,
|
|
1071
|
-
|
|
1095
|
+
getConfigForFileSystem(
|
|
1096
|
+
info,
|
|
1097
|
+
isSSR ? ssrConfig : query === browserEntryQuery ? hydrateConfig : domConfig
|
|
1098
|
+
)
|
|
1072
1099
|
);
|
|
1073
1100
|
const { map, meta } = compiled;
|
|
1074
1101
|
let { code } = compiled;
|
|
@@ -1090,7 +1117,11 @@ if (import.meta.hot) import.meta.hot.accept(() => {});`;
|
|
|
1090
1117
|
]);
|
|
1091
1118
|
transformWatchFiles.set(id, meta.watchFiles);
|
|
1092
1119
|
}
|
|
1093
|
-
return {
|
|
1120
|
+
return {
|
|
1121
|
+
code,
|
|
1122
|
+
map,
|
|
1123
|
+
meta: isBuild ? { arcSourceCode: source, arcScanIds: meta.analyzedTags } : void 0
|
|
1124
|
+
};
|
|
1094
1125
|
}
|
|
1095
1126
|
},
|
|
1096
1127
|
{
|
|
@@ -1238,6 +1269,26 @@ function stripVersionAndTimeStamp(id) {
|
|
|
1238
1269
|
return `${url}?${query}`;
|
|
1239
1270
|
return url;
|
|
1240
1271
|
}
|
|
1272
|
+
function getConfigForFileSystem(info, config) {
|
|
1273
|
+
const fileSystem = info?.meta.arcFS;
|
|
1274
|
+
if (!fileSystem)
|
|
1275
|
+
return config;
|
|
1276
|
+
let configsForFileSystem = configsByFileSystem.get(fileSystem);
|
|
1277
|
+
if (!configsForFileSystem) {
|
|
1278
|
+
configsForFileSystem = /* @__PURE__ */ new Map();
|
|
1279
|
+
configsByFileSystem.set(fileSystem, configsForFileSystem);
|
|
1280
|
+
}
|
|
1281
|
+
let configForFileSystem = configsForFileSystem.get(config);
|
|
1282
|
+
if (!configForFileSystem) {
|
|
1283
|
+
configForFileSystem = {
|
|
1284
|
+
...config,
|
|
1285
|
+
fileSystem,
|
|
1286
|
+
cache: configsForFileSystem
|
|
1287
|
+
};
|
|
1288
|
+
configsForFileSystem.set(config, configForFileSystem);
|
|
1289
|
+
}
|
|
1290
|
+
return configForFileSystem;
|
|
1291
|
+
}
|
|
1241
1292
|
export {
|
|
1242
1293
|
markoPlugin as default
|
|
1243
1294
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@marko/vite",
|
|
3
3
|
"description": "A Marko plugin for Vite",
|
|
4
|
-
"version": "4.0.
|
|
4
|
+
"version": "4.0.3",
|
|
5
5
|
"author": "Dylan Piercey <dpiercey@ebay.com>",
|
|
6
6
|
"bugs": "https://github.com/marko-js/vite/issues",
|
|
7
7
|
"dependencies": {
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"devDependencies": {
|
|
16
16
|
"@changesets/changelog-github": "^0.4.8",
|
|
17
17
|
"@changesets/cli": "^2.26.2",
|
|
18
|
-
"@marko/compiler": "^5.33.
|
|
18
|
+
"@marko/compiler": "^5.33.8",
|
|
19
19
|
"@marko/fixture-snapshots": "^2.2.1",
|
|
20
20
|
"@marko/testing-library": "^6.1.4",
|
|
21
21
|
"@types/babel__core": "^7.20.4",
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
"@types/node": "^20.9.0",
|
|
25
25
|
"@types/resolve": "^1.20.5",
|
|
26
26
|
"@types/serve-handler": "^6.1.4",
|
|
27
|
-
"@typescript-eslint/eslint-plugin": "^6.
|
|
28
|
-
"@typescript-eslint/parser": "^6.
|
|
27
|
+
"@typescript-eslint/eslint-plugin": "^6.11.0",
|
|
28
|
+
"@typescript-eslint/parser": "^6.11.0",
|
|
29
29
|
"cross-env": "^7.0.3",
|
|
30
30
|
"esbuild": "^0.19.5",
|
|
31
31
|
"eslint": "^8.53.0",
|
|
@@ -33,15 +33,15 @@
|
|
|
33
33
|
"fixpack": "^4.0.0",
|
|
34
34
|
"husky": "^8.0.3",
|
|
35
35
|
"jsdom": "^22.1.0",
|
|
36
|
-
"lint-staged": "^15.0
|
|
37
|
-
"marko": "^5.31.
|
|
36
|
+
"lint-staged": "^15.1.0",
|
|
37
|
+
"marko": "^5.31.18",
|
|
38
38
|
"mocha": "^10.2.0",
|
|
39
39
|
"mocha-snap": "^5.0.0",
|
|
40
40
|
"nyc": "^15.1.0",
|
|
41
41
|
"playwright": "^1.39.0",
|
|
42
|
-
"prettier": "^3.0
|
|
42
|
+
"prettier": "^3.1.0",
|
|
43
43
|
"serve-handler": "^6.1.5",
|
|
44
|
-
"tsx": "^4.1.
|
|
44
|
+
"tsx": "^4.1.2",
|
|
45
45
|
"typescript": "^5.2.2",
|
|
46
46
|
"vite": "^5.0.0-beta.17"
|
|
47
47
|
},
|