Skip to content

Commit

Permalink
Merge pull request #1946 from embroider-build/app-not-addon
Browse files Browse the repository at this point in the history
remove the ember-addon keyword from rewritten app
  • Loading branch information
ef4 committed Jun 4, 2024
2 parents 05796e6 + 0ee4e30 commit 4d74274
Show file tree
Hide file tree
Showing 10 changed files with 16 additions and 15 deletions.
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@
"browserslist": "^4.14.0",
"graceful-fs": "^4.0.0",
"@types/eslint": "^8.37.0",
"babel-plugin-module-resolver@5.0.1": "5.0.0",
"@embroider/shared-internals": "workspace:*"
"babel-plugin-module-resolver@5.0.1": "5.0.0"
},
"patchedDependencies": {
"ember-source@5.8.0": "patches/ember-source@5.8.0.patch"
Expand Down
2 changes: 1 addition & 1 deletion packages/compat/src/compat-app-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ export class CompatAppBuilder {
pkgLayers.push(fastbootConfig.packageJSON);
}
// but our own new v2 app metadata takes precedence over both
pkgLayers.push({ keywords: ['ember-addon'], 'ember-addon': meta });
pkgLayers.push({ 'ember-addon': meta });
return combinePackageJSON(...pkgLayers);
}

Expand Down
4 changes: 2 additions & 2 deletions packages/compat/src/standalone-addon-build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export function convertLegacyAddons(compatApp: CompatApp) {

let appPackage = compatApp.appPackage();

let violations = validatePeerDependencies(appPackage).filter(({ dep }) => dep.isEmberPackage() && !dep.isV2Ember());
let violations = validatePeerDependencies(appPackage).filter(({ dep }) => dep.isEmberAddon() && !dep.isV2Ember());
if (violations.length > 0) {
if (process.env.I_HAVE_BAD_PEER_DEPS_AND_WANT_A_BROKEN_BUILD) {
console.warn(
Expand Down Expand Up @@ -116,7 +116,7 @@ function findV1Addons(pkg: Package, seen: Set<Package> = new Set(), output: Set<
continue;
}
seen.add(dep);
if (dep.isEmberPackage()) {
if (dep.isEmberAddon()) {
if (!dep.isV2Addon()) {
output.add(dep);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/module-resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1163,7 +1163,7 @@ export class Resolver {
if (logicalPackage.meta['auto-upgraded'] && !logicalPackage.hasDependency('ember-auto-import')) {
try {
let dep = this.packageCache.resolve(packageName, logicalPackage);
if (!dep.isEmberPackage()) {
if (!dep.isEmberAddon()) {
// classic ember addons can only import non-ember dependencies if they
// have ember-auto-import.
return this.external('v1 package without auto-import', request, specifier);
Expand Down
2 changes: 1 addition & 1 deletion packages/macros/src/babel/macros-babel-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ export default function main(context: typeof Babel): unknown {
state.opts.hideRequires &&
path.node.name === 'require' &&
!path.scope.hasBinding('require') &&
state.owningPackage().isEmberPackage()
state.owningPackage().isEmberAddon()
) {
// Our importSync macro has been compiled to `require`. But we want to
// distinguish that from any pre-existing, user-written `require` in an
Expand Down
2 changes: 1 addition & 1 deletion packages/shared-internals/src/babel-filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default function babelFilter(skipBabel: { package: string; semverRange?:
if (owner) {
for (let { package: pkg, semverRange } of skipBabel) {
if (owner.name === pkg && (semverRange == null || semver.satisfies(owner.version, semverRange))) {
if (owner.isEmberPackage()) {
if (owner.isEmberAddon()) {
throw new Error(
`You can't use skipBabel to disable transpilation of Ember addons, it only works for non-Ember third-party packages`
);
Expand Down
2 changes: 1 addition & 1 deletion packages/shared-internals/src/dep-validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export function validatePeerDependencies(appPackage: Package): PeerDepViolation[
for (let ancestor of ancestors.slice().reverse()) {
if (ancestor.hasDependency(dep.name)) {
let ancestorsDep = ancestor.dependencies.find(d => d.name === dep.name)!;
if (ancestorsDep !== dep && dep.isEmberPackage()) {
if (ancestorsDep !== dep && dep.isEmberAddon()) {
violations.push({ pkg, dep, ancestors, ancestor, ancestorsDep });
}
continue;
Expand Down
7 changes: 5 additions & 2 deletions packages/shared-internals/src/package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export default class Package {
}
}

isEmberPackage(): boolean {
isEmberAddon(): boolean {
let keywords = this.packageJSON.keywords;
return Boolean(keywords && (keywords as string[]).includes('ember-addon'));
}
Expand All @@ -71,7 +71,10 @@ export default class Package {
}

isV2Ember(): this is V2Package {
return this.isEmberPackage() && get(this.packageJSON, 'ember-addon.version') === 2;
return (
get(this.packageJSON, 'ember-addon.version') === 2 &&
(get(this.packageJSON, 'ember-addon.type') === 'app' || this.isEmberAddon())
);
}

isV2App(): this is V2AppPackage {
Expand Down
4 changes: 2 additions & 2 deletions packages/shared-internals/src/rewritten-package-cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,8 @@ class WrappedPackage implements PackageTheGoodParts {
return this.plainPkg.meta;
}

isEmberPackage() {
return this.plainPkg.isEmberPackage();
isEmberAddon() {
return this.plainPkg.isEmberAddon();
}

isEngine() {
Expand Down
3 changes: 1 addition & 2 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 4d74274

Please sign in to comment.