@marko/compiler 5.39.37 → 5.39.39

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.
@@ -223,13 +223,15 @@ function getMarkoFile(code, fileOpts, markoOpts) {
223
223
  };
224
224
 
225
225
  (0, _parser.parseMarko)(file);
226
+ file.path.scope.crawl(); // Initialize bindings.
226
227
 
227
228
  if (isSource) {
229
+ if (markoOpts.stripTypes) {
230
+ stripTypes(file);
231
+ }
228
232
  return file;
229
233
  }
230
234
 
231
- file.path.scope.crawl(); // Initialize bindings.
232
-
233
235
  const rootMigrators = [];
234
236
  for (const id in taglibLookup.taglibsById) {
235
237
  for (const migrator of taglibLookup.taglibsById[id].migrators) {
@@ -270,66 +272,15 @@ function getMarkoFile(code, fileOpts, markoOpts) {
270
272
  }
271
273
  }
272
274
 
275
+ if (markoOpts.stripTypes) {
276
+ stripTypes(file);
277
+ }
278
+
273
279
  if (isMigrate) {
274
280
  return file;
275
281
  }
276
282
 
277
283
  file.___compileStage = "transform";
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
-
296
- traverseAll(file, stripTypesVisitor);
297
-
298
- for (const path of file.path.get("body")) {
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
- let hasTypes = false;
312
- for (const specifier of path.get("specifiers")) {
313
- if (
314
- specifier.node.type === "ImportSpecifier" &&
315
- specifier.node.importKind === "type")
316
- {
317
- hasTypes = true;
318
- specifier.remove();
319
- }
320
- }
321
-
322
- path.remove();
323
-
324
- // Add back imports from scriptlets that were
325
- // hoisted for the babel typescript transform.
326
- if (!hasTypes || importNode.specifiers.length) {
327
- scriptlet.body.unshift(importNode);
328
- }
329
- }
330
- }
331
- }
332
- }
333
284
 
334
285
  const rootTransformers = [];
335
286
  for (const id in taglibLookup.taglibsById) {
@@ -455,6 +406,62 @@ function addPlugin(meta, arr, plugin) {
455
406
  }
456
407
  }
457
408
 
409
+ function stripTypes(file) {
410
+ const importScriptlets = new Map();
411
+ for (const path of file.path.get("body")) {
412
+ if (path.type === "MarkoScriptlet" && path.node.static) {
413
+ for (const stmt of path.get("body")) {
414
+ if (stmt.isImportDeclaration()) {
415
+ // Hoist import declarations from scriptlets
416
+ // temporarily so that they will be processed by
417
+ // babel typescript transform.
418
+ const importNode = stmt.node;
419
+ importScriptlets.set(importNode, path.node);
420
+ stmt.remove();
421
+ path.insertBefore(importNode);
422
+ }
423
+ }
424
+ }
425
+ }
426
+
427
+ traverseAll(file, stripTypesVisitor);
428
+
429
+ for (const path of file.path.get("body")) {
430
+ if (path.type === "ExportNamedDeclaration") {
431
+ if (!(path.node.declaration || path.node.specifiers.length)) {
432
+ // The babel typescript plugin will add an empty export declaration
433
+ // if there are no other imports/exports in the file.
434
+ // This is not needed for Marko file outputs since there is always
435
+ // a default export.
436
+ path.remove();
437
+ }
438
+ } else if (path.isImportDeclaration()) {
439
+ const importNode = path.node;
440
+ const scriptlet = importScriptlets.get(importNode);
441
+ if (scriptlet) {
442
+ let hasTypes = false;
443
+ for (const specifier of path.get("specifiers")) {
444
+ if (
445
+ specifier.node.type === "ImportSpecifier" &&
446
+ specifier.node.importKind === "type")
447
+ {
448
+ hasTypes = true;
449
+ specifier.remove();
450
+ }
451
+ }
452
+
453
+ path.remove();
454
+
455
+ // Add back imports from scriptlets that were
456
+ // hoisted for the babel typescript transform.
457
+ if (!hasTypes || importNode.specifiers.length) {
458
+ scriptlet.body.unshift(importNode);
459
+ }
460
+ }
461
+ }
462
+ }
463
+ }
464
+
458
465
  function isMarkoOutput(output) {
459
466
  return output === "source" || output === "migrate";
460
467
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marko/compiler",
3
- "version": "5.39.37",
3
+ "version": "5.39.39",
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.57"
90
+ "marko": "^5.37.59"
91
91
  },
92
92
  "engines": {
93
93
  "node": "18 || 20 || >=22"