@marko/compiler 5.39.34 → 5.39.35
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 +43 -27
- package/dist/babel-types/types/definitions.js +1 -1
- package/dist/index.js +1 -16
- package/dist/types.d.ts +1 -1
- package/package.json +2 -2
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
"use strict";var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");exports.__esModule = true;exports.default = void 0;var
|
|
1
|
+
"use strict";var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");exports.__esModule = true;exports.default = void 0;var _pluginTransformTypescript = _interopRequireDefault(require("@babel/plugin-transform-typescript"));
|
|
2
|
+
var _traverse = _interopRequireDefault(require("@babel/traverse"));
|
|
2
3
|
var _path = _interopRequireDefault(require("path"));
|
|
3
4
|
|
|
4
5
|
var t = _interopRequireWildcard(require("../babel-types"));
|
|
@@ -17,7 +18,8 @@ var _parser = require("./parser");
|
|
|
17
18
|
var _migrate = require("./plugins/migrate");
|
|
18
19
|
var _transform = require("./plugins/transform");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);}
|
|
19
20
|
|
|
20
|
-
const SOURCE_FILES = new WeakMap();
|
|
21
|
+
const SOURCE_FILES = new WeakMap();
|
|
22
|
+
let stripTypesVisitor;var _default =
|
|
21
23
|
|
|
22
24
|
(api, markoOpts) => {
|
|
23
25
|
api.assertVersion(7);
|
|
@@ -46,6 +48,17 @@ const SOURCE_FILES = new WeakMap();var _default =
|
|
|
46
48
|
);
|
|
47
49
|
}
|
|
48
50
|
|
|
51
|
+
if (markoOpts.stripTypes) {
|
|
52
|
+
stripTypesVisitor ||= (0, _pluginTransformTypescript.default)(api, {
|
|
53
|
+
isTSX: false,
|
|
54
|
+
allowNamespaces: true,
|
|
55
|
+
allowDeclareFields: true,
|
|
56
|
+
optimizeConstEnums: true,
|
|
57
|
+
onlyRemoveTypeImports: true,
|
|
58
|
+
disallowAmbiguousJSXLike: false
|
|
59
|
+
}).visitor;
|
|
60
|
+
}
|
|
61
|
+
|
|
49
62
|
let curOpts;
|
|
50
63
|
|
|
51
64
|
return {
|
|
@@ -60,6 +73,14 @@ const SOURCE_FILES = new WeakMap();var _default =
|
|
|
60
73
|
opts.parserOpts.allowUndeclaredExports =
|
|
61
74
|
opts.parserOpts.allowNewTargetOutsideFunction =
|
|
62
75
|
true;
|
|
76
|
+
|
|
77
|
+
opts.parserOpts.plugins.push("objectRestSpread", "classProperties", [
|
|
78
|
+
"typescript",
|
|
79
|
+
{
|
|
80
|
+
disallowAmbiguousJSXLike: false,
|
|
81
|
+
dts: false
|
|
82
|
+
}]
|
|
83
|
+
);
|
|
63
84
|
curOpts = opts;
|
|
64
85
|
},
|
|
65
86
|
parserOverride(code) {
|
|
@@ -120,29 +141,7 @@ const SOURCE_FILES = new WeakMap();var _default =
|
|
|
120
141
|
file.___getMarkoFile =
|
|
121
142
|
undefined;
|
|
122
143
|
}
|
|
123
|
-
}
|
|
124
|
-
visitor:
|
|
125
|
-
markoOpts.stripTypes && isMarkoOutput(markoOpts.output) ?
|
|
126
|
-
{
|
|
127
|
-
MarkoClass(path) {
|
|
128
|
-
// We replace the MarkoClass with a regular class declaration so babel can strip it's types.
|
|
129
|
-
path.replaceWith(
|
|
130
|
-
t.classDeclaration(t.identifier(""), null, path.node.body)
|
|
131
|
-
);
|
|
132
|
-
},
|
|
133
|
-
ExportNamedDeclaration: {
|
|
134
|
-
exit(path) {
|
|
135
|
-
const { node } = path;
|
|
136
|
-
// The babel typescript plugin will add an empty export declaration
|
|
137
|
-
// if there are no other imports/exports in the file.
|
|
138
|
-
// This is not needed for Marko file outputs since there is always
|
|
139
|
-
// a default export.
|
|
140
|
-
if (!(node.declaration || node.specifiers.length))
|
|
141
|
-
path.remove();
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
} :
|
|
145
|
-
undefined
|
|
144
|
+
}
|
|
146
145
|
};
|
|
147
146
|
};exports.default = _default;
|
|
148
147
|
|
|
@@ -275,6 +274,24 @@ function getMarkoFile(code, fileOpts, markoOpts) {
|
|
|
275
274
|
return file;
|
|
276
275
|
}
|
|
277
276
|
|
|
277
|
+
file.___compileStage = "transform";
|
|
278
|
+
if (markoOpts.stripTypes) {
|
|
279
|
+
traverseAll(file, stripTypesVisitor);
|
|
280
|
+
|
|
281
|
+
for (const path of file.path.get("body")) {
|
|
282
|
+
if (
|
|
283
|
+
path.type === "ExportNamedDeclaration" &&
|
|
284
|
+
!(path.node.declaration || path.node.specifiers.length))
|
|
285
|
+
{
|
|
286
|
+
// The babel typescript plugin will add an empty export declaration
|
|
287
|
+
// if there are no other imports/exports in the file.
|
|
288
|
+
// This is not needed for Marko file outputs since there is always
|
|
289
|
+
// a default export.
|
|
290
|
+
path.remove();
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
|
|
278
295
|
const rootTransformers = [];
|
|
279
296
|
for (const id in taglibLookup.taglibsById) {
|
|
280
297
|
for (const transformer of taglibLookup.taglibsById[id].transformers) {
|
|
@@ -286,7 +303,6 @@ function getMarkoFile(code, fileOpts, markoOpts) {
|
|
|
286
303
|
if (translator.transform) {
|
|
287
304
|
rootTransformers.push(translator.transform);
|
|
288
305
|
}
|
|
289
|
-
file.___compileStage = "transform";
|
|
290
306
|
traverseAll(file, rootTransformers);
|
|
291
307
|
|
|
292
308
|
for (const taglibId in taglibLookup.taglibsById) {
|
|
@@ -378,7 +394,7 @@ function traverseAll(file, visitors) {
|
|
|
378
394
|
program.node,
|
|
379
395
|
mergeVisitors(visitors),
|
|
380
396
|
program.scope,
|
|
381
|
-
program.state = {},
|
|
397
|
+
program.state = { file },
|
|
382
398
|
program,
|
|
383
399
|
true
|
|
384
400
|
);
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
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 = exports.globalConfig = void 0;var _types = _interopRequireWildcard(require("./babel-types"));exports.types = _types;
|
|
2
2
|
var babel = _interopRequireWildcard(require("@babel/core"));
|
|
3
|
-
var _pluginSyntaxTypescript = _interopRequireDefault(require("@babel/plugin-syntax-typescript"));
|
|
4
3
|
var _pluginTransformModulesCommonjs = _interopRequireDefault(require("@babel/plugin-transform-modules-commonjs"));
|
|
5
|
-
var _pluginTransformTypescript = _interopRequireDefault(require("@babel/plugin-transform-typescript"));
|
|
6
4
|
var _babelUtils = require("@marko/compiler/babel-utils");
|
|
7
5
|
var _modules = _interopRequireDefault(require("@marko/compiler/modules"));
|
|
8
6
|
var _path = _interopRequireDefault(require("path"));
|
|
@@ -87,20 +85,7 @@ function loadBabelConfigSync(filename, config) {
|
|
|
87
85
|
|
|
88
86
|
function getBaseBabelConfig(filename, { babelConfig, ...markoConfig }) {
|
|
89
87
|
const isTranslated = isTranslatedOutput(markoConfig.output);
|
|
90
|
-
const requiredPlugins = [
|
|
91
|
-
[_babelPlugin.default, markoConfig],
|
|
92
|
-
[
|
|
93
|
-
markoConfig.stripTypes ? _pluginTransformTypescript.default : _pluginSyntaxTypescript.default,
|
|
94
|
-
{
|
|
95
|
-
isTSX: false,
|
|
96
|
-
allowNamespaces: true,
|
|
97
|
-
allowDeclareFields: true,
|
|
98
|
-
optimizeConstEnums: true,
|
|
99
|
-
onlyRemoveTypeImports: true,
|
|
100
|
-
disallowAmbiguousJSXLike: false
|
|
101
|
-
}]];
|
|
102
|
-
|
|
103
|
-
|
|
88
|
+
const requiredPlugins = [[_babelPlugin.default, markoConfig]];
|
|
104
89
|
const baseBabelConfig = {
|
|
105
90
|
filenameRelative: filename ?
|
|
106
91
|
_path.default.relative(_modules.default.cwd, filename) :
|
package/dist/types.d.ts
CHANGED
|
@@ -1826,7 +1826,7 @@ export type ObjectMember = ObjectMethod | ObjectProperty;
|
|
|
1826
1826
|
export type Property = ObjectProperty | ClassProperty | ClassAccessorProperty | ClassPrivateProperty;
|
|
1827
1827
|
export type UnaryLike = UnaryExpression | SpreadElement;
|
|
1828
1828
|
export type Pattern = AssignmentPattern | ArrayPattern | ObjectPattern | VoidPattern;
|
|
1829
|
-
export type Class = ClassExpression | ClassDeclaration;
|
|
1829
|
+
export type Class = ClassExpression | ClassDeclaration | MarkoClass;
|
|
1830
1830
|
export type ImportOrExportDeclaration = ExportAllDeclaration | ExportDefaultDeclaration | ExportNamedDeclaration | ImportDeclaration;
|
|
1831
1831
|
export type ExportDeclaration = ExportAllDeclaration | ExportDefaultDeclaration | ExportNamedDeclaration;
|
|
1832
1832
|
export type ModuleSpecifier = ExportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier | ImportSpecifier | ExportNamespaceSpecifier | ExportDefaultSpecifier;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@marko/compiler",
|
|
3
|
-
"version": "5.39.
|
|
3
|
+
"version": "5.39.35",
|
|
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.55"
|
|
91
91
|
},
|
|
92
92
|
"engines": {
|
|
93
93
|
"node": "18 || 20 || >=22"
|