@marko/vite 2.3.9 → 2.3.11
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 +20 -0
- package/dist/chunk-DCBMHGK4.mjs +20 -0
- package/dist/{chunk-MPTD6LHF.mjs → chunk-DSFBTWOA.mjs} +35 -19
- package/dist/chunk-FCWFM7VD.mjs +63 -0
- package/dist/chunk-KIYHBIE6.mjs +0 -0
- package/dist/{chunk-Z64RCGRQ.mjs → chunk-KRSZ5IRT.mjs} +14 -6
- package/dist/esbuild-plugin.js +22 -7
- package/dist/esbuild-plugin.mjs +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.js +103 -51
- package/dist/index.mjs +103 -52
- package/dist/manifest-generator.d.ts +1 -1
- package/dist/manifest-generator.js +43 -20
- package/dist/manifest-generator.mjs +1 -1
- package/dist/render-assets-transform.js +10 -1
- package/dist/render-assets-transform.mjs +10 -1
- package/dist/server-entry-template.js +8 -1
- package/dist/store/file-store.d.ts +11 -0
- package/dist/store/file-store.js +93 -0
- package/dist/store/file-store.mjs +6 -0
- package/dist/store/index.d.ts +3 -0
- package/dist/store/index.js +41 -0
- package/dist/store/index.mjs +11 -0
- package/dist/store/memory-store.d.ts +8 -0
- package/dist/store/memory-store.js +40 -0
- package/dist/store/memory-store.mjs +6 -0
- package/dist/store/types.d.ts +5 -0
- package/dist/store/types.js +16 -0
- package/dist/store/types.mjs +0 -0
- package/package.json +26 -26
package/dist/index.mjs
CHANGED
|
@@ -1,17 +1,23 @@
|
|
|
1
1
|
import {
|
|
2
2
|
esbuildPlugin
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-KRSZ5IRT.mjs";
|
|
4
4
|
import {
|
|
5
5
|
generateDocManifest,
|
|
6
6
|
generateInputDoc
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-DSFBTWOA.mjs";
|
|
8
8
|
import "./chunk-VL2HLMVE.mjs";
|
|
9
9
|
import {
|
|
10
10
|
server_entry_template_default
|
|
11
11
|
} from "./chunk-HWRQJHCN.mjs";
|
|
12
|
+
import "./chunk-KIYHBIE6.mjs";
|
|
13
|
+
import {
|
|
14
|
+
MemoryStore
|
|
15
|
+
} from "./chunk-DCBMHGK4.mjs";
|
|
16
|
+
import {
|
|
17
|
+
FileStore
|
|
18
|
+
} from "./chunk-FCWFM7VD.mjs";
|
|
12
19
|
|
|
13
20
|
// src/index.ts
|
|
14
|
-
import os from "os";
|
|
15
21
|
import fs from "fs";
|
|
16
22
|
import path from "path";
|
|
17
23
|
import crypto from "crypto";
|
|
@@ -24,12 +30,12 @@ var queryReg = /\?marko-.+$/;
|
|
|
24
30
|
var browserEntryQuery = "?marko-browser-entry";
|
|
25
31
|
var serverEntryQuery = "?marko-server-entry";
|
|
26
32
|
var virtualFileQuery = "?marko-virtual";
|
|
33
|
+
var manifestFileName = "manifest.json";
|
|
27
34
|
var markoExt = ".marko";
|
|
28
35
|
var htmlExt = ".html";
|
|
29
36
|
var resolveOpts = { skipSelf: true };
|
|
30
37
|
var cache = /* @__PURE__ */ new Map();
|
|
31
38
|
var thisFile = typeof __filename === "string" ? __filename : fileURLToPath(import.meta.url);
|
|
32
|
-
var tempDir;
|
|
33
39
|
function markoPlugin(opts = {}) {
|
|
34
40
|
var _a;
|
|
35
41
|
let compiler;
|
|
@@ -57,7 +63,9 @@ function markoPlugin(opts = {}) {
|
|
|
57
63
|
if (devServer) {
|
|
58
64
|
const prev = virtualFiles.get(id);
|
|
59
65
|
if (prev && prev.code !== dep.code) {
|
|
60
|
-
devServer.moduleGraph.invalidateModule(
|
|
66
|
+
devServer.moduleGraph.invalidateModule(
|
|
67
|
+
devServer.moduleGraph.getModuleById(id)
|
|
68
|
+
);
|
|
61
69
|
}
|
|
62
70
|
}
|
|
63
71
|
virtualFiles.set(id, dep);
|
|
@@ -85,6 +93,7 @@ function markoPlugin(opts = {}) {
|
|
|
85
93
|
let devServer;
|
|
86
94
|
let registeredTag = false;
|
|
87
95
|
let serverManifest;
|
|
96
|
+
let store;
|
|
88
97
|
const entrySources = /* @__PURE__ */ new Map();
|
|
89
98
|
const transformWatchFiles = /* @__PURE__ */ new Map();
|
|
90
99
|
const transformOptionalFiles = /* @__PURE__ */ new Map();
|
|
@@ -92,15 +101,24 @@ function markoPlugin(opts = {}) {
|
|
|
92
101
|
{
|
|
93
102
|
name: "marko-vite:pre",
|
|
94
103
|
enforce: "pre",
|
|
104
|
+
// Must be pre to allow us to resolve assets before vite.
|
|
95
105
|
async config(config, env) {
|
|
96
106
|
compiler ?? (compiler = await import(opts.compiler || "@marko/compiler"));
|
|
97
107
|
root = normalizePath(config.root || process.cwd());
|
|
98
108
|
devEntryFile = path.join(root, "index.html");
|
|
99
109
|
isBuild = env.command === "build";
|
|
100
110
|
isSSRBuild = isBuild && linked && Boolean(config.build.ssr);
|
|
111
|
+
store = opts.store || new FileStore(
|
|
112
|
+
`marko-vite-${crypto.createHash("SHA1").update(root).digest("hex")}`
|
|
113
|
+
);
|
|
101
114
|
if (linked && !registeredTag) {
|
|
102
|
-
const transformer = path.resolve(
|
|
103
|
-
|
|
115
|
+
const transformer = path.resolve(
|
|
116
|
+
thisFile,
|
|
117
|
+
"../render-assets-transform"
|
|
118
|
+
);
|
|
119
|
+
registeredTag = normalizePath(
|
|
120
|
+
path.resolve(thisFile, "../components", "vite.marko")
|
|
121
|
+
);
|
|
104
122
|
compiler.taglib.register("@marko/vite", {
|
|
105
123
|
"<_vite>": { template: registeredTag },
|
|
106
124
|
"<head>": { transformer },
|
|
@@ -122,12 +140,14 @@ function markoPlugin(opts = {}) {
|
|
|
122
140
|
}
|
|
123
141
|
}
|
|
124
142
|
const optimizeDeps = config.optimizeDeps ?? (config.optimizeDeps = {});
|
|
125
|
-
optimizeDeps.include = Array.from(
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
143
|
+
optimizeDeps.include = Array.from(
|
|
144
|
+
/* @__PURE__ */ new Set([
|
|
145
|
+
...optimizeDeps.include || [],
|
|
146
|
+
...compiler.getRuntimeEntryFiles("dom", opts.translator),
|
|
147
|
+
...compiler.getRuntimeEntryFiles("html", opts.translator),
|
|
148
|
+
...taglibDeps
|
|
149
|
+
])
|
|
150
|
+
);
|
|
131
151
|
const optimizeExtensions = optimizeDeps.extensions ?? (optimizeDeps.extensions = []);
|
|
132
152
|
optimizeExtensions.push(".marko");
|
|
133
153
|
const esbuildOptions = optimizeDeps.esbuildOptions ?? (optimizeDeps.esbuildOptions = {});
|
|
@@ -135,7 +155,11 @@ function markoPlugin(opts = {}) {
|
|
|
135
155
|
esbuildPlugins.push(esbuildPlugin(compiler, baseConfig));
|
|
136
156
|
const ssr = config.ssr ?? (config.ssr = {});
|
|
137
157
|
if (ssr.noExternal !== true) {
|
|
138
|
-
ssr.noExternal = Array.from(
|
|
158
|
+
ssr.noExternal = Array.from(
|
|
159
|
+
new Set(
|
|
160
|
+
taglibDeps.concat(ssr.noExternal || [])
|
|
161
|
+
)
|
|
162
|
+
);
|
|
139
163
|
}
|
|
140
164
|
},
|
|
141
165
|
configureServer(_server) {
|
|
@@ -166,16 +190,21 @@ function markoPlugin(opts = {}) {
|
|
|
166
190
|
},
|
|
167
191
|
async buildStart(inputOptions) {
|
|
168
192
|
if (isBuild && linked && !isSSRBuild) {
|
|
169
|
-
const serverMetaFile = await getServerManifestFile(root);
|
|
170
|
-
this.addWatchFile(serverMetaFile);
|
|
171
193
|
try {
|
|
172
|
-
serverManifest = JSON.parse(
|
|
194
|
+
serverManifest = JSON.parse(
|
|
195
|
+
await store.get(manifestFileName)
|
|
196
|
+
);
|
|
173
197
|
inputOptions.input = toHTMLEntries(root, serverManifest.entries);
|
|
174
198
|
for (const entry in serverManifest.entrySources) {
|
|
175
|
-
entrySources.set(
|
|
199
|
+
entrySources.set(
|
|
200
|
+
path.resolve(root, entry),
|
|
201
|
+
serverManifest.entrySources[entry]
|
|
202
|
+
);
|
|
176
203
|
}
|
|
177
204
|
} catch (err) {
|
|
178
|
-
this.error(
|
|
205
|
+
this.error(
|
|
206
|
+
`You must run the "ssr" build before the "browser" build.`
|
|
207
|
+
);
|
|
179
208
|
}
|
|
180
209
|
if (isEmpty(inputOptions.input)) {
|
|
181
210
|
this.error("No Marko files were found when compiling the server.");
|
|
@@ -190,14 +219,17 @@ function markoPlugin(opts = {}) {
|
|
|
190
219
|
let importeeQuery = getMarkoQuery(importee);
|
|
191
220
|
if (importeeQuery) {
|
|
192
221
|
importee = importee.slice(0, -importeeQuery.length);
|
|
193
|
-
} else if (ssr && linked && importer && importer !== devEntryFile &&
|
|
222
|
+
} else if (ssr && linked && importer && importer !== devEntryFile && // Vite tries to resolve against an `index.html` in some cases, we ignore it here.
|
|
223
|
+
isMarkoFile(importee) && !isMarkoFile(importer.replace(queryReg, ""))) {
|
|
194
224
|
importeeQuery = serverEntryQuery;
|
|
195
225
|
} else if (!ssr && isBuild && importer && isMarkoFile(importee) && ((_a2 = this.getModuleInfo(importer)) == null ? void 0 : _a2.isEntry)) {
|
|
196
226
|
importeeQuery = browserEntryQuery;
|
|
197
227
|
}
|
|
198
228
|
if (importeeQuery) {
|
|
199
229
|
const resolved = importee[0] === "." ? {
|
|
200
|
-
id: normalizePath(
|
|
230
|
+
id: normalizePath(
|
|
231
|
+
importer ? path.resolve(importer, "..", importee) : path.resolve(root, importee)
|
|
232
|
+
)
|
|
201
233
|
} : await this.resolve(importee, importer, resolveOpts);
|
|
202
234
|
if (resolved) {
|
|
203
235
|
resolved.id += importeeQuery;
|
|
@@ -235,7 +267,14 @@ function markoPlugin(opts = {}) {
|
|
|
235
267
|
serverManifest.entries[entryId] = relativeFileName;
|
|
236
268
|
entryData = JSON.stringify(entryId);
|
|
237
269
|
} else {
|
|
238
|
-
entryData = JSON.stringify(
|
|
270
|
+
entryData = JSON.stringify(
|
|
271
|
+
await generateDocManifest(
|
|
272
|
+
await devServer.transformIndexHtml(
|
|
273
|
+
"/",
|
|
274
|
+
generateInputDoc(fileNameToURL(fileName, root))
|
|
275
|
+
)
|
|
276
|
+
)
|
|
277
|
+
);
|
|
239
278
|
}
|
|
240
279
|
return server_entry_template_default({
|
|
241
280
|
fileName,
|
|
@@ -253,7 +292,10 @@ function markoPlugin(opts = {}) {
|
|
|
253
292
|
if (isBuild) {
|
|
254
293
|
return html;
|
|
255
294
|
}
|
|
256
|
-
return html.replace(
|
|
295
|
+
return html.replace(
|
|
296
|
+
/(src\s*=\s*(['"])(?:(?!\2).)*\.marko)(?:\?((?:(?!\2).)*))?\2/gim,
|
|
297
|
+
(_, prefix, quote, query) => prefix + browserEntryQuery + (query ? "&" + query : "") + quote
|
|
298
|
+
);
|
|
257
299
|
},
|
|
258
300
|
async transform(source, id, ssr) {
|
|
259
301
|
const query = getMarkoQuery(id);
|
|
@@ -272,7 +314,11 @@ function markoPlugin(opts = {}) {
|
|
|
272
314
|
serverManifest.entrySources[path.relative(root, id)] = source;
|
|
273
315
|
}
|
|
274
316
|
}
|
|
275
|
-
const compiled = await compiler.compile(
|
|
317
|
+
const compiled = await compiler.compile(
|
|
318
|
+
source,
|
|
319
|
+
id,
|
|
320
|
+
(typeof ssr === "object" ? ssr.ssr : ssr) ? ssrConfig : query === browserEntryQuery ? hydrateConfig : domConfig
|
|
321
|
+
);
|
|
276
322
|
const { map, meta } = compiled;
|
|
277
323
|
let { code } = compiled;
|
|
278
324
|
if (query !== browserEntryQuery && devServer) {
|
|
@@ -300,15 +346,20 @@ if (import.meta.hot) import.meta.hot.accept();`;
|
|
|
300
346
|
name: "marko-vite:post",
|
|
301
347
|
apply: "build",
|
|
302
348
|
enforce: "post",
|
|
349
|
+
// We use a "post" plugin to allow us to read the final generated `.html` from vite.
|
|
303
350
|
async generateBundle(outputOptions, bundle, isWrite) {
|
|
304
351
|
if (!linked) {
|
|
305
352
|
return;
|
|
306
353
|
}
|
|
307
354
|
if (!isWrite) {
|
|
308
|
-
this.error(
|
|
355
|
+
this.error(
|
|
356
|
+
`Linked builds are currently only supported when in "write" mode.`
|
|
357
|
+
);
|
|
309
358
|
}
|
|
310
359
|
if (!serverManifest) {
|
|
311
|
-
this.error(
|
|
360
|
+
this.error(
|
|
361
|
+
"No Marko files were found when bundling the server in linked mode."
|
|
362
|
+
);
|
|
312
363
|
}
|
|
313
364
|
if (isSSRBuild) {
|
|
314
365
|
const dir = outputOptions.dir ? path.resolve(outputOptions.dir) : path.resolve(outputOptions.file, "..");
|
|
@@ -317,13 +368,15 @@ if (import.meta.hot) import.meta.hot.accept();`;
|
|
|
317
368
|
if (chunk.type === "chunk") {
|
|
318
369
|
for (const id in chunk.modules) {
|
|
319
370
|
if (id === registeredTag) {
|
|
320
|
-
serverManifest.chunksNeedingAssets.push(
|
|
371
|
+
serverManifest.chunksNeedingAssets.push(
|
|
372
|
+
path.resolve(dir, fileName)
|
|
373
|
+
);
|
|
321
374
|
break;
|
|
322
375
|
}
|
|
323
376
|
}
|
|
324
377
|
}
|
|
325
378
|
}
|
|
326
|
-
await
|
|
379
|
+
await store.set(manifestFileName, JSON.stringify(serverManifest));
|
|
327
380
|
} else {
|
|
328
381
|
const browserManifest = {};
|
|
329
382
|
for (const entryId in serverManifest.entries) {
|
|
@@ -335,13 +388,19 @@ if (import.meta.hot) import.meta.hot.accept();`;
|
|
|
335
388
|
chunk = bundle[chunkId];
|
|
336
389
|
}
|
|
337
390
|
if ((chunk == null ? void 0 : chunk.type) === "asset") {
|
|
338
|
-
browserManifest[entryId] = await generateDocManifest(
|
|
391
|
+
browserManifest[entryId] = await generateDocManifest(
|
|
392
|
+
chunk.source.toString()
|
|
393
|
+
);
|
|
339
394
|
delete bundle[chunkId];
|
|
340
395
|
} else {
|
|
341
|
-
this.error(
|
|
396
|
+
this.error(
|
|
397
|
+
`Marko template had unexpected output from vite, ${fileName}`
|
|
398
|
+
);
|
|
342
399
|
}
|
|
343
400
|
}
|
|
344
|
-
const manifestStr = `;var __MARKO_MANIFEST__=${JSON.stringify(
|
|
401
|
+
const manifestStr = `;var __MARKO_MANIFEST__=${JSON.stringify(
|
|
402
|
+
browserManifest
|
|
403
|
+
)};
|
|
345
404
|
`;
|
|
346
405
|
for (const fileName of serverManifest.chunksNeedingAssets) {
|
|
347
406
|
await fs.promises.appendFile(fileName, manifestStr);
|
|
@@ -370,36 +429,26 @@ function toHTMLEntries(root, serverEntries) {
|
|
|
370
429
|
}
|
|
371
430
|
return result;
|
|
372
431
|
}
|
|
373
|
-
async function getServerManifestFile(root) {
|
|
374
|
-
return path.join(await getTempDir(root), "manifest.json");
|
|
375
|
-
}
|
|
376
|
-
function getTempDir(root) {
|
|
377
|
-
return tempDir || (tempDir = (async () => {
|
|
378
|
-
const dir = path.join(os.tmpdir(), `marko-vite-${crypto.createHash("SHA1").update(root).digest("hex")}`);
|
|
379
|
-
try {
|
|
380
|
-
const stat = await fs.promises.stat(dir);
|
|
381
|
-
if (stat.isDirectory()) {
|
|
382
|
-
return dir;
|
|
383
|
-
}
|
|
384
|
-
} catch {
|
|
385
|
-
await fs.promises.mkdir(dir);
|
|
386
|
-
return dir;
|
|
387
|
-
}
|
|
388
|
-
throw new Error("Unable to create temp directory");
|
|
389
|
-
})());
|
|
390
|
-
}
|
|
391
432
|
function toEntryId(id) {
|
|
392
433
|
const lastSepIndex = id.lastIndexOf(path.sep);
|
|
393
434
|
let name = id.slice(lastSepIndex + 1, id.indexOf(".", lastSepIndex));
|
|
394
435
|
if (name === "index" || name === "template") {
|
|
395
|
-
name = id.slice(
|
|
436
|
+
name = id.slice(
|
|
437
|
+
id.lastIndexOf(path.sep, lastSepIndex - 1) + 1,
|
|
438
|
+
lastSepIndex
|
|
439
|
+
);
|
|
396
440
|
}
|
|
397
441
|
return `${name}_${crypto.createHash("SHA1").update(id).digest("base64").replace(/[/+]/g, "-").slice(0, 4)}`;
|
|
398
442
|
}
|
|
399
443
|
function fileNameToURL(fileName, root) {
|
|
400
|
-
const relativeURL = path.posix.relative(
|
|
444
|
+
const relativeURL = path.posix.relative(
|
|
445
|
+
pathToFileURL(root).pathname,
|
|
446
|
+
pathToFileURL(fileName).pathname
|
|
447
|
+
);
|
|
401
448
|
if (relativeURL[0] === ".") {
|
|
402
|
-
throw new Error(
|
|
449
|
+
throw new Error(
|
|
450
|
+
"@marko/vite: Entry templates must exist under the current root directory."
|
|
451
|
+
);
|
|
403
452
|
}
|
|
404
453
|
return `/${relativeURL}`;
|
|
405
454
|
}
|
|
@@ -415,5 +464,7 @@ function isEmpty(obj) {
|
|
|
415
464
|
return true;
|
|
416
465
|
}
|
|
417
466
|
export {
|
|
467
|
+
FileStore,
|
|
468
|
+
MemoryStore,
|
|
418
469
|
markoPlugin as default
|
|
419
470
|
};
|
|
@@ -17,7 +17,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
}
|
|
18
18
|
return to;
|
|
19
19
|
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
21
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
22
29
|
var manifest_generator_exports = {};
|
|
23
30
|
__export(manifest_generator_exports, {
|
|
@@ -32,30 +39,46 @@ var import_serializer = __toESM(require("./serializer"));
|
|
|
32
39
|
const MARKER_COMMENT = "MARKO_VITE";
|
|
33
40
|
function generateDocManifest(rawHtml) {
|
|
34
41
|
return new Promise((resolve, reject) => {
|
|
35
|
-
const parser = new import_htmlparser2.Parser(
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
42
|
+
const parser = new import_htmlparser2.Parser(
|
|
43
|
+
new import_domhandler.DomHandler(function(err, dom) {
|
|
44
|
+
if (err) {
|
|
45
|
+
return reject(err);
|
|
46
|
+
}
|
|
47
|
+
const htmlChildren = dom.find(isElement).childNodes;
|
|
48
|
+
const headPrepend = [];
|
|
49
|
+
const head = [];
|
|
50
|
+
const bodyPrepend = [];
|
|
51
|
+
const body = [];
|
|
52
|
+
splitNodesByMarker(
|
|
53
|
+
htmlChildren.find(
|
|
54
|
+
(node) => isElement(node) && node.tagName === "head"
|
|
55
|
+
).childNodes,
|
|
56
|
+
headPrepend,
|
|
57
|
+
head
|
|
58
|
+
);
|
|
59
|
+
splitNodesByMarker(
|
|
60
|
+
htmlChildren.find(
|
|
61
|
+
(node) => isElement(node) && node.tagName === "body"
|
|
62
|
+
).childNodes,
|
|
63
|
+
bodyPrepend,
|
|
64
|
+
body
|
|
65
|
+
);
|
|
66
|
+
resolve({
|
|
67
|
+
"head-prepend": serializeOrNull(headPrepend),
|
|
68
|
+
head: serializeOrNull(head),
|
|
69
|
+
"body-prepend": serializeOrNull(bodyPrepend),
|
|
70
|
+
body: serializeOrNull(body)
|
|
71
|
+
});
|
|
72
|
+
})
|
|
73
|
+
);
|
|
53
74
|
parser.write(rawHtml);
|
|
54
75
|
parser.end();
|
|
55
76
|
});
|
|
56
77
|
}
|
|
57
78
|
function generateInputDoc(entry) {
|
|
58
|
-
return `<!DOCTYPE html><html><head><!--${MARKER_COMMENT}--></head><body><!--${MARKER_COMMENT}--><script async type="module" src=${JSON.stringify(
|
|
79
|
+
return `<!DOCTYPE html><html><head><!--${MARKER_COMMENT}--></head><body><!--${MARKER_COMMENT}--><script async type="module" src=${JSON.stringify(
|
|
80
|
+
entry
|
|
81
|
+
)}></script></body></html>`;
|
|
59
82
|
}
|
|
60
83
|
function serializeOrNull(nodes) {
|
|
61
84
|
const result = (0, import_serializer.default)(nodes);
|
|
@@ -28,7 +28,16 @@ var render_assets_transform_default = (tag, t) => {
|
|
|
28
28
|
body.pushContainer("body", renderAssetsCall(t, tagName));
|
|
29
29
|
};
|
|
30
30
|
function renderAssetsCall(t, slot) {
|
|
31
|
-
return t.markoPlaceholder(
|
|
31
|
+
return t.markoPlaceholder(
|
|
32
|
+
t.callExpression(
|
|
33
|
+
t.memberExpression(
|
|
34
|
+
t.memberExpression(t.identifier("out"), t.identifier("global")),
|
|
35
|
+
t.identifier("___viteRenderAssets")
|
|
36
|
+
),
|
|
37
|
+
[t.stringLiteral(slot)]
|
|
38
|
+
),
|
|
39
|
+
false
|
|
40
|
+
);
|
|
32
41
|
}
|
|
33
42
|
// Annotate the CommonJS export names for ESM import in node:
|
|
34
43
|
0 && (module.exports = {});
|
|
@@ -6,7 +6,16 @@ var render_assets_transform_default = (tag, t) => {
|
|
|
6
6
|
body.pushContainer("body", renderAssetsCall(t, tagName));
|
|
7
7
|
};
|
|
8
8
|
function renderAssetsCall(t, slot) {
|
|
9
|
-
return t.markoPlaceholder(
|
|
9
|
+
return t.markoPlaceholder(
|
|
10
|
+
t.callExpression(
|
|
11
|
+
t.memberExpression(
|
|
12
|
+
t.memberExpression(t.identifier("out"), t.identifier("global")),
|
|
13
|
+
t.identifier("___viteRenderAssets")
|
|
14
|
+
),
|
|
15
|
+
[t.stringLiteral(slot)]
|
|
16
|
+
),
|
|
17
|
+
false
|
|
18
|
+
);
|
|
10
19
|
}
|
|
11
20
|
export {
|
|
12
21
|
render_assets_transform_default as default
|
|
@@ -17,7 +17,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
}
|
|
18
18
|
return to;
|
|
19
19
|
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
21
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
22
29
|
var server_entry_template_exports = {};
|
|
23
30
|
__export(server_entry_template_exports, {
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { BuildStore } from "./types";
|
|
2
|
+
export default class FileStore implements BuildStore {
|
|
3
|
+
_id: string;
|
|
4
|
+
_temp: Promise<string> | undefined;
|
|
5
|
+
_cache: Map<string, string>;
|
|
6
|
+
constructor(id: string);
|
|
7
|
+
_getKeyPath(key: string): Promise<string>;
|
|
8
|
+
has(key: string): Promise<boolean>;
|
|
9
|
+
get(key: string): Promise<string | undefined>;
|
|
10
|
+
set(key: string, value: string): Promise<void>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var file_store_exports = {};
|
|
30
|
+
__export(file_store_exports, {
|
|
31
|
+
default: () => FileStore
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(file_store_exports);
|
|
34
|
+
var import_path = __toESM(require("path"));
|
|
35
|
+
var import_fs = __toESM(require("fs"));
|
|
36
|
+
var import_os = __toESM(require("os"));
|
|
37
|
+
class FileStore {
|
|
38
|
+
_id;
|
|
39
|
+
_temp;
|
|
40
|
+
_cache;
|
|
41
|
+
constructor(id) {
|
|
42
|
+
this._id = id;
|
|
43
|
+
this._cache = /* @__PURE__ */ new Map();
|
|
44
|
+
}
|
|
45
|
+
async _getKeyPath(key) {
|
|
46
|
+
this._temp ?? (this._temp = getTempDir(this._id));
|
|
47
|
+
return import_path.default.join(await this._temp, key);
|
|
48
|
+
}
|
|
49
|
+
async has(key) {
|
|
50
|
+
if (!this._cache.has(key)) {
|
|
51
|
+
const path2 = await this._getKeyPath(key);
|
|
52
|
+
try {
|
|
53
|
+
await import_fs.default.promises.access(path2);
|
|
54
|
+
} catch (e) {
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return true;
|
|
59
|
+
}
|
|
60
|
+
async get(key) {
|
|
61
|
+
let value = this._cache.get(key);
|
|
62
|
+
if (value === void 0) {
|
|
63
|
+
const path2 = await this._getKeyPath(key);
|
|
64
|
+
try {
|
|
65
|
+
value = await import_fs.default.promises.readFile(path2, "utf-8");
|
|
66
|
+
} catch (e) {
|
|
67
|
+
return void 0;
|
|
68
|
+
}
|
|
69
|
+
this._cache.set(key, value);
|
|
70
|
+
}
|
|
71
|
+
return value;
|
|
72
|
+
}
|
|
73
|
+
async set(key, value) {
|
|
74
|
+
this._cache.set(key, value);
|
|
75
|
+
const path2 = await this._getKeyPath(key);
|
|
76
|
+
await import_fs.default.promises.writeFile(path2, value, "utf-8");
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
async function getTempDir(id) {
|
|
80
|
+
const dir = import_path.default.join(import_os.default.tmpdir(), id);
|
|
81
|
+
try {
|
|
82
|
+
const stat = await import_fs.default.promises.stat(dir);
|
|
83
|
+
if (stat.isDirectory()) {
|
|
84
|
+
return dir;
|
|
85
|
+
}
|
|
86
|
+
} catch {
|
|
87
|
+
await import_fs.default.promises.mkdir(dir);
|
|
88
|
+
return dir;
|
|
89
|
+
}
|
|
90
|
+
throw new Error("Unable to create temp directory");
|
|
91
|
+
}
|
|
92
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
93
|
+
0 && (module.exports = {});
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var store_exports = {};
|
|
30
|
+
__export(store_exports, {
|
|
31
|
+
FileStore: () => import_file_store.default,
|
|
32
|
+
MemoryStore: () => import_memory_store.default
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(store_exports);
|
|
35
|
+
var import_file_store = __toESM(require("./file-store"));
|
|
36
|
+
var import_memory_store = __toESM(require("./memory-store"));
|
|
37
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
38
|
+
0 && (module.exports = {
|
|
39
|
+
FileStore,
|
|
40
|
+
MemoryStore
|
|
41
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { BuildStore } from "./types";
|
|
2
|
+
export default class MemoryStore implements BuildStore {
|
|
3
|
+
_store: Map<string, string>;
|
|
4
|
+
constructor();
|
|
5
|
+
has(key: string): Promise<boolean>;
|
|
6
|
+
get(key: string): Promise<string | undefined>;
|
|
7
|
+
set(key: string, value: string): Promise<void>;
|
|
8
|
+
}
|