@marko/vite 2.2.14 → 2.3.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/dist/chunk-2WEBYHWI.mjs +82 -0
- package/dist/components/vite.marko +1 -1
- package/dist/esbuild-plugin.d.ts +3 -0
- package/dist/esbuild-plugin.js +123 -0
- package/dist/esbuild-plugin.mjs +7 -0
- package/dist/index.js +37 -23
- package/dist/index.mjs +37 -21
- package/package.json +1 -1
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__spreadProps,
|
|
3
|
+
__spreadValues
|
|
4
|
+
} from "./chunk-SOEV5HRE.mjs";
|
|
5
|
+
|
|
6
|
+
// src/esbuild-plugin.ts
|
|
7
|
+
import fs from "fs";
|
|
8
|
+
import path from "path";
|
|
9
|
+
var markoErrorRegExp = /^(.+?)(?:\((\d+)(?:\s*,\s*(\d+))?\))?: (.*)$/gm;
|
|
10
|
+
function esbuildPlugin(compiler, config) {
|
|
11
|
+
return {
|
|
12
|
+
name: "marko",
|
|
13
|
+
async setup(build) {
|
|
14
|
+
const { platform = "browser" } = build.initialOptions;
|
|
15
|
+
const virtualFiles = /* @__PURE__ */ new Map();
|
|
16
|
+
const finalConfig = __spreadProps(__spreadValues({}, config), {
|
|
17
|
+
output: platform === "browser" ? "dom" : "html",
|
|
18
|
+
resolveVirtualDependency(from, dep) {
|
|
19
|
+
virtualFiles.set(path.join(from, "..", dep.virtualPath), dep);
|
|
20
|
+
return dep.virtualPath;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
if (platform === "browser") {
|
|
24
|
+
build.onResolve({ filter: /\.marko\./ }, (args) => {
|
|
25
|
+
return {
|
|
26
|
+
namespace: "marko:virtual",
|
|
27
|
+
path: path.resolve(args.resolveDir, args.path)
|
|
28
|
+
};
|
|
29
|
+
});
|
|
30
|
+
build.onLoad({ filter: /\.marko\./, namespace: "marko:virtual" }, (args) => ({
|
|
31
|
+
contents: virtualFiles.get(args.path).code,
|
|
32
|
+
loader: path.extname(args.path).slice(1)
|
|
33
|
+
}));
|
|
34
|
+
build.onResolve({ filter: /\.marko$/ }, async (args) => ({
|
|
35
|
+
namespace: "file",
|
|
36
|
+
path: path.resolve(args.resolveDir, args.path)
|
|
37
|
+
}));
|
|
38
|
+
}
|
|
39
|
+
build.onLoad({ filter: /\.marko$/, namespace: "file" }, async (args) => {
|
|
40
|
+
try {
|
|
41
|
+
const { code, meta } = await compiler.compileFile(args.path, finalConfig);
|
|
42
|
+
return {
|
|
43
|
+
loader: "js",
|
|
44
|
+
contents: code,
|
|
45
|
+
watchFiles: meta.watchFiles,
|
|
46
|
+
resolveDir: path.dirname(args.path)
|
|
47
|
+
};
|
|
48
|
+
} catch (e) {
|
|
49
|
+
const text = e.message;
|
|
50
|
+
const errors = [];
|
|
51
|
+
let match;
|
|
52
|
+
let lines;
|
|
53
|
+
while (match = markoErrorRegExp.exec(text)) {
|
|
54
|
+
const [, file, rawLine, rawCol, text2] = match;
|
|
55
|
+
const line = parseInt(rawLine, 10) || 1;
|
|
56
|
+
const column = parseInt(rawCol, 10) || 1;
|
|
57
|
+
lines || (lines = (await fs.promises.readFile(args.path, "utf-8")).split(/\n/g));
|
|
58
|
+
errors.push({
|
|
59
|
+
text: text2,
|
|
60
|
+
location: {
|
|
61
|
+
file,
|
|
62
|
+
line,
|
|
63
|
+
column,
|
|
64
|
+
lineText: ` ${lines[line - 1]}`
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
if (!errors.length) {
|
|
69
|
+
errors.push({ text });
|
|
70
|
+
}
|
|
71
|
+
return {
|
|
72
|
+
errors
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export {
|
|
81
|
+
esbuildPlugin
|
|
82
|
+
};
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defProps = Object.defineProperties;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
9
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
11
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
12
|
+
var __spreadValues = (a, b) => {
|
|
13
|
+
for (var prop in b || (b = {}))
|
|
14
|
+
if (__hasOwnProp.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
if (__getOwnPropSymbols)
|
|
17
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
18
|
+
if (__propIsEnum.call(b, prop))
|
|
19
|
+
__defNormalProp(a, prop, b[prop]);
|
|
20
|
+
}
|
|
21
|
+
return a;
|
|
22
|
+
};
|
|
23
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
24
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
25
|
+
var __export = (target, all) => {
|
|
26
|
+
for (var name in all)
|
|
27
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
28
|
+
};
|
|
29
|
+
var __reExport = (target, module2, copyDefault, desc) => {
|
|
30
|
+
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
31
|
+
for (let key of __getOwnPropNames(module2))
|
|
32
|
+
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
|
|
33
|
+
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
34
|
+
}
|
|
35
|
+
return target;
|
|
36
|
+
};
|
|
37
|
+
var __toESM = (module2, isNodeMode) => {
|
|
38
|
+
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
39
|
+
};
|
|
40
|
+
var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
41
|
+
return (module2, temp) => {
|
|
42
|
+
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
43
|
+
};
|
|
44
|
+
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
45
|
+
var esbuild_plugin_exports = {};
|
|
46
|
+
__export(esbuild_plugin_exports, {
|
|
47
|
+
default: () => esbuildPlugin
|
|
48
|
+
});
|
|
49
|
+
var import_fs = __toESM(require("fs"));
|
|
50
|
+
var import_path = __toESM(require("path"));
|
|
51
|
+
const markoErrorRegExp = /^(.+?)(?:\((\d+)(?:\s*,\s*(\d+))?\))?: (.*)$/gm;
|
|
52
|
+
function esbuildPlugin(compiler, config) {
|
|
53
|
+
return {
|
|
54
|
+
name: "marko",
|
|
55
|
+
async setup(build) {
|
|
56
|
+
const { platform = "browser" } = build.initialOptions;
|
|
57
|
+
const virtualFiles = /* @__PURE__ */ new Map();
|
|
58
|
+
const finalConfig = __spreadProps(__spreadValues({}, config), {
|
|
59
|
+
output: platform === "browser" ? "dom" : "html",
|
|
60
|
+
resolveVirtualDependency(from, dep) {
|
|
61
|
+
virtualFiles.set(import_path.default.join(from, "..", dep.virtualPath), dep);
|
|
62
|
+
return dep.virtualPath;
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
if (platform === "browser") {
|
|
66
|
+
build.onResolve({ filter: /\.marko\./ }, (args) => {
|
|
67
|
+
return {
|
|
68
|
+
namespace: "marko:virtual",
|
|
69
|
+
path: import_path.default.resolve(args.resolveDir, args.path)
|
|
70
|
+
};
|
|
71
|
+
});
|
|
72
|
+
build.onLoad({ filter: /\.marko\./, namespace: "marko:virtual" }, (args) => ({
|
|
73
|
+
contents: virtualFiles.get(args.path).code,
|
|
74
|
+
loader: import_path.default.extname(args.path).slice(1)
|
|
75
|
+
}));
|
|
76
|
+
build.onResolve({ filter: /\.marko$/ }, async (args) => ({
|
|
77
|
+
namespace: "file",
|
|
78
|
+
path: import_path.default.resolve(args.resolveDir, args.path)
|
|
79
|
+
}));
|
|
80
|
+
}
|
|
81
|
+
build.onLoad({ filter: /\.marko$/, namespace: "file" }, async (args) => {
|
|
82
|
+
try {
|
|
83
|
+
const { code, meta } = await compiler.compileFile(args.path, finalConfig);
|
|
84
|
+
return {
|
|
85
|
+
loader: "js",
|
|
86
|
+
contents: code,
|
|
87
|
+
watchFiles: meta.watchFiles,
|
|
88
|
+
resolveDir: import_path.default.dirname(args.path)
|
|
89
|
+
};
|
|
90
|
+
} catch (e) {
|
|
91
|
+
const text = e.message;
|
|
92
|
+
const errors = [];
|
|
93
|
+
let match;
|
|
94
|
+
let lines;
|
|
95
|
+
while (match = markoErrorRegExp.exec(text)) {
|
|
96
|
+
const [, file, rawLine, rawCol, text2] = match;
|
|
97
|
+
const line = parseInt(rawLine, 10) || 1;
|
|
98
|
+
const column = parseInt(rawCol, 10) || 1;
|
|
99
|
+
lines || (lines = (await import_fs.default.promises.readFile(args.path, "utf-8")).split(/\n/g));
|
|
100
|
+
errors.push({
|
|
101
|
+
text: text2,
|
|
102
|
+
location: {
|
|
103
|
+
file,
|
|
104
|
+
line,
|
|
105
|
+
column,
|
|
106
|
+
lineText: ` ${lines[line - 1]}`
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
if (!errors.length) {
|
|
111
|
+
errors.push({ text });
|
|
112
|
+
}
|
|
113
|
+
return {
|
|
114
|
+
errors
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
module.exports = __toCommonJS(esbuild_plugin_exports);
|
|
122
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
123
|
+
0 && (module.exports = {});
|
package/dist/index.js
CHANGED
|
@@ -37,9 +37,9 @@ var __reExport = (target, module2, copyDefault, desc) => {
|
|
|
37
37
|
var __toESM = (module2, isNodeMode) => {
|
|
38
38
|
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
39
39
|
};
|
|
40
|
-
var __toCommonJS = /* @__PURE__ */ ((
|
|
40
|
+
var __toCommonJS = /* @__PURE__ */ ((cache2) => {
|
|
41
41
|
return (module2, temp) => {
|
|
42
|
-
return
|
|
42
|
+
return cache2 && cache2.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache2 && cache2.set(module2, temp), temp);
|
|
43
43
|
};
|
|
44
44
|
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
45
45
|
var src_exports = {};
|
|
@@ -54,6 +54,7 @@ var import_anymatch = __toESM(require("anymatch"));
|
|
|
54
54
|
var import_url = require("url");
|
|
55
55
|
var import_server_entry_template = __toESM(require("./server-entry-template"));
|
|
56
56
|
var import_manifest_generator = require("./manifest-generator");
|
|
57
|
+
var import_esbuild_plugin = __toESM(require("./esbuild-plugin"));
|
|
57
58
|
const import_meta = {};
|
|
58
59
|
const normalizePath = import_path.default.sep === "\\" ? (id) => id.replace(/\\/g, "/") : (id) => id;
|
|
59
60
|
const virtualFiles = /* @__PURE__ */ new Map();
|
|
@@ -64,6 +65,7 @@ const virtualFileQuery = "?marko-virtual";
|
|
|
64
65
|
const markoExt = ".marko";
|
|
65
66
|
const htmlExt = ".html";
|
|
66
67
|
const resolveOpts = { skipSelf: true };
|
|
68
|
+
const cache = /* @__PURE__ */ new Map();
|
|
67
69
|
const thisFile = typeof __filename === "string" ? __filename : (0, import_url.fileURLToPath)(import_meta.url);
|
|
68
70
|
let tempDir;
|
|
69
71
|
function markoPlugin(opts = {}) {
|
|
@@ -71,10 +73,10 @@ function markoPlugin(opts = {}) {
|
|
|
71
73
|
let compiler;
|
|
72
74
|
const { runtimeId, linked = true } = opts;
|
|
73
75
|
const baseConfig = {
|
|
76
|
+
cache,
|
|
74
77
|
runtimeId,
|
|
75
78
|
sourceMaps: true,
|
|
76
79
|
writeVersionComment: false,
|
|
77
|
-
cache: /* @__PURE__ */ new Map(),
|
|
78
80
|
babelConfig: __spreadProps(__spreadValues({}, opts.babelConfig), {
|
|
79
81
|
caller: __spreadValues({
|
|
80
82
|
name: "@marko/vite",
|
|
@@ -83,27 +85,30 @@ function markoPlugin(opts = {}) {
|
|
|
83
85
|
supportsTopLevelAwait: true,
|
|
84
86
|
supportsExportNamespaceFrom: true
|
|
85
87
|
}, (_a = opts.babelConfig) == null ? void 0 : _a.caller)
|
|
86
|
-
})
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
88
|
+
})
|
|
89
|
+
};
|
|
90
|
+
const resolveViteVirtualDep = (from, dep) => {
|
|
91
|
+
const query = `${virtualFileQuery}&id=${normalizePath(dep.virtualPath)}`;
|
|
92
|
+
const id = normalizePath(from) + query;
|
|
93
|
+
if (devServer) {
|
|
94
|
+
const prev = virtualFiles.get(id);
|
|
95
|
+
if (prev && prev.code !== dep.code) {
|
|
96
|
+
devServer.moduleGraph.invalidateModule(devServer.moduleGraph.getModuleById(id));
|
|
95
97
|
}
|
|
96
|
-
virtualFiles.set(id, dep);
|
|
97
|
-
return `./${import_path.default.basename(from) + query}`;
|
|
98
98
|
}
|
|
99
|
+
virtualFiles.set(id, dep);
|
|
100
|
+
return `./${import_path.default.basename(from) + query}`;
|
|
99
101
|
};
|
|
100
102
|
const ssrConfig = __spreadProps(__spreadValues({}, baseConfig), {
|
|
103
|
+
resolveVirtualDependency: resolveViteVirtualDep,
|
|
101
104
|
output: "html"
|
|
102
105
|
});
|
|
103
106
|
const domConfig = __spreadProps(__spreadValues({}, baseConfig), {
|
|
107
|
+
resolveVirtualDependency: resolveViteVirtualDep,
|
|
104
108
|
output: "dom"
|
|
105
109
|
});
|
|
106
|
-
const hydrateConfig = __spreadProps(__spreadValues({},
|
|
110
|
+
const hydrateConfig = __spreadProps(__spreadValues({}, baseConfig), {
|
|
111
|
+
resolveVirtualDependency: resolveViteVirtualDep,
|
|
107
112
|
output: "hydrate"
|
|
108
113
|
});
|
|
109
114
|
let root;
|
|
@@ -120,6 +125,7 @@ function markoPlugin(opts = {}) {
|
|
|
120
125
|
name: "marko-vite:pre",
|
|
121
126
|
enforce: "pre",
|
|
122
127
|
async config(config, env) {
|
|
128
|
+
var _a2, _b, _c;
|
|
123
129
|
compiler ?? (compiler = await import(opts.compiler || "@marko/compiler"));
|
|
124
130
|
root = normalizePath(config.root || process.cwd());
|
|
125
131
|
devEntryFile = import_path.default.join(root, "index.html");
|
|
@@ -151,19 +157,27 @@ function markoPlugin(opts = {}) {
|
|
|
151
157
|
const domDeps = Array.from(new Set(compiler.getRuntimeEntryFiles("dom", opts.translator).concat(taglibDeps)));
|
|
152
158
|
const optimizeDeps = config.optimizeDeps ?? (config.optimizeDeps = {});
|
|
153
159
|
optimizeDeps.include ?? (optimizeDeps.include = []);
|
|
154
|
-
optimizeDeps.include = optimizeDeps.include.concat(domDeps
|
|
155
|
-
optimizeDeps.exclude ?? (optimizeDeps.exclude = []);
|
|
156
|
-
optimizeDeps.exclude = optimizeDeps.exclude.concat(domDeps.filter((dep) => import_path.default.extname(dep) === markoExt));
|
|
160
|
+
optimizeDeps.include = optimizeDeps.include.concat(domDeps);
|
|
157
161
|
if (!isBuild) {
|
|
158
|
-
const serverDeps = Array.from(new Set(compiler.getRuntimeEntryFiles("html", opts.translator)
|
|
162
|
+
const serverDeps = Array.from(new Set(compiler.getRuntimeEntryFiles("html", opts.translator)));
|
|
159
163
|
const ssr = config.ssr ?? (config.ssr = {});
|
|
160
164
|
ssr.external ?? (ssr.external = []);
|
|
161
165
|
ssr.external = ssr.external.concat(serverDeps);
|
|
162
|
-
(await import("@marko/compiler/register.js")).default(__spreadProps(__spreadValues({}, ssrConfig), {
|
|
163
|
-
sourceMaps: "inline",
|
|
164
|
-
modules: "cjs"
|
|
165
|
-
}));
|
|
166
166
|
}
|
|
167
|
+
return __spreadProps(__spreadValues({}, config), {
|
|
168
|
+
optimizeDeps: __spreadProps(__spreadValues({}, config.optimizeDeps), {
|
|
169
|
+
extensions: [
|
|
170
|
+
".marko",
|
|
171
|
+
...((_a2 = config.optimizeDeps) == null ? void 0 : _a2.extensions) || []
|
|
172
|
+
],
|
|
173
|
+
esbuildOptions: {
|
|
174
|
+
plugins: [
|
|
175
|
+
(0, import_esbuild_plugin.default)(compiler, baseConfig),
|
|
176
|
+
...((_c = (_b = config.optimizeDeps) == null ? void 0 : _b.esbuildOptions) == null ? void 0 : _c.plugins) || []
|
|
177
|
+
]
|
|
178
|
+
}
|
|
179
|
+
})
|
|
180
|
+
});
|
|
167
181
|
},
|
|
168
182
|
configureServer(_server) {
|
|
169
183
|
ssrConfig.hot = domConfig.hot = true;
|
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import {
|
|
2
|
+
esbuildPlugin
|
|
3
|
+
} from "./chunk-2WEBYHWI.mjs";
|
|
1
4
|
import {
|
|
2
5
|
generateDocManifest,
|
|
3
6
|
generateInputDoc
|
|
@@ -27,6 +30,7 @@ var virtualFileQuery = "?marko-virtual";
|
|
|
27
30
|
var markoExt = ".marko";
|
|
28
31
|
var htmlExt = ".html";
|
|
29
32
|
var resolveOpts = { skipSelf: true };
|
|
33
|
+
var cache = /* @__PURE__ */ new Map();
|
|
30
34
|
var thisFile = typeof __filename === "string" ? __filename : fileURLToPath(import.meta.url);
|
|
31
35
|
var tempDir;
|
|
32
36
|
function markoPlugin(opts = {}) {
|
|
@@ -34,10 +38,10 @@ function markoPlugin(opts = {}) {
|
|
|
34
38
|
let compiler;
|
|
35
39
|
const { runtimeId, linked = true } = opts;
|
|
36
40
|
const baseConfig = {
|
|
41
|
+
cache,
|
|
37
42
|
runtimeId,
|
|
38
43
|
sourceMaps: true,
|
|
39
44
|
writeVersionComment: false,
|
|
40
|
-
cache: /* @__PURE__ */ new Map(),
|
|
41
45
|
babelConfig: __spreadProps(__spreadValues({}, opts.babelConfig), {
|
|
42
46
|
caller: __spreadValues({
|
|
43
47
|
name: "@marko/vite",
|
|
@@ -46,27 +50,30 @@ function markoPlugin(opts = {}) {
|
|
|
46
50
|
supportsTopLevelAwait: true,
|
|
47
51
|
supportsExportNamespaceFrom: true
|
|
48
52
|
}, (_a = opts.babelConfig) == null ? void 0 : _a.caller)
|
|
49
|
-
})
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
53
|
+
})
|
|
54
|
+
};
|
|
55
|
+
const resolveViteVirtualDep = (from, dep) => {
|
|
56
|
+
const query = `${virtualFileQuery}&id=${normalizePath(dep.virtualPath)}`;
|
|
57
|
+
const id = normalizePath(from) + query;
|
|
58
|
+
if (devServer) {
|
|
59
|
+
const prev = virtualFiles.get(id);
|
|
60
|
+
if (prev && prev.code !== dep.code) {
|
|
61
|
+
devServer.moduleGraph.invalidateModule(devServer.moduleGraph.getModuleById(id));
|
|
58
62
|
}
|
|
59
|
-
virtualFiles.set(id, dep);
|
|
60
|
-
return `./${path.basename(from) + query}`;
|
|
61
63
|
}
|
|
64
|
+
virtualFiles.set(id, dep);
|
|
65
|
+
return `./${path.basename(from) + query}`;
|
|
62
66
|
};
|
|
63
67
|
const ssrConfig = __spreadProps(__spreadValues({}, baseConfig), {
|
|
68
|
+
resolveVirtualDependency: resolveViteVirtualDep,
|
|
64
69
|
output: "html"
|
|
65
70
|
});
|
|
66
71
|
const domConfig = __spreadProps(__spreadValues({}, baseConfig), {
|
|
72
|
+
resolveVirtualDependency: resolveViteVirtualDep,
|
|
67
73
|
output: "dom"
|
|
68
74
|
});
|
|
69
|
-
const hydrateConfig = __spreadProps(__spreadValues({},
|
|
75
|
+
const hydrateConfig = __spreadProps(__spreadValues({}, baseConfig), {
|
|
76
|
+
resolveVirtualDependency: resolveViteVirtualDep,
|
|
70
77
|
output: "hydrate"
|
|
71
78
|
});
|
|
72
79
|
let root;
|
|
@@ -83,6 +90,7 @@ function markoPlugin(opts = {}) {
|
|
|
83
90
|
name: "marko-vite:pre",
|
|
84
91
|
enforce: "pre",
|
|
85
92
|
async config(config, env) {
|
|
93
|
+
var _a2, _b, _c;
|
|
86
94
|
compiler ?? (compiler = await import(opts.compiler || "@marko/compiler"));
|
|
87
95
|
root = normalizePath(config.root || process.cwd());
|
|
88
96
|
devEntryFile = path.join(root, "index.html");
|
|
@@ -114,19 +122,27 @@ function markoPlugin(opts = {}) {
|
|
|
114
122
|
const domDeps = Array.from(new Set(compiler.getRuntimeEntryFiles("dom", opts.translator).concat(taglibDeps)));
|
|
115
123
|
const optimizeDeps = config.optimizeDeps ?? (config.optimizeDeps = {});
|
|
116
124
|
optimizeDeps.include ?? (optimizeDeps.include = []);
|
|
117
|
-
optimizeDeps.include = optimizeDeps.include.concat(domDeps
|
|
118
|
-
optimizeDeps.exclude ?? (optimizeDeps.exclude = []);
|
|
119
|
-
optimizeDeps.exclude = optimizeDeps.exclude.concat(domDeps.filter((dep) => path.extname(dep) === markoExt));
|
|
125
|
+
optimizeDeps.include = optimizeDeps.include.concat(domDeps);
|
|
120
126
|
if (!isBuild) {
|
|
121
|
-
const serverDeps = Array.from(new Set(compiler.getRuntimeEntryFiles("html", opts.translator)
|
|
127
|
+
const serverDeps = Array.from(new Set(compiler.getRuntimeEntryFiles("html", opts.translator)));
|
|
122
128
|
const ssr = config.ssr ?? (config.ssr = {});
|
|
123
129
|
ssr.external ?? (ssr.external = []);
|
|
124
130
|
ssr.external = ssr.external.concat(serverDeps);
|
|
125
|
-
(await import("@marko/compiler/register.js")).default(__spreadProps(__spreadValues({}, ssrConfig), {
|
|
126
|
-
sourceMaps: "inline",
|
|
127
|
-
modules: "cjs"
|
|
128
|
-
}));
|
|
129
131
|
}
|
|
132
|
+
return __spreadProps(__spreadValues({}, config), {
|
|
133
|
+
optimizeDeps: __spreadProps(__spreadValues({}, config.optimizeDeps), {
|
|
134
|
+
extensions: [
|
|
135
|
+
".marko",
|
|
136
|
+
...((_a2 = config.optimizeDeps) == null ? void 0 : _a2.extensions) || []
|
|
137
|
+
],
|
|
138
|
+
esbuildOptions: {
|
|
139
|
+
plugins: [
|
|
140
|
+
esbuildPlugin(compiler, baseConfig),
|
|
141
|
+
...((_c = (_b = config.optimizeDeps) == null ? void 0 : _b.esbuildOptions) == null ? void 0 : _c.plugins) || []
|
|
142
|
+
]
|
|
143
|
+
}
|
|
144
|
+
})
|
|
145
|
+
});
|
|
130
146
|
},
|
|
131
147
|
configureServer(_server) {
|
|
132
148
|
ssrConfig.hot = domConfig.hot = true;
|
package/package.json
CHANGED