@marko/vite 4.1.20 → 5.0.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/esbuild-plugin.d.ts +2 -2
- package/dist/index.d.ts +2 -3
- package/dist/index.mjs +66 -32
- package/dist/server-entry-template.d.ts +1 -0
- package/package.json +19 -19
package/dist/esbuild-plugin.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type * as vite from "vite";
|
|
2
|
-
import
|
|
2
|
+
import * as compiler from "@marko/compiler";
|
|
3
3
|
type ESBuildOptions = Exclude<vite.DepOptimizationConfig["esbuildOptions"], undefined>;
|
|
4
4
|
type ESBuildPlugin = Exclude<ESBuildOptions["plugins"], undefined>[number];
|
|
5
|
-
export default function esbuildPlugin(
|
|
5
|
+
export default function esbuildPlugin(config: compiler.Config): ESBuildPlugin;
|
|
6
6
|
export {};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import type * as vite from "vite";
|
|
2
|
-
import
|
|
2
|
+
import * as compiler from "@marko/compiler";
|
|
3
3
|
export declare namespace API {
|
|
4
4
|
type getMarkoAssetCodeForEntry = (id: string) => string | void;
|
|
5
5
|
}
|
|
6
6
|
export interface Options {
|
|
7
7
|
linked?: boolean;
|
|
8
|
-
compiler?: string;
|
|
9
8
|
runtimeId?: string;
|
|
10
9
|
translator?: string;
|
|
11
10
|
basePathVar?: string;
|
|
12
|
-
babelConfig?:
|
|
11
|
+
babelConfig?: compiler.Config["babelConfig"];
|
|
13
12
|
}
|
|
14
13
|
export default function markoPlugin(opts?: Options): vite.Plugin[];
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
|
+
import * as compiler2 from "@marko/compiler";
|
|
2
3
|
import fs4 from "fs";
|
|
3
4
|
import path6 from "path";
|
|
4
5
|
import crypto from "crypto";
|
|
@@ -106,41 +107,41 @@ function renderAssets(slot) {
|
|
|
106
107
|
|
|
107
108
|
// src/server-entry-template.ts
|
|
108
109
|
var server_entry_template_default = async (opts) => {
|
|
110
|
+
const addAssetsCall = `addAssets($global, [${opts.entryData.join(",")}])`;
|
|
109
111
|
const fileNameStr = JSON.stringify(`./${path.basename(opts.fileName)}`);
|
|
110
112
|
return `import template from ${fileNameStr};
|
|
111
113
|
export * from ${fileNameStr};
|
|
112
114
|
import { addAssets } from "${renderAssetsRuntimeId}";
|
|
113
115
|
|
|
114
|
-
$ const
|
|
115
|
-
$ const writeSync = addAssets(g, [${opts.entryData.join(",")}]);
|
|
116
|
+
${opts.tagsAPI ? `<const/writeSync=${addAssetsCall}/>` : `$ const writeSync = ${addAssetsCall};`}
|
|
116
117
|
|
|
117
118
|
<if(writeSync)>
|
|
118
119
|
$!{
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
120
|
+
$global.___viteRenderAssets("head-prepend") +
|
|
121
|
+
$global.___viteRenderAssets("head") +
|
|
122
|
+
$global.___viteRenderAssets("body-prepend")
|
|
122
123
|
}
|
|
123
124
|
</>
|
|
124
125
|
<else>
|
|
125
126
|
<__flush_here_and_after__>
|
|
126
127
|
$!{
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
128
|
+
$global.___viteRenderAssets("head-prepend") +
|
|
129
|
+
$global.___viteRenderAssets("head") +
|
|
130
|
+
$global.___viteRenderAssets("body-prepend")
|
|
130
131
|
}
|
|
131
132
|
</__flush_here_and_after__>
|
|
132
133
|
</>
|
|
133
134
|
|
|
134
|
-
<\${template} ...input
|
|
135
|
+
<\${template} ...input/>${opts.tagsAPI ? "" : `
|
|
135
136
|
<init-components/>
|
|
136
|
-
<await-reorderer
|
|
137
|
+
<await-reorderer/>`}
|
|
137
138
|
|
|
138
139
|
<if(writeSync)>
|
|
139
|
-
$!{
|
|
140
|
+
$!{$global.___viteRenderAssets("body")}
|
|
140
141
|
</>
|
|
141
142
|
<else>
|
|
142
143
|
<__flush_here_and_after__>
|
|
143
|
-
$!{
|
|
144
|
+
$!{$global.___viteRenderAssets("body")}
|
|
144
145
|
</__flush_here_and_after__>
|
|
145
146
|
</>
|
|
146
147
|
`;
|
|
@@ -356,8 +357,9 @@ function isElement(node) {
|
|
|
356
357
|
// src/esbuild-plugin.ts
|
|
357
358
|
import fs from "fs";
|
|
358
359
|
import path2 from "path";
|
|
360
|
+
import * as compiler from "@marko/compiler";
|
|
359
361
|
var markoErrorRegExp = /^(.+?)(?:\((\d+)(?:\s*,\s*(\d+))?\))?: (.*)$/gm;
|
|
360
|
-
function esbuildPlugin(
|
|
362
|
+
function esbuildPlugin(config) {
|
|
361
363
|
return {
|
|
362
364
|
name: "marko",
|
|
363
365
|
async setup(build) {
|
|
@@ -533,24 +535,45 @@ function plugin(options) {
|
|
|
533
535
|
namespaceId = s.local;
|
|
534
536
|
}
|
|
535
537
|
}
|
|
536
|
-
|
|
537
|
-
defaultImportId?.name || path7.node.source.value
|
|
538
|
+
const rawImport = path7.scope.generateUidIdentifier(
|
|
539
|
+
namespaceId?.name || defaultImportId?.name || path7.node.source.value
|
|
538
540
|
);
|
|
539
|
-
path7.node.specifiers = [t.
|
|
541
|
+
path7.node.specifiers = [t.importNamespaceSpecifier(rawImport)];
|
|
540
542
|
if (defaultImportId) {
|
|
541
543
|
path7.insertAfter(
|
|
542
544
|
t.variableDeclaration("const", [
|
|
543
545
|
t.variableDeclarator(
|
|
544
|
-
|
|
546
|
+
t.objectPattern([
|
|
547
|
+
t.objectProperty(t.identifier("default"), defaultImportId)
|
|
548
|
+
]),
|
|
545
549
|
t.conditionalExpression(
|
|
546
550
|
t.optionalMemberExpression(
|
|
547
|
-
|
|
551
|
+
t.memberExpression(rawImport, t.identifier("default")),
|
|
548
552
|
t.identifier("__esModule"),
|
|
549
553
|
false,
|
|
550
554
|
true
|
|
551
555
|
),
|
|
552
|
-
t.memberExpression(
|
|
553
|
-
|
|
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"))
|
|
554
577
|
)
|
|
555
578
|
)
|
|
556
579
|
])
|
|
@@ -570,7 +593,16 @@ function plugin(options) {
|
|
|
570
593
|
)
|
|
571
594
|
)
|
|
572
595
|
),
|
|
573
|
-
|
|
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
|
+
)
|
|
574
606
|
)
|
|
575
607
|
])
|
|
576
608
|
);
|
|
@@ -593,7 +625,7 @@ function renderAssetsCall(t3, slot) {
|
|
|
593
625
|
return t3.markoPlaceholder(
|
|
594
626
|
t3.callExpression(
|
|
595
627
|
t3.memberExpression(
|
|
596
|
-
t3.
|
|
628
|
+
t3.identifier("$global"),
|
|
597
629
|
t3.identifier("___viteRenderAssets")
|
|
598
630
|
),
|
|
599
631
|
[t3.stringLiteral(slot)]
|
|
@@ -773,7 +805,6 @@ var babelCaller = {
|
|
|
773
805
|
var registeredTagLib = false;
|
|
774
806
|
var cjsToEsm;
|
|
775
807
|
function markoPlugin(opts = {}) {
|
|
776
|
-
let compiler;
|
|
777
808
|
let { linked = true } = opts;
|
|
778
809
|
let runtimeId;
|
|
779
810
|
let basePathVar;
|
|
@@ -806,6 +837,9 @@ function markoPlugin(opts = {}) {
|
|
|
806
837
|
let serverManifest;
|
|
807
838
|
let basePath = "/";
|
|
808
839
|
let getMarkoAssetFns;
|
|
840
|
+
const tagsAPI = !/^@marko\/translator-(?:default|interop-class-tags)$/.test(
|
|
841
|
+
opts.translator || compiler2.globalConfig?.translator || "@marko/translator-default"
|
|
842
|
+
);
|
|
809
843
|
const entryIds = /* @__PURE__ */ new Set();
|
|
810
844
|
const cachedSources = /* @__PURE__ */ new Map();
|
|
811
845
|
const transformWatchFiles = /* @__PURE__ */ new Map();
|
|
@@ -825,7 +859,6 @@ function markoPlugin(opts = {}) {
|
|
|
825
859
|
} else {
|
|
826
860
|
process.env.MARKO_DEBUG = optimize ? "false" : "true";
|
|
827
861
|
}
|
|
828
|
-
compiler ??= await import(opts.compiler || "@marko/compiler");
|
|
829
862
|
runtimeId = opts.runtimeId;
|
|
830
863
|
basePathVar = opts.basePathVar;
|
|
831
864
|
if ("BASE_URL" in process.env && config.base == null) {
|
|
@@ -874,7 +907,7 @@ function markoPlugin(opts = {}) {
|
|
|
874
907
|
resolveVirtualDependency,
|
|
875
908
|
output: "hydrate"
|
|
876
909
|
};
|
|
877
|
-
|
|
910
|
+
compiler2.configure(baseConfig);
|
|
878
911
|
root = normalizePath(config.root || process.cwd());
|
|
879
912
|
devEntryFile = path6.join(root, "index.html");
|
|
880
913
|
devEntryFilePosix = normalizePath(devEntryFile);
|
|
@@ -901,7 +934,7 @@ function markoPlugin(opts = {}) {
|
|
|
901
934
|
}
|
|
902
935
|
if (!registeredTagLib) {
|
|
903
936
|
registeredTagLib = true;
|
|
904
|
-
|
|
937
|
+
compiler2.taglib.register("@marko/vite", {
|
|
905
938
|
transform: glob_import_transform_default,
|
|
906
939
|
"<head>": { transformer: render_assets_transform_default },
|
|
907
940
|
"<body>": { transformer: render_assets_transform_default },
|
|
@@ -917,13 +950,13 @@ function markoPlugin(opts = {}) {
|
|
|
917
950
|
`!**/coverage/**`
|
|
918
951
|
];
|
|
919
952
|
}
|
|
920
|
-
const domDeps =
|
|
953
|
+
const domDeps = compiler2.getRuntimeEntryFiles("dom", opts.translator);
|
|
921
954
|
optimizeDeps.include = optimizeDeps.include ? [...optimizeDeps.include, ...domDeps] : domDeps;
|
|
922
955
|
const optimizeExtensions = optimizeDeps.extensions ??= [];
|
|
923
956
|
optimizeExtensions.push(".marko");
|
|
924
957
|
const esbuildOptions = optimizeDeps.esbuildOptions ??= {};
|
|
925
958
|
const esbuildPlugins = esbuildOptions.plugins ??= [];
|
|
926
|
-
esbuildPlugins.push(esbuildPlugin(
|
|
959
|
+
esbuildPlugins.push(esbuildPlugin(baseConfig));
|
|
927
960
|
const ssr = config.ssr ??= {};
|
|
928
961
|
const { noExternal } = ssr;
|
|
929
962
|
if (noExternal !== true) {
|
|
@@ -1042,7 +1075,7 @@ function markoPlugin(opts = {}) {
|
|
|
1042
1075
|
});
|
|
1043
1076
|
},
|
|
1044
1077
|
handleHotUpdate(ctx) {
|
|
1045
|
-
|
|
1078
|
+
compiler2.taglib.clearCaches();
|
|
1046
1079
|
baseConfig.cache.clear();
|
|
1047
1080
|
for (const [, cache2] of configsByFileSystem) {
|
|
1048
1081
|
cache2.clear();
|
|
@@ -1191,7 +1224,8 @@ function markoPlugin(opts = {}) {
|
|
|
1191
1224
|
fileName,
|
|
1192
1225
|
entryData,
|
|
1193
1226
|
runtimeId,
|
|
1194
|
-
basePathVar: isBuild ? basePathVar : void 0
|
|
1227
|
+
basePathVar: isBuild ? basePathVar : void 0,
|
|
1228
|
+
tagsAPI
|
|
1195
1229
|
});
|
|
1196
1230
|
}
|
|
1197
1231
|
}
|
|
@@ -1224,7 +1258,7 @@ function markoPlugin(opts = {}) {
|
|
|
1224
1258
|
}
|
|
1225
1259
|
if (!query && isCJSModule(id)) {
|
|
1226
1260
|
if (isBuild) {
|
|
1227
|
-
const { code: code2, map: map2, meta: meta2 } = await
|
|
1261
|
+
const { code: code2, map: map2, meta: meta2 } = await compiler2.compile(
|
|
1228
1262
|
source,
|
|
1229
1263
|
id,
|
|
1230
1264
|
getConfigForFileSystem(info, ssrCjsConfig)
|
|
@@ -1237,7 +1271,7 @@ function markoPlugin(opts = {}) {
|
|
|
1237
1271
|
}
|
|
1238
1272
|
}
|
|
1239
1273
|
}
|
|
1240
|
-
const compiled = await
|
|
1274
|
+
const compiled = await compiler2.compile(
|
|
1241
1275
|
source,
|
|
1242
1276
|
id,
|
|
1243
1277
|
getConfigForFileSystem(
|
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": "
|
|
4
|
+
"version": "5.0.1",
|
|
5
5
|
"author": "Dylan Piercey <dpiercey@ebay.com>",
|
|
6
6
|
"bugs": "https://github.com/marko-js/vite/issues",
|
|
7
7
|
"dependencies": {
|
|
@@ -16,37 +16,37 @@
|
|
|
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/jsdom": "^21.1.
|
|
25
|
-
"@types/mocha": "^10.0.
|
|
26
|
-
"@types/node": "^
|
|
24
|
+
"@types/jsdom": "^21.1.7",
|
|
25
|
+
"@types/mocha": "^10.0.9",
|
|
26
|
+
"@types/node": "^22.9.0",
|
|
27
27
|
"@types/resolve": "^1.20.6",
|
|
28
28
|
"@types/serve-handler": "^6.1.4",
|
|
29
29
|
"@typescript-eslint/eslint-plugin": "^7.11.0",
|
|
30
30
|
"@typescript-eslint/parser": "^7.11.0",
|
|
31
31
|
"cross-env": "^7.0.3",
|
|
32
|
-
"esbuild": "^0.
|
|
32
|
+
"esbuild": "^0.24.0",
|
|
33
33
|
"eslint": "^8.57.0",
|
|
34
34
|
"eslint-config-prettier": "^9.1.0",
|
|
35
35
|
"fixpack": "^4.0.0",
|
|
36
|
-
"husky": "^9.
|
|
37
|
-
"jsdom": "^
|
|
36
|
+
"husky": "^9.1.7",
|
|
37
|
+
"jsdom": "^25.0.1",
|
|
38
38
|
"less": "^4.2.0",
|
|
39
|
-
"lint-staged": "^15.2.
|
|
40
|
-
"marko": "^5.35.
|
|
41
|
-
"mocha": "^10.
|
|
39
|
+
"lint-staged": "^15.2.10",
|
|
40
|
+
"marko": "^5.35.35",
|
|
41
|
+
"mocha": "^10.8.2",
|
|
42
42
|
"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.
|
|
43
|
+
"nyc": "^17.1.0",
|
|
44
|
+
"playwright": "^1.49.0",
|
|
45
|
+
"prettier": "^3.3.3",
|
|
46
|
+
"serve-handler": "^6.1.6",
|
|
47
|
+
"tsx": "^4.19.2",
|
|
48
|
+
"typescript": "^5.6.3",
|
|
49
|
+
"vite": "^5.4.11"
|
|
50
50
|
},
|
|
51
51
|
"files": [
|
|
52
52
|
"dist",
|