@marko/compiler 5.39.35 → 5.39.36
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/babel-plugin/index.js +34 -9
- package/package.json +2 -2
|
@@ -276,18 +276,43 @@ function getMarkoFile(code, fileOpts, markoOpts) {
|
|
|
276
276
|
|
|
277
277
|
file.___compileStage = "transform";
|
|
278
278
|
if (markoOpts.stripTypes) {
|
|
279
|
+
const importScriptlets = new Map();
|
|
280
|
+
for (const path of file.path.get("body")) {
|
|
281
|
+
if (path.type === "MarkoScriptlet" && path.node.static) {
|
|
282
|
+
for (const stmt of path.get("body")) {
|
|
283
|
+
if (stmt.isImportDeclaration()) {
|
|
284
|
+
// Hoist import declarations from scriptlets
|
|
285
|
+
// temporarily so that they will be processed by
|
|
286
|
+
// babel typescript transform.
|
|
287
|
+
const importNode = stmt.node;
|
|
288
|
+
importScriptlets.set(importNode, path.node);
|
|
289
|
+
stmt.remove();
|
|
290
|
+
path.insertBefore(importNode);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
|
|
279
296
|
traverseAll(file, stripTypesVisitor);
|
|
280
297
|
|
|
281
298
|
for (const path of file.path.get("body")) {
|
|
282
|
-
if (
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
299
|
+
if (path.type === "ExportNamedDeclaration") {
|
|
300
|
+
if (!(path.node.declaration || path.node.specifiers.length)) {
|
|
301
|
+
// The babel typescript plugin will add an empty export declaration
|
|
302
|
+
// if there are no other imports/exports in the file.
|
|
303
|
+
// This is not needed for Marko file outputs since there is always
|
|
304
|
+
// a default export.
|
|
305
|
+
path.remove();
|
|
306
|
+
}
|
|
307
|
+
} else if (path.isImportDeclaration()) {
|
|
308
|
+
const importNode = path.node;
|
|
309
|
+
const scriptlet = importScriptlets.get(importNode);
|
|
310
|
+
if (scriptlet) {
|
|
311
|
+
path.remove();
|
|
312
|
+
// Add back imports from scriptlets that were
|
|
313
|
+
// hoisted for the babel typescript transform.
|
|
314
|
+
scriptlet.body.unshift(importNode);
|
|
315
|
+
}
|
|
291
316
|
}
|
|
292
317
|
}
|
|
293
318
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@marko/compiler",
|
|
3
|
-
"version": "5.39.
|
|
3
|
+
"version": "5.39.36",
|
|
4
4
|
"description": "Marko template to JS compiler.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"babel",
|
|
@@ -87,7 +87,7 @@
|
|
|
87
87
|
"source-map-support": "^0.5.21"
|
|
88
88
|
},
|
|
89
89
|
"devDependencies": {
|
|
90
|
-
"marko": "^5.37.
|
|
90
|
+
"marko": "^5.37.56"
|
|
91
91
|
},
|
|
92
92
|
"engines": {
|
|
93
93
|
"node": "18 || 20 || >=22"
|