@marko/vite 4.1.19 → 5.0.0
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 +32 -27
- package/dist/server-entry-template.d.ts +1 -0
- package/package.json +1 -1
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,6 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
|
+
import * as compiler2 from "@marko/compiler";
|
|
3
|
+
import defaultConfig from "@marko/compiler/config";
|
|
2
4
|
import fs4 from "fs";
|
|
3
5
|
import path6 from "path";
|
|
4
6
|
import crypto from "crypto";
|
|
@@ -106,41 +108,41 @@ function renderAssets(slot) {
|
|
|
106
108
|
|
|
107
109
|
// src/server-entry-template.ts
|
|
108
110
|
var server_entry_template_default = async (opts) => {
|
|
111
|
+
const addAssetsCall = `addAssets($global, [${opts.entryData.join(",")}])`;
|
|
109
112
|
const fileNameStr = JSON.stringify(`./${path.basename(opts.fileName)}`);
|
|
110
113
|
return `import template from ${fileNameStr};
|
|
111
114
|
export * from ${fileNameStr};
|
|
112
115
|
import { addAssets } from "${renderAssetsRuntimeId}";
|
|
113
116
|
|
|
114
|
-
$ const
|
|
115
|
-
$ const writeSync = addAssets(g, [${opts.entryData.join(",")}]);
|
|
117
|
+
${opts.tagsAPI ? `<const/writeSync=${addAssetsCall}/>` : `$ const writeSync = ${addAssetsCall};`}
|
|
116
118
|
|
|
117
119
|
<if(writeSync)>
|
|
118
120
|
$!{
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
121
|
+
$global.___viteRenderAssets("head-prepend") +
|
|
122
|
+
$global.___viteRenderAssets("head") +
|
|
123
|
+
$global.___viteRenderAssets("body-prepend")
|
|
122
124
|
}
|
|
123
125
|
</>
|
|
124
126
|
<else>
|
|
125
127
|
<__flush_here_and_after__>
|
|
126
128
|
$!{
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
129
|
+
$global.___viteRenderAssets("head-prepend") +
|
|
130
|
+
$global.___viteRenderAssets("head") +
|
|
131
|
+
$global.___viteRenderAssets("body-prepend")
|
|
130
132
|
}
|
|
131
133
|
</__flush_here_and_after__>
|
|
132
134
|
</>
|
|
133
135
|
|
|
134
|
-
<\${template} ...input
|
|
136
|
+
<\${template} ...input/>${opts.tagsAPI ? "" : `
|
|
135
137
|
<init-components/>
|
|
136
|
-
<await-reorderer
|
|
138
|
+
<await-reorderer/>`}
|
|
137
139
|
|
|
138
140
|
<if(writeSync)>
|
|
139
|
-
$!{
|
|
141
|
+
$!{$global.___viteRenderAssets("body")}
|
|
140
142
|
</>
|
|
141
143
|
<else>
|
|
142
144
|
<__flush_here_and_after__>
|
|
143
|
-
$!{
|
|
145
|
+
$!{$global.___viteRenderAssets("body")}
|
|
144
146
|
</__flush_here_and_after__>
|
|
145
147
|
</>
|
|
146
148
|
`;
|
|
@@ -356,8 +358,9 @@ function isElement(node) {
|
|
|
356
358
|
// src/esbuild-plugin.ts
|
|
357
359
|
import fs from "fs";
|
|
358
360
|
import path2 from "path";
|
|
361
|
+
import * as compiler from "@marko/compiler";
|
|
359
362
|
var markoErrorRegExp = /^(.+?)(?:\((\d+)(?:\s*,\s*(\d+))?\))?: (.*)$/gm;
|
|
360
|
-
function esbuildPlugin(
|
|
363
|
+
function esbuildPlugin(config) {
|
|
361
364
|
return {
|
|
362
365
|
name: "marko",
|
|
363
366
|
async setup(build) {
|
|
@@ -593,7 +596,7 @@ function renderAssetsCall(t3, slot) {
|
|
|
593
596
|
return t3.markoPlaceholder(
|
|
594
597
|
t3.callExpression(
|
|
595
598
|
t3.memberExpression(
|
|
596
|
-
t3.
|
|
599
|
+
t3.identifier("$global"),
|
|
597
600
|
t3.identifier("___viteRenderAssets")
|
|
598
601
|
),
|
|
599
602
|
[t3.stringLiteral(slot)]
|
|
@@ -773,7 +776,6 @@ var babelCaller = {
|
|
|
773
776
|
var registeredTagLib = false;
|
|
774
777
|
var cjsToEsm;
|
|
775
778
|
function markoPlugin(opts = {}) {
|
|
776
|
-
let compiler;
|
|
777
779
|
let { linked = true } = opts;
|
|
778
780
|
let runtimeId;
|
|
779
781
|
let basePathVar;
|
|
@@ -806,6 +808,9 @@ function markoPlugin(opts = {}) {
|
|
|
806
808
|
let serverManifest;
|
|
807
809
|
let basePath = "/";
|
|
808
810
|
let getMarkoAssetFns;
|
|
811
|
+
const tagsAPI = !/^@marko\/translator-(?:default|interop-class-tags)$/.test(
|
|
812
|
+
opts.translator ?? defaultConfig.translator
|
|
813
|
+
);
|
|
809
814
|
const entryIds = /* @__PURE__ */ new Set();
|
|
810
815
|
const cachedSources = /* @__PURE__ */ new Map();
|
|
811
816
|
const transformWatchFiles = /* @__PURE__ */ new Map();
|
|
@@ -825,7 +830,6 @@ function markoPlugin(opts = {}) {
|
|
|
825
830
|
} else {
|
|
826
831
|
process.env.MARKO_DEBUG = optimize ? "false" : "true";
|
|
827
832
|
}
|
|
828
|
-
compiler ??= await import(opts.compiler || "@marko/compiler");
|
|
829
833
|
runtimeId = opts.runtimeId;
|
|
830
834
|
basePathVar = opts.basePathVar;
|
|
831
835
|
if ("BASE_URL" in process.env && config.base == null) {
|
|
@@ -856,14 +860,14 @@ function markoPlugin(opts = {}) {
|
|
|
856
860
|
caller: babelCaller
|
|
857
861
|
}
|
|
858
862
|
};
|
|
863
|
+
if (linked) {
|
|
864
|
+
baseConfig.markoViteLinked = linked;
|
|
865
|
+
}
|
|
859
866
|
ssrConfig = {
|
|
860
867
|
...baseConfig,
|
|
861
868
|
resolveVirtualDependency,
|
|
862
869
|
output: "html"
|
|
863
870
|
};
|
|
864
|
-
if (linked) {
|
|
865
|
-
ssrConfig.markoViteLinked = linked;
|
|
866
|
-
}
|
|
867
871
|
domConfig = {
|
|
868
872
|
...baseConfig,
|
|
869
873
|
resolveVirtualDependency,
|
|
@@ -874,7 +878,7 @@ function markoPlugin(opts = {}) {
|
|
|
874
878
|
resolveVirtualDependency,
|
|
875
879
|
output: "hydrate"
|
|
876
880
|
};
|
|
877
|
-
|
|
881
|
+
compiler2.configure(baseConfig);
|
|
878
882
|
root = normalizePath(config.root || process.cwd());
|
|
879
883
|
devEntryFile = path6.join(root, "index.html");
|
|
880
884
|
devEntryFilePosix = normalizePath(devEntryFile);
|
|
@@ -901,7 +905,7 @@ function markoPlugin(opts = {}) {
|
|
|
901
905
|
}
|
|
902
906
|
if (!registeredTagLib) {
|
|
903
907
|
registeredTagLib = true;
|
|
904
|
-
|
|
908
|
+
compiler2.taglib.register("@marko/vite", {
|
|
905
909
|
transform: glob_import_transform_default,
|
|
906
910
|
"<head>": { transformer: render_assets_transform_default },
|
|
907
911
|
"<body>": { transformer: render_assets_transform_default },
|
|
@@ -917,13 +921,13 @@ function markoPlugin(opts = {}) {
|
|
|
917
921
|
`!**/coverage/**`
|
|
918
922
|
];
|
|
919
923
|
}
|
|
920
|
-
const domDeps =
|
|
924
|
+
const domDeps = compiler2.getRuntimeEntryFiles("dom", opts.translator);
|
|
921
925
|
optimizeDeps.include = optimizeDeps.include ? [...optimizeDeps.include, ...domDeps] : domDeps;
|
|
922
926
|
const optimizeExtensions = optimizeDeps.extensions ??= [];
|
|
923
927
|
optimizeExtensions.push(".marko");
|
|
924
928
|
const esbuildOptions = optimizeDeps.esbuildOptions ??= {};
|
|
925
929
|
const esbuildPlugins = esbuildOptions.plugins ??= [];
|
|
926
|
-
esbuildPlugins.push(esbuildPlugin(
|
|
930
|
+
esbuildPlugins.push(esbuildPlugin(baseConfig));
|
|
927
931
|
const ssr = config.ssr ??= {};
|
|
928
932
|
const { noExternal } = ssr;
|
|
929
933
|
if (noExternal !== true) {
|
|
@@ -1042,7 +1046,7 @@ function markoPlugin(opts = {}) {
|
|
|
1042
1046
|
});
|
|
1043
1047
|
},
|
|
1044
1048
|
handleHotUpdate(ctx) {
|
|
1045
|
-
|
|
1049
|
+
compiler2.taglib.clearCaches();
|
|
1046
1050
|
baseConfig.cache.clear();
|
|
1047
1051
|
for (const [, cache2] of configsByFileSystem) {
|
|
1048
1052
|
cache2.clear();
|
|
@@ -1191,7 +1195,8 @@ function markoPlugin(opts = {}) {
|
|
|
1191
1195
|
fileName,
|
|
1192
1196
|
entryData,
|
|
1193
1197
|
runtimeId,
|
|
1194
|
-
basePathVar: isBuild ? basePathVar : void 0
|
|
1198
|
+
basePathVar: isBuild ? basePathVar : void 0,
|
|
1199
|
+
tagsAPI
|
|
1195
1200
|
});
|
|
1196
1201
|
}
|
|
1197
1202
|
}
|
|
@@ -1224,7 +1229,7 @@ function markoPlugin(opts = {}) {
|
|
|
1224
1229
|
}
|
|
1225
1230
|
if (!query && isCJSModule(id)) {
|
|
1226
1231
|
if (isBuild) {
|
|
1227
|
-
const { code: code2, map: map2, meta: meta2 } = await
|
|
1232
|
+
const { code: code2, map: map2, meta: meta2 } = await compiler2.compile(
|
|
1228
1233
|
source,
|
|
1229
1234
|
id,
|
|
1230
1235
|
getConfigForFileSystem(info, ssrCjsConfig)
|
|
@@ -1237,7 +1242,7 @@ function markoPlugin(opts = {}) {
|
|
|
1237
1242
|
}
|
|
1238
1243
|
}
|
|
1239
1244
|
}
|
|
1240
|
-
const compiled = await
|
|
1245
|
+
const compiled = await compiler2.compile(
|
|
1241
1246
|
source,
|
|
1242
1247
|
id,
|
|
1243
1248
|
getConfigForFileSystem(
|
package/package.json
CHANGED