@marko/vite 2.4.1 → 2.4.2
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 +23 -24
- package/dist/index.mjs +23 -24
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -112,13 +112,14 @@ function markoPlugin(opts = {}) {
|
|
|
112
112
|
let root;
|
|
113
113
|
let devEntryFile;
|
|
114
114
|
let devEntryFilePosix;
|
|
115
|
+
let isTest = false;
|
|
115
116
|
let isBuild = false;
|
|
116
117
|
let isSSRBuild = false;
|
|
117
118
|
let devServer;
|
|
118
119
|
let registeredTag = false;
|
|
119
120
|
let serverManifest;
|
|
120
121
|
let store;
|
|
121
|
-
let
|
|
122
|
+
let CJSTemplates;
|
|
122
123
|
let basePath = "/";
|
|
123
124
|
const entrySources = /* @__PURE__ */ new Map();
|
|
124
125
|
const transformWatchFiles = /* @__PURE__ */ new Map();
|
|
@@ -134,6 +135,7 @@ function markoPlugin(opts = {}) {
|
|
|
134
135
|
root = normalizePath(config.root || process.cwd());
|
|
135
136
|
devEntryFile = import_path.default.join(root, "index.html");
|
|
136
137
|
devEntryFilePosix = normalizePath(devEntryFile);
|
|
138
|
+
isTest = env.mode === "test";
|
|
137
139
|
isBuild = env.command === "build";
|
|
138
140
|
isSSRBuild = isBuild && linked && Boolean(config.build.ssr);
|
|
139
141
|
store = opts.store || new import_store.FileStore(
|
|
@@ -166,12 +168,10 @@ function markoPlugin(opts = {}) {
|
|
|
166
168
|
if (entry) {
|
|
167
169
|
const relativePath = (0, import_relative_import_path.relativeImportPath)(devEntryFile, entry);
|
|
168
170
|
taglibDeps.push(relativePath);
|
|
169
|
-
if (isBuild || (isEsm ?? (isEsm = getModuleType(taglib.path) === "esm"))) {
|
|
171
|
+
if (isTest || isBuild || (isEsm ?? (isEsm = getModuleType(taglib.path) === "esm"))) {
|
|
170
172
|
optimizeTaglibDeps.push(relativePath);
|
|
171
173
|
} else {
|
|
172
|
-
(
|
|
173
|
-
template: tag.template
|
|
174
|
-
});
|
|
174
|
+
(CJSTemplates ?? (CJSTemplates = /* @__PURE__ */ new Set())).add(normalizePath(entry));
|
|
175
175
|
}
|
|
176
176
|
}
|
|
177
177
|
}
|
|
@@ -320,22 +320,6 @@ function markoPlugin(opts = {}) {
|
|
|
320
320
|
return null;
|
|
321
321
|
},
|
|
322
322
|
async load(id) {
|
|
323
|
-
if (cjsImports == null ? void 0 : cjsImports.has(id)) {
|
|
324
|
-
const tag = cjsImports.get(id);
|
|
325
|
-
if (!tag.esmWrapper) {
|
|
326
|
-
const { ast } = await compiler.compileFile(tag.template, {
|
|
327
|
-
output: "source",
|
|
328
|
-
ast: true,
|
|
329
|
-
sourceMaps: false,
|
|
330
|
-
code: false
|
|
331
|
-
});
|
|
332
|
-
tag.esmWrapper = await createEsmWrapper(
|
|
333
|
-
id,
|
|
334
|
-
getExportIdentifiers(ast)
|
|
335
|
-
);
|
|
336
|
-
}
|
|
337
|
-
return tag.esmWrapper;
|
|
338
|
-
}
|
|
339
323
|
switch (getMarkoQuery(id)) {
|
|
340
324
|
case serverEntryQuery: {
|
|
341
325
|
const fileName = id.slice(0, -serverEntryQuery.length);
|
|
@@ -385,6 +369,7 @@ function markoPlugin(opts = {}) {
|
|
|
385
369
|
);
|
|
386
370
|
},
|
|
387
371
|
async transform(source, id, ssr) {
|
|
372
|
+
const isSSR = typeof ssr === "object" ? ssr.ssr : ssr;
|
|
388
373
|
const query = getMarkoQuery(id);
|
|
389
374
|
if (query && !query.startsWith(virtualFileQuery)) {
|
|
390
375
|
id = id.slice(0, -query.length);
|
|
@@ -392,10 +377,24 @@ function markoPlugin(opts = {}) {
|
|
|
392
377
|
id = `${id.slice(0, -markoExt.length)}.entry.marko`;
|
|
393
378
|
}
|
|
394
379
|
}
|
|
395
|
-
if (!isMarkoFile(id)
|
|
380
|
+
if (!isMarkoFile(id)) {
|
|
396
381
|
return null;
|
|
397
382
|
}
|
|
398
|
-
if (
|
|
383
|
+
if (CJSTemplates == null ? void 0 : CJSTemplates.has(id)) {
|
|
384
|
+
return createEsmWrapper(
|
|
385
|
+
id,
|
|
386
|
+
getExportIdentifiers(
|
|
387
|
+
(await compiler.compile(source, id, {
|
|
388
|
+
cache,
|
|
389
|
+
ast: true,
|
|
390
|
+
code: false,
|
|
391
|
+
output: "source",
|
|
392
|
+
sourceMaps: false
|
|
393
|
+
})).ast
|
|
394
|
+
)
|
|
395
|
+
);
|
|
396
|
+
}
|
|
397
|
+
if (isSSR && linked && entrySources.has(id)) {
|
|
399
398
|
entrySources.set(id, source);
|
|
400
399
|
if (serverManifest) {
|
|
401
400
|
serverManifest.entrySources[import_path.default.posix.relative(root, id)] = source;
|
|
@@ -404,7 +403,7 @@ function markoPlugin(opts = {}) {
|
|
|
404
403
|
const compiled = await compiler.compile(
|
|
405
404
|
source,
|
|
406
405
|
id,
|
|
407
|
-
|
|
406
|
+
isSSR ? ssrConfig : query === browserEntryQuery ? hydrateConfig : domConfig
|
|
408
407
|
);
|
|
409
408
|
const { map, meta } = compiled;
|
|
410
409
|
let { code } = compiled;
|
package/dist/index.mjs
CHANGED
|
@@ -92,13 +92,14 @@ function markoPlugin(opts = {}) {
|
|
|
92
92
|
let root;
|
|
93
93
|
let devEntryFile;
|
|
94
94
|
let devEntryFilePosix;
|
|
95
|
+
let isTest = false;
|
|
95
96
|
let isBuild = false;
|
|
96
97
|
let isSSRBuild = false;
|
|
97
98
|
let devServer;
|
|
98
99
|
let registeredTag = false;
|
|
99
100
|
let serverManifest;
|
|
100
101
|
let store;
|
|
101
|
-
let
|
|
102
|
+
let CJSTemplates;
|
|
102
103
|
let basePath = "/";
|
|
103
104
|
const entrySources = /* @__PURE__ */ new Map();
|
|
104
105
|
const transformWatchFiles = /* @__PURE__ */ new Map();
|
|
@@ -114,6 +115,7 @@ function markoPlugin(opts = {}) {
|
|
|
114
115
|
root = normalizePath(config.root || process.cwd());
|
|
115
116
|
devEntryFile = path.join(root, "index.html");
|
|
116
117
|
devEntryFilePosix = normalizePath(devEntryFile);
|
|
118
|
+
isTest = env.mode === "test";
|
|
117
119
|
isBuild = env.command === "build";
|
|
118
120
|
isSSRBuild = isBuild && linked && Boolean(config.build.ssr);
|
|
119
121
|
store = opts.store || new FileStore(
|
|
@@ -146,12 +148,10 @@ function markoPlugin(opts = {}) {
|
|
|
146
148
|
if (entry) {
|
|
147
149
|
const relativePath = relativeImportPath(devEntryFile, entry);
|
|
148
150
|
taglibDeps.push(relativePath);
|
|
149
|
-
if (isBuild || (isEsm ?? (isEsm = getModuleType(taglib.path) === "esm"))) {
|
|
151
|
+
if (isTest || isBuild || (isEsm ?? (isEsm = getModuleType(taglib.path) === "esm"))) {
|
|
150
152
|
optimizeTaglibDeps.push(relativePath);
|
|
151
153
|
} else {
|
|
152
|
-
(
|
|
153
|
-
template: tag.template
|
|
154
|
-
});
|
|
154
|
+
(CJSTemplates ?? (CJSTemplates = /* @__PURE__ */ new Set())).add(normalizePath(entry));
|
|
155
155
|
}
|
|
156
156
|
}
|
|
157
157
|
}
|
|
@@ -300,22 +300,6 @@ function markoPlugin(opts = {}) {
|
|
|
300
300
|
return null;
|
|
301
301
|
},
|
|
302
302
|
async load(id) {
|
|
303
|
-
if (cjsImports == null ? void 0 : cjsImports.has(id)) {
|
|
304
|
-
const tag = cjsImports.get(id);
|
|
305
|
-
if (!tag.esmWrapper) {
|
|
306
|
-
const { ast } = await compiler.compileFile(tag.template, {
|
|
307
|
-
output: "source",
|
|
308
|
-
ast: true,
|
|
309
|
-
sourceMaps: false,
|
|
310
|
-
code: false
|
|
311
|
-
});
|
|
312
|
-
tag.esmWrapper = await createEsmWrapper(
|
|
313
|
-
id,
|
|
314
|
-
getExportIdentifiers(ast)
|
|
315
|
-
);
|
|
316
|
-
}
|
|
317
|
-
return tag.esmWrapper;
|
|
318
|
-
}
|
|
319
303
|
switch (getMarkoQuery(id)) {
|
|
320
304
|
case serverEntryQuery: {
|
|
321
305
|
const fileName = id.slice(0, -serverEntryQuery.length);
|
|
@@ -365,6 +349,7 @@ function markoPlugin(opts = {}) {
|
|
|
365
349
|
);
|
|
366
350
|
},
|
|
367
351
|
async transform(source, id, ssr) {
|
|
352
|
+
const isSSR = typeof ssr === "object" ? ssr.ssr : ssr;
|
|
368
353
|
const query = getMarkoQuery(id);
|
|
369
354
|
if (query && !query.startsWith(virtualFileQuery)) {
|
|
370
355
|
id = id.slice(0, -query.length);
|
|
@@ -372,10 +357,24 @@ function markoPlugin(opts = {}) {
|
|
|
372
357
|
id = `${id.slice(0, -markoExt.length)}.entry.marko`;
|
|
373
358
|
}
|
|
374
359
|
}
|
|
375
|
-
if (!isMarkoFile(id)
|
|
360
|
+
if (!isMarkoFile(id)) {
|
|
376
361
|
return null;
|
|
377
362
|
}
|
|
378
|
-
if (
|
|
363
|
+
if (CJSTemplates == null ? void 0 : CJSTemplates.has(id)) {
|
|
364
|
+
return createEsmWrapper(
|
|
365
|
+
id,
|
|
366
|
+
getExportIdentifiers(
|
|
367
|
+
(await compiler.compile(source, id, {
|
|
368
|
+
cache,
|
|
369
|
+
ast: true,
|
|
370
|
+
code: false,
|
|
371
|
+
output: "source",
|
|
372
|
+
sourceMaps: false
|
|
373
|
+
})).ast
|
|
374
|
+
)
|
|
375
|
+
);
|
|
376
|
+
}
|
|
377
|
+
if (isSSR && linked && entrySources.has(id)) {
|
|
379
378
|
entrySources.set(id, source);
|
|
380
379
|
if (serverManifest) {
|
|
381
380
|
serverManifest.entrySources[path.posix.relative(root, id)] = source;
|
|
@@ -384,7 +383,7 @@ function markoPlugin(opts = {}) {
|
|
|
384
383
|
const compiled = await compiler.compile(
|
|
385
384
|
source,
|
|
386
385
|
id,
|
|
387
|
-
|
|
386
|
+
isSSR ? ssrConfig : query === browserEntryQuery ? hydrateConfig : domConfig
|
|
388
387
|
);
|
|
389
388
|
const { map, meta } = compiled;
|
|
390
389
|
let { code } = compiled;
|