@marko/vite 2.3.12 → 2.3.14
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.
|
@@ -4,9 +4,8 @@ var server_entry_template_default = async (opts) => {
|
|
|
4
4
|
const fileNameStr = JSON.stringify(`./${path.basename(opts.fileName)}`);
|
|
5
5
|
return `import template from ${fileNameStr};
|
|
6
6
|
export * from ${fileNameStr};
|
|
7
|
-
$
|
|
8
|
-
$
|
|
9
|
-
` : ""}$ ($global.___viteEntries || ($global.___viteEntries = [])).push(${opts.entryData});
|
|
7
|
+
${opts.runtimeId ? `$ out.global.runtimeId = ${JSON.stringify(opts.runtimeId)};
|
|
8
|
+
` : ""}$ (out.global.___viteEntries || (out.global.___viteEntries = [])).push(${opts.entryData});
|
|
10
9
|
<_vite slot="head-prepend"/>
|
|
11
10
|
<_vite slot="head"/>
|
|
12
11
|
<_vite slot="body-prepend"/>
|
|
@@ -21,14 +21,13 @@ static function renderAssets(slot) {
|
|
|
21
21
|
|
|
22
22
|
return html;
|
|
23
23
|
}
|
|
24
|
-
$
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
? ` nonce="${$global.cspNonce.replace(/"/g, "'")}"`
|
|
24
|
+
$ if (!out.global.___viteRenderAssets) {
|
|
25
|
+
out.global.___viteInjectAttrs = out.global.cspNonce
|
|
26
|
+
? ` nonce="${out.global.cspNonce.replace(/"/g, "'")}"`
|
|
28
27
|
: "";
|
|
29
|
-
|
|
28
|
+
out.global.___viteRenderAssets = renderAssets;
|
|
30
29
|
}
|
|
31
30
|
|
|
32
31
|
<__flush_here_and_after__>
|
|
33
|
-
$!{
|
|
32
|
+
$!{out.global.___viteRenderAssets(input.slot)}
|
|
34
33
|
</__flush_here_and_after__>
|
package/dist/index.js
CHANGED
|
@@ -44,7 +44,9 @@ var import_esbuild_plugin = __toESM(require("./esbuild-plugin"));
|
|
|
44
44
|
var import_store = require("./store");
|
|
45
45
|
__reExport(src_exports, require("./store"), module.exports);
|
|
46
46
|
const import_meta = {};
|
|
47
|
-
const
|
|
47
|
+
const POSIX_SEP = "/";
|
|
48
|
+
const WINDOWS_SEP = "\\";
|
|
49
|
+
const normalizePath = import_path.default.sep === WINDOWS_SEP ? (id) => id.replace(/\\/g, POSIX_SEP) : (id) => id;
|
|
48
50
|
const virtualFiles = /* @__PURE__ */ new Map();
|
|
49
51
|
const queryReg = /\?marko-.+$/;
|
|
50
52
|
const browserEntryQuery = "?marko-browser-entry";
|
|
@@ -79,7 +81,8 @@ function markoPlugin(opts = {}) {
|
|
|
79
81
|
};
|
|
80
82
|
const resolveViteVirtualDep = (from, dep) => {
|
|
81
83
|
const query = `${virtualFileQuery}&id=${normalizePath(dep.virtualPath)}`;
|
|
82
|
-
const
|
|
84
|
+
const normalizedFrom = normalizePath(from);
|
|
85
|
+
const id = normalizePath(normalizedFrom) + query;
|
|
83
86
|
if (devServer) {
|
|
84
87
|
const prev = virtualFiles.get(id);
|
|
85
88
|
if (isDeferredPromise(prev)) {
|
|
@@ -87,7 +90,7 @@ function markoPlugin(opts = {}) {
|
|
|
87
90
|
}
|
|
88
91
|
}
|
|
89
92
|
virtualFiles.set(id, dep);
|
|
90
|
-
return `./${import_path.default.basename(
|
|
93
|
+
return `./${import_path.default.posix.basename(normalizedFrom) + query}`;
|
|
91
94
|
};
|
|
92
95
|
const ssrConfig = {
|
|
93
96
|
...baseConfig,
|
|
@@ -106,6 +109,7 @@ function markoPlugin(opts = {}) {
|
|
|
106
109
|
};
|
|
107
110
|
let root;
|
|
108
111
|
let devEntryFile;
|
|
112
|
+
let devEntryFilePosix;
|
|
109
113
|
let isBuild = false;
|
|
110
114
|
let isSSRBuild = false;
|
|
111
115
|
let devServer;
|
|
@@ -124,6 +128,7 @@ function markoPlugin(opts = {}) {
|
|
|
124
128
|
compiler ?? (compiler = await import(opts.compiler || "@marko/compiler"));
|
|
125
129
|
root = normalizePath(config.root || process.cwd());
|
|
126
130
|
devEntryFile = import_path.default.join(root, "index.html");
|
|
131
|
+
devEntryFilePosix = normalizePath(devEntryFile);
|
|
127
132
|
isBuild = env.command === "build";
|
|
128
133
|
isSSRBuild = isBuild && linked && Boolean(config.build.ssr);
|
|
129
134
|
store = opts.store || new import_store.FileStore(
|
|
@@ -221,7 +226,7 @@ function markoPlugin(opts = {}) {
|
|
|
221
226
|
inputOptions.input = toHTMLEntries(root, serverManifest.entries);
|
|
222
227
|
for (const entry in serverManifest.entrySources) {
|
|
223
228
|
entrySources.set(
|
|
224
|
-
import_path.default.resolve(root, entry),
|
|
229
|
+
normalizePath(import_path.default.resolve(root, entry)),
|
|
225
230
|
serverManifest.entrySources[entry]
|
|
226
231
|
);
|
|
227
232
|
}
|
|
@@ -243,7 +248,7 @@ function markoPlugin(opts = {}) {
|
|
|
243
248
|
let importeeQuery = getMarkoQuery(importee);
|
|
244
249
|
if (importeeQuery) {
|
|
245
250
|
importee = importee.slice(0, -importeeQuery.length);
|
|
246
|
-
} else if (ssr && linked && importer && importer !== devEntryFile && // Vite tries to resolve against an `index.html` in some cases, we ignore it here.
|
|
251
|
+
} else if (ssr && linked && importer && (importer !== devEntryFile || normalizePath(importer) !== devEntryFilePosix) && // Vite tries to resolve against an `index.html` in some cases, we ignore it here.
|
|
247
252
|
isMarkoFile(importee) && !isMarkoFile(importer.replace(queryReg, ""))) {
|
|
248
253
|
importeeQuery = serverEntryQuery;
|
|
249
254
|
} else if (!ssr && isBuild && importer && isMarkoFile(importee) && ((_a2 = this.getModuleInfo(importer)) == null ? void 0 : _a2.isEntry)) {
|
|
@@ -265,8 +270,10 @@ function markoPlugin(opts = {}) {
|
|
|
265
270
|
if (importerQuery) {
|
|
266
271
|
importer = importer.slice(0, -importerQuery.length);
|
|
267
272
|
if (importee[0] === ".") {
|
|
268
|
-
const resolved =
|
|
269
|
-
|
|
273
|
+
const resolved = normalizePath(
|
|
274
|
+
import_path.default.resolve(importer, "..", importee)
|
|
275
|
+
);
|
|
276
|
+
if (resolved === normalizePath(importer))
|
|
270
277
|
return resolved;
|
|
271
278
|
}
|
|
272
279
|
return this.resolve(importee, importer, resolveOpts);
|
|
@@ -295,7 +302,7 @@ function markoPlugin(opts = {}) {
|
|
|
295
302
|
await (0, import_manifest_generator.generateDocManifest)(
|
|
296
303
|
await devServer.transformIndexHtml(
|
|
297
304
|
"/",
|
|
298
|
-
(0, import_manifest_generator.generateInputDoc)(
|
|
305
|
+
(0, import_manifest_generator.generateInputDoc)(posixFileNameToURL(fileName, root))
|
|
299
306
|
)
|
|
300
307
|
)
|
|
301
308
|
);
|
|
@@ -335,7 +342,7 @@ function markoPlugin(opts = {}) {
|
|
|
335
342
|
if (ssr && entrySources.has(id)) {
|
|
336
343
|
entrySources.set(id, source);
|
|
337
344
|
if (serverManifest) {
|
|
338
|
-
serverManifest.entrySources[import_path.default.relative(root, id)] = source;
|
|
345
|
+
serverManifest.entrySources[import_path.default.posix.relative(root, id)] = source;
|
|
339
346
|
}
|
|
340
347
|
}
|
|
341
348
|
const compiled = await compiler.compile(
|
|
@@ -350,7 +357,7 @@ function markoPlugin(opts = {}) {
|
|
|
350
357
|
if (import.meta.hot) import.meta.hot.accept(() => {});`;
|
|
351
358
|
}
|
|
352
359
|
if (devServer) {
|
|
353
|
-
const templateName =
|
|
360
|
+
const templateName = getPosixBasenameWithoutExt(id);
|
|
354
361
|
const optionalFilePrefix = import_path.default.dirname(id) + import_path.default.sep + (templateName === "index" ? "" : `${templateName}.`);
|
|
355
362
|
for (const file of meta.watchFiles) {
|
|
356
363
|
this.addWatchFile(file);
|
|
@@ -454,17 +461,17 @@ function toHTMLEntries(root, serverEntries) {
|
|
|
454
461
|
return result;
|
|
455
462
|
}
|
|
456
463
|
function toEntryId(id) {
|
|
457
|
-
const lastSepIndex = id.lastIndexOf(
|
|
464
|
+
const lastSepIndex = id.lastIndexOf(POSIX_SEP);
|
|
458
465
|
let name = id.slice(lastSepIndex + 1, id.indexOf(".", lastSepIndex));
|
|
459
466
|
if (name === "index" || name === "template") {
|
|
460
467
|
name = id.slice(
|
|
461
|
-
id.lastIndexOf(
|
|
468
|
+
id.lastIndexOf(POSIX_SEP, lastSepIndex - 1) + 1,
|
|
462
469
|
lastSepIndex
|
|
463
470
|
);
|
|
464
471
|
}
|
|
465
472
|
return `${name}_${import_crypto.default.createHash("SHA1").update(id).digest("base64").replace(/[/+]/g, "-").slice(0, 4)}`;
|
|
466
473
|
}
|
|
467
|
-
function
|
|
474
|
+
function posixFileNameToURL(fileName, root) {
|
|
468
475
|
const relativeURL = import_path.default.posix.relative(
|
|
469
476
|
(0, import_url.pathToFileURL)(root).pathname,
|
|
470
477
|
(0, import_url.pathToFileURL)(fileName).pathname
|
|
@@ -476,8 +483,8 @@ function fileNameToURL(fileName, root) {
|
|
|
476
483
|
}
|
|
477
484
|
return `/${relativeURL}`;
|
|
478
485
|
}
|
|
479
|
-
function
|
|
480
|
-
const baseStart = file.lastIndexOf(
|
|
486
|
+
function getPosixBasenameWithoutExt(file) {
|
|
487
|
+
const baseStart = file.lastIndexOf(POSIX_SEP) + 1;
|
|
481
488
|
const extStart = file.indexOf(".", baseStart + 1);
|
|
482
489
|
return file.slice(baseStart, extStart);
|
|
483
490
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
import "./chunk-VL2HLMVE.mjs";
|
|
9
9
|
import {
|
|
10
10
|
server_entry_template_default
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-EYX7LIK3.mjs";
|
|
12
12
|
import "./chunk-KIYHBIE6.mjs";
|
|
13
13
|
import {
|
|
14
14
|
MemoryStore
|
|
@@ -24,7 +24,9 @@ import crypto from "crypto";
|
|
|
24
24
|
import anyMatch from "anymatch";
|
|
25
25
|
import { pathToFileURL, fileURLToPath } from "url";
|
|
26
26
|
import { relativeImportPath } from "relative-import-path";
|
|
27
|
-
var
|
|
27
|
+
var POSIX_SEP = "/";
|
|
28
|
+
var WINDOWS_SEP = "\\";
|
|
29
|
+
var normalizePath = path.sep === WINDOWS_SEP ? (id) => id.replace(/\\/g, POSIX_SEP) : (id) => id;
|
|
28
30
|
var virtualFiles = /* @__PURE__ */ new Map();
|
|
29
31
|
var queryReg = /\?marko-.+$/;
|
|
30
32
|
var browserEntryQuery = "?marko-browser-entry";
|
|
@@ -59,7 +61,8 @@ function markoPlugin(opts = {}) {
|
|
|
59
61
|
};
|
|
60
62
|
const resolveViteVirtualDep = (from, dep) => {
|
|
61
63
|
const query = `${virtualFileQuery}&id=${normalizePath(dep.virtualPath)}`;
|
|
62
|
-
const
|
|
64
|
+
const normalizedFrom = normalizePath(from);
|
|
65
|
+
const id = normalizePath(normalizedFrom) + query;
|
|
63
66
|
if (devServer) {
|
|
64
67
|
const prev = virtualFiles.get(id);
|
|
65
68
|
if (isDeferredPromise(prev)) {
|
|
@@ -67,7 +70,7 @@ function markoPlugin(opts = {}) {
|
|
|
67
70
|
}
|
|
68
71
|
}
|
|
69
72
|
virtualFiles.set(id, dep);
|
|
70
|
-
return `./${path.basename(
|
|
73
|
+
return `./${path.posix.basename(normalizedFrom) + query}`;
|
|
71
74
|
};
|
|
72
75
|
const ssrConfig = {
|
|
73
76
|
...baseConfig,
|
|
@@ -86,6 +89,7 @@ function markoPlugin(opts = {}) {
|
|
|
86
89
|
};
|
|
87
90
|
let root;
|
|
88
91
|
let devEntryFile;
|
|
92
|
+
let devEntryFilePosix;
|
|
89
93
|
let isBuild = false;
|
|
90
94
|
let isSSRBuild = false;
|
|
91
95
|
let devServer;
|
|
@@ -104,6 +108,7 @@ function markoPlugin(opts = {}) {
|
|
|
104
108
|
compiler ?? (compiler = await import(opts.compiler || "@marko/compiler"));
|
|
105
109
|
root = normalizePath(config.root || process.cwd());
|
|
106
110
|
devEntryFile = path.join(root, "index.html");
|
|
111
|
+
devEntryFilePosix = normalizePath(devEntryFile);
|
|
107
112
|
isBuild = env.command === "build";
|
|
108
113
|
isSSRBuild = isBuild && linked && Boolean(config.build.ssr);
|
|
109
114
|
store = opts.store || new FileStore(
|
|
@@ -201,7 +206,7 @@ function markoPlugin(opts = {}) {
|
|
|
201
206
|
inputOptions.input = toHTMLEntries(root, serverManifest.entries);
|
|
202
207
|
for (const entry in serverManifest.entrySources) {
|
|
203
208
|
entrySources.set(
|
|
204
|
-
path.resolve(root, entry),
|
|
209
|
+
normalizePath(path.resolve(root, entry)),
|
|
205
210
|
serverManifest.entrySources[entry]
|
|
206
211
|
);
|
|
207
212
|
}
|
|
@@ -223,7 +228,7 @@ function markoPlugin(opts = {}) {
|
|
|
223
228
|
let importeeQuery = getMarkoQuery(importee);
|
|
224
229
|
if (importeeQuery) {
|
|
225
230
|
importee = importee.slice(0, -importeeQuery.length);
|
|
226
|
-
} else if (ssr && linked && importer && importer !== devEntryFile && // Vite tries to resolve against an `index.html` in some cases, we ignore it here.
|
|
231
|
+
} else if (ssr && linked && importer && (importer !== devEntryFile || normalizePath(importer) !== devEntryFilePosix) && // Vite tries to resolve against an `index.html` in some cases, we ignore it here.
|
|
227
232
|
isMarkoFile(importee) && !isMarkoFile(importer.replace(queryReg, ""))) {
|
|
228
233
|
importeeQuery = serverEntryQuery;
|
|
229
234
|
} else if (!ssr && isBuild && importer && isMarkoFile(importee) && ((_a2 = this.getModuleInfo(importer)) == null ? void 0 : _a2.isEntry)) {
|
|
@@ -245,8 +250,10 @@ function markoPlugin(opts = {}) {
|
|
|
245
250
|
if (importerQuery) {
|
|
246
251
|
importer = importer.slice(0, -importerQuery.length);
|
|
247
252
|
if (importee[0] === ".") {
|
|
248
|
-
const resolved =
|
|
249
|
-
|
|
253
|
+
const resolved = normalizePath(
|
|
254
|
+
path.resolve(importer, "..", importee)
|
|
255
|
+
);
|
|
256
|
+
if (resolved === normalizePath(importer))
|
|
250
257
|
return resolved;
|
|
251
258
|
}
|
|
252
259
|
return this.resolve(importee, importer, resolveOpts);
|
|
@@ -275,7 +282,7 @@ function markoPlugin(opts = {}) {
|
|
|
275
282
|
await generateDocManifest(
|
|
276
283
|
await devServer.transformIndexHtml(
|
|
277
284
|
"/",
|
|
278
|
-
generateInputDoc(
|
|
285
|
+
generateInputDoc(posixFileNameToURL(fileName, root))
|
|
279
286
|
)
|
|
280
287
|
)
|
|
281
288
|
);
|
|
@@ -315,7 +322,7 @@ function markoPlugin(opts = {}) {
|
|
|
315
322
|
if (ssr && entrySources.has(id)) {
|
|
316
323
|
entrySources.set(id, source);
|
|
317
324
|
if (serverManifest) {
|
|
318
|
-
serverManifest.entrySources[path.relative(root, id)] = source;
|
|
325
|
+
serverManifest.entrySources[path.posix.relative(root, id)] = source;
|
|
319
326
|
}
|
|
320
327
|
}
|
|
321
328
|
const compiled = await compiler.compile(
|
|
@@ -330,7 +337,7 @@ function markoPlugin(opts = {}) {
|
|
|
330
337
|
if (import.meta.hot) import.meta.hot.accept(() => {});`;
|
|
331
338
|
}
|
|
332
339
|
if (devServer) {
|
|
333
|
-
const templateName =
|
|
340
|
+
const templateName = getPosixBasenameWithoutExt(id);
|
|
334
341
|
const optionalFilePrefix = path.dirname(id) + path.sep + (templateName === "index" ? "" : `${templateName}.`);
|
|
335
342
|
for (const file of meta.watchFiles) {
|
|
336
343
|
this.addWatchFile(file);
|
|
@@ -434,17 +441,17 @@ function toHTMLEntries(root, serverEntries) {
|
|
|
434
441
|
return result;
|
|
435
442
|
}
|
|
436
443
|
function toEntryId(id) {
|
|
437
|
-
const lastSepIndex = id.lastIndexOf(
|
|
444
|
+
const lastSepIndex = id.lastIndexOf(POSIX_SEP);
|
|
438
445
|
let name = id.slice(lastSepIndex + 1, id.indexOf(".", lastSepIndex));
|
|
439
446
|
if (name === "index" || name === "template") {
|
|
440
447
|
name = id.slice(
|
|
441
|
-
id.lastIndexOf(
|
|
448
|
+
id.lastIndexOf(POSIX_SEP, lastSepIndex - 1) + 1,
|
|
442
449
|
lastSepIndex
|
|
443
450
|
);
|
|
444
451
|
}
|
|
445
452
|
return `${name}_${crypto.createHash("SHA1").update(id).digest("base64").replace(/[/+]/g, "-").slice(0, 4)}`;
|
|
446
453
|
}
|
|
447
|
-
function
|
|
454
|
+
function posixFileNameToURL(fileName, root) {
|
|
448
455
|
const relativeURL = path.posix.relative(
|
|
449
456
|
pathToFileURL(root).pathname,
|
|
450
457
|
pathToFileURL(fileName).pathname
|
|
@@ -456,8 +463,8 @@ function fileNameToURL(fileName, root) {
|
|
|
456
463
|
}
|
|
457
464
|
return `/${relativeURL}`;
|
|
458
465
|
}
|
|
459
|
-
function
|
|
460
|
-
const baseStart = file.lastIndexOf(
|
|
466
|
+
function getPosixBasenameWithoutExt(file) {
|
|
467
|
+
const baseStart = file.lastIndexOf(POSIX_SEP) + 1;
|
|
461
468
|
const extStart = file.indexOf(".", baseStart + 1);
|
|
462
469
|
return file.slice(baseStart, extStart);
|
|
463
470
|
}
|
|
@@ -36,9 +36,8 @@ var server_entry_template_default = async (opts) => {
|
|
|
36
36
|
const fileNameStr = JSON.stringify(`./${import_path.default.basename(opts.fileName)}`);
|
|
37
37
|
return `import template from ${fileNameStr};
|
|
38
38
|
export * from ${fileNameStr};
|
|
39
|
-
$
|
|
40
|
-
$
|
|
41
|
-
` : ""}$ ($global.___viteEntries || ($global.___viteEntries = [])).push(${opts.entryData});
|
|
39
|
+
${opts.runtimeId ? `$ out.global.runtimeId = ${JSON.stringify(opts.runtimeId)};
|
|
40
|
+
` : ""}$ (out.global.___viteEntries || (out.global.___viteEntries = [])).push(${opts.entryData});
|
|
42
41
|
<_vite slot="head-prepend"/>
|
|
43
42
|
<_vite slot="head"/>
|
|
44
43
|
<_vite slot="body-prepend"/>
|
package/package.json
CHANGED