@embroider/shared-internals
Advanced tools
Comparing version 1.8.3 to 2.0.0
{ | ||
"name": "@embroider/shared-internals", | ||
"version": "1.8.3", | ||
"version": "2.0.0", | ||
"private": false, | ||
@@ -28,3 +28,2 @@ "description": "Utilities shared among the other embroider packages", | ||
"scripts": { | ||
"prepare": "tsc", | ||
"test": "jest" | ||
@@ -31,0 +30,0 @@ }, |
@@ -19,6 +19,2 @@ "use strict"; | ||
// earlier plugins should take care of them. | ||
// | ||
// In embroider builds using ember-source >= 3.28, you won't see *any* of these | ||
// in stage3 because ember-source uses the standard rename-modules feature to | ||
// map them into real modules within ember-source. | ||
exports.emberVirtualPackages = new Set(mappings_json_1.default.map((m) => m.module)); | ||
@@ -25,0 +21,0 @@ // these are *real* packages that every ember addon is allowed to resolve *as if |
@@ -1,1 +0,8 @@ | ||
export declare function hbsToJS(hbsContents: string): string; | ||
export interface Options { | ||
filename?: string; | ||
compatModuleNaming?: { | ||
rootDir: string; | ||
modulePrefix: string; | ||
}; | ||
} | ||
export declare function hbsToJS(hbsContents: string, options?: Options): string; |
@@ -8,6 +8,24 @@ "use strict"; | ||
const js_string_escape_1 = __importDefault(require("js-string-escape")); | ||
function hbsToJS(hbsContents) { | ||
return [`import { hbs } from 'ember-cli-htmlbars';`, `export default hbs("${(0, js_string_escape_1.default)(hbsContents)}")`].join('\n'); | ||
const path_1 = require("path"); | ||
function hbsToJS(hbsContents, options) { | ||
let optsSource = ''; | ||
if (options === null || options === void 0 ? void 0 : options.filename) { | ||
let filename = options.filename; | ||
let { compatModuleNaming: renaming } = options; | ||
if (renaming) { | ||
if (filename.startsWith(renaming.rootDir)) { | ||
filename = renaming.modulePrefix + filename.slice(renaming.rootDir.length); | ||
} | ||
if (path_1.sep !== '/') { | ||
filename = filename.replace(/\\/g, '/'); | ||
} | ||
} | ||
optsSource = `,{ moduleName: "${(0, js_string_escape_1.default)(filename)}" }`; | ||
} | ||
return [ | ||
`import { precompileTemplate } from "@ember/template-compilation";`, | ||
`export default precompileTemplate("${(0, js_string_escape_1.default)(hbsContents)}"${optsSource})`, | ||
].join('\n'); | ||
} | ||
exports.hbsToJS = hbsToJS; | ||
//# sourceMappingURL=hbs-to-js.js.map |
@@ -77,3 +77,7 @@ "use strict"; | ||
static shared(identifier, appRoot) { | ||
return (0, get_or_create_1.getOrCreate)(shared, identifier, () => new PackageCache(appRoot)); | ||
let pk = (0, get_or_create_1.getOrCreate)(shared, identifier + appRoot, () => new PackageCache(appRoot)); | ||
if (pk.appRoot !== appRoot) { | ||
throw new Error(`bug: PackageCache appRoot disagreement ${appRoot}!=${pk.appRoot}`); | ||
} | ||
return pk; | ||
} | ||
@@ -80,0 +84,0 @@ } |
@@ -64,3 +64,3 @@ "use strict"; | ||
isLazyEngine() { | ||
return this.isEngine() && (0, get_1.default)(this.packageJSON, 'ember-addon.lazy-engine'); | ||
return this.isEngine() && Boolean((0, get_1.default)(this.packageJSON, 'ember-addon.lazy-engine')); | ||
} | ||
@@ -67,0 +67,0 @@ isV2Ember() { |
@@ -23,11 +23,5 @@ "use strict"; | ||
} | ||
// windows supports both "./" and ".\", but webpack 5 insists on "./" | ||
if (result.startsWith('.\\')) { | ||
return './' + result.slice(2); | ||
} | ||
// windows supports both "../" and "..\", but webpack 5 insists on "../" | ||
if (result.startsWith('..\\')) { | ||
return '../' + result.slice(3); | ||
} | ||
return result; | ||
// windows supports both kinds of path separators but webpack wants relative | ||
// paths to use forward slashes. | ||
return result.replace(/\\/g, '/'); | ||
} | ||
@@ -34,0 +28,0 @@ exports.explicitRelative = explicitRelative; |
@@ -8,2 +8,3 @@ import type { NodePath } from '@babel/traverse'; | ||
appRoot: string; | ||
templateExtensions?: string[]; | ||
} | ||
@@ -10,0 +11,0 @@ interface State { |
@@ -16,2 +16,3 @@ "use strict"; | ||
enter(path, state) { | ||
var _a; | ||
state.adder = new babel_import_util_1.ImportUtil(t, path); | ||
@@ -25,5 +26,8 @@ let filename = path.hub.file.opts.filename; | ||
} | ||
let hbsFilename = filename.replace(/\.\w{1,3}$/, '') + '.hbs'; | ||
if (hbsFilename !== filename && (0, fs_1.existsSync)(hbsFilename)) { | ||
state.colocatedTemplate = hbsFilename; | ||
let extensions = (_a = state.opts.templateExtensions) !== null && _a !== void 0 ? _a : ['.hbs']; | ||
for (let ext of extensions) { | ||
let hbsFilename = filename.replace(/\.\w{1,3}$/, '') + ext; | ||
if (hbsFilename !== filename && (0, fs_1.existsSync)(hbsFilename)) { | ||
state.colocatedTemplate = hbsFilename; | ||
} | ||
} | ||
@@ -30,0 +34,0 @@ }, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
94392
49
999