@marko/compiler 5.37.1 → 5.37.2
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/config.d.ts +1 -1
- package/dist/config.js +4 -4
- package/dist/taglib/finder/index.js +3 -1
- package/dist/taglib/index.js +39 -16
- package/index.d.ts +3 -0
- package/package.json +2 -2
package/config.d.ts
CHANGED
|
@@ -24,7 +24,7 @@ declare const Config: {
|
|
|
24
24
|
hydrateIncludeImports?: RegExp | ((request: string) => boolean);
|
|
25
25
|
hydrateInit?: boolean;
|
|
26
26
|
optimize?: boolean;
|
|
27
|
-
|
|
27
|
+
optimizeKnownTemplates?: string[];
|
|
28
28
|
cache?: Map<unknown, unknown>;
|
|
29
29
|
hot?: boolean;
|
|
30
30
|
/** @deprecated */
|
package/dist/config.js
CHANGED
|
@@ -210,10 +210,10 @@ var _config = _interopRequireDefault(require("./taglib/config"));const config =
|
|
|
210
210
|
* Enables production mode optimizations if true, or not if false.
|
|
211
211
|
* If left as undefined checks for env === "production".
|
|
212
212
|
*/optimize: undefined, /**
|
|
213
|
-
* If `optimize` is enabled you can provide
|
|
214
|
-
* use to
|
|
215
|
-
* if the same `
|
|
216
|
-
*/
|
|
213
|
+
* If `optimize` is enabled you can provide an array of template paths which the compiler will
|
|
214
|
+
* use to generate shorter registry/template ids using incrementing ids. This can only be used
|
|
215
|
+
* if the same `optimizeKnownTemplates` are used for both server and client compilations.
|
|
216
|
+
*/optimizeKnownTemplates: undefined, /**
|
|
217
217
|
* This option should be set if `hydrate` output is specified.
|
|
218
218
|
* Maps a virtual dependency to a resolved file which can be implemented
|
|
219
219
|
* for specific bundlers.
|
|
@@ -127,7 +127,9 @@ function find(dirname, registeredTaglibs) {
|
|
|
127
127
|
});
|
|
128
128
|
}
|
|
129
129
|
|
|
130
|
-
|
|
130
|
+
for (const registeredTaglib of registeredTaglibs) {
|
|
131
|
+
helper.addTaglib(registeredTaglib);
|
|
132
|
+
}
|
|
131
133
|
|
|
132
134
|
findCache[dirname] = found;
|
|
133
135
|
|
package/dist/taglib/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
"use strict";var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");exports.__esModule = true;exports._loader = exports._finder = void 0;exports.buildLookup = buildLookup;exports.clearCaches = clearCaches;exports.excludePackage = exports.excludeDir = void 0;exports.register = register;var _path = _interopRequireDefault(require("path"));
|
|
1
|
+
"use strict";var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");exports.__esModule = true;exports._loader = exports._finder = void 0;exports.buildLookup = buildLookup;exports.clearCaches = clearCaches;exports.excludePackage = exports.excludeDir = void 0;exports.register = register;exports.resolveOptionalTaglibs = resolveOptionalTaglibs;var _path = _interopRequireDefault(require("path"));
|
|
2
|
+
var _lassoPackageRoot = require("lasso-package-root");
|
|
2
3
|
var _modules = _interopRequireDefault(require("../../modules"));
|
|
3
4
|
var _tryLoadTranslator = _interopRequireDefault(require("../util/try-load-translator"));
|
|
4
5
|
var _config = _interopRequireDefault(require("./config"));
|
|
@@ -35,7 +36,9 @@ function buildLookup(dirname, requestedTranslator, onError) {
|
|
|
35
36
|
loadedTranslatorsTaglibs.set(
|
|
36
37
|
translator,
|
|
37
38
|
taglibsForDir = registeredTaglibs.concat(
|
|
38
|
-
translator.
|
|
39
|
+
resolveOptionalTaglibs(translator.optionalTaglibs || []).
|
|
40
|
+
concat(translator.taglibs).
|
|
41
|
+
map(([id, props]) => loadTaglib(id, props))
|
|
39
42
|
)
|
|
40
43
|
);
|
|
41
44
|
}
|
|
@@ -80,21 +83,8 @@ function buildLookup(dirname, requestedTranslator, onError) {
|
|
|
80
83
|
|
|
81
84
|
function register(id, props) {
|
|
82
85
|
if (typeof props === "undefined") {
|
|
83
|
-
|
|
84
|
-
case ".":
|
|
85
|
-
case "/":
|
|
86
|
-
case "\\":
|
|
87
|
-
break;
|
|
88
|
-
default:
|
|
89
|
-
if (!id.endsWith(".json")) {
|
|
90
|
-
id = _path.default.join(id, "marko.json");
|
|
91
|
-
}
|
|
92
|
-
break;
|
|
93
|
-
}
|
|
94
|
-
id = _modules.default.require.resolve(id);
|
|
95
|
-
props = _modules.default.require(id);
|
|
86
|
+
[id, props] = resolveTaglib(id);
|
|
96
87
|
}
|
|
97
|
-
|
|
98
88
|
registeredTaglibs.push(loadTaglib(id, props));
|
|
99
89
|
}
|
|
100
90
|
|
|
@@ -104,10 +94,43 @@ function clearCaches() {
|
|
|
104
94
|
lookupCache = Object.create(null);
|
|
105
95
|
}
|
|
106
96
|
|
|
97
|
+
function resolveOptionalTaglibs(taglibIds) {
|
|
98
|
+
const resolvedTaglibs = [];
|
|
99
|
+
for (const id of taglibIds) {
|
|
100
|
+
if (hasRootDependency(id)) {
|
|
101
|
+
resolvedTaglibs.push(resolveTaglib(id));
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return resolvedTaglibs;
|
|
106
|
+
}
|
|
107
|
+
|
|
107
108
|
// Used by legacy compiler api.
|
|
108
109
|
const _loader = exports._loader = _loader2.default;
|
|
109
110
|
const _finder = exports._finder = _finder2.default;
|
|
110
111
|
|
|
111
112
|
function loadTaglib(id, props) {
|
|
112
113
|
return _loader2.default.loadTaglibFromProps(_loader2.default.createTaglib(id), props);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function resolveTaglib(id) {
|
|
117
|
+
switch (id[0]) {
|
|
118
|
+
case ".":
|
|
119
|
+
case "/":
|
|
120
|
+
case "\\":
|
|
121
|
+
break;
|
|
122
|
+
default:
|
|
123
|
+
if (!id.endsWith(".json")) {
|
|
124
|
+
id = _path.default.join(id, "marko.json");
|
|
125
|
+
}
|
|
126
|
+
break;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
const resolved = _modules.default.require.resolve(id);
|
|
130
|
+
return [resolved, _modules.default.require(resolved)];
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function hasRootDependency(id) {
|
|
134
|
+
const pkg = (0, _lassoPackageRoot.getRootPackage)(process.cwd());
|
|
135
|
+
return !!(pkg && pkg.dependencies?.[id] || pkg.devDependencies?.[id]);
|
|
113
136
|
}
|
package/index.d.ts
CHANGED
|
@@ -67,6 +67,9 @@ export function getRuntimeEntryFiles(
|
|
|
67
67
|
): string[];
|
|
68
68
|
|
|
69
69
|
export namespace taglib {
|
|
70
|
+
export function resolveOptionalTaglibs(
|
|
71
|
+
taglibIds: string[],
|
|
72
|
+
): [id: string, props: { [x: string]: unknown }][];
|
|
70
73
|
export function excludeDir(dirname: string): void;
|
|
71
74
|
export function excludePackage(packageName: string): void;
|
|
72
75
|
export function register(id: string): void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@marko/compiler",
|
|
3
|
-
"version": "5.37.
|
|
3
|
+
"version": "5.37.2",
|
|
4
4
|
"description": "Marko template to JS compiler.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"babel",
|
|
@@ -80,7 +80,7 @@
|
|
|
80
80
|
"source-map-support": "^0.5.21"
|
|
81
81
|
},
|
|
82
82
|
"devDependencies": {
|
|
83
|
-
"@marko/translator-default": "^6.0.
|
|
83
|
+
"@marko/translator-default": "^6.0.3"
|
|
84
84
|
},
|
|
85
85
|
"publishConfig": {
|
|
86
86
|
"access": "public"
|