@marko/vite 2.3.7 → 2.3.9
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.js +18 -30
- package/dist/index.mjs +18 -30
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -102,7 +102,7 @@ function markoPlugin(opts = {}) {
|
|
|
102
102
|
let devServer;
|
|
103
103
|
let registeredTag = false;
|
|
104
104
|
let serverManifest;
|
|
105
|
-
const
|
|
105
|
+
const entrySources = /* @__PURE__ */ new Map();
|
|
106
106
|
const transformWatchFiles = /* @__PURE__ */ new Map();
|
|
107
107
|
const transformOptionalFiles = /* @__PURE__ */ new Map();
|
|
108
108
|
return [
|
|
@@ -110,7 +110,6 @@ function markoPlugin(opts = {}) {
|
|
|
110
110
|
name: "marko-vite:pre",
|
|
111
111
|
enforce: "pre",
|
|
112
112
|
async config(config, env) {
|
|
113
|
-
var _a2, _b, _c;
|
|
114
113
|
compiler ?? (compiler = await import(opts.compiler || "@marko/compiler"));
|
|
115
114
|
root = normalizePath(config.root || process.cwd());
|
|
116
115
|
devEntryFile = import_path.default.join(root, "index.html");
|
|
@@ -146,30 +145,22 @@ function markoPlugin(opts = {}) {
|
|
|
146
145
|
...compiler.getRuntimeEntryFiles("html", opts.translator),
|
|
147
146
|
...taglibDeps
|
|
148
147
|
]));
|
|
148
|
+
const optimizeExtensions = optimizeDeps.extensions ?? (optimizeDeps.extensions = []);
|
|
149
|
+
optimizeExtensions.push(".marko");
|
|
150
|
+
const esbuildOptions = optimizeDeps.esbuildOptions ?? (optimizeDeps.esbuildOptions = {});
|
|
151
|
+
const esbuildPlugins = esbuildOptions.plugins ?? (esbuildOptions.plugins = []);
|
|
152
|
+
esbuildPlugins.push((0, import_esbuild_plugin.default)(compiler, baseConfig));
|
|
149
153
|
const ssr = config.ssr ?? (config.ssr = {});
|
|
150
154
|
if (ssr.noExternal !== true) {
|
|
151
155
|
ssr.noExternal = Array.from(new Set(taglibDeps.concat(ssr.noExternal || [])));
|
|
152
156
|
}
|
|
153
|
-
return {
|
|
154
|
-
...config,
|
|
155
|
-
optimizeDeps: {
|
|
156
|
-
...config.optimizeDeps,
|
|
157
|
-
extensions: [".marko", ...((_a2 = config.optimizeDeps) == null ? void 0 : _a2.extensions) || []],
|
|
158
|
-
esbuildOptions: {
|
|
159
|
-
plugins: [
|
|
160
|
-
(0, import_esbuild_plugin.default)(compiler, baseConfig),
|
|
161
|
-
...((_c = (_b = config.optimizeDeps) == null ? void 0 : _b.esbuildOptions) == null ? void 0 : _c.plugins) || []
|
|
162
|
-
]
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
};
|
|
166
157
|
},
|
|
167
158
|
configureServer(_server) {
|
|
168
159
|
ssrConfig.hot = domConfig.hot = true;
|
|
169
160
|
devServer = _server;
|
|
170
161
|
devServer.watcher.on("all", (type, filename) => {
|
|
171
162
|
if (type === "unlink") {
|
|
172
|
-
|
|
163
|
+
entrySources.delete(filename);
|
|
173
164
|
}
|
|
174
165
|
for (const [id, files] of transformWatchFiles) {
|
|
175
166
|
if ((0, import_anymatch.default)(files, filename)) {
|
|
@@ -197,6 +188,9 @@ function markoPlugin(opts = {}) {
|
|
|
197
188
|
try {
|
|
198
189
|
serverManifest = JSON.parse(await import_fs.default.promises.readFile(serverMetaFile, "utf-8"));
|
|
199
190
|
inputOptions.input = toHTMLEntries(root, serverManifest.entries);
|
|
191
|
+
for (const entry in serverManifest.entrySources) {
|
|
192
|
+
entrySources.set(import_path.default.resolve(root, entry), serverManifest.entrySources[entry]);
|
|
193
|
+
}
|
|
200
194
|
} catch (err) {
|
|
201
195
|
this.error(`You must run the "ssr" build before the "browser" build.`);
|
|
202
196
|
}
|
|
@@ -246,17 +240,18 @@ function markoPlugin(opts = {}) {
|
|
|
246
240
|
case serverEntryQuery: {
|
|
247
241
|
const fileName = id.slice(0, -serverEntryQuery.length);
|
|
248
242
|
let entryData;
|
|
243
|
+
entrySources.set(fileName, "");
|
|
249
244
|
if (isBuild) {
|
|
250
245
|
const relativeFileName = import_path.default.posix.relative(root, fileName);
|
|
251
246
|
const entryId = toEntryId(relativeFileName);
|
|
252
247
|
serverManifest ?? (serverManifest = {
|
|
253
248
|
entries: {},
|
|
249
|
+
entrySources: {},
|
|
254
250
|
chunksNeedingAssets: []
|
|
255
251
|
});
|
|
256
252
|
serverManifest.entries[entryId] = relativeFileName;
|
|
257
253
|
entryData = JSON.stringify(entryId);
|
|
258
254
|
} else {
|
|
259
|
-
devEntryFileSources.set(fileName, "");
|
|
260
255
|
entryData = JSON.stringify(await (0, import_manifest_generator.generateDocManifest)(await devServer.transformIndexHtml("/", (0, import_manifest_generator.generateInputDoc)(fileNameToURL(fileName, root)))));
|
|
261
256
|
}
|
|
262
257
|
return (0, import_server_entry_template.default)({
|
|
@@ -266,17 +261,7 @@ function markoPlugin(opts = {}) {
|
|
|
266
261
|
});
|
|
267
262
|
}
|
|
268
263
|
case browserEntryQuery: {
|
|
269
|
-
|
|
270
|
-
if (isBuild) {
|
|
271
|
-
const {
|
|
272
|
-
meta: { source }
|
|
273
|
-
} = await this.load({
|
|
274
|
-
id: realId,
|
|
275
|
-
resolveDependencies: false
|
|
276
|
-
});
|
|
277
|
-
return source;
|
|
278
|
-
}
|
|
279
|
-
return devEntryFileSources.get(realId);
|
|
264
|
+
return entrySources.get(id.slice(0, -browserEntryQuery.length));
|
|
280
265
|
}
|
|
281
266
|
}
|
|
282
267
|
return virtualFiles.get(id) || null;
|
|
@@ -298,8 +283,11 @@ function markoPlugin(opts = {}) {
|
|
|
298
283
|
if (!isMarkoFile(id)) {
|
|
299
284
|
return null;
|
|
300
285
|
}
|
|
301
|
-
if (ssr &&
|
|
302
|
-
|
|
286
|
+
if (ssr && entrySources.has(id)) {
|
|
287
|
+
entrySources.set(id, source);
|
|
288
|
+
if (serverManifest) {
|
|
289
|
+
serverManifest.entrySources[import_path.default.relative(root, id)] = source;
|
|
290
|
+
}
|
|
303
291
|
}
|
|
304
292
|
const compiled = await compiler.compile(source, id, (typeof ssr === "object" ? ssr.ssr : ssr) ? ssrConfig : query === browserEntryQuery ? hydrateConfig : domConfig);
|
|
305
293
|
const { map, meta } = compiled;
|
package/dist/index.mjs
CHANGED
|
@@ -85,7 +85,7 @@ function markoPlugin(opts = {}) {
|
|
|
85
85
|
let devServer;
|
|
86
86
|
let registeredTag = false;
|
|
87
87
|
let serverManifest;
|
|
88
|
-
const
|
|
88
|
+
const entrySources = /* @__PURE__ */ new Map();
|
|
89
89
|
const transformWatchFiles = /* @__PURE__ */ new Map();
|
|
90
90
|
const transformOptionalFiles = /* @__PURE__ */ new Map();
|
|
91
91
|
return [
|
|
@@ -93,7 +93,6 @@ function markoPlugin(opts = {}) {
|
|
|
93
93
|
name: "marko-vite:pre",
|
|
94
94
|
enforce: "pre",
|
|
95
95
|
async config(config, env) {
|
|
96
|
-
var _a2, _b, _c;
|
|
97
96
|
compiler ?? (compiler = await import(opts.compiler || "@marko/compiler"));
|
|
98
97
|
root = normalizePath(config.root || process.cwd());
|
|
99
98
|
devEntryFile = path.join(root, "index.html");
|
|
@@ -129,30 +128,22 @@ function markoPlugin(opts = {}) {
|
|
|
129
128
|
...compiler.getRuntimeEntryFiles("html", opts.translator),
|
|
130
129
|
...taglibDeps
|
|
131
130
|
]));
|
|
131
|
+
const optimizeExtensions = optimizeDeps.extensions ?? (optimizeDeps.extensions = []);
|
|
132
|
+
optimizeExtensions.push(".marko");
|
|
133
|
+
const esbuildOptions = optimizeDeps.esbuildOptions ?? (optimizeDeps.esbuildOptions = {});
|
|
134
|
+
const esbuildPlugins = esbuildOptions.plugins ?? (esbuildOptions.plugins = []);
|
|
135
|
+
esbuildPlugins.push(esbuildPlugin(compiler, baseConfig));
|
|
132
136
|
const ssr = config.ssr ?? (config.ssr = {});
|
|
133
137
|
if (ssr.noExternal !== true) {
|
|
134
138
|
ssr.noExternal = Array.from(new Set(taglibDeps.concat(ssr.noExternal || [])));
|
|
135
139
|
}
|
|
136
|
-
return {
|
|
137
|
-
...config,
|
|
138
|
-
optimizeDeps: {
|
|
139
|
-
...config.optimizeDeps,
|
|
140
|
-
extensions: [".marko", ...((_a2 = config.optimizeDeps) == null ? void 0 : _a2.extensions) || []],
|
|
141
|
-
esbuildOptions: {
|
|
142
|
-
plugins: [
|
|
143
|
-
esbuildPlugin(compiler, baseConfig),
|
|
144
|
-
...((_c = (_b = config.optimizeDeps) == null ? void 0 : _b.esbuildOptions) == null ? void 0 : _c.plugins) || []
|
|
145
|
-
]
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
};
|
|
149
140
|
},
|
|
150
141
|
configureServer(_server) {
|
|
151
142
|
ssrConfig.hot = domConfig.hot = true;
|
|
152
143
|
devServer = _server;
|
|
153
144
|
devServer.watcher.on("all", (type, filename) => {
|
|
154
145
|
if (type === "unlink") {
|
|
155
|
-
|
|
146
|
+
entrySources.delete(filename);
|
|
156
147
|
}
|
|
157
148
|
for (const [id, files] of transformWatchFiles) {
|
|
158
149
|
if (anyMatch(files, filename)) {
|
|
@@ -180,6 +171,9 @@ function markoPlugin(opts = {}) {
|
|
|
180
171
|
try {
|
|
181
172
|
serverManifest = JSON.parse(await fs.promises.readFile(serverMetaFile, "utf-8"));
|
|
182
173
|
inputOptions.input = toHTMLEntries(root, serverManifest.entries);
|
|
174
|
+
for (const entry in serverManifest.entrySources) {
|
|
175
|
+
entrySources.set(path.resolve(root, entry), serverManifest.entrySources[entry]);
|
|
176
|
+
}
|
|
183
177
|
} catch (err) {
|
|
184
178
|
this.error(`You must run the "ssr" build before the "browser" build.`);
|
|
185
179
|
}
|
|
@@ -229,17 +223,18 @@ function markoPlugin(opts = {}) {
|
|
|
229
223
|
case serverEntryQuery: {
|
|
230
224
|
const fileName = id.slice(0, -serverEntryQuery.length);
|
|
231
225
|
let entryData;
|
|
226
|
+
entrySources.set(fileName, "");
|
|
232
227
|
if (isBuild) {
|
|
233
228
|
const relativeFileName = path.posix.relative(root, fileName);
|
|
234
229
|
const entryId = toEntryId(relativeFileName);
|
|
235
230
|
serverManifest ?? (serverManifest = {
|
|
236
231
|
entries: {},
|
|
232
|
+
entrySources: {},
|
|
237
233
|
chunksNeedingAssets: []
|
|
238
234
|
});
|
|
239
235
|
serverManifest.entries[entryId] = relativeFileName;
|
|
240
236
|
entryData = JSON.stringify(entryId);
|
|
241
237
|
} else {
|
|
242
|
-
devEntryFileSources.set(fileName, "");
|
|
243
238
|
entryData = JSON.stringify(await generateDocManifest(await devServer.transformIndexHtml("/", generateInputDoc(fileNameToURL(fileName, root)))));
|
|
244
239
|
}
|
|
245
240
|
return server_entry_template_default({
|
|
@@ -249,17 +244,7 @@ function markoPlugin(opts = {}) {
|
|
|
249
244
|
});
|
|
250
245
|
}
|
|
251
246
|
case browserEntryQuery: {
|
|
252
|
-
|
|
253
|
-
if (isBuild) {
|
|
254
|
-
const {
|
|
255
|
-
meta: { source }
|
|
256
|
-
} = await this.load({
|
|
257
|
-
id: realId,
|
|
258
|
-
resolveDependencies: false
|
|
259
|
-
});
|
|
260
|
-
return source;
|
|
261
|
-
}
|
|
262
|
-
return devEntryFileSources.get(realId);
|
|
247
|
+
return entrySources.get(id.slice(0, -browserEntryQuery.length));
|
|
263
248
|
}
|
|
264
249
|
}
|
|
265
250
|
return virtualFiles.get(id) || null;
|
|
@@ -281,8 +266,11 @@ function markoPlugin(opts = {}) {
|
|
|
281
266
|
if (!isMarkoFile(id)) {
|
|
282
267
|
return null;
|
|
283
268
|
}
|
|
284
|
-
if (ssr &&
|
|
285
|
-
|
|
269
|
+
if (ssr && entrySources.has(id)) {
|
|
270
|
+
entrySources.set(id, source);
|
|
271
|
+
if (serverManifest) {
|
|
272
|
+
serverManifest.entrySources[path.relative(root, id)] = source;
|
|
273
|
+
}
|
|
286
274
|
}
|
|
287
275
|
const compiled = await compiler.compile(source, id, (typeof ssr === "object" ? ssr.ssr : ssr) ? ssrConfig : query === browserEntryQuery ? hydrateConfig : domConfig);
|
|
288
276
|
const { map, meta } = compiled;
|