@marko/compiler 5.39.50 → 5.39.52
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/file.js +2 -2
- package/dist/babel-plugin/index.js +14 -12
- package/dist/babel-plugin/parser.js +39 -39
- package/dist/babel-plugin/plugins/migrate.js +4 -4
- package/dist/babel-plugin/plugins/transform.js +4 -4
- package/dist/babel-utils/imports.js +2 -2
- package/dist/babel-utils/parse.js +12 -9
- package/dist/babel-utils/tags.js +2 -2
- package/dist/babel-utils/template-string.js +2 -2
- package/dist/babel.js +65127 -0
- package/dist/config.js +2 -2
- package/dist/index.js +18 -10
- package/dist/taglib/index.js +2 -2
- package/dist/types.d.ts +5 -5
- package/dist/util/build-code-frame.js +3 -3
- package/dist/util/try-load-translator.js +2 -2
- package/internal/babel/index.ts +22 -0
- package/internal/babel/modules.d.ts +9 -0
- package/internal/babel/package.json +5 -0
- package/package.json +7 -14
- package/dist/babel-types/generator/patch.js +0 -358
- package/dist/babel-types/index.js +0 -5
- package/dist/babel-types/traverse/patch.js +0 -133
- package/dist/babel-types/types/definitions.js +0 -254
- package/dist/babel-types/types/patch.js +0 -124
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
"use strict";exports.__esModule = true;exports.MarkoFile = void 0;var
|
|
1
|
+
"use strict";exports.__esModule = true;exports.MarkoFile = void 0;var _babel = require("@marko/compiler/internal/babel");
|
|
2
2
|
|
|
3
3
|
var _buildCodeFrame = require("../util/build-code-frame");
|
|
4
4
|
|
|
5
|
-
class MarkoFile extends
|
|
5
|
+
class MarkoFile extends _babel.File {
|
|
6
6
|
addHelper() {
|
|
7
7
|
throw new Error("addHelper is not supported during a Marko transform");
|
|
8
8
|
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
1
|
+
"use strict";exports.__esModule = true;exports.default = void 0;var _babel = require("@marko/compiler/internal/babel");
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
3
6
|
var _path = _interopRequireDefault(require("path"));
|
|
4
7
|
|
|
5
|
-
var t = _interopRequireWildcard(require("../babel-types"));
|
|
6
8
|
var _diagnostics = require("../babel-utils/diagnostics");
|
|
7
9
|
var _getFile = require("../babel-utils/get-file");
|
|
8
10
|
var _tags = require("../babel-utils/tags");
|
|
@@ -16,7 +18,7 @@ var _tryLoadTranslator = _interopRequireDefault(require("../util/try-load-transl
|
|
|
16
18
|
var _file = require("./file");
|
|
17
19
|
var _parser = require("./parser");
|
|
18
20
|
var _migrate = require("./plugins/migrate");
|
|
19
|
-
var _transform = require("./plugins/transform");function
|
|
21
|
+
var _transform = require("./plugins/transform");function _interopRequireDefault(e) {return e && e.__esModule ? e : { default: e };}
|
|
20
22
|
|
|
21
23
|
const SOURCE_FILES = new WeakMap();
|
|
22
24
|
let stripTypesVisitor;var _default =
|
|
@@ -49,7 +51,7 @@ let stripTypesVisitor;var _default =
|
|
|
49
51
|
}
|
|
50
52
|
|
|
51
53
|
if (markoOpts.stripTypes) {
|
|
52
|
-
stripTypesVisitor ||= (0,
|
|
54
|
+
stripTypesVisitor ||= (0, _babel.pluginTransformTypeScript)(api, {
|
|
53
55
|
isTSX: false,
|
|
54
56
|
allowNamespaces: true,
|
|
55
57
|
allowDeclareFields: true,
|
|
@@ -88,7 +90,7 @@ let stripTypesVisitor;var _default =
|
|
|
88
90
|
},
|
|
89
91
|
parserOverride(code) {
|
|
90
92
|
const file = getMarkoFile(code, curOpts, markoOpts);
|
|
91
|
-
const finalAst =
|
|
93
|
+
const finalAst = _babel.types.cloneNode(file.ast, true);
|
|
92
94
|
SOURCE_FILES.set(finalAst, file);
|
|
93
95
|
return finalAst;
|
|
94
96
|
},
|
|
@@ -206,7 +208,7 @@ function getMarkoFile(code, fileOpts, markoOpts) {
|
|
|
206
208
|
sourceType: "module",
|
|
207
209
|
body: [],
|
|
208
210
|
directives: [],
|
|
209
|
-
params: [
|
|
211
|
+
params: [_babel.types.identifier("input")]
|
|
210
212
|
}
|
|
211
213
|
}
|
|
212
214
|
})
|
|
@@ -250,7 +252,7 @@ function getMarkoFile(code, fileOpts, markoOpts) {
|
|
|
250
252
|
|
|
251
253
|
if (file.___hasParseErrors) {
|
|
252
254
|
if (markoOpts.errorRecovery) {
|
|
253
|
-
|
|
255
|
+
_babel.types.traverseFast(file.path.node, (node) => {
|
|
254
256
|
if (node.type === "MarkoParseError") {
|
|
255
257
|
(0, _diagnostics.diagnosticError)(file.path, {
|
|
256
258
|
label: node.label,
|
|
@@ -260,7 +262,7 @@ function getMarkoFile(code, fileOpts, markoOpts) {
|
|
|
260
262
|
});
|
|
261
263
|
} else {
|
|
262
264
|
let errors = [];
|
|
263
|
-
|
|
265
|
+
_babel.types.traverseFast(file.path.node, (node) => {
|
|
264
266
|
if (node.type === "MarkoParseError") {
|
|
265
267
|
errors.push(
|
|
266
268
|
(0, _buildCodeFrame.buildCodeFrameError)(
|
|
@@ -381,7 +383,7 @@ function mergeVisitors(all) {
|
|
|
381
383
|
if (all.length === 1) {
|
|
382
384
|
all = all[0];
|
|
383
385
|
} else {
|
|
384
|
-
return
|
|
386
|
+
return _babel.traverse.visitors.merge(all.map(toExploded));
|
|
385
387
|
}
|
|
386
388
|
}
|
|
387
389
|
|
|
@@ -392,7 +394,7 @@ const explodeCache = new WeakMap();
|
|
|
392
394
|
function toExploded(visitor) {
|
|
393
395
|
let cached = explodeCache.get(visitor);
|
|
394
396
|
if (!cached) {
|
|
395
|
-
cached =
|
|
397
|
+
cached = _babel.traverse.visitors.explode(cloneVisitor(visitor));
|
|
396
398
|
explodeCache.set(visitor, cached);
|
|
397
399
|
}
|
|
398
400
|
|
|
@@ -418,7 +420,7 @@ function cloneVisit(visit) {
|
|
|
418
420
|
|
|
419
421
|
function traverseAll(file, visitors) {
|
|
420
422
|
const program = file.path;
|
|
421
|
-
(0,
|
|
423
|
+
(0, _babel.traverse)(
|
|
422
424
|
program.node,
|
|
423
425
|
mergeVisitors(visitors),
|
|
424
426
|
program.scope,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";exports.__esModule = true;exports.parseMarko = parseMarko;var _babelUtils = require("@marko/compiler/babel-utils");
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
@@ -9,11 +9,11 @@
|
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
|
|
12
|
+
var _babel = require("@marko/compiler/internal/babel");
|
|
12
13
|
var _htmljsParser = require("htmljs-parser");
|
|
13
14
|
|
|
14
|
-
var t = _interopRequireWildcard(require("../babel-types"));
|
|
15
15
|
var _buildCodeFrame = require("../util/build-code-frame");
|
|
16
|
-
var _mergeErrors = _interopRequireDefault(require("../util/merge-errors"));function
|
|
16
|
+
var _mergeErrors = _interopRequireDefault(require("../util/merge-errors"));function _interopRequireDefault(e) {return e && e.__esModule ? e : { default: e };}
|
|
17
17
|
|
|
18
18
|
const noop = () => {};
|
|
19
19
|
const emptyRange = (part) => part.start === part.end;
|
|
@@ -64,7 +64,7 @@ function parseMarko(file) {
|
|
|
64
64
|
let previousSiblingIndex = currentBody.length;
|
|
65
65
|
while (previousSiblingIndex) {
|
|
66
66
|
let previousSibling = currentBody[--previousSiblingIndex];
|
|
67
|
-
if (!
|
|
67
|
+
if (!_babel.types.isMarkoComment(previousSibling)) {
|
|
68
68
|
break;
|
|
69
69
|
}
|
|
70
70
|
currentTag.pushContainer("attributeTags", previousSibling.node);
|
|
@@ -92,7 +92,7 @@ function parseMarko(file) {
|
|
|
92
92
|
switch (expressions.length) {
|
|
93
93
|
case 0:{
|
|
94
94
|
const [first] = quasis;
|
|
95
|
-
return withLoc(
|
|
95
|
+
return withLoc(_babel.types.stringLiteral(parser.read(first)), first);
|
|
96
96
|
}
|
|
97
97
|
case 1:{
|
|
98
98
|
if (emptyRange(quasis[0]) && emptyRange(quasis[1])) {
|
|
@@ -103,10 +103,10 @@ function parseMarko(file) {
|
|
|
103
103
|
value.start,
|
|
104
104
|
value.end
|
|
105
105
|
);
|
|
106
|
-
if (
|
|
106
|
+
if (_babel.types.isStringLiteral(result)) {
|
|
107
107
|
// convert to template literal just so that we don't mistake it for a native tag if this is a tag name.
|
|
108
108
|
return withLoc(
|
|
109
|
-
|
|
109
|
+
_babel.types.templateLiteral([templateElement(result.value, true)], []),
|
|
110
110
|
value
|
|
111
111
|
);
|
|
112
112
|
} else {
|
|
@@ -135,7 +135,7 @@ function parseMarko(file) {
|
|
|
135
135
|
}
|
|
136
136
|
|
|
137
137
|
const errors = [];
|
|
138
|
-
|
|
138
|
+
_babel.types.traverseFast(file.path.node, (node) => {
|
|
139
139
|
if (node.type === "MarkoParseError") {
|
|
140
140
|
errors.push(
|
|
141
141
|
(0, _buildCodeFrame.buildCodeFrameError)(
|
|
@@ -155,7 +155,7 @@ function parseMarko(file) {
|
|
|
155
155
|
const rawValue = parser.read(part);
|
|
156
156
|
|
|
157
157
|
if (preservingWhitespaceUntil) {
|
|
158
|
-
pushContent(withLoc(
|
|
158
|
+
pushContent(withLoc(_babel.types.markoText(rawValue), part));
|
|
159
159
|
return;
|
|
160
160
|
}
|
|
161
161
|
|
|
@@ -168,7 +168,7 @@ function parseMarko(file) {
|
|
|
168
168
|
while (prevIndex > 0) {
|
|
169
169
|
prev = body[--prevIndex];
|
|
170
170
|
|
|
171
|
-
if (
|
|
171
|
+
if (_babel.types.isMarkoScriptlet(prev) || _babel.types.isMarkoComment(prev)) {
|
|
172
172
|
prev = undefined;
|
|
173
173
|
} else {
|
|
174
174
|
break;
|
|
@@ -194,7 +194,7 @@ function parseMarko(file) {
|
|
|
194
194
|
break;
|
|
195
195
|
}
|
|
196
196
|
|
|
197
|
-
const node =
|
|
197
|
+
const node = _babel.types.markoText(value);
|
|
198
198
|
pushContent(node);
|
|
199
199
|
onNext = (next) => {
|
|
200
200
|
switch (next?.type) {
|
|
@@ -235,16 +235,16 @@ function parseMarko(file) {
|
|
|
235
235
|
};
|
|
236
236
|
},
|
|
237
237
|
onCDATA(part) {
|
|
238
|
-
pushContent(withLoc(
|
|
238
|
+
pushContent(withLoc(_babel.types.markoCDATA(parser.read(part.value)), part));
|
|
239
239
|
},
|
|
240
240
|
onDoctype(part) {
|
|
241
|
-
pushContent(withLoc(
|
|
241
|
+
pushContent(withLoc(_babel.types.markoDocumentType(parser.read(part.value)), part));
|
|
242
242
|
},
|
|
243
243
|
onDeclaration(part) {
|
|
244
|
-
pushContent(withLoc(
|
|
244
|
+
pushContent(withLoc(_babel.types.markoDeclaration(parser.read(part.value)), part));
|
|
245
245
|
},
|
|
246
246
|
onComment(part) {
|
|
247
|
-
pushContent(withLoc(
|
|
247
|
+
pushContent(withLoc(_babel.types.markoComment(parser.read(part.value)), part));
|
|
248
248
|
},
|
|
249
249
|
onTagTypeArgs(part) {
|
|
250
250
|
currentTag.node.typeArguments = (0, _babelUtils.parseTypeArgs)(
|
|
@@ -265,7 +265,7 @@ function parseMarko(file) {
|
|
|
265
265
|
onPlaceholder(part) {
|
|
266
266
|
pushContent(
|
|
267
267
|
withLoc(
|
|
268
|
-
|
|
268
|
+
_babel.types.markoPlaceholder(
|
|
269
269
|
(0, _babelUtils.parseExpression)(
|
|
270
270
|
file,
|
|
271
271
|
parser.read(part.value),
|
|
@@ -281,7 +281,7 @@ function parseMarko(file) {
|
|
|
281
281
|
onScriptlet(part) {
|
|
282
282
|
pushContent(
|
|
283
283
|
withLoc(
|
|
284
|
-
|
|
284
|
+
_babel.types.markoScriptlet(
|
|
285
285
|
(0, _babelUtils.parseStatements)(
|
|
286
286
|
file,
|
|
287
287
|
parser.read(part.value),
|
|
@@ -295,13 +295,13 @@ function parseMarko(file) {
|
|
|
295
295
|
},
|
|
296
296
|
onOpenTagName(part) {
|
|
297
297
|
const tagName = parseTemplateString(part);
|
|
298
|
-
const node =
|
|
298
|
+
const node = _babel.types.markoTag(tagName, [], _babel.types.markoTagBody());
|
|
299
299
|
let parseType = _htmljsParser.TagType.html;
|
|
300
300
|
node.start =
|
|
301
301
|
part.start - (part.start && code[part.start - 1] === "<" ? 1 : 0); // Account for leading `<` in html mode.
|
|
302
302
|
node.end = part.end;
|
|
303
303
|
|
|
304
|
-
if (
|
|
304
|
+
if (_babel.types.isStringLiteral(tagName)) {
|
|
305
305
|
const literalTagName = tagName.value || (tagName.value = "div");
|
|
306
306
|
|
|
307
307
|
if (literalTagName === "%") {
|
|
@@ -376,9 +376,9 @@ function parseMarko(file) {
|
|
|
376
376
|
const [, name, modifier] = /^([^:]*)(?::(.*))?/.exec(parser.read(part));
|
|
377
377
|
endAttr();
|
|
378
378
|
currentTag.node.attributes.push(
|
|
379
|
-
currentAttr =
|
|
379
|
+
currentAttr = _babel.types.markoAttribute(
|
|
380
380
|
name || "value",
|
|
381
|
-
|
|
381
|
+
_babel.types.booleanLiteral(true),
|
|
382
382
|
modifier,
|
|
383
383
|
undefined,
|
|
384
384
|
!name
|
|
@@ -413,7 +413,7 @@ function parseMarko(file) {
|
|
|
413
413
|
onAttrMethod(part) {
|
|
414
414
|
currentAttr.end = part.end;
|
|
415
415
|
currentAttr.value = withLoc(
|
|
416
|
-
|
|
416
|
+
_babel.types.functionExpression(
|
|
417
417
|
undefined,
|
|
418
418
|
(0, _babelUtils.parseParams)(
|
|
419
419
|
file,
|
|
@@ -421,7 +421,7 @@ function parseMarko(file) {
|
|
|
421
421
|
part.params.value.start,
|
|
422
422
|
part.params.value.end
|
|
423
423
|
),
|
|
424
|
-
|
|
424
|
+
_babel.types.blockStatement(
|
|
425
425
|
(0, _babelUtils.parseStatements)(
|
|
426
426
|
file,
|
|
427
427
|
parser.read(part.body.value),
|
|
@@ -438,7 +438,7 @@ function parseMarko(file) {
|
|
|
438
438
|
endAttr();
|
|
439
439
|
currentTag.node.attributes.push(
|
|
440
440
|
withLoc(
|
|
441
|
-
|
|
441
|
+
_babel.types.markoSpreadAttribute(
|
|
442
442
|
(0, _babelUtils.parseExpression)(file, parser.read(part.value), part.value.start)
|
|
443
443
|
),
|
|
444
444
|
part
|
|
@@ -458,10 +458,10 @@ function parseMarko(file) {
|
|
|
458
458
|
currentShorthandClassNames.length === 1 ?
|
|
459
459
|
currentShorthandClassNames[0] :
|
|
460
460
|
currentShorthandClassNames.every((expr) =>
|
|
461
|
-
|
|
461
|
+
_babel.types.isStringLiteral(expr)
|
|
462
462
|
) ?
|
|
463
463
|
withLoc(
|
|
464
|
-
|
|
464
|
+
_babel.types.stringLiteral(
|
|
465
465
|
currentShorthandClassNames.
|
|
466
466
|
map((node) => node.value).
|
|
467
467
|
join(" ")
|
|
@@ -473,16 +473,16 @@ function parseMarko(file) {
|
|
|
473
473
|
end
|
|
474
474
|
}
|
|
475
475
|
) :
|
|
476
|
-
|
|
476
|
+
_babel.types.arrayExpression(currentShorthandClassNames);
|
|
477
477
|
|
|
478
478
|
for (const attr of attributes) {
|
|
479
479
|
if (attr.name === "class") {
|
|
480
480
|
foundClassAttr = true;
|
|
481
481
|
if (
|
|
482
|
-
|
|
483
|
-
|
|
482
|
+
_babel.types.isStringLiteral(attr.value) &&
|
|
483
|
+
_babel.types.isStringLiteral(classShorthandValue))
|
|
484
484
|
{
|
|
485
|
-
attr.value =
|
|
485
|
+
attr.value = _babel.types.templateLiteral(
|
|
486
486
|
[
|
|
487
487
|
templateElement("", false),
|
|
488
488
|
templateElement(" ", false),
|
|
@@ -491,14 +491,14 @@ function parseMarko(file) {
|
|
|
491
491
|
[classShorthandValue, attr.value]
|
|
492
492
|
);
|
|
493
493
|
} else {
|
|
494
|
-
attr.value =
|
|
495
|
-
|
|
494
|
+
attr.value = _babel.types.arrayExpression(
|
|
495
|
+
_babel.types.isArrayExpression(classShorthandValue) ?
|
|
496
496
|
classShorthandValue.elements.concat(
|
|
497
|
-
|
|
497
|
+
_babel.types.isArrayExpression(attr.value) ?
|
|
498
498
|
attr.value.elements :
|
|
499
499
|
attr.value
|
|
500
500
|
) :
|
|
501
|
-
|
|
501
|
+
_babel.types.isArrayExpression(attr.value) ?
|
|
502
502
|
[classShorthandValue].concat(attr.value.elements) :
|
|
503
503
|
[classShorthandValue, attr.value]
|
|
504
504
|
);
|
|
@@ -508,7 +508,7 @@ function parseMarko(file) {
|
|
|
508
508
|
}
|
|
509
509
|
|
|
510
510
|
if (!foundClassAttr) {
|
|
511
|
-
attributes.push(
|
|
511
|
+
attributes.push(_babel.types.markoAttribute("class", classShorthandValue));
|
|
512
512
|
}
|
|
513
513
|
|
|
514
514
|
currentShorthandClassNames = undefined;
|
|
@@ -523,7 +523,7 @@ function parseMarko(file) {
|
|
|
523
523
|
);
|
|
524
524
|
}
|
|
525
525
|
}
|
|
526
|
-
attributes.push(
|
|
526
|
+
attributes.push(_babel.types.markoAttribute("id", currentShorthandId));
|
|
527
527
|
currentShorthandId = undefined;
|
|
528
528
|
}
|
|
529
529
|
|
|
@@ -580,8 +580,8 @@ function parseMarko(file) {
|
|
|
580
580
|
// Otherwise we only move scriptlets.
|
|
581
581
|
for (const child of node.body.body) {
|
|
582
582
|
if (
|
|
583
|
-
|
|
584
|
-
isControlFlow &&
|
|
583
|
+
_babel.types.isMarkoScriptlet(child) ||
|
|
584
|
+
isControlFlow && _babel.types.isMarkoComment(child))
|
|
585
585
|
{
|
|
586
586
|
attributeTags.push(child);
|
|
587
587
|
} else if (
|
|
@@ -658,7 +658,7 @@ function sortByStart(a, b) {
|
|
|
658
658
|
}
|
|
659
659
|
|
|
660
660
|
function templateElement(value, tail) {
|
|
661
|
-
return
|
|
661
|
+
return _babel.types.templateElement({
|
|
662
662
|
tail,
|
|
663
663
|
raw: value,
|
|
664
664
|
cooked: value
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";exports.__esModule = true;exports.visitor = void 0;var _babelUtils = require("@marko/compiler/babel-utils");
|
|
2
|
+
var _babel = require("@marko/compiler/internal/babel");
|
|
2
3
|
|
|
3
|
-
var
|
|
4
|
-
var _pluginHooks = require("../util/plugin-hooks");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);}
|
|
4
|
+
var _pluginHooks = require("../util/plugin-hooks");
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Applies custom migrators on tags.
|
|
@@ -12,7 +12,7 @@ const visitor = exports.visitor = {
|
|
|
12
12
|
const migrators = getMigratorsForTag(path);
|
|
13
13
|
const { node } = path;
|
|
14
14
|
for (const migrator of migrators) {
|
|
15
|
-
(0, _pluginHooks.enter)(migrator, path,
|
|
15
|
+
(0, _pluginHooks.enter)(migrator, path, _babel.types);
|
|
16
16
|
if (path.node !== node) break; // Stop if node is replaced.
|
|
17
17
|
}
|
|
18
18
|
},
|
|
@@ -20,7 +20,7 @@ const visitor = exports.visitor = {
|
|
|
20
20
|
const migrators = getMigratorsForTag(path);
|
|
21
21
|
const { node } = path;
|
|
22
22
|
for (const migrator of migrators) {
|
|
23
|
-
(0, _pluginHooks.exit)(migrator, path,
|
|
23
|
+
(0, _pluginHooks.exit)(migrator, path, _babel.types);
|
|
24
24
|
if (path.node !== node) break; // Stop if node is replaced.
|
|
25
25
|
}
|
|
26
26
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";exports.__esModule = true;exports.visitor = void 0;var _babelUtils = require("@marko/compiler/babel-utils");
|
|
2
|
+
var _babel = require("@marko/compiler/internal/babel");
|
|
2
3
|
|
|
3
|
-
var
|
|
4
|
-
var _pluginHooks = require("../util/plugin-hooks");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);}
|
|
4
|
+
var _pluginHooks = require("../util/plugin-hooks");
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Applies custom transformers on tags.
|
|
@@ -13,7 +13,7 @@ const visitor = exports.visitor = {
|
|
|
13
13
|
const { node } = path;
|
|
14
14
|
|
|
15
15
|
for (const transformer of transformers) {
|
|
16
|
-
(0, _pluginHooks.enter)(transformer, path,
|
|
16
|
+
(0, _pluginHooks.enter)(transformer, path, _babel.types);
|
|
17
17
|
if (path.node !== node) break; // Stop if node is replaced.
|
|
18
18
|
}
|
|
19
19
|
},
|
|
@@ -22,7 +22,7 @@ const visitor = exports.visitor = {
|
|
|
22
22
|
const { node } = path;
|
|
23
23
|
|
|
24
24
|
for (const transformer of transformers) {
|
|
25
|
-
(0, _pluginHooks.exit)(transformer, path,
|
|
25
|
+
(0, _pluginHooks.exit)(transformer, path, _babel.types);
|
|
26
26
|
if (path.node !== node) break; // Stop if node is replaced.
|
|
27
27
|
}
|
|
28
28
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";exports.__esModule = true;exports.importDefault = importDefault;exports.importNamed = importNamed;exports.importStar = importStar;exports.resolveRelativePath = resolveRelativePath;var _compiler = require("@marko/compiler");
|
|
2
2
|
var _modules = require("@marko/compiler/modules");
|
|
3
3
|
var _path = _interopRequireDefault(require("path"));
|
|
4
|
-
var _relativeImportPath = require("relative-import-path");
|
|
4
|
+
var _relativeImportPath = require("relative-import-path");function _interopRequireDefault(e) {return e && e.__esModule ? e : { default: e };}
|
|
5
5
|
|
|
6
6
|
const IMPORTS_KEY = Symbol();
|
|
7
7
|
const FS_START = _path.default.sep === "/" ? _path.default.sep : /^(.*?:)/.exec(_modules.cwd)[1];
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
"use strict";exports.__esModule = true;exports.parseArgs = parseArgs;exports.parseExpression = parseExpression;exports.parseParams = parseParams;exports.parseStatements = parseStatements;exports.parseTemplateLiteral = parseTemplateLiteral;exports.parseTypeArgs = parseTypeArgs;exports.parseTypeParams = parseTypeParams;exports.parseVar = parseVar;var
|
|
2
|
-
var
|
|
1
|
+
"use strict";exports.__esModule = true;exports.parseArgs = parseArgs;exports.parseExpression = parseExpression;exports.parseParams = parseParams;exports.parseStatements = parseStatements;exports.parseTemplateLiteral = parseTemplateLiteral;exports.parseTypeArgs = parseTypeArgs;exports.parseTypeParams = parseTypeParams;exports.parseVar = parseVar;var _compiler = require("@marko/compiler");
|
|
2
|
+
var _babel = require("@marko/compiler/internal/babel");
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
var _loc = require("./loc");
|
|
5
8
|
|
|
6
9
|
function parseStatements(
|
|
7
10
|
file,
|
|
@@ -135,9 +138,9 @@ sourceOffset)
|
|
|
135
138
|
|
|
136
139
|
try {
|
|
137
140
|
if (isExpression) {
|
|
138
|
-
return
|
|
141
|
+
return (0, _babel.parseExpression)(code, parserOpts);
|
|
139
142
|
} else {
|
|
140
|
-
const { program } =
|
|
143
|
+
const { program } = (0, _babel.parse)(code, parserOpts);
|
|
141
144
|
if (program.innerComments) {
|
|
142
145
|
const lastNode = _compiler.types.emptyStatement();
|
|
143
146
|
lastNode.trailingComments = program.innerComments;
|
|
@@ -166,10 +169,10 @@ sourceOffset)
|
|
|
166
169
|
}
|
|
167
170
|
} else {
|
|
168
171
|
return isExpression ?
|
|
169
|
-
_compiler.types.cloneDeepWithoutLoc(
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
172
|
+
_compiler.types.cloneDeepWithoutLoc((0, _babel.parseExpression)(code, parserOpts)) :
|
|
173
|
+
(0, _babel.parse)(code, parserOpts).program.body.map((node) =>
|
|
174
|
+
_compiler.types.cloneDeepWithoutLoc(node)
|
|
175
|
+
);
|
|
173
176
|
}
|
|
174
177
|
}
|
|
175
178
|
|
package/dist/babel-utils/tags.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";exports.__esModule = true;exports.findAttributeTags = findAttributeTags;exports.findParentTag = findParentTag;exports.getArgOrSequence = getArgOrSequence;exports.getFullyResolvedTagName = getFullyResolvedTagName;exports.getMacroIdentifier = getMacroIdentifier;exports.getMacroIdentifierForName = getMacroIdentifierForName;exports.getTagDef = getTagDef;exports.getTagTemplate = getTagTemplate;exports.getTemplateId = getTemplateId;exports.hasMacro = hasMacro;exports.isAttributeTag = isAttributeTag;exports.isDynamicTag = isDynamicTag;exports.isLoopTag = isLoopTag;exports.isMacroTag = isMacroTag;exports.isNativeTag = isNativeTag;exports.isTransparentTag = isTransparentTag;exports.loadFileForImport = loadFileForImport;exports.loadFileForTag = loadFileForTag;exports.registerMacro = registerMacro;exports.resolveTagImport = resolveTagImport;var _compiler = require("@marko/compiler");
|
|
2
2
|
var _modules = _interopRequireDefault(require("@marko/compiler/modules"));
|
|
3
3
|
var _path = require("path");
|
|
4
4
|
|
|
5
5
|
var _quickHash = require("../util/quick-hash");
|
|
6
6
|
var _diagnostics = require("./diagnostics");
|
|
7
7
|
var _imports = require("./imports");
|
|
8
|
-
var _taglib = require("./taglib");
|
|
8
|
+
var _taglib = require("./taglib");function _interopRequireDefault(e) {return e && e.__esModule ? e : { default: e };}
|
|
9
9
|
|
|
10
10
|
const { cwd, root } = _modules.default;
|
|
11
11
|
const MACRO_IDS_KEY = Symbol();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var _jsesc = _interopRequireDefault(require("jsesc"));
|
|
1
|
+
"use strict";exports.__esModule = true;exports.normalizeTemplateString = normalizeTemplateString;var _compiler = require("@marko/compiler");
|
|
2
|
+
var _jsesc = _interopRequireDefault(require("jsesc"));function _interopRequireDefault(e) {return e && e.__esModule ? e : { default: e };}
|
|
3
3
|
|
|
4
4
|
function normalizeTemplateString(quasis, ...expressions) {
|
|
5
5
|
quasis = quasis.map((q) => _compiler.types.isTemplateElement(q) ? q.value.cooked : q);
|