@marko/translator-default 5.32.2 → 5.32.3
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 +0 -4
- package/dist/tag/custom-tag.js +4 -7
- package/dist/util/add-dependencies.js +40 -30
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -72,10 +72,6 @@ const analyze = exports.analyze = {
|
|
|
72
72
|
(0, _babelUtils.resolveRelativePath)(file, filename) :
|
|
73
73
|
filename
|
|
74
74
|
);
|
|
75
|
-
|
|
76
|
-
meta.imports = program.node.body.
|
|
77
|
-
filter((child) => _compiler.types.isImportDeclaration(child)).
|
|
78
|
-
map((child) => child.source.value);
|
|
79
75
|
}
|
|
80
76
|
},
|
|
81
77
|
MarkoTag(tag) {
|
package/dist/tag/custom-tag.js
CHANGED
|
@@ -44,13 +44,10 @@ function _default(path, isNullable) {
|
|
|
44
44
|
const childProgram = childFile?.ast.program;
|
|
45
45
|
|
|
46
46
|
if (childProgram?.extra?.___featureType === "tags") {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}.js`,
|
|
52
|
-
"marko_tags_compat"
|
|
53
|
-
);
|
|
47
|
+
const compatRuntimeFile = `marko/src/runtime/helpers/tags-compat/${
|
|
48
|
+
markoOpts.output === "html" ? "html" : "dom"
|
|
49
|
+
}${markoOpts.optimize ? "" : "-debug"}.${markoOpts.modules === "esm" ? "mjs" : "js"}`;
|
|
50
|
+
(0, _babelUtils.importDefault)(file, compatRuntimeFile);
|
|
54
51
|
path.set("name", (0, _babelUtils.importDefault)(file, relativePath, path.node.name.value));
|
|
55
52
|
return (0, _dynamicTag.default)(path);
|
|
56
53
|
} else if (relativePath) {
|
|
@@ -11,23 +11,25 @@ var _resolveFrom = _interopRequireDefault(require("resolve-from"));var _default
|
|
|
11
11
|
(entryFile, isHydrate) => {
|
|
12
12
|
const { resolveVirtualDependency, hydrateIncludeImports, hydrateInit } =
|
|
13
13
|
entryFile.markoOpts;
|
|
14
|
-
const hydratedFiles = new Set();
|
|
15
14
|
const program = entryFile.path;
|
|
16
15
|
const shouldIncludeImport = toTestFn(hydrateIncludeImports);
|
|
16
|
+
const resolvedDeps = new Set();
|
|
17
|
+
const body = [];
|
|
17
18
|
|
|
18
19
|
if (!isHydrate) {
|
|
19
|
-
|
|
20
|
+
scanBrowserDeps(entryFile);
|
|
21
|
+
if (body.length) {
|
|
22
|
+
program.node.body = body.concat(program.node.body);
|
|
23
|
+
}
|
|
20
24
|
return;
|
|
21
25
|
}
|
|
22
26
|
|
|
27
|
+
const hydratedTemplates = new Set();
|
|
23
28
|
const watchFiles = new Set();
|
|
24
29
|
let hasComponents = false;
|
|
25
30
|
let splitComponentIndex = 0;
|
|
26
|
-
program.set("body", []);
|
|
27
|
-
program.skip();
|
|
28
31
|
|
|
29
|
-
|
|
30
|
-
entryFile.metadata.marko.watchFiles = Array.from(watchFiles);
|
|
32
|
+
scanHydrateDeps(entryFile);
|
|
31
33
|
|
|
32
34
|
if (hasComponents) {
|
|
33
35
|
const initId = _compiler.types.identifier("init");
|
|
@@ -40,15 +42,11 @@ var _resolveFrom = _interopRequireDefault(require("resolve-from"));var _default
|
|
|
40
42
|
);
|
|
41
43
|
}
|
|
42
44
|
|
|
43
|
-
|
|
44
|
-
markoComponentsImport.specifiers.push(_compiler.types.importSpecifier(initId, initId));
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
program.unshiftContainer("body", markoComponentsImport);
|
|
45
|
+
body.unshift(markoComponentsImport);
|
|
48
46
|
|
|
49
47
|
if (hydrateInit) {
|
|
50
|
-
|
|
51
|
-
|
|
48
|
+
markoComponentsImport.specifiers.push(_compiler.types.importSpecifier(initId, initId));
|
|
49
|
+
body.push(
|
|
52
50
|
_compiler.types.expressionStatement(
|
|
53
51
|
_compiler.types.callExpression(
|
|
54
52
|
initId,
|
|
@@ -61,19 +59,23 @@ var _resolveFrom = _interopRequireDefault(require("resolve-from"));var _default
|
|
|
61
59
|
}
|
|
62
60
|
}
|
|
63
61
|
|
|
64
|
-
|
|
62
|
+
entryFile.metadata.marko.watchFiles = Array.from(watchFiles);
|
|
63
|
+
program.node.body = body;
|
|
64
|
+
program.skip();
|
|
65
|
+
|
|
66
|
+
function scanHydrateDeps(file) {
|
|
65
67
|
const meta = file.metadata.marko;
|
|
66
68
|
const resolved = (0, _babelUtils.resolveRelativePath)(entryFile, file.opts.filename);
|
|
67
|
-
if (
|
|
69
|
+
if (hydratedTemplates.has(resolved)) return;
|
|
68
70
|
|
|
69
|
-
|
|
71
|
+
hydratedTemplates.add(resolved);
|
|
70
72
|
|
|
71
73
|
if (meta.component) {
|
|
72
74
|
hasComponents = true;
|
|
73
75
|
|
|
74
76
|
if (_path.default.basename(meta.component) === _path.default.basename(file.opts.filename)) {
|
|
75
77
|
// Stateful component.
|
|
76
|
-
|
|
78
|
+
addDep(resolved);
|
|
77
79
|
return;
|
|
78
80
|
}
|
|
79
81
|
}
|
|
@@ -84,25 +86,28 @@ var _resolveFrom = _interopRequireDefault(require("resolve-from"));var _default
|
|
|
84
86
|
watchFiles.add(watchFile);
|
|
85
87
|
}
|
|
86
88
|
|
|
87
|
-
|
|
89
|
+
scanBrowserDeps(file);
|
|
88
90
|
|
|
89
|
-
for (const
|
|
90
|
-
if (
|
|
91
|
-
|
|
91
|
+
for (const child of file.path.node.body) {
|
|
92
|
+
if (_compiler.types.isImportDeclaration(child)) {
|
|
93
|
+
const { value } = child.source;
|
|
94
|
+
if (shouldIncludeImport(value)) {
|
|
95
|
+
addDep(resolvePath(file, value));
|
|
96
|
+
}
|
|
92
97
|
}
|
|
93
98
|
}
|
|
94
99
|
|
|
95
100
|
for (const tag of meta.tags) {
|
|
96
101
|
if (tag.endsWith(".marko")) {
|
|
97
|
-
if (!
|
|
98
|
-
|
|
102
|
+
if (!hydratedTemplates.has(resolvePath(file, tag))) {
|
|
103
|
+
scanHydrateDeps((0, _babelUtils.loadFileForImport)(file, tag));
|
|
99
104
|
}
|
|
100
105
|
} else {
|
|
101
106
|
const importedTemplates = tryGetTemplateImports(file, tag);
|
|
102
107
|
if (importedTemplates) {
|
|
103
108
|
for (const templateFile of importedTemplates) {
|
|
104
|
-
if (!
|
|
105
|
-
|
|
109
|
+
if (!hydratedTemplates.has(resolvePath(file, templateFile))) {
|
|
110
|
+
scanHydrateDeps((0, _babelUtils.loadFileForImport)(file, templateFile));
|
|
106
111
|
}
|
|
107
112
|
}
|
|
108
113
|
}
|
|
@@ -120,9 +125,8 @@ var _resolveFrom = _interopRequireDefault(require("resolve-from"));var _default
|
|
|
120
125
|
splitComponentImport.specifiers.push(
|
|
121
126
|
_compiler.types.importDefaultSpecifier(splitComponentId)
|
|
122
127
|
);
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
"body",
|
|
128
|
+
body.push(
|
|
129
|
+
splitComponentImport,
|
|
126
130
|
_compiler.types.expressionStatement(
|
|
127
131
|
_compiler.types.callExpression(_compiler.types.identifier("register"), [
|
|
128
132
|
_compiler.types.stringLiteral(meta.id),
|
|
@@ -133,7 +137,7 @@ var _resolveFrom = _interopRequireDefault(require("resolve-from"));var _default
|
|
|
133
137
|
}
|
|
134
138
|
}
|
|
135
139
|
|
|
136
|
-
function
|
|
140
|
+
function scanBrowserDeps(file) {
|
|
137
141
|
const { filename, sourceMaps } = file.opts;
|
|
138
142
|
let s;
|
|
139
143
|
|
|
@@ -174,10 +178,16 @@ var _resolveFrom = _interopRequireDefault(require("resolve-from"));var _default
|
|
|
174
178
|
continue;
|
|
175
179
|
}
|
|
176
180
|
|
|
177
|
-
|
|
181
|
+
addDep(resolvePath(file, dep));
|
|
178
182
|
}
|
|
179
183
|
}
|
|
180
184
|
|
|
185
|
+
function addDep(resolved) {
|
|
186
|
+
if (resolvedDeps.has(resolved)) return;
|
|
187
|
+
resolvedDeps.add(resolved);
|
|
188
|
+
body.push(importPath(resolved));
|
|
189
|
+
}
|
|
190
|
+
|
|
181
191
|
function resolvePath(file, req) {
|
|
182
192
|
return file === entryFile ?
|
|
183
193
|
(0, _babelUtils.resolveRelativePath)(file, req) :
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@marko/translator-default",
|
|
3
|
-
"version": "5.32.
|
|
3
|
+
"version": "5.32.3",
|
|
4
4
|
"description": "Translates Marko templates to the default Marko runtime.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"babel",
|
|
@@ -28,14 +28,14 @@
|
|
|
28
28
|
"build": "babel ./src --out-dir ./dist --copy-files --config-file ../../babel.config.js --env-name=production"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@babel/runtime": "^7.
|
|
31
|
+
"@babel/runtime": "^7.24.0",
|
|
32
32
|
"@marko/babel-utils": "^6.4.1",
|
|
33
|
-
"magic-string": "^0.30.
|
|
33
|
+
"magic-string": "^0.30.8",
|
|
34
34
|
"self-closing-tags": "^1.0.1"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@marko/compiler": "^5.35.
|
|
38
|
-
"marko": "^5.33.
|
|
37
|
+
"@marko/compiler": "^5.35.4",
|
|
38
|
+
"marko": "^5.33.4"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
41
|
"@marko/compiler": "^5.16.1",
|