@marko/compiler 5.21.5 → 5.22.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/babel-plugin/index.js +1 -0
- package/dist/babel-plugin/parser.js +9 -5
- package/dist/config.js +12 -1
- package/dist/index.js +23 -5
- package/index.d.ts +1 -0
- package/package.json +5 -3
|
@@ -102,6 +102,7 @@ const SOURCE_FILES = new WeakMap();var _default =
|
|
|
102
102
|
undefined;
|
|
103
103
|
|
|
104
104
|
metadata.marko.watchFiles = metadata.marko.watchFiles.filter(unique);
|
|
105
|
+
file.path.scope.crawl(); // Ensure all scopes are accurate for subsequent babel plugins
|
|
105
106
|
} finally {
|
|
106
107
|
(0, _fs.setFS)(prevFS);
|
|
107
108
|
}
|
|
@@ -213,7 +213,7 @@ function parseMarko(file) {
|
|
|
213
213
|
|
|
214
214
|
|
|
215
215
|
},
|
|
216
|
-
|
|
216
|
+
onOpenTagName(part) {
|
|
217
217
|
const tagName = parseTemplateString(part);
|
|
218
218
|
const node = t.markoTag(tagName, [], t.markoTagBody());
|
|
219
219
|
let parseType = _htmljsParser.TagType.html;
|
|
@@ -334,7 +334,11 @@ function parseMarko(file) {
|
|
|
334
334
|
`${parser.read(part.params)}=>{}`,
|
|
335
335
|
part.params.start).
|
|
336
336
|
params,
|
|
337
|
-
(0, _babelUtils.
|
|
337
|
+
(0, _babelUtils.parseExpression)(
|
|
338
|
+
file,
|
|
339
|
+
`()=>${parser.read(part.body)}`,
|
|
340
|
+
part.params.start + "()=>".length).
|
|
341
|
+
body),
|
|
338
342
|
|
|
339
343
|
part);
|
|
340
344
|
|
|
@@ -436,13 +440,13 @@ function parseMarko(file) {
|
|
|
436
440
|
parseOptions.statement ||
|
|
437
441
|
parseOptions.openTagOnly)
|
|
438
442
|
{
|
|
439
|
-
this.
|
|
443
|
+
this.onCloseTagEnd(part);
|
|
440
444
|
}
|
|
441
445
|
} else if (part.selfClosed) {
|
|
442
|
-
this.
|
|
446
|
+
this.onCloseTagEnd(part);
|
|
443
447
|
}
|
|
444
448
|
},
|
|
445
|
-
|
|
449
|
+
onCloseTagEnd(part) {var _node$tagDef3;
|
|
446
450
|
const { node } = currentTag;
|
|
447
451
|
const parserPlugin = (_node$tagDef3 = node.tagDef) == null ? void 0 : _node$tagDef3.parser;
|
|
448
452
|
if (preservingWhitespaceUntil === node) {
|
package/dist/config.js
CHANGED
|
@@ -141,6 +141,13 @@ var _lassoPackageRoot = require("lasso-package-root");
|
|
|
141
141
|
|
|
142
142
|
|
|
143
143
|
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
|
|
144
151
|
|
|
145
152
|
|
|
146
153
|
|
|
@@ -151,7 +158,11 @@ var _lassoPackageRoot = require("lasso-package-root");
|
|
|
151
158
|
|
|
152
159
|
var _fs2 = require("./taglib/fs");let config;const globalThis = typeof window === "undefined" ? global : window;const MARKO_CONFIG_KEY = Symbol("Default Marko Compiler Config");if (globalThis[MARKO_CONFIG_KEY]) {config = globalThis[MARKO_CONFIG_KEY];} else {config = globalThis[MARKO_CONFIG_KEY] = { // The default output mode for compiled templates
|
|
153
160
|
output: "html", // Override the runtimeid used when calling `marko/components.init` in the `hydrate` output.
|
|
154
|
-
runtimeId: null,
|
|
161
|
+
runtimeId: null, /**
|
|
162
|
+
* Remove all typescript types from the output.
|
|
163
|
+
* By default, the compiler will remove types from the output if the
|
|
164
|
+
* `output` option is not `source` or `migrate`.
|
|
165
|
+
*/stripTypes: undefined, // Have Marko provide the final AST in the compile result.
|
|
155
166
|
ast: false, // Set the false to have Marko not generate the final code string, useful if just reading metadata or AST.
|
|
156
167
|
code: true, /**
|
|
157
168
|
* Whether the version should be written to the template as a comment e.g.
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
"use strict";var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");exports.__esModule = true;exports._clearDefaults = _clearDefaults;exports.compile = compile;exports.compileFile = compileFile;exports.compileFileSync = compileFileSync;exports.compileSync = compileSync;exports.configure = configure;exports.getRuntimeEntryFiles = getRuntimeEntryFiles;exports.types = exports.taglib = void 0;var _types = _interopRequireWildcard(require("./babel-types"));exports.types = _types;
|
|
2
2
|
var _path = _interopRequireDefault(require("path"));
|
|
3
3
|
var babel = _interopRequireWildcard(require("@babel/core"));
|
|
4
|
+
var _pluginTransformModulesCommonjs = _interopRequireDefault(require("@babel/plugin-transform-modules-commonjs"));
|
|
5
|
+
var _pluginSyntaxTypescript = _interopRequireDefault(require("@babel/plugin-syntax-typescript"));
|
|
6
|
+
var _pluginTransformTypescript = _interopRequireDefault(require("@babel/plugin-transform-typescript"));
|
|
4
7
|
var _babelPlugin = _interopRequireDefault(require("./babel-plugin"));
|
|
5
8
|
var _config = _interopRequireDefault(require("./config"));
|
|
6
9
|
var taglib = _interopRequireWildcard(require("./taglib"));exports.taglib = taglib;
|
|
@@ -55,7 +58,25 @@ function getRuntimeEntryFiles(output, requestedTranslator) {
|
|
|
55
58
|
|
|
56
59
|
function loadBabelConfig(filename, config) {
|
|
57
60
|
const markoConfig = { ...globalConfig, ...config, babelConfig: undefined };
|
|
58
|
-
|
|
61
|
+
|
|
62
|
+
if (markoConfig.stripTypes === undefined) {
|
|
63
|
+
markoConfig.stripTypes =
|
|
64
|
+
markoConfig.output !== "source" && markoConfig.output !== "migrate";
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const requiredPlugins = [
|
|
68
|
+
[_babelPlugin.default, markoConfig],
|
|
69
|
+
[
|
|
70
|
+
markoConfig.stripTypes ? _pluginTransformTypescript.default : _pluginSyntaxTypescript.default,
|
|
71
|
+
{
|
|
72
|
+
isTSX: false,
|
|
73
|
+
allowNamespaces: true,
|
|
74
|
+
optimizeConstEnums: true,
|
|
75
|
+
onlyRemoveTypeImports: true,
|
|
76
|
+
disallowAmbiguousJSXLike: false }]];
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
|
|
59
80
|
const baseBabelConfig = {
|
|
60
81
|
filenameRelative: filename ?
|
|
61
82
|
_path.default.relative(process.cwd(), filename) :
|
|
@@ -70,10 +91,7 @@ function loadBabelConfig(filename, config) {
|
|
|
70
91
|
|
|
71
92
|
|
|
72
93
|
if (markoConfig.modules === "cjs") {
|
|
73
|
-
requiredPlugins.push([
|
|
74
|
-
require.resolve("@babel/plugin-transform-modules-commonjs"),
|
|
75
|
-
{ loose: true }]);
|
|
76
|
-
|
|
94
|
+
requiredPlugins.push([_pluginTransformModulesCommonjs.default, { loose: true }]);
|
|
77
95
|
}
|
|
78
96
|
|
|
79
97
|
baseBabelConfig.plugins = requiredPlugins.concat(
|
package/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@marko/compiler",
|
|
3
3
|
"description": "Marko template to JS compiler.",
|
|
4
|
-
"version": "5.
|
|
4
|
+
"version": "5.22.0",
|
|
5
5
|
"author": "Dylan Piercey <dpiercey@ebay.com>",
|
|
6
6
|
"bugs": "https://github.com/marko-js/marko/issues/new?template=Bug_report.md",
|
|
7
7
|
"dependencies": {
|
|
@@ -9,14 +9,16 @@
|
|
|
9
9
|
"@babel/core": "^7.16.0",
|
|
10
10
|
"@babel/generator": "^7.16.0",
|
|
11
11
|
"@babel/parser": "^7.16.0",
|
|
12
|
+
"@babel/plugin-syntax-typescript": "^7.16.0",
|
|
12
13
|
"@babel/plugin-transform-modules-commonjs": "^7.16.0",
|
|
14
|
+
"@babel/plugin-transform-typescript": "^7.16.0",
|
|
13
15
|
"@babel/runtime": "^7.16.0",
|
|
14
16
|
"@babel/traverse": "^7.16.0",
|
|
15
17
|
"@babel/types": "^7.16.0",
|
|
16
18
|
"@marko/babel-utils": "^5.21.1",
|
|
17
19
|
"complain": "^1.6.0",
|
|
18
20
|
"he": "^1.2.0",
|
|
19
|
-
"htmljs-parser": "^
|
|
21
|
+
"htmljs-parser": "^5.0.0",
|
|
20
22
|
"jsesc": "^3.0.2",
|
|
21
23
|
"lasso-package-root": "^1.0.1",
|
|
22
24
|
"property-handlers": "^1.1.1",
|
|
@@ -28,7 +30,7 @@
|
|
|
28
30
|
"strip-json-comments": "^3.1.1"
|
|
29
31
|
},
|
|
30
32
|
"devDependencies": {
|
|
31
|
-
"@marko/translator-default": "^5.21.
|
|
33
|
+
"@marko/translator-default": "^5.21.3"
|
|
32
34
|
},
|
|
33
35
|
"files": [
|
|
34
36
|
"dist",
|