@marko/compiler
Advanced tools
Comparing version 5.37.1 to 5.37.2
@@ -27,3 +27,3 @@ declare const Config: { | ||
optimize?: boolean; | ||
optimizedRegistryIds?: Map<string, string>; | ||
optimizeKnownTemplates?: string[]; | ||
cache?: Map<unknown, unknown>; | ||
@@ -30,0 +30,0 @@ hot?: boolean; |
@@ -213,6 +213,6 @@ "use strict";var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");exports.__esModule = true;exports.default = void 0;var _fs = _interopRequireDefault(require("fs")); | ||
*/optimize: undefined, /** | ||
* If `optimize` is enabled you can provide a Map which the compiler will | ||
* use to store shorter registry/template id's in. This can only be used | ||
* if the same `optimizedRegistryIds` are used for both server and client compilations. | ||
*/optimizedRegistryIds: undefined, /** | ||
* If `optimize` is enabled you can provide an array of template paths which the compiler will | ||
* use to generate shorter registry/template ids using incrementing ids. This can only be used | ||
* if the same `optimizeKnownTemplates` are used for both server and client compilations. | ||
*/optimizeKnownTemplates: undefined, /** | ||
* This option should be set if `hydrate` output is specified. | ||
@@ -219,0 +219,0 @@ * Maps a virtual dependency to a resolved file which can be implemented |
@@ -130,3 +130,5 @@ "use strict"; | ||
found = found.concat(registeredTaglibs); | ||
for (const registeredTaglib of registeredTaglibs) { | ||
helper.addTaglib(registeredTaglib); | ||
} | ||
@@ -133,0 +135,0 @@ findCache[dirname] = found; |
@@ -1,2 +0,3 @@ | ||
"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")); | ||
"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")); | ||
var _lassoPackageRoot = require("lasso-package-root"); | ||
var _modules = _interopRequireDefault(require("../../modules")); | ||
@@ -38,3 +39,5 @@ var _tryLoadTranslator = _interopRequireDefault(require("../util/try-load-translator")); | ||
taglibsForDir = registeredTaglibs.concat( | ||
translator.taglibs.map(([id, props]) => loadTaglib(id, props)) | ||
resolveOptionalTaglibs(translator.optionalTaglibs || []). | ||
concat(translator.taglibs). | ||
map(([id, props]) => loadTaglib(id, props)) | ||
) | ||
@@ -84,17 +87,4 @@ ); | ||
if (typeof props === "undefined") { | ||
switch (id[0]) { | ||
case ".": | ||
case "/": | ||
case "\\": | ||
break; | ||
default: | ||
if (!id.endsWith(".json")) { | ||
id = _path.default.join(id, "marko.json"); | ||
} | ||
break; | ||
} | ||
id = _modules.default.require.resolve(id); | ||
props = _modules.default.require(id); | ||
[id, props] = resolveTaglib(id); | ||
} | ||
registeredTaglibs.push(loadTaglib(id, props)); | ||
@@ -109,2 +99,13 @@ } | ||
function resolveOptionalTaglibs(taglibIds) { | ||
const resolvedTaglibs = []; | ||
for (const id of taglibIds) { | ||
if (hasRootDependency(id)) { | ||
resolvedTaglibs.push(resolveTaglib(id)); | ||
} | ||
} | ||
return resolvedTaglibs; | ||
} | ||
// Used by legacy compiler api. | ||
@@ -116,2 +117,24 @@ const _loader = exports._loader = _loader2.default; | ||
return _loader2.default.loadTaglibFromProps(_loader2.default.createTaglib(id), props); | ||
} | ||
function resolveTaglib(id) { | ||
switch (id[0]) { | ||
case ".": | ||
case "/": | ||
case "\\": | ||
break; | ||
default: | ||
if (!id.endsWith(".json")) { | ||
id = _path.default.join(id, "marko.json"); | ||
} | ||
break; | ||
} | ||
const resolved = _modules.default.require.resolve(id); | ||
return [resolved, _modules.default.require(resolved)]; | ||
} | ||
function hasRootDependency(id) { | ||
const pkg = (0, _lassoPackageRoot.getRootPackage)(process.cwd()); | ||
return !!(pkg && pkg.dependencies?.[id] || pkg.devDependencies?.[id]); | ||
} |
@@ -70,2 +70,5 @@ import { Diagnostic, TaglibLookup } from "@marko/babel-utils"; | ||
export namespace taglib { | ||
export function resolveOptionalTaglibs( | ||
taglibIds: string[], | ||
): [id: string, props: { [x: string]: unknown }][]; | ||
export function excludeDir(dirname: string): void; | ||
@@ -72,0 +75,0 @@ export function excludePackage(packageName: string): void; |
{ | ||
"name": "@marko/compiler", | ||
"version": "5.37.1", | ||
"version": "5.37.2", | ||
"description": "Marko template to JS compiler.", | ||
@@ -83,3 +83,3 @@ "keywords": [ | ||
"devDependencies": { | ||
"@marko/translator-default": "^6.0.2" | ||
"@marko/translator-default": "^6.0.3" | ||
}, | ||
@@ -86,0 +86,0 @@ "publishConfig": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
462578
10791