@marko/vite 5.0.4 → 5.0.6
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 +60 -57
- package/package.json +7 -7
package/dist/index.mjs
CHANGED
|
@@ -3,7 +3,6 @@ import * as compiler2 from "@marko/compiler";
|
|
|
3
3
|
import fs4 from "fs";
|
|
4
4
|
import path6 from "path";
|
|
5
5
|
import crypto from "crypto";
|
|
6
|
-
import glob2 from "fast-glob";
|
|
7
6
|
import anyMatch from "anymatch";
|
|
8
7
|
import { pathToFileURL } from "url";
|
|
9
8
|
|
|
@@ -16,6 +15,19 @@ function getRenderAssetsRuntime(opts) {
|
|
|
16
15
|
return `${opts.basePathVar && opts.isBuild ? `const base = globalThis.${opts.basePathVar};
|
|
17
16
|
if (typeof base !== "string") throw new Error("${opts.basePathVar} must be defined when using basePathVar.");
|
|
18
17
|
if (!base.endsWith("/")) throw new Error("${opts.basePathVar} must end with a '/' when using basePathVar.");` : "const base = import.meta.env.BASE_URL;"}
|
|
18
|
+
|
|
19
|
+
export function getPrepend(g) {
|
|
20
|
+
return (
|
|
21
|
+
g.___viteRenderAssets("head-prepend") +
|
|
22
|
+
g.___viteRenderAssets("head") +
|
|
23
|
+
g.___viteRenderAssets("body-prepend")
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
export function getAppend(g) {
|
|
27
|
+
return (
|
|
28
|
+
g.___viteRenderAssets("body-prepend")
|
|
29
|
+
);
|
|
30
|
+
}
|
|
19
31
|
export function addAssets(g, newEntries) {
|
|
20
32
|
const entries = g.___viteEntries;
|
|
21
33
|
if (entries) {
|
|
@@ -108,42 +120,39 @@ function renderAssets(slot) {
|
|
|
108
120
|
|
|
109
121
|
// src/server-entry-template.ts
|
|
110
122
|
var server_entry_template_default = async (opts) => {
|
|
111
|
-
const addAssetsCall = `addAssets($global, [${opts.entryData.join(",")}])`;
|
|
112
123
|
const fileNameStr = JSON.stringify(`./${path.basename(opts.fileName)}`);
|
|
113
|
-
|
|
124
|
+
if (opts.tagsAPI) {
|
|
125
|
+
return `import Template from ${fileNameStr};
|
|
114
126
|
export * from ${fileNameStr};
|
|
115
|
-
import { addAssets } from "${renderAssetsRuntimeId}";
|
|
116
|
-
|
|
117
|
-
$
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
127
|
+
import { addAssets, getPrepend, getAppend } from "${renderAssetsRuntimeId}";
|
|
128
|
+
static function flush($global, html) {
|
|
129
|
+
return getPrepend($global) + html + getAppend($global);
|
|
130
|
+
}
|
|
131
|
+
static function setFlush($global) {
|
|
132
|
+
$global.__flush__ = flush;
|
|
133
|
+
}
|
|
134
|
+
static const assets = [${opts.entryData.join(",")}];
|
|
135
|
+
<const/writeSync=addAssets($global, assets) || setFlush($global)/>
|
|
136
|
+
-- $!{writeSync && getPrepend($global)}
|
|
137
|
+
<Template ...input/>
|
|
138
|
+
-- $!{writeSync && getAppend($global)}
|
|
139
|
+
`;
|
|
124
140
|
}
|
|
141
|
+
return `import template from ${fileNameStr};
|
|
142
|
+
export * from ${fileNameStr};
|
|
143
|
+
import { addAssets, getPrepend, getAppend } from "${renderAssetsRuntimeId}";
|
|
144
|
+
static const assets = [${opts.entryData.join(",")}];
|
|
145
|
+
<if(addAssets($global, assets))>
|
|
146
|
+
$!{getPrepend($global)}
|
|
147
|
+
<\${template} ...input/>
|
|
148
|
+
$!{getAppend($global)}
|
|
125
149
|
</>
|
|
126
150
|
<else>
|
|
127
|
-
<__flush_here_and_after__
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
}
|
|
133
|
-
</__flush_here_and_after__>
|
|
134
|
-
</>
|
|
135
|
-
|
|
136
|
-
<\${template} ...input/>${opts.tagsAPI ? "" : `
|
|
137
|
-
<init-components/>
|
|
138
|
-
<await-reorderer/>`}
|
|
139
|
-
|
|
140
|
-
${opts.tagsAPI ? "<if=writeSync>" : "<if(writeSync)>"}
|
|
141
|
-
$!{$global.___viteRenderAssets("body")}
|
|
142
|
-
</>
|
|
143
|
-
<else>
|
|
144
|
-
<__flush_here_and_after__>
|
|
145
|
-
$!{$global.___viteRenderAssets("body")}
|
|
146
|
-
</__flush_here_and_after__>
|
|
151
|
+
<__flush_here_and_after__>$!{getPrepend($global)}</>
|
|
152
|
+
<\${template} ...input/>
|
|
153
|
+
<init-components/>
|
|
154
|
+
<await-reorderer/>
|
|
155
|
+
<__flush_here_and_after__>$!{getAppend($global)}</>
|
|
147
156
|
</>
|
|
148
157
|
`;
|
|
149
158
|
};
|
|
@@ -803,7 +812,6 @@ var babelCaller = {
|
|
|
803
812
|
supportsTopLevelAwait: true,
|
|
804
813
|
supportsExportNamespaceFrom: true
|
|
805
814
|
};
|
|
806
|
-
var optimizeKnownTemplatesForRoot = /* @__PURE__ */ new Map();
|
|
807
815
|
var registeredTagLib = false;
|
|
808
816
|
var cjsToEsm;
|
|
809
817
|
function noop2() {
|
|
@@ -846,6 +854,7 @@ function markoPlugin(opts = {}) {
|
|
|
846
854
|
);
|
|
847
855
|
const entryIds = /* @__PURE__ */ new Set();
|
|
848
856
|
const cachedSources = /* @__PURE__ */ new Map();
|
|
857
|
+
const optimizedRegisistyIdMap = /* @__PURE__ */ new Map();
|
|
849
858
|
const transformWatchFiles = /* @__PURE__ */ new Map();
|
|
850
859
|
const transformOptionalFiles = /* @__PURE__ */ new Map();
|
|
851
860
|
const store = new ReadOncePersistedStore(
|
|
@@ -875,7 +884,16 @@ function markoPlugin(opts = {}) {
|
|
|
875
884
|
runtimeId,
|
|
876
885
|
sourceMaps: true,
|
|
877
886
|
writeVersionComment: false,
|
|
878
|
-
|
|
887
|
+
optimizeRegistryId(id) {
|
|
888
|
+
let registryId = optimizedRegisistyIdMap.get(id);
|
|
889
|
+
if (registryId === void 0) {
|
|
890
|
+
optimizedRegisistyIdMap.set(
|
|
891
|
+
id,
|
|
892
|
+
registryId = optimizedRegisistyIdMap.size
|
|
893
|
+
);
|
|
894
|
+
}
|
|
895
|
+
return registryId;
|
|
896
|
+
},
|
|
879
897
|
babelConfig: opts.babelConfig ? {
|
|
880
898
|
...opts.babelConfig,
|
|
881
899
|
caller: opts.babelConfig.caller ? {
|
|
@@ -1080,7 +1098,6 @@ function markoPlugin(opts = {}) {
|
|
|
1080
1098
|
handleHotUpdate(ctx) {
|
|
1081
1099
|
compiler2.taglib.clearCaches();
|
|
1082
1100
|
baseConfig.cache.clear();
|
|
1083
|
-
optimizeKnownTemplatesForRoot.clear();
|
|
1084
1101
|
for (const [, cache2] of configsByFileSystem) {
|
|
1085
1102
|
cache2.clear();
|
|
1086
1103
|
}
|
|
@@ -1095,6 +1112,11 @@ function markoPlugin(opts = {}) {
|
|
|
1095
1112
|
try {
|
|
1096
1113
|
serverManifest = await store.read();
|
|
1097
1114
|
inputOptions.input = toHTMLEntries(root, serverManifest.entries);
|
|
1115
|
+
if (serverManifest.registered) {
|
|
1116
|
+
for (let i = 0; i < serverManifest.registered.length; i++) {
|
|
1117
|
+
optimizedRegisistyIdMap.set(serverManifest.registered[i], i);
|
|
1118
|
+
}
|
|
1119
|
+
}
|
|
1098
1120
|
for (const entry in serverManifest.entrySources) {
|
|
1099
1121
|
const id = normalizePath(path6.resolve(root, entry));
|
|
1100
1122
|
entryIds.add(id);
|
|
@@ -1359,6 +1381,9 @@ if (import.meta.hot) import.meta.hot.accept(() => {});`;
|
|
|
1359
1381
|
}
|
|
1360
1382
|
}
|
|
1361
1383
|
}
|
|
1384
|
+
if (optimizedRegisistyIdMap.size) {
|
|
1385
|
+
serverManifest.registered = [...optimizedRegisistyIdMap.keys()];
|
|
1386
|
+
}
|
|
1362
1387
|
store.write(serverManifest);
|
|
1363
1388
|
} else {
|
|
1364
1389
|
const browserManifest = {};
|
|
@@ -1487,28 +1512,6 @@ function getConfigForFileSystem(info, config) {
|
|
|
1487
1512
|
}
|
|
1488
1513
|
return configForFileSystem;
|
|
1489
1514
|
}
|
|
1490
|
-
function getKnownTemplates(root) {
|
|
1491
|
-
let knownTemplates = optimizeKnownTemplatesForRoot.get(root);
|
|
1492
|
-
if (!knownTemplates) {
|
|
1493
|
-
optimizeKnownTemplatesForRoot.set(
|
|
1494
|
-
root,
|
|
1495
|
-
knownTemplates = glob2.globSync("**/*.marko", {
|
|
1496
|
-
absolute: true,
|
|
1497
|
-
cwd: root,
|
|
1498
|
-
ignore: [
|
|
1499
|
-
"**/*test*/**",
|
|
1500
|
-
"**/*example*/**",
|
|
1501
|
-
"**/*stories*/**",
|
|
1502
|
-
"**/*coverage*/**",
|
|
1503
|
-
"**/*snapshots*/**",
|
|
1504
|
-
"**/node_modules/**",
|
|
1505
|
-
"**/*.d.marko"
|
|
1506
|
-
]
|
|
1507
|
-
})
|
|
1508
|
-
);
|
|
1509
|
-
}
|
|
1510
|
-
return knownTemplates;
|
|
1511
|
-
}
|
|
1512
1515
|
export {
|
|
1513
1516
|
markoPlugin as default
|
|
1514
1517
|
};
|
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": "5.0.
|
|
4
|
+
"version": "5.0.6",
|
|
5
5
|
"author": "Dylan Piercey <dpiercey@ebay.com>",
|
|
6
6
|
"bugs": "https://github.com/marko-js/vite/issues",
|
|
7
7
|
"dependencies": {
|
|
@@ -16,15 +16,15 @@
|
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
18
|
"@changesets/changelog-github": "^0.5.0",
|
|
19
|
-
"@changesets/cli": "^2.27.
|
|
20
|
-
"@marko/compiler": "^5.
|
|
19
|
+
"@changesets/cli": "^2.27.10",
|
|
20
|
+
"@marko/compiler": "^5.38.0",
|
|
21
21
|
"@marko/fixture-snapshots": "^2.2.1",
|
|
22
22
|
"@marko/testing-library": "^6.2.0",
|
|
23
23
|
"@types/babel__core": "^7.20.5",
|
|
24
24
|
"@types/diff": "^6.0.0",
|
|
25
25
|
"@types/jsdom": "^21.1.7",
|
|
26
|
-
"@types/mocha": "^10.0.
|
|
27
|
-
"@types/node": "^22.9.
|
|
26
|
+
"@types/mocha": "^10.0.10",
|
|
27
|
+
"@types/node": "^22.9.1",
|
|
28
28
|
"@types/resolve": "^1.20.6",
|
|
29
29
|
"@types/serve-handler": "^6.1.4",
|
|
30
30
|
"@typescript-eslint/eslint-plugin": "^7.11.0",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"jsdom": "^25.0.1",
|
|
40
40
|
"less": "^4.2.0",
|
|
41
41
|
"lint-staged": "^15.2.10",
|
|
42
|
-
"marko": "^5.
|
|
42
|
+
"marko": "^5.36.0",
|
|
43
43
|
"mocha": "^10.8.2",
|
|
44
44
|
"mocha-snap": "^5.0.0",
|
|
45
45
|
"nyc": "^17.1.0",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"prettier": "^3.3.3",
|
|
48
48
|
"serve-handler": "^6.1.6",
|
|
49
49
|
"tsx": "^4.19.2",
|
|
50
|
-
"typescript": "^5.
|
|
50
|
+
"typescript": "^5.7.2",
|
|
51
51
|
"vite": "^5.4.11"
|
|
52
52
|
},
|
|
53
53
|
"files": [
|