marko 5.37.62 → 5.38.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.
@@ -599,9 +599,8 @@ function getRuntimeEntryFiles(output, optimize) {
599
599
 
600
600
  }
601
601
 
602
- function isRenderContent(path) {
603
- const { node } = path;
604
- return _compiler.types.MARKO_TYPES.includes(node.type) && !node.static;
602
+ function isRenderContent({ node }) {
603
+ return /^Marko/.test(node.type) && !node.static;
605
604
  }
606
605
 
607
606
  function resolveRelativeTagEntry(file, tagDef) {
@@ -1,4 +1,35 @@
1
- "use strict";exports.__esModule = true;exports.default = _default;function _default(path) {
1
+ "use strict";exports.__esModule = true;exports.default = _default;var _compiler = require("@marko/compiler");
2
+
3
+ function _default(path) {
2
4
  const { node } = path;
5
+ const isHTML = path.hub.file.markoOpts.output === "html";
6
+ switch (node.target) {
7
+ case "server":
8
+ if (!isHTML) {
9
+ replaceWithUndefinedIdentifiers(path);
10
+ return;
11
+ }
12
+ break;
13
+ case "client":
14
+ if (isHTML) {
15
+ replaceWithUndefinedIdentifiers(path);
16
+ return;
17
+ }
18
+ break;
19
+ }
3
20
  path.replaceWithMultiple(node.body);
21
+ }
22
+
23
+ function replaceWithUndefinedIdentifiers(path) {
24
+ const keys = Object.keys(path.getOuterBindingIdentifiers());
25
+ if (keys.length) {
26
+ path.replaceWith(
27
+ _compiler.types.variableDeclaration(
28
+ "var",
29
+ keys.map((key) => _compiler.types.variableDeclarator(_compiler.types.identifier(key)))
30
+ )
31
+ );
32
+ } else {
33
+ path.remove();
34
+ }
4
35
  }
@@ -57,7 +57,29 @@ var _nativeTag = _interopRequireDefault(require("./native-tag"));function _inter
57
57
  moveIgnoredAttrTags(path);
58
58
  }
59
59
 
60
- if ((0, _babelUtils.isDynamicTag)(path) || !((0, _babelUtils.isMacroTag)(path) || (0, _babelUtils.isNativeTag)(path))) {
60
+ if ((0, _babelUtils.isNativeTag)(path)) {
61
+ if (tagDef && tagDef.name === "body") {
62
+ path.
63
+ get("body").
64
+ pushContainer("body", [
65
+ _compiler.types.markoTag(
66
+ _compiler.types.stringLiteral("init-components"),
67
+ [],
68
+ _compiler.types.markoTagBody()
69
+ ),
70
+ _compiler.types.markoTag(
71
+ _compiler.types.stringLiteral("await-reorderer"),
72
+ [],
73
+ _compiler.types.markoTagBody()
74
+ ),
75
+ _compiler.types.markoTag(
76
+ _compiler.types.stringLiteral("_preferred-script-location"),
77
+ [],
78
+ _compiler.types.markoTagBody()
79
+ )]
80
+ );
81
+ }
82
+ } else if (!(0, _babelUtils.isMacroTag)(path)) {
61
83
  (0, _attributeTag.analyzeAttributeTags)(path);
62
84
  }
63
85
 
@@ -1,12 +1,15 @@
1
- "use strict";exports.__esModule = true;exports.default = void 0;var translateElse = _interopRequireWildcard(require("./conditional/translate-else"));
1
+ "use strict";var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");exports.__esModule = true;exports.default = void 0;var translateElse = _interopRequireWildcard(require("./conditional/translate-else"));
2
2
  var translateElseIf = _interopRequireWildcard(require("./conditional/translate-else-if"));
3
3
  var translateIf = _interopRequireWildcard(require("./conditional/translate-if"));
4
4
  var parseMacro = _interopRequireWildcard(require("./macro/parse"));
5
5
  var translateMacro = _interopRequireWildcard(require("./macro/translate"));
6
+ var _migrate = _interopRequireDefault(require("./migrate"));
6
7
  var parseClass = _interopRequireWildcard(require("./parse-class"));
8
+ var parseClient = _interopRequireWildcard(require("./parse-client"));
7
9
  var parseExport = _interopRequireWildcard(require("./parse-export"));
8
10
  var parseImport = _interopRequireWildcard(require("./parse-import"));
9
11
  var parseModuleCode = _interopRequireWildcard(require("./parse-module-code"));
12
+ var parseServer = _interopRequireWildcard(require("./parse-server"));
10
13
  var parseStatic = _interopRequireWildcard(require("./parse-static"));
11
14
  var transformBody = _interopRequireWildcard(require("./transform-body"));
12
15
  var transformStyle = _interopRequireWildcard(require("./transform-style"));
@@ -18,7 +21,8 @@ var translateServerOnly = _interopRequireWildcard(require("./translate-server-on
18
21
  var translateWhile = _interopRequireWildcard(require("./translate-while"));function _interopRequireWildcard(e, t) {if ("function" == typeof WeakMap) var r = new WeakMap(),n = new WeakMap();return (_interopRequireWildcard = function (e, t) {if (!t && e && e.__esModule) return e;var o,i,f = { __proto__: null, default: e };if (null === e || "object" != typeof e && "function" != typeof e) return f;if (o = t ? n : r) {if (o.has(e)) return o.get(e);o.set(e, f);}for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]);return f;})(e, t);}var _default = exports.default =
19
22
 
20
23
  {
21
- "taglib-id": "marko-default-core",
24
+ taglibId: "marko-core",
25
+ migrate: _migrate.default,
22
26
  "<import>": {
23
27
  "node-factory": parseImport,
24
28
  "parse-options": {
@@ -53,6 +57,20 @@ var translateWhile = _interopRequireWildcard(require("./translate-while"));funct
53
57
  }]
54
58
 
55
59
  },
60
+ "<client>": {
61
+ "node-factory": parseClient,
62
+ "parse-options": {
63
+ statement: true,
64
+ rawOpenTag: true
65
+ }
66
+ },
67
+ "<server>": {
68
+ "node-factory": parseServer,
69
+ "parse-options": {
70
+ statement: true,
71
+ rawOpenTag: true
72
+ }
73
+ },
56
74
  "<class>": {
57
75
  "node-factory": parseClass,
58
76
  "parse-options": {
@@ -89,7 +107,9 @@ var translateWhile = _interopRequireWildcard(require("./translate-while"));funct
89
107
  "<style>": {
90
108
  transformer: transformStyle,
91
109
  "parse-options": {
92
- rawOpenTag: true
110
+ text: true,
111
+ rawOpenTag: true,
112
+ preserveWhitespace: true
93
113
  }
94
114
  },
95
115
  "<macro>": {
@@ -283,9 +303,6 @@ var translateWhile = _interopRequireWildcard(require("./translate-while"));funct
283
303
  "code-generator": translateServerOnly,
284
304
  renderer: "marko/src/core-tags/components/preferred-script-location-tag.js"
285
305
  },
286
- "<body>": {
287
- transformer: transformBody
288
- },
289
306
  "<await>": {
290
307
  renderer: "marko/src/core-tags/core/await/renderer.js",
291
308
  types: "marko/src/core-tags/core/await/index.d.marko",
@@ -0,0 +1,18 @@
1
+ "use strict";exports.__esModule = true;exports.default = _default;var _compiler = require("@marko/compiler");
2
+ var _babelUtils = require("@marko/compiler/babel-utils");
3
+
4
+ function _default(path) {
5
+ const {
6
+ node,
7
+ hub: { file }
8
+ } = path;
9
+ const { rawValue, end } = node;
10
+ const code = rawValue.replace(/^client\s*/, "");
11
+ const start = node.start + (rawValue.length - code.length);
12
+ let body = (0, _babelUtils.parseStatements)(file, code, start, end);
13
+ if (body.length === 1 && _compiler.types.isBlockStatement(body[0])) {
14
+ body = body[0].body;
15
+ }
16
+
17
+ path.replaceWith(_compiler.types.markoScriptlet(body, true, "client"));
18
+ }
@@ -0,0 +1,18 @@
1
+ "use strict";exports.__esModule = true;exports.default = _default;var _compiler = require("@marko/compiler");
2
+ var _babelUtils = require("@marko/compiler/babel-utils");
3
+
4
+ function _default(path) {
5
+ const {
6
+ node,
7
+ hub: { file }
8
+ } = path;
9
+ const { rawValue, end } = node;
10
+ const code = rawValue.replace(/^server\s*/, "");
11
+ const start = node.start + (rawValue.length - code.length);
12
+ let body = (0, _babelUtils.parseStatements)(file, code, start, end);
13
+ if (body.length === 1 && _compiler.types.isBlockStatement(body[0])) {
14
+ body = body[0].body;
15
+ }
16
+
17
+ path.replaceWith(_compiler.types.markoScriptlet(body, true, "server"));
18
+ }
@@ -14,5 +14,5 @@ function _default(path) {
14
14
  body = body[0].body;
15
15
  }
16
16
 
17
- path.replaceWith(_compiler.types.MarkoScriptlet(body, true));
17
+ path.replaceWith(_compiler.types.markoScriptlet(body, true));
18
18
  }
@@ -1,6 +1,5 @@
1
1
  "use strict";var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");exports.__esModule = true;exports.optionalTaglibs = exports.default = void 0;var _core = _interopRequireDefault(require("./core"));
2
- var _migrate = _interopRequireDefault(require("./migrate"));
3
2
  const optionalTaglibs = exports.optionalTaglibs = ["marko-widgets", "@marko/compat-v4"];var _default = exports.default =
4
3
  [
5
- ["marko/core", _core.default],
6
- ["marko/migrate", _migrate.default]];
4
+ ["marko-html-title", { "<title>": { parseOptions: { text: false } } }], // In Marko 5 the title tag parses as html even though only text is really allowed.
5
+ [_core.default.taglibId, _core.default]];
@@ -140,6 +140,23 @@ const entryBuilder = exports.entryBuilder = {
140
140
  resolveRelativeToEntry(entryFile, file, value)
141
141
  );
142
142
  }
143
+ } else if (
144
+ _compiler.types.isMarkoScriptlet(child) &&
145
+ child.static &&
146
+ child.target !== "server")
147
+ {
148
+ for (const stmt of child.body) {
149
+ if (_compiler.types.isImportDeclaration(stmt)) {
150
+ const { value } = stmt.source;
151
+ if (child.target === "client" || state.shouldIncludeImport(value)) {
152
+ addImport(
153
+ imports,
154
+ body,
155
+ resolveRelativeToEntry(entryFile, file, value)
156
+ );
157
+ }
158
+ }
159
+ }
143
160
  }
144
161
  }
145
162
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "marko",
3
- "version": "5.37.62",
3
+ "version": "5.38.0",
4
4
  "description": "UI Components + streaming, async, high performance, HTML templating for Node.js and the browser.",
5
5
  "keywords": [
6
6
  "front-end",
@@ -70,7 +70,7 @@
70
70
  },
71
71
  "dependencies": {
72
72
  "@babel/runtime": "^7.28.2",
73
- "@marko/compiler": "^5.39.42",
73
+ "@marko/compiler": "^5.39.44",
74
74
  "app-module-path": "^2.2.0",
75
75
  "argly": "^1.2.0",
76
76
  "browser-refresh-client": "1.1.4",
@@ -599,9 +599,8 @@ export function getRuntimeEntryFiles(output, optimize) {
599
599
  ];
600
600
  }
601
601
 
602
- function isRenderContent(path) {
603
- const { node } = path;
604
- return t.MARKO_TYPES.includes(node.type) && !node.static;
602
+ function isRenderContent({ node }) {
603
+ return /^Marko/.test(node.type) && !node.static;
605
604
  }
606
605
 
607
606
  function resolveRelativeTagEntry(file, tagDef) {
@@ -1,4 +1,35 @@
1
+ import { types as t } from "@marko/compiler";
2
+
1
3
  export default function (path) {
2
4
  const { node } = path;
5
+ const isHTML = path.hub.file.markoOpts.output === "html";
6
+ switch (node.target) {
7
+ case "server":
8
+ if (!isHTML) {
9
+ replaceWithUndefinedIdentifiers(path);
10
+ return;
11
+ }
12
+ break;
13
+ case "client":
14
+ if (isHTML) {
15
+ replaceWithUndefinedIdentifiers(path);
16
+ return;
17
+ }
18
+ break;
19
+ }
3
20
  path.replaceWithMultiple(node.body);
4
21
  }
22
+
23
+ function replaceWithUndefinedIdentifiers(path) {
24
+ const keys = Object.keys(path.getOuterBindingIdentifiers());
25
+ if (keys.length) {
26
+ path.replaceWith(
27
+ t.variableDeclaration(
28
+ "var",
29
+ keys.map((key) => t.variableDeclarator(t.identifier(key))),
30
+ ),
31
+ );
32
+ } else {
33
+ path.remove();
34
+ }
35
+ }
@@ -57,7 +57,29 @@ export default {
57
57
  moveIgnoredAttrTags(path);
58
58
  }
59
59
 
60
- if (isDynamicTag(path) || !(isMacroTag(path) || isNativeTag(path))) {
60
+ if (isNativeTag(path)) {
61
+ if (tagDef && tagDef.name === "body") {
62
+ path
63
+ .get("body")
64
+ .pushContainer("body", [
65
+ t.markoTag(
66
+ t.stringLiteral("init-components"),
67
+ [],
68
+ t.markoTagBody(),
69
+ ),
70
+ t.markoTag(
71
+ t.stringLiteral("await-reorderer"),
72
+ [],
73
+ t.markoTagBody(),
74
+ ),
75
+ t.markoTag(
76
+ t.stringLiteral("_preferred-script-location"),
77
+ [],
78
+ t.markoTagBody(),
79
+ ),
80
+ ]);
81
+ }
82
+ } else if (!isMacroTag(path)) {
61
83
  analyzeAttributeTags(path);
62
84
  }
63
85
 
@@ -3,10 +3,13 @@ import * as translateElseIf from "./conditional/translate-else-if";
3
3
  import * as translateIf from "./conditional/translate-if";
4
4
  import * as parseMacro from "./macro/parse";
5
5
  import * as translateMacro from "./macro/translate";
6
+ import migrate from "./migrate";
6
7
  import * as parseClass from "./parse-class";
8
+ import * as parseClient from "./parse-client";
7
9
  import * as parseExport from "./parse-export";
8
10
  import * as parseImport from "./parse-import";
9
11
  import * as parseModuleCode from "./parse-module-code";
12
+ import * as parseServer from "./parse-server";
10
13
  import * as parseStatic from "./parse-static";
11
14
  import * as transformBody from "./transform-body";
12
15
  import * as transformStyle from "./transform-style";
@@ -18,7 +21,8 @@ import * as translateServerOnly from "./translate-server-only";
18
21
  import * as translateWhile from "./translate-while";
19
22
 
20
23
  export default {
21
- "taglib-id": "marko-default-core",
24
+ taglibId: "marko-core",
25
+ migrate,
22
26
  "<import>": {
23
27
  "node-factory": parseImport,
24
28
  "parse-options": {
@@ -53,6 +57,20 @@ export default {
53
57
  },
54
58
  ],
55
59
  },
60
+ "<client>": {
61
+ "node-factory": parseClient,
62
+ "parse-options": {
63
+ statement: true,
64
+ rawOpenTag: true,
65
+ },
66
+ },
67
+ "<server>": {
68
+ "node-factory": parseServer,
69
+ "parse-options": {
70
+ statement: true,
71
+ rawOpenTag: true,
72
+ },
73
+ },
56
74
  "<class>": {
57
75
  "node-factory": parseClass,
58
76
  "parse-options": {
@@ -89,7 +107,9 @@ export default {
89
107
  "<style>": {
90
108
  transformer: transformStyle,
91
109
  "parse-options": {
110
+ text: true,
92
111
  rawOpenTag: true,
112
+ preserveWhitespace: true,
93
113
  },
94
114
  },
95
115
  "<macro>": {
@@ -283,9 +303,6 @@ export default {
283
303
  "code-generator": translateServerOnly,
284
304
  renderer: "marko/src/core-tags/components/preferred-script-location-tag.js",
285
305
  },
286
- "<body>": {
287
- transformer: transformBody,
288
- },
289
306
  "<await>": {
290
307
  renderer: "marko/src/core-tags/core/await/renderer.js",
291
308
  types: "marko/src/core-tags/core/await/index.d.marko",
@@ -0,0 +1,18 @@
1
+ import { types as t } from "@marko/compiler";
2
+ import { parseStatements } from "@marko/compiler/babel-utils";
3
+
4
+ export default function (path) {
5
+ const {
6
+ node,
7
+ hub: { file },
8
+ } = path;
9
+ const { rawValue, end } = node;
10
+ const code = rawValue.replace(/^client\s*/, "");
11
+ const start = node.start + (rawValue.length - code.length);
12
+ let body = parseStatements(file, code, start, end);
13
+ if (body.length === 1 && t.isBlockStatement(body[0])) {
14
+ body = body[0].body;
15
+ }
16
+
17
+ path.replaceWith(t.markoScriptlet(body, true, "client"));
18
+ }
@@ -0,0 +1,18 @@
1
+ import { types as t } from "@marko/compiler";
2
+ import { parseStatements } from "@marko/compiler/babel-utils";
3
+
4
+ export default function (path) {
5
+ const {
6
+ node,
7
+ hub: { file },
8
+ } = path;
9
+ const { rawValue, end } = node;
10
+ const code = rawValue.replace(/^server\s*/, "");
11
+ const start = node.start + (rawValue.length - code.length);
12
+ let body = parseStatements(file, code, start, end);
13
+ if (body.length === 1 && t.isBlockStatement(body[0])) {
14
+ body = body[0].body;
15
+ }
16
+
17
+ path.replaceWith(t.markoScriptlet(body, true, "server"));
18
+ }
@@ -14,5 +14,5 @@ export default function (path) {
14
14
  body = body[0].body;
15
15
  }
16
16
 
17
- path.replaceWith(t.MarkoScriptlet(body, true));
17
+ path.replaceWith(t.markoScriptlet(body, true));
18
18
  }
@@ -1,7 +1,6 @@
1
1
  import coreTaglib from "./core";
2
- import migrateTaglib from "./migrate";
3
2
  export const optionalTaglibs = ["marko-widgets", "@marko/compat-v4"];
4
3
  export default [
5
- ["marko/core", coreTaglib],
6
- ["marko/migrate", migrateTaglib],
4
+ ["marko-html-title", { "<title>": { parseOptions: { text: false } } }], // In Marko 5 the title tag parses as html even though only text is really allowed.
5
+ [coreTaglib.taglibId, coreTaglib],
7
6
  ];
@@ -140,6 +140,23 @@ export const entryBuilder = {
140
140
  resolveRelativeToEntry(entryFile, file, value),
141
141
  );
142
142
  }
143
+ } else if (
144
+ t.isMarkoScriptlet(child) &&
145
+ child.static &&
146
+ child.target !== "server"
147
+ ) {
148
+ for (const stmt of child.body) {
149
+ if (t.isImportDeclaration(stmt)) {
150
+ const { value } = stmt.source;
151
+ if (child.target === "client" || state.shouldIncludeImport(value)) {
152
+ addImport(
153
+ imports,
154
+ body,
155
+ resolveRelativeToEntry(entryFile, file, value),
156
+ );
157
+ }
158
+ }
159
+ }
143
160
  }
144
161
  }
145
162
 
@@ -1,5 +0,0 @@
1
- "use strict";exports.__esModule = true;exports.default = void 0;var migrateAllTemplates = _interopRequireWildcard(require("./all-templates"));function _interopRequireWildcard(e, t) {if ("function" == typeof WeakMap) var r = new WeakMap(),n = new WeakMap();return (_interopRequireWildcard = function (e, t) {if (!t && e && e.__esModule) return e;var o,i,f = { __proto__: null, default: e };if (null === e || "object" != typeof e && "function" != typeof e) return f;if (o = t ? n : r) {if (o.has(e)) return o.get(e);o.set(e, f);}for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]);return f;})(e, t);}var _default = exports.default =
2
- {
3
- "taglib-id": "marko-default-migrate",
4
- migrator: migrateAllTemplates
5
- };
@@ -1,5 +0,0 @@
1
- import * as migrateAllTemplates from "./all-templates";
2
- export default {
3
- "taglib-id": "marko-default-migrate",
4
- migrator: migrateAllTemplates,
5
- };