@embroider/shared-internals
Advanced tools
Comparing version 2.6.4-unstable.ad1534d to 2.6.4-unstable.d195a3b
{ | ||
"name": "@embroider/shared-internals", | ||
"version": "2.6.4-unstable.ad1534d", | ||
"version": "2.6.4-unstable.d195a3b", | ||
"private": false, | ||
@@ -16,4 +16,3 @@ "description": "Utilities shared among the other embroider packages", | ||
}, | ||
"./src/babel-plugin-cache-busting.js": "./src/babel-plugin-cache-busting.js", | ||
"./src/template-colocation-plugin": "./src/template-colocation-plugin.js" | ||
"./src/*": "./src/*.js" | ||
}, | ||
@@ -20,0 +19,0 @@ "license": "MIT", |
import type PackageCache from './package-cache'; | ||
export declare function syntheticJStoHBS(source: string): string | null; | ||
export declare function needsSyntheticComponentJS(requestedSpecifier: string, foundFile: string, packageCache: Pick<PackageCache, 'ownerOfFile'>): string | null; | ||
export declare function isInComponents(id: string, packageCache: Pick<PackageCache, 'ownerOfFile'>): boolean; | ||
export declare function needsSyntheticComponentJS(requestedSpecifier: string, foundFile: string): string | null; | ||
export declare function isInComponents(url: string, packageCache: Pick<PackageCache, 'ownerOfFile'>): boolean; | ||
export declare function templateOnlyComponentSource(): string; |
@@ -20,3 +20,3 @@ "use strict"; | ||
} | ||
function needsSyntheticComponentJS(requestedSpecifier, foundFile, packageCache) { | ||
function needsSyntheticComponentJS(requestedSpecifier, foundFile) { | ||
requestedSpecifier = (0, paths_1.cleanUrl)(requestedSpecifier); | ||
@@ -26,4 +26,3 @@ foundFile = (0, paths_1.cleanUrl)(foundFile); | ||
!foundFile.split(path_1.sep).join('/').endsWith('/template.hbs') && | ||
!correspondingJSExists(foundFile) && | ||
isInComponents(foundFile, packageCache)) { | ||
!correspondingJSExists(foundFile)) { | ||
return foundFile.slice(0, -3) + 'js'; | ||
@@ -39,4 +38,5 @@ } | ||
} | ||
function isInComponents(id, packageCache) { | ||
function isInComponents(url, packageCache) { | ||
var _a; | ||
const id = (0, paths_1.cleanUrl)(url); | ||
const pkg = packageCache.ownerOfFile(id); | ||
@@ -43,0 +43,0 @@ if (!(pkg === null || pkg === void 0 ? void 0 : pkg.isV2App())) { |
@@ -17,2 +17,30 @@ "use strict"; | ||
const flatMap_1 = __importDefault(require("lodash/flatMap")); | ||
// This is controllable via env var because there are many different contexts | ||
// (babel/rollup/vite/webpack/handlebars plugins) that can all depend on | ||
// `@embroider/shared-internals` to help understand the structure of packages, | ||
// and we want one clear way to signal to all of those whether this feature is | ||
// configured. | ||
// | ||
// The initial motivating use case for this is that new-enough ember-source can | ||
// function as a v2 addon despite not declaring itself to be a v2 addon, because | ||
// that would be potentially-breaking for people who still consume it via AMD | ||
// and/or depend on the specific timng of the classic vendor.js file. We don't | ||
// want to break people but we also want people on the bleeding edge to be able | ||
// to take advantage of the capability. | ||
const forcedV2Packages = (() => { | ||
let cached; | ||
return () => { | ||
if (!cached) { | ||
if (typeof process !== undefined && | ||
typeof process.env !== undefined && | ||
process.env.EMBROIDER_FORCED_V2_PACKAGES) { | ||
cached = process.env.EMBROIDER_FORCED_V2_PACKAGES.split(','); | ||
} | ||
else { | ||
cached = []; | ||
} | ||
} | ||
return cached; | ||
}; | ||
})(); | ||
class Package { | ||
@@ -46,2 +74,20 @@ constructor(root, packageCache, isApp) { | ||
} | ||
if (forcedV2Packages().includes(json.name)) { | ||
let defaults; | ||
if (this.isApp) { | ||
defaults = { | ||
version: 2, | ||
type: 'app', | ||
assets: [], | ||
'root-url': '/', | ||
}; | ||
} | ||
else { | ||
defaults = { | ||
version: 2, | ||
type: 'addon', | ||
}; | ||
} | ||
json['ember-addon'] = Object.assign(defaults, json['ember-addon']); | ||
} | ||
return json; | ||
@@ -48,0 +94,0 @@ } |
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
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances 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
165692
1643
15