@marko/vite 5.0.0 → 5.0.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.mjs +60 -11
- package/package.json +21 -19
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
2
|
import * as compiler2 from "@marko/compiler";
|
|
3
|
-
import defaultConfig from "@marko/compiler/config";
|
|
4
3
|
import fs4 from "fs";
|
|
5
4
|
import path6 from "path";
|
|
6
5
|
import crypto from "crypto";
|
|
@@ -536,24 +535,45 @@ function plugin(options) {
|
|
|
536
535
|
namespaceId = s.local;
|
|
537
536
|
}
|
|
538
537
|
}
|
|
539
|
-
|
|
540
|
-
defaultImportId?.name || path7.node.source.value
|
|
538
|
+
const rawImport = path7.scope.generateUidIdentifier(
|
|
539
|
+
namespaceId?.name || defaultImportId?.name || path7.node.source.value
|
|
541
540
|
);
|
|
542
|
-
path7.node.specifiers = [t.
|
|
541
|
+
path7.node.specifiers = [t.importNamespaceSpecifier(rawImport)];
|
|
543
542
|
if (defaultImportId) {
|
|
544
543
|
path7.insertAfter(
|
|
545
544
|
t.variableDeclaration("const", [
|
|
546
545
|
t.variableDeclarator(
|
|
547
|
-
|
|
546
|
+
t.objectPattern([
|
|
547
|
+
t.objectProperty(t.identifier("default"), defaultImportId)
|
|
548
|
+
]),
|
|
548
549
|
t.conditionalExpression(
|
|
549
550
|
t.optionalMemberExpression(
|
|
550
|
-
|
|
551
|
+
t.memberExpression(rawImport, t.identifier("default")),
|
|
551
552
|
t.identifier("__esModule"),
|
|
552
553
|
false,
|
|
553
554
|
true
|
|
554
555
|
),
|
|
555
|
-
t.memberExpression(
|
|
556
|
-
|
|
556
|
+
t.memberExpression(rawImport, t.identifier("default")),
|
|
557
|
+
rawImport
|
|
558
|
+
)
|
|
559
|
+
)
|
|
560
|
+
])
|
|
561
|
+
);
|
|
562
|
+
}
|
|
563
|
+
if (namespaceId) {
|
|
564
|
+
path7.insertAfter(
|
|
565
|
+
t.variableDeclaration("const", [
|
|
566
|
+
t.variableDeclarator(
|
|
567
|
+
namespaceId,
|
|
568
|
+
t.conditionalExpression(
|
|
569
|
+
t.optionalMemberExpression(
|
|
570
|
+
rawImport,
|
|
571
|
+
t.identifier("__esModule"),
|
|
572
|
+
false,
|
|
573
|
+
true
|
|
574
|
+
),
|
|
575
|
+
rawImport,
|
|
576
|
+
t.memberExpression(rawImport, t.identifier("default"))
|
|
557
577
|
)
|
|
558
578
|
)
|
|
559
579
|
])
|
|
@@ -573,7 +593,16 @@ function plugin(options) {
|
|
|
573
593
|
)
|
|
574
594
|
)
|
|
575
595
|
),
|
|
576
|
-
|
|
596
|
+
t.conditionalExpression(
|
|
597
|
+
t.optionalMemberExpression(
|
|
598
|
+
rawImport,
|
|
599
|
+
t.identifier("__esModule"),
|
|
600
|
+
false,
|
|
601
|
+
true
|
|
602
|
+
),
|
|
603
|
+
rawImport,
|
|
604
|
+
t.memberExpression(rawImport, t.identifier("default"))
|
|
605
|
+
)
|
|
577
606
|
)
|
|
578
607
|
])
|
|
579
608
|
);
|
|
@@ -775,6 +804,8 @@ var babelCaller = {
|
|
|
775
804
|
};
|
|
776
805
|
var registeredTagLib = false;
|
|
777
806
|
var cjsToEsm;
|
|
807
|
+
function noop2() {
|
|
808
|
+
}
|
|
778
809
|
function markoPlugin(opts = {}) {
|
|
779
810
|
let { linked = true } = opts;
|
|
780
811
|
let runtimeId;
|
|
@@ -809,7 +840,7 @@ function markoPlugin(opts = {}) {
|
|
|
809
840
|
let basePath = "/";
|
|
810
841
|
let getMarkoAssetFns;
|
|
811
842
|
const tagsAPI = !/^@marko\/translator-(?:default|interop-class-tags)$/.test(
|
|
812
|
-
opts.translator
|
|
843
|
+
opts.translator || compiler2.globalConfig?.translator || "@marko/translator-default"
|
|
813
844
|
);
|
|
814
845
|
const entryIds = /* @__PURE__ */ new Set();
|
|
815
846
|
const cachedSources = /* @__PURE__ */ new Map();
|
|
@@ -1067,6 +1098,12 @@ function markoPlugin(opts = {}) {
|
|
|
1067
1098
|
entryIds.add(id);
|
|
1068
1099
|
cachedSources.set(id, serverManifest.entrySources[entry]);
|
|
1069
1100
|
}
|
|
1101
|
+
for (const assetId of serverManifest.ssrAssetIds) {
|
|
1102
|
+
this.load({
|
|
1103
|
+
id: normalizePath(path6.resolve(root, assetId)),
|
|
1104
|
+
resolveDependencies: false
|
|
1105
|
+
}).catch(noop2);
|
|
1106
|
+
}
|
|
1070
1107
|
} catch (err) {
|
|
1071
1108
|
this.error(
|
|
1072
1109
|
`You must run the "ssr" build before the "browser" build.`
|
|
@@ -1164,7 +1201,8 @@ function markoPlugin(opts = {}) {
|
|
|
1164
1201
|
serverManifest ??= {
|
|
1165
1202
|
entries: {},
|
|
1166
1203
|
entrySources: {},
|
|
1167
|
-
chunksNeedingAssets: []
|
|
1204
|
+
chunksNeedingAssets: [],
|
|
1205
|
+
ssrAssetIds: []
|
|
1168
1206
|
};
|
|
1169
1207
|
serverManifest.entries[entryId] = relativeFileName;
|
|
1170
1208
|
serverManifest.entrySources[relativeFileName] = source;
|
|
@@ -1308,6 +1346,17 @@ if (import.meta.hot) import.meta.hot.accept(() => {});`;
|
|
|
1308
1346
|
}
|
|
1309
1347
|
}
|
|
1310
1348
|
}
|
|
1349
|
+
serverManifest.ssrAssetIds = [];
|
|
1350
|
+
for (const moduleId of this.getModuleIds()) {
|
|
1351
|
+
if (moduleId.startsWith(root)) {
|
|
1352
|
+
const module = this.getModuleInfo(moduleId);
|
|
1353
|
+
if (module?.meta["vite:asset"]) {
|
|
1354
|
+
serverManifest.ssrAssetIds.push(
|
|
1355
|
+
"." + moduleId.slice(root.length)
|
|
1356
|
+
);
|
|
1357
|
+
}
|
|
1358
|
+
}
|
|
1359
|
+
}
|
|
1311
1360
|
store.write(serverManifest);
|
|
1312
1361
|
} else {
|
|
1313
1362
|
const browserManifest = {};
|
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": "5.0.
|
|
4
|
+
"version": "5.0.2",
|
|
5
5
|
"author": "Dylan Piercey <dpiercey@ebay.com>",
|
|
6
6
|
"bugs": "https://github.com/marko-js/vite/issues",
|
|
7
7
|
"dependencies": {
|
|
@@ -16,37 +16,39 @@
|
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
18
|
"@changesets/changelog-github": "^0.5.0",
|
|
19
|
-
"@changesets/cli": "^2.27.
|
|
20
|
-
"@marko/compiler": "^5.37.
|
|
19
|
+
"@changesets/cli": "^2.27.9",
|
|
20
|
+
"@marko/compiler": "^5.37.26",
|
|
21
21
|
"@marko/fixture-snapshots": "^2.2.1",
|
|
22
22
|
"@marko/testing-library": "^6.2.0",
|
|
23
23
|
"@types/babel__core": "^7.20.5",
|
|
24
|
-
"@types/
|
|
25
|
-
"@types/
|
|
26
|
-
"@types/
|
|
24
|
+
"@types/diff": "^6.0.0",
|
|
25
|
+
"@types/jsdom": "^21.1.7",
|
|
26
|
+
"@types/mocha": "^10.0.9",
|
|
27
|
+
"@types/node": "^22.9.0",
|
|
27
28
|
"@types/resolve": "^1.20.6",
|
|
28
29
|
"@types/serve-handler": "^6.1.4",
|
|
29
30
|
"@typescript-eslint/eslint-plugin": "^7.11.0",
|
|
30
31
|
"@typescript-eslint/parser": "^7.11.0",
|
|
31
32
|
"cross-env": "^7.0.3",
|
|
32
|
-
"
|
|
33
|
+
"diff": "^7.0.0",
|
|
34
|
+
"esbuild": "^0.24.0",
|
|
33
35
|
"eslint": "^8.57.0",
|
|
34
36
|
"eslint-config-prettier": "^9.1.0",
|
|
35
37
|
"fixpack": "^4.0.0",
|
|
36
|
-
"husky": "^9.
|
|
37
|
-
"jsdom": "^
|
|
38
|
+
"husky": "^9.1.7",
|
|
39
|
+
"jsdom": "^25.0.1",
|
|
38
40
|
"less": "^4.2.0",
|
|
39
|
-
"lint-staged": "^15.2.
|
|
40
|
-
"marko": "^5.35.
|
|
41
|
-
"mocha": "^10.
|
|
41
|
+
"lint-staged": "^15.2.10",
|
|
42
|
+
"marko": "^5.35.35",
|
|
43
|
+
"mocha": "^10.8.2",
|
|
42
44
|
"mocha-snap": "^5.0.0",
|
|
43
|
-
"nyc": "^
|
|
44
|
-
"playwright": "^1.
|
|
45
|
-
"prettier": "^3.
|
|
46
|
-
"serve-handler": "^6.1.
|
|
47
|
-
"tsx": "^4.
|
|
48
|
-
"typescript": "^5.
|
|
49
|
-
"vite": "^5.
|
|
45
|
+
"nyc": "^17.1.0",
|
|
46
|
+
"playwright": "^1.49.0",
|
|
47
|
+
"prettier": "^3.3.3",
|
|
48
|
+
"serve-handler": "^6.1.6",
|
|
49
|
+
"tsx": "^4.19.2",
|
|
50
|
+
"typescript": "^5.6.3",
|
|
51
|
+
"vite": "^5.4.11"
|
|
50
52
|
},
|
|
51
53
|
"files": [
|
|
52
54
|
"dist",
|