@embroider/shared-internals
Advanced tools
Comparing version 1.8.3 to 2.0.0-unstable.00ec2e7
{ | ||
"name": "@embroider/shared-internals", | ||
"version": "1.8.3", | ||
"version": "2.0.0-unstable.00ec2e7", | ||
"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 |
export { AppMeta, AddonMeta, PackageInfo } from './metadata'; | ||
export { explicitRelative, extensionsPattern } from './paths'; | ||
export { explicitRelative, extensionsPattern, unrelativize } from './paths'; | ||
export { getOrCreate } from './get-or-create'; | ||
@@ -4,0 +4,0 @@ export { default as Package, V2AddonPackage as AddonPackage, V2AppPackage as AppPackage, V2Package } from './package'; |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
}) : (function(o, m, k, k2) { | ||
@@ -20,6 +16,7 @@ if (k2 === undefined) k2 = k; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.templateColocationPlugin = exports.hbsToJS = exports.tmpdir = exports.packageName = exports.babelFilter = exports.PackageCache = exports.Package = exports.getOrCreate = exports.extensionsPattern = exports.explicitRelative = void 0; | ||
exports.templateColocationPlugin = exports.hbsToJS = exports.tmpdir = exports.packageName = exports.babelFilter = exports.PackageCache = exports.Package = exports.getOrCreate = exports.unrelativize = exports.extensionsPattern = exports.explicitRelative = void 0; | ||
var paths_1 = require("./paths"); | ||
Object.defineProperty(exports, "explicitRelative", { enumerable: true, get: function () { return paths_1.explicitRelative; } }); | ||
Object.defineProperty(exports, "extensionsPattern", { enumerable: true, get: function () { return paths_1.extensionsPattern; } }); | ||
Object.defineProperty(exports, "unrelativize", { enumerable: true, get: function () { return paths_1.unrelativize; } }); | ||
var get_or_create_1 = require("./get-or-create"); | ||
@@ -26,0 +23,0 @@ Object.defineProperty(exports, "getOrCreate", { enumerable: true, get: function () { return get_or_create_1.getOrCreate; } }); |
@@ -14,3 +14,2 @@ declare type Filename = string; | ||
}; | ||
'resolvable-extensions': string[]; | ||
'root-url': string; | ||
@@ -17,0 +16,0 @@ version: 2; |
@@ -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() { |
@@ -0,2 +1,4 @@ | ||
import type Package from './package'; | ||
export declare function explicitRelative(fromDir: string, toFile: string): string; | ||
export declare function extensionsPattern(extensions: string[]): RegExp; | ||
export declare function unrelativize(pkg: Package, specifier: string, fromFile: string): string; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.extensionsPattern = exports.explicitRelative = void 0; | ||
exports.unrelativize = exports.extensionsPattern = exports.explicitRelative = void 0; | ||
const path_1 = require("path"); | ||
@@ -23,11 +23,5 @@ // by "explicit", I mean that we want "./local/thing" instead of "local/thing" | ||
} | ||
// 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, '/'); | ||
} | ||
@@ -41,2 +35,13 @@ exports.explicitRelative = explicitRelative; | ||
exports.extensionsPattern = extensionsPattern; | ||
function unrelativize(pkg, specifier, fromFile) { | ||
if (pkg.packageJSON.exports) { | ||
throw new Error(`unsupported: engines cannot use package.json exports`); | ||
} | ||
let result = (0, path_1.resolve)((0, path_1.dirname)(fromFile), specifier).replace(pkg.root, pkg.name); | ||
if (path_1.sep !== '/') { | ||
result = result.split(path_1.sep).join('/'); | ||
} | ||
return result; | ||
} | ||
exports.unrelativize = unrelativize; | ||
//# sourceMappingURL=paths.js.map |
@@ -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
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
95794
49
1008
2