@marko/vite 2.2.7 → 2.2.8
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 +28 -33
- package/dist/index.mjs +28 -33
- package/package.json +18 -17
package/dist/index.js
CHANGED
|
@@ -55,6 +55,7 @@ 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
57
|
const import_meta = {};
|
|
58
|
+
const normalizePath = import_path.default.sep === "\\" ? (id) => id.replace(/\\/g, "/") : (id) => id;
|
|
58
59
|
const virtualFiles = /* @__PURE__ */ new Map();
|
|
59
60
|
const queryReg = /\?marko-.+$/;
|
|
60
61
|
const browserEntryQuery = "?marko-browser-entry";
|
|
@@ -89,8 +90,8 @@ function markoPlugin(opts = {}) {
|
|
|
89
90
|
});
|
|
90
91
|
const domConfig = __spreadProps(__spreadValues({}, baseConfig), {
|
|
91
92
|
resolveVirtualDependency(from, dep) {
|
|
92
|
-
const query = `${virtualFileQuery}&id=${dep.virtualPath}`;
|
|
93
|
-
const id = from + query;
|
|
93
|
+
const query = `${virtualFileQuery}&id=${encodeURIComponent(dep.virtualPath)}`;
|
|
94
|
+
const id = normalizePath(from) + query;
|
|
94
95
|
if (devServer) {
|
|
95
96
|
const prev = virtualFiles.get(id);
|
|
96
97
|
if (prev && prev.code !== dep.code) {
|
|
@@ -120,13 +121,13 @@ function markoPlugin(opts = {}) {
|
|
|
120
121
|
enforce: "pre",
|
|
121
122
|
async config(config, env) {
|
|
122
123
|
compiler ?? (compiler = await import(opts.compiler || "@marko/compiler"));
|
|
123
|
-
root = config.root || process.cwd();
|
|
124
|
+
root = normalizePath(config.root || process.cwd());
|
|
124
125
|
devEntryFile = import_path.default.join(root, "index.html");
|
|
125
126
|
isBuild = env.command === "build";
|
|
126
127
|
isSSRBuild = isBuild && linked && Boolean(config.build.ssr);
|
|
127
128
|
if (!registeredTag) {
|
|
128
129
|
const transformer = import_path.default.resolve(thisFile, "../render-assets-transform");
|
|
129
|
-
registeredTag = import_path.default.resolve(thisFile, "../components", isBuild ? "vite.marko" : "vite-watch.marko");
|
|
130
|
+
registeredTag = normalizePath(import_path.default.resolve(thisFile, "../components", isBuild ? "vite.marko" : "vite-watch.marko"));
|
|
130
131
|
compiler.taglib.register("@marko/vite", {
|
|
131
132
|
"<_vite>": { template: registeredTag },
|
|
132
133
|
"<head>": { transformer },
|
|
@@ -219,7 +220,7 @@ function markoPlugin(opts = {}) {
|
|
|
219
220
|
}
|
|
220
221
|
if (importeeQuery) {
|
|
221
222
|
const resolved = importee[0] === "." ? {
|
|
222
|
-
id: importer ? import_path.default.resolve(importer, "..", importee) : import_path.default.resolve(root, importee)
|
|
223
|
+
id: normalizePath(importer ? import_path.default.resolve(importer, "..", importee) : import_path.default.resolve(root, importee))
|
|
223
224
|
} : await this.resolve(importee, importer, resolveOpts);
|
|
224
225
|
if (resolved) {
|
|
225
226
|
resolved.id += importeeQuery;
|
|
@@ -229,36 +230,30 @@ function markoPlugin(opts = {}) {
|
|
|
229
230
|
return null;
|
|
230
231
|
},
|
|
231
232
|
async load(id) {
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
const relativeFileName = import_path.default.relative(root, fileName);
|
|
243
|
-
const entryId = toEntryId(relativeFileName);
|
|
244
|
-
serverManifest ?? (serverManifest = {
|
|
245
|
-
entries: {},
|
|
246
|
-
chunksNeedingAssets: []
|
|
247
|
-
});
|
|
248
|
-
serverManifest.entries[entryId] = relativeFileName;
|
|
249
|
-
entryData = JSON.stringify(entryId);
|
|
250
|
-
} else {
|
|
251
|
-
entryData = JSON.stringify(await (0, import_manifest_generator.generateDocManifest)(await devServer.transformIndexHtml("/", (0, import_manifest_generator.generateInputDoc)(fileNameToURL(fileName, root)))));
|
|
252
|
-
}
|
|
253
|
-
return (0, import_server_entry_template.default)({
|
|
254
|
-
fileName,
|
|
255
|
-
entryData,
|
|
256
|
-
runtimeId
|
|
233
|
+
switch (getMarkoQuery(id)) {
|
|
234
|
+
case serverEntryQuery: {
|
|
235
|
+
const fileName = id.slice(0, -serverEntryQuery.length);
|
|
236
|
+
let entryData;
|
|
237
|
+
if (isBuild) {
|
|
238
|
+
const relativeFileName = import_path.default.posix.relative(root, fileName);
|
|
239
|
+
const entryId = toEntryId(relativeFileName);
|
|
240
|
+
serverManifest ?? (serverManifest = {
|
|
241
|
+
entries: {},
|
|
242
|
+
chunksNeedingAssets: []
|
|
257
243
|
});
|
|
244
|
+
serverManifest.entries[entryId] = relativeFileName;
|
|
245
|
+
entryData = JSON.stringify(entryId);
|
|
246
|
+
} else {
|
|
247
|
+
entryData = JSON.stringify(await (0, import_manifest_generator.generateDocManifest)(await devServer.transformIndexHtml("/", (0, import_manifest_generator.generateInputDoc)(fileNameToURL(fileName, root)))));
|
|
258
248
|
}
|
|
259
|
-
|
|
260
|
-
|
|
249
|
+
return (0, import_server_entry_template.default)({
|
|
250
|
+
fileName,
|
|
251
|
+
entryData,
|
|
252
|
+
runtimeId
|
|
253
|
+
});
|
|
261
254
|
}
|
|
255
|
+
case browserEntryQuery:
|
|
256
|
+
return import_fs.default.promises.readFile(id.slice(0, -browserEntryQuery.length), "utf-8");
|
|
262
257
|
}
|
|
263
258
|
return virtualFiles.get(id) || null;
|
|
264
259
|
},
|
|
@@ -364,7 +359,7 @@ function isMarkoFile(id) {
|
|
|
364
359
|
function toHTMLEntries(root, serverEntries) {
|
|
365
360
|
const result = [];
|
|
366
361
|
for (const id in serverEntries) {
|
|
367
|
-
const markoFile = import_path.default.join(root, serverEntries[id]);
|
|
362
|
+
const markoFile = import_path.default.posix.join(root, serverEntries[id]);
|
|
368
363
|
const htmlFile = markoFile + htmlExt;
|
|
369
364
|
virtualFiles.set(htmlFile, {
|
|
370
365
|
code: (0, import_manifest_generator.generateInputDoc)(markoFile)
|
package/dist/index.mjs
CHANGED
|
@@ -18,6 +18,7 @@ import path from "path";
|
|
|
18
18
|
import crypto from "crypto";
|
|
19
19
|
import anyMatch from "anymatch";
|
|
20
20
|
import { pathToFileURL, fileURLToPath } from "url";
|
|
21
|
+
var normalizePath = path.sep === "\\" ? (id) => id.replace(/\\/g, "/") : (id) => id;
|
|
21
22
|
var virtualFiles = /* @__PURE__ */ new Map();
|
|
22
23
|
var queryReg = /\?marko-.+$/;
|
|
23
24
|
var browserEntryQuery = "?marko-browser-entry";
|
|
@@ -52,8 +53,8 @@ function markoPlugin(opts = {}) {
|
|
|
52
53
|
});
|
|
53
54
|
const domConfig = __spreadProps(__spreadValues({}, baseConfig), {
|
|
54
55
|
resolveVirtualDependency(from, dep) {
|
|
55
|
-
const query = `${virtualFileQuery}&id=${dep.virtualPath}`;
|
|
56
|
-
const id = from + query;
|
|
56
|
+
const query = `${virtualFileQuery}&id=${encodeURIComponent(dep.virtualPath)}`;
|
|
57
|
+
const id = normalizePath(from) + query;
|
|
57
58
|
if (devServer) {
|
|
58
59
|
const prev = virtualFiles.get(id);
|
|
59
60
|
if (prev && prev.code !== dep.code) {
|
|
@@ -83,13 +84,13 @@ function markoPlugin(opts = {}) {
|
|
|
83
84
|
enforce: "pre",
|
|
84
85
|
async config(config, env) {
|
|
85
86
|
compiler ?? (compiler = await import(opts.compiler || "@marko/compiler"));
|
|
86
|
-
root = config.root || process.cwd();
|
|
87
|
+
root = normalizePath(config.root || process.cwd());
|
|
87
88
|
devEntryFile = path.join(root, "index.html");
|
|
88
89
|
isBuild = env.command === "build";
|
|
89
90
|
isSSRBuild = isBuild && linked && Boolean(config.build.ssr);
|
|
90
91
|
if (!registeredTag) {
|
|
91
92
|
const transformer = path.resolve(thisFile, "../render-assets-transform");
|
|
92
|
-
registeredTag = path.resolve(thisFile, "../components", isBuild ? "vite.marko" : "vite-watch.marko");
|
|
93
|
+
registeredTag = normalizePath(path.resolve(thisFile, "../components", isBuild ? "vite.marko" : "vite-watch.marko"));
|
|
93
94
|
compiler.taglib.register("@marko/vite", {
|
|
94
95
|
"<_vite>": { template: registeredTag },
|
|
95
96
|
"<head>": { transformer },
|
|
@@ -182,7 +183,7 @@ function markoPlugin(opts = {}) {
|
|
|
182
183
|
}
|
|
183
184
|
if (importeeQuery) {
|
|
184
185
|
const resolved = importee[0] === "." ? {
|
|
185
|
-
id: importer ? path.resolve(importer, "..", importee) : path.resolve(root, importee)
|
|
186
|
+
id: normalizePath(importer ? path.resolve(importer, "..", importee) : path.resolve(root, importee))
|
|
186
187
|
} : await this.resolve(importee, importer, resolveOpts);
|
|
187
188
|
if (resolved) {
|
|
188
189
|
resolved.id += importeeQuery;
|
|
@@ -192,36 +193,30 @@ function markoPlugin(opts = {}) {
|
|
|
192
193
|
return null;
|
|
193
194
|
},
|
|
194
195
|
async load(id) {
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
const relativeFileName = path.relative(root, fileName);
|
|
206
|
-
const entryId = toEntryId(relativeFileName);
|
|
207
|
-
serverManifest ?? (serverManifest = {
|
|
208
|
-
entries: {},
|
|
209
|
-
chunksNeedingAssets: []
|
|
210
|
-
});
|
|
211
|
-
serverManifest.entries[entryId] = relativeFileName;
|
|
212
|
-
entryData = JSON.stringify(entryId);
|
|
213
|
-
} else {
|
|
214
|
-
entryData = JSON.stringify(await generateDocManifest(await devServer.transformIndexHtml("/", generateInputDoc(fileNameToURL(fileName, root)))));
|
|
215
|
-
}
|
|
216
|
-
return server_entry_template_default({
|
|
217
|
-
fileName,
|
|
218
|
-
entryData,
|
|
219
|
-
runtimeId
|
|
196
|
+
switch (getMarkoQuery(id)) {
|
|
197
|
+
case serverEntryQuery: {
|
|
198
|
+
const fileName = id.slice(0, -serverEntryQuery.length);
|
|
199
|
+
let entryData;
|
|
200
|
+
if (isBuild) {
|
|
201
|
+
const relativeFileName = path.posix.relative(root, fileName);
|
|
202
|
+
const entryId = toEntryId(relativeFileName);
|
|
203
|
+
serverManifest ?? (serverManifest = {
|
|
204
|
+
entries: {},
|
|
205
|
+
chunksNeedingAssets: []
|
|
220
206
|
});
|
|
207
|
+
serverManifest.entries[entryId] = relativeFileName;
|
|
208
|
+
entryData = JSON.stringify(entryId);
|
|
209
|
+
} else {
|
|
210
|
+
entryData = JSON.stringify(await generateDocManifest(await devServer.transformIndexHtml("/", generateInputDoc(fileNameToURL(fileName, root)))));
|
|
221
211
|
}
|
|
222
|
-
|
|
223
|
-
|
|
212
|
+
return server_entry_template_default({
|
|
213
|
+
fileName,
|
|
214
|
+
entryData,
|
|
215
|
+
runtimeId
|
|
216
|
+
});
|
|
224
217
|
}
|
|
218
|
+
case browserEntryQuery:
|
|
219
|
+
return fs.promises.readFile(id.slice(0, -browserEntryQuery.length), "utf-8");
|
|
225
220
|
}
|
|
226
221
|
return virtualFiles.get(id) || null;
|
|
227
222
|
},
|
|
@@ -327,7 +322,7 @@ function isMarkoFile(id) {
|
|
|
327
322
|
function toHTMLEntries(root, serverEntries) {
|
|
328
323
|
const result = [];
|
|
329
324
|
for (const id in serverEntries) {
|
|
330
|
-
const markoFile = path.join(root, serverEntries[id]);
|
|
325
|
+
const markoFile = path.posix.join(root, serverEntries[id]);
|
|
331
326
|
const htmlFile = markoFile + htmlExt;
|
|
332
327
|
virtualFiles.set(htmlFile, {
|
|
333
328
|
code: generateInputDoc(markoFile)
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@marko/vite",
|
|
3
3
|
"description": "A Marko plugin for Vite",
|
|
4
|
-
"version": "2.2.
|
|
4
|
+
"version": "2.2.8",
|
|
5
5
|
"author": "Dylan Piercey <dpiercey@ebay.com>",
|
|
6
6
|
"bugs": "https://github.com/marko-js/vite/issues",
|
|
7
7
|
"dependencies": {
|
|
@@ -11,36 +11,37 @@
|
|
|
11
11
|
"htmlparser2": "^7.2.0"
|
|
12
12
|
},
|
|
13
13
|
"devDependencies": {
|
|
14
|
-
"@commitlint/cli": "^16.1
|
|
15
|
-
"@commitlint/config-conventional": "^16.
|
|
14
|
+
"@commitlint/cli": "^16.2.1",
|
|
15
|
+
"@commitlint/config-conventional": "^16.2.1",
|
|
16
16
|
"@marko/compiler": "^5.19.1",
|
|
17
17
|
"@marko/fixture-snapshots": "^2.1.6",
|
|
18
18
|
"@marko/testing-library": "^6.0.0",
|
|
19
19
|
"@types/jsdom": "^16.2.14",
|
|
20
20
|
"@types/mocha": "^9.1.0",
|
|
21
|
-
"@types/node": "^17.0.
|
|
21
|
+
"@types/node": "^17.0.21",
|
|
22
22
|
"@types/serve-handler": "^6.1.1",
|
|
23
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
24
|
-
"@typescript-eslint/parser": "^5.
|
|
25
|
-
"
|
|
23
|
+
"@typescript-eslint/eslint-plugin": "^5.14.0",
|
|
24
|
+
"@typescript-eslint/parser": "^5.14.0",
|
|
25
|
+
"cross-env": "^7.0.3",
|
|
26
|
+
"esbuild": "^0.14.25",
|
|
26
27
|
"esbuild-register": "^3.3.2",
|
|
27
|
-
"eslint": "^8.
|
|
28
|
-
"eslint-config-prettier": "^8.
|
|
28
|
+
"eslint": "^8.10.0",
|
|
29
|
+
"eslint-config-prettier": "^8.5.0",
|
|
29
30
|
"fast-glob": "^3.2.11",
|
|
30
31
|
"fixpack": "^4.0.0",
|
|
31
32
|
"husky": "^7.0.4",
|
|
32
33
|
"jsdom": "^19.0.0",
|
|
33
|
-
"lint-staged": "^12.3.
|
|
34
|
+
"lint-staged": "^12.3.5",
|
|
34
35
|
"marko": "^5.19.0",
|
|
35
|
-
"mocha": "^9.2.
|
|
36
|
-
"mocha-snap": "^4.
|
|
36
|
+
"mocha": "^9.2.1",
|
|
37
|
+
"mocha-snap": "^4.3.0",
|
|
37
38
|
"nyc": "^15.1.0",
|
|
38
|
-
"playwright": "^1.
|
|
39
|
+
"playwright": "^1.19.2",
|
|
39
40
|
"prettier": "^2.5.1",
|
|
40
41
|
"semantic-release": "^19.0.2",
|
|
41
42
|
"serve-handler": "^6.1.3",
|
|
42
|
-
"typescript": "^4.
|
|
43
|
-
"vite": "^2.
|
|
43
|
+
"typescript": "^4.6.2",
|
|
44
|
+
"vite": "^2.8.6"
|
|
44
45
|
},
|
|
45
46
|
"exports": {
|
|
46
47
|
".": {
|
|
@@ -80,8 +81,8 @@
|
|
|
80
81
|
"format": "npm run lint:eslint -- --fix && npm run lint:prettier -- --write && (fixpack || true)",
|
|
81
82
|
"lint": "tsc -b && npm run lint:eslint && npm run lint:prettier -- -l && fixpack",
|
|
82
83
|
"lint:eslint": "eslint -f visualstudio .",
|
|
83
|
-
"lint:prettier": "prettier
|
|
84
|
-
"mocha": "NODE_ENV=test mocha
|
|
84
|
+
"lint:prettier": "prettier \"./**/*{.ts,.js,.json,.md,.yml,rc}\"",
|
|
85
|
+
"mocha": "cross-env NODE_ENV=test mocha \"./src/**/__tests__/*.test.ts\"",
|
|
85
86
|
"prepare": "husky install",
|
|
86
87
|
"prepublishOnly": "npm run build",
|
|
87
88
|
"release": "semantic-release",
|