Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support v2 ember-source #2164

Merged
merged 1 commit into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -1036,7 +1036,7 @@ export class CompatAppBuilder {

let resolver = new Resolver(resolverConfig);
let resolution = resolver.nodeResolve(
'ember-source/vendor/ember/ember-template-compiler',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is only present on disk in the rewritten form of ember-source. Once it's v2 it doesn't get rewritten.

'ember-source/dist/ember-template-compiler',
resolvePath(this.root, 'package.json')
);
if (resolution.type !== 'real') {
Expand Down
18 changes: 18 additions & 0 deletions packages/compat/src/compat-app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import { readFileSync } from 'fs';
import semver from 'semver';
import type { Transform } from 'babel-plugin-ember-template-compilation';
import { CompatAppBuilder } from './compat-app-builder';
import writeFile from 'broccoli-file-creator';

interface Group {
outputFiles: OutputFileToInputFileMap;
Expand Down Expand Up @@ -346,6 +347,23 @@ export default class CompatApp {
destDir: 'vendor',
})
);

let emberSource = this.legacyEmberAppInstance.project.addons.find(a => a.name === 'ember-source');
if (emberSource && (emberSource.pkg['ember-addon']?.['version'] ?? 1) >= 2) {
// there's stuff in the ecosystem that assumes these files will always be
// present in the vendor tree. But when ember-source is V2, it cannot put
// them there, so @embroider/compat will fill in defaults. The bundles are
// empty because we're just trying to keep the build from blowing up, the
// actual ember modules get loaded as modules instead.
//
// The template compiler is still here so that apps using a V2 ember can
// still app.import the traditional runtime template compiler.
trees.push(writeFile('vendor/ember/ember.js', () => ''));
trees.push(writeFile('vendor/ember/ember-testing.js', () => ''));
const templateCompilerSrc = readFileSync(join(emberSource.root, 'dist/ember-template-compiler.js'), 'utf8');
trees.push(writeFile('vendor/ember/ember-testing.js', () => templateCompilerSrc));
}

if (this.vendorTree) {
trees.push(
buildFunnel(this.vendorTree, {
Expand Down