@marko/vite 3.1.6 → 4.0.1
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 +0 -20
- package/dist/index.d.ts +3 -4
- package/dist/index.mjs +674 -103
- package/dist/manifest-generator.d.ts +1 -1
- package/dist/read-once-persisted-store.d.ts +6 -0
- package/dist/render-assets-runtime.d.ts +6 -0
- package/dist/serializer.d.ts +1 -1
- package/dist/server-entry-template.d.ts +1 -1
- package/package.json +20 -30
- package/dist/babel-plugin-cjs-interop.js +0 -117
- package/dist/babel-plugin-cjs-interop.mjs +0 -7
- package/dist/chunk-2E5QX7AF.mjs +0 -83
- package/dist/chunk-6IJ5UJ3N.mjs +0 -29
- package/dist/chunk-AEF7OQDP.mjs +0 -93
- package/dist/chunk-DCBMHGK4.mjs +0 -20
- package/dist/chunk-FCWFM7VD.mjs +0 -63
- package/dist/chunk-J6VIHWF4.mjs +0 -85
- package/dist/chunk-KIYHBIE6.mjs +0 -0
- package/dist/chunk-NTHVNXFC.mjs +0 -104
- package/dist/chunk-Y3E2OP42.mjs +0 -61
- package/dist/components/vite.marko +0 -74
- package/dist/esbuild-plugin.js +0 -113
- package/dist/esbuild-plugin.mjs +0 -6
- package/dist/index.js +0 -687
- package/dist/manifest-generator.js +0 -113
- package/dist/manifest-generator.mjs +0 -9
- package/dist/render-assets-transform.js +0 -41
- package/dist/render-assets-transform.mjs +0 -22
- package/dist/resolve.js +0 -94
- package/dist/resolve.mjs +0 -8
- package/dist/serializer.js +0 -127
- package/dist/serializer.mjs +0 -6
- package/dist/server-entry-template.js +0 -57
- package/dist/server-entry-template.mjs +0 -6
- package/dist/store/file-store.d.ts +0 -11
- package/dist/store/file-store.js +0 -91
- package/dist/store/file-store.mjs +0 -6
- package/dist/store/index.d.ts +0 -3
- package/dist/store/index.js +0 -41
- package/dist/store/index.mjs +0 -11
- package/dist/store/memory-store.d.ts +0 -8
- package/dist/store/memory-store.js +0 -38
- package/dist/store/memory-store.mjs +0 -6
- package/dist/store/types.d.ts +0 -5
- package/dist/store/types.js +0 -16
- package/dist/store/types.mjs +0 -0
package/dist/chunk-NTHVNXFC.mjs
DELETED
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
// src/serializer.ts
|
|
2
|
-
import { ElementType } from "domelementtype";
|
|
3
|
-
var voidElements = /* @__PURE__ */ new Set([
|
|
4
|
-
"area",
|
|
5
|
-
"base",
|
|
6
|
-
"br",
|
|
7
|
-
"col",
|
|
8
|
-
"embed",
|
|
9
|
-
"hr",
|
|
10
|
-
"img",
|
|
11
|
-
"input",
|
|
12
|
-
"link",
|
|
13
|
-
"meta",
|
|
14
|
-
"param",
|
|
15
|
-
"source",
|
|
16
|
-
"track",
|
|
17
|
-
"wbr"
|
|
18
|
-
]);
|
|
19
|
-
function serialize(basePath, nodes, entries, parts) {
|
|
20
|
-
let curString = parts ? parts.pop() : "";
|
|
21
|
-
parts ?? (parts = []);
|
|
22
|
-
for (const node of nodes) {
|
|
23
|
-
switch (node.type) {
|
|
24
|
-
case ElementType.Tag:
|
|
25
|
-
case ElementType.Style:
|
|
26
|
-
case ElementType.Script: {
|
|
27
|
-
const tag = node;
|
|
28
|
-
const { name } = tag;
|
|
29
|
-
let urlAttr;
|
|
30
|
-
curString += `<${name}`;
|
|
31
|
-
switch (tag.tagName) {
|
|
32
|
-
case "script":
|
|
33
|
-
parts.push(curString, 0 /* AssetAttrs */);
|
|
34
|
-
urlAttr = "src";
|
|
35
|
-
curString = "";
|
|
36
|
-
break;
|
|
37
|
-
case "style":
|
|
38
|
-
parts.push(curString, 0 /* AssetAttrs */);
|
|
39
|
-
curString = "";
|
|
40
|
-
break;
|
|
41
|
-
case "link":
|
|
42
|
-
urlAttr = "href";
|
|
43
|
-
if (tag.attribs.rel === "stylesheet" || tag.attribs.rel === "modulepreload" || tag.attribs.as === "style" || tag.attribs.as === "script") {
|
|
44
|
-
parts.push(curString, 0 /* AssetAttrs */);
|
|
45
|
-
curString = "";
|
|
46
|
-
}
|
|
47
|
-
break;
|
|
48
|
-
}
|
|
49
|
-
for (const attr of tag.attributes) {
|
|
50
|
-
if (attr.value === "") {
|
|
51
|
-
curString += ` ${attr.name}`;
|
|
52
|
-
} else if (attr.name === urlAttr) {
|
|
53
|
-
const id = stripBasePath(basePath, attr.value).replace(/^\.\//, "");
|
|
54
|
-
if (tag.name === "script") {
|
|
55
|
-
entries.push(id);
|
|
56
|
-
}
|
|
57
|
-
curString += ` ${attr.name}="`;
|
|
58
|
-
parts.push(
|
|
59
|
-
curString,
|
|
60
|
-
1 /* PublicPath */,
|
|
61
|
-
id.replace(/"/g, "'") + '"'
|
|
62
|
-
);
|
|
63
|
-
curString = "";
|
|
64
|
-
} else {
|
|
65
|
-
curString += ` ${attr.name}="${attr.value.replace(/"/g, "'")}"`;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
curString += ">";
|
|
69
|
-
if (tag.children.length) {
|
|
70
|
-
parts.push(curString);
|
|
71
|
-
serialize(basePath, tag.children, entries, parts);
|
|
72
|
-
curString = parts.pop();
|
|
73
|
-
}
|
|
74
|
-
if (!voidElements.has(name)) {
|
|
75
|
-
curString += `</${name}>`;
|
|
76
|
-
}
|
|
77
|
-
break;
|
|
78
|
-
}
|
|
79
|
-
case ElementType.Text: {
|
|
80
|
-
const text = node.data;
|
|
81
|
-
if (!/^\s*$/.test(text)) {
|
|
82
|
-
curString += text;
|
|
83
|
-
}
|
|
84
|
-
break;
|
|
85
|
-
}
|
|
86
|
-
case ElementType.Comment:
|
|
87
|
-
curString += `<!--${node.data}-->`;
|
|
88
|
-
break;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
if (curString) {
|
|
92
|
-
parts.push(curString);
|
|
93
|
-
}
|
|
94
|
-
return parts;
|
|
95
|
-
}
|
|
96
|
-
function stripBasePath(basePath, path) {
|
|
97
|
-
if (path.startsWith(basePath))
|
|
98
|
-
return path.slice(basePath.length);
|
|
99
|
-
return path;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
export {
|
|
103
|
-
serialize
|
|
104
|
-
};
|
package/dist/chunk-Y3E2OP42.mjs
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
// src/resolve.ts
|
|
2
|
-
import { exports } from "resolve.exports";
|
|
3
|
-
import Resolve from "resolve";
|
|
4
|
-
import path from "path";
|
|
5
|
-
import fs from "fs";
|
|
6
|
-
var exportsMainFile = `__package_exports__`;
|
|
7
|
-
var modulePathReg = /^.*[/\\]node_modules[/\\](?:@[^/\\]+[/\\])?[^/\\]+[/\\]/;
|
|
8
|
-
var cjsModuleLookup = /* @__PURE__ */ new Map();
|
|
9
|
-
function isCJSModule(id) {
|
|
10
|
-
var _a;
|
|
11
|
-
const modulePath = (_a = modulePathReg.exec(id)) == null ? void 0 : _a[0];
|
|
12
|
-
if (modulePath) {
|
|
13
|
-
const pkgPath = modulePath + "package.json";
|
|
14
|
-
let isCJS = cjsModuleLookup.get(pkgPath);
|
|
15
|
-
if (isCJS === void 0) {
|
|
16
|
-
try {
|
|
17
|
-
const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf8"));
|
|
18
|
-
isCJS = pkg.type !== "module" && !pkg.exports;
|
|
19
|
-
} catch {
|
|
20
|
-
isCJS = false;
|
|
21
|
-
}
|
|
22
|
-
cjsModuleLookup.set(pkgPath, isCJS);
|
|
23
|
-
}
|
|
24
|
-
return isCJS;
|
|
25
|
-
}
|
|
26
|
-
return false;
|
|
27
|
-
}
|
|
28
|
-
function resolve(id, from, extensions, conditions) {
|
|
29
|
-
return Resolve.sync(id, {
|
|
30
|
-
basedir: path.dirname(from),
|
|
31
|
-
filename: from,
|
|
32
|
-
pathFilter,
|
|
33
|
-
packageFilter,
|
|
34
|
-
extensions
|
|
35
|
-
});
|
|
36
|
-
function pathFilter(pkg, pkgFile, relativePath) {
|
|
37
|
-
var _a;
|
|
38
|
-
cjsModuleLookup.set(pkgFile, pkg.type !== "module" && !pkg.exports);
|
|
39
|
-
if (pkg.exports) {
|
|
40
|
-
return (_a = exports(
|
|
41
|
-
pkg,
|
|
42
|
-
relativePath === exportsMainFile ? "." : relativePath,
|
|
43
|
-
{
|
|
44
|
-
conditions
|
|
45
|
-
}
|
|
46
|
-
)) == null ? void 0 : _a[0];
|
|
47
|
-
}
|
|
48
|
-
return relativePath;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
function packageFilter(pkg) {
|
|
52
|
-
if (pkg.exports) {
|
|
53
|
-
pkg.main = exportsMainFile;
|
|
54
|
-
}
|
|
55
|
-
return pkg;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export {
|
|
59
|
-
isCJSModule,
|
|
60
|
-
resolve
|
|
61
|
-
};
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
static function renderAssets(slot) {
|
|
2
|
-
const entries = this.___viteEntries;
|
|
3
|
-
let html = "";
|
|
4
|
-
|
|
5
|
-
if (entries) {
|
|
6
|
-
const slotWrittenEntriesKey = `___viteWrittenEntries-${slot}`;
|
|
7
|
-
const lastWrittenEntry = this[slotWrittenEntriesKey] || 0;
|
|
8
|
-
const writtenEntries = (this[slotWrittenEntriesKey] = entries.length);
|
|
9
|
-
|
|
10
|
-
if(this.___viteBasePath && !this.___flushedMBP && slot !== "head-prepend") {
|
|
11
|
-
this.___flushedMBP = true;
|
|
12
|
-
|
|
13
|
-
html += `<script${this.___viteInjectAttrs}>${
|
|
14
|
-
this.___viteBaseVar
|
|
15
|
-
}=${JSON.stringify(this.___viteBasePath)}</script>`
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
for (let i = lastWrittenEntry; i < writtenEntries; i++) {
|
|
19
|
-
let entry = entries[i];
|
|
20
|
-
|
|
21
|
-
if (typeof __MARKO_MANIFEST__ === "object") {
|
|
22
|
-
entry = __MARKO_MANIFEST__[entry] || {};
|
|
23
|
-
} else if (slot === "head") {
|
|
24
|
-
// In dev mode we have is a list entries of the top level modules that need to be imported.
|
|
25
|
-
// To avoid FOUC we will hide the page until all of these modules are loaded.
|
|
26
|
-
const { entries } = entry;
|
|
27
|
-
if (entries) {
|
|
28
|
-
let sep = "";
|
|
29
|
-
html += `<script${this.___viteInjectAttrs}>((root=document.documentElement)=>{`;
|
|
30
|
-
html += "root.style.visibility='hidden';";
|
|
31
|
-
html += "document.currentScript.remove();";
|
|
32
|
-
html += "Promise.allSettled([";
|
|
33
|
-
|
|
34
|
-
for (const id of entries) {
|
|
35
|
-
html += `${sep}import(${JSON.stringify(this.___viteBasePath + id)})`;
|
|
36
|
-
sep = ",";
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
html += "]).then(()=>{";
|
|
40
|
-
html += "root.style.visibility='';";
|
|
41
|
-
html +=
|
|
42
|
-
"if(root.getAttribute('style')==='')root.removeAttribute('style')";
|
|
43
|
-
html += "})})()</script>";
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const parts = entry[slot];
|
|
48
|
-
|
|
49
|
-
if (parts) {
|
|
50
|
-
for (const part of parts) {
|
|
51
|
-
html +=
|
|
52
|
-
part === 0 /** InjectType.AssetAttrs */
|
|
53
|
-
? this.___viteInjectAttrs
|
|
54
|
-
: part === 1 /** InjectType.PublicPath */
|
|
55
|
-
? this.___viteBasePath
|
|
56
|
-
: part;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
return html;
|
|
63
|
-
}
|
|
64
|
-
$ if (!out.global.___viteRenderAssets) {
|
|
65
|
-
out.global.___viteInjectAttrs = out.global.cspNonce
|
|
66
|
-
? ` nonce="${out.global.cspNonce.replace(/"/g, "'")}"`
|
|
67
|
-
: "";
|
|
68
|
-
out.global.___viteRenderAssets = renderAssets;
|
|
69
|
-
out.global.___viteBasePath = input.base || import.meta.env.BASE_URL;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
<__flush_here_and_after__>
|
|
73
|
-
$!{out.global.___viteRenderAssets(input.slot)}
|
|
74
|
-
</__flush_here_and_after__>
|
package/dist/esbuild-plugin.js
DELETED
|
@@ -1,113 +0,0 @@
|
|
|
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 esbuild_plugin_exports = {};
|
|
30
|
-
__export(esbuild_plugin_exports, {
|
|
31
|
-
default: () => esbuildPlugin
|
|
32
|
-
});
|
|
33
|
-
module.exports = __toCommonJS(esbuild_plugin_exports);
|
|
34
|
-
var import_fs = __toESM(require("fs"));
|
|
35
|
-
var import_path = __toESM(require("path"));
|
|
36
|
-
const markoErrorRegExp = /^(.+?)(?:\((\d+)(?:\s*,\s*(\d+))?\))?: (.*)$/gm;
|
|
37
|
-
function esbuildPlugin(compiler, config) {
|
|
38
|
-
return {
|
|
39
|
-
name: "marko",
|
|
40
|
-
async setup(build) {
|
|
41
|
-
var _a;
|
|
42
|
-
const { platform = "browser" } = build.initialOptions;
|
|
43
|
-
const isScan = (_a = build.initialOptions.plugins) == null ? void 0 : _a.some(
|
|
44
|
-
(v) => v.name === "vite:dep-scan"
|
|
45
|
-
);
|
|
46
|
-
const virtualFiles = /* @__PURE__ */ new Map();
|
|
47
|
-
const finalConfig = {
|
|
48
|
-
...config,
|
|
49
|
-
output: isScan ? "hydrate" : platform === "browser" ? "dom" : "html",
|
|
50
|
-
resolveVirtualDependency(from, dep) {
|
|
51
|
-
virtualFiles.set(import_path.default.join(from, "..", dep.virtualPath), dep);
|
|
52
|
-
return dep.virtualPath;
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
build.onResolve({ filter: /\.marko\./ }, (args) => {
|
|
56
|
-
return {
|
|
57
|
-
namespace: "marko:virtual",
|
|
58
|
-
path: import_path.default.resolve(args.resolveDir, args.path),
|
|
59
|
-
external: isScan
|
|
60
|
-
};
|
|
61
|
-
});
|
|
62
|
-
build.onLoad(
|
|
63
|
-
{ filter: /\.marko\./, namespace: "marko:virtual" },
|
|
64
|
-
(args) => ({
|
|
65
|
-
contents: virtualFiles.get(args.path).code,
|
|
66
|
-
loader: import_path.default.extname(args.path).slice(1)
|
|
67
|
-
})
|
|
68
|
-
);
|
|
69
|
-
build.onLoad({ filter: /\.marko$/ }, async (args) => {
|
|
70
|
-
try {
|
|
71
|
-
const { code, meta } = await compiler.compileFile(
|
|
72
|
-
args.path,
|
|
73
|
-
finalConfig
|
|
74
|
-
);
|
|
75
|
-
return {
|
|
76
|
-
loader: "js",
|
|
77
|
-
contents: code,
|
|
78
|
-
watchFiles: meta.watchFiles,
|
|
79
|
-
resolveDir: import_path.default.dirname(args.path)
|
|
80
|
-
};
|
|
81
|
-
} catch (e) {
|
|
82
|
-
const text = e.message;
|
|
83
|
-
const errors = [];
|
|
84
|
-
let match;
|
|
85
|
-
let lines;
|
|
86
|
-
while (match = markoErrorRegExp.exec(text)) {
|
|
87
|
-
const [, file, rawLine, rawCol, text2] = match;
|
|
88
|
-
const line = parseInt(rawLine, 10) || 1;
|
|
89
|
-
const column = parseInt(rawCol, 10) || 1;
|
|
90
|
-
lines || (lines = (await import_fs.default.promises.readFile(args.path, "utf-8")).split(
|
|
91
|
-
/\n/g
|
|
92
|
-
));
|
|
93
|
-
errors.push({
|
|
94
|
-
text: text2,
|
|
95
|
-
location: {
|
|
96
|
-
file,
|
|
97
|
-
line,
|
|
98
|
-
column,
|
|
99
|
-
lineText: ` ${lines[line - 1]}`
|
|
100
|
-
}
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
if (!errors.length) {
|
|
104
|
-
errors.push({ text });
|
|
105
|
-
}
|
|
106
|
-
return {
|
|
107
|
-
errors
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
};
|
|
113
|
-
}
|