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

Resolve the template compiler from ember-source instead of project root #696

Closed
wants to merge 4 commits into from
Closed
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
14 changes: 9 additions & 5 deletions packages/compat/src/compat-app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -317,10 +317,6 @@ class CompatAppAdapter implements AppAdapter<TreeNames> {
return this.configTree.readConfig().rootURL;
}

templateCompilerPath(): string {
return 'ember-source/vendor/ember/ember-template-compiler';
Copy link
Collaborator

Choose a reason for hiding this comment

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

It seems like this is actually trying to resolve the path relative to the build itself. That is why it is ember-source/vendor/ember-template-compiler.js instead of where it actually is in the npm package ember-source/dist/ember-template-compiler.js.

This is where that is done:

https://github.com/emberjs/ember.js/blob/eff00a35624cd33f9f46f0991252182c367bb045/lib/index.js#L298-L300

}

strictV2Format() {
return false;
}
Expand Down Expand Up @@ -377,6 +373,13 @@ class CompatAppAdapter implements AppAdapter<TreeNames> {
};
}

@Memoize()
resolveTemplateCompilerPath() {
let emberSource = this.oldPackage.app.project.findAddonByName('ember-source');
let templateCompilerPath = emberSource.absolutePaths.templateCompiler;
return templateCompilerPath;
Comment on lines +378 to +380
Copy link
Collaborator

Choose a reason for hiding this comment

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

This changes away from resolving the template compiler relative to the vendor asset output to resolving it in normal node modules resolution system.

This means that it would be no longer possible for folks to provide a custom / overridden ember-template-compiler asset (before all they needed to do was put it in the right location in their vendor folder).

I think this might be perfectly fine, but I'm not 100% sure...

}

// unlike `templateResolver`, this one brings its own simple TemplateCompiler
// along so it's capable of parsing component snippets in people's module
// rules.
Expand All @@ -392,9 +395,10 @@ class CompatAppAdapter implements AppAdapter<TreeNames> {

// It's ok that this isn't a fully configured template compiler. We're only
// using it to parse component snippets out of rules.

resolver.astTransformer(
new TemplateCompiler({
compilerPath: resolveSync(this.templateCompilerPath(), { basedir: this.root }),
compilerPath: this.resolveTemplateCompilerPath(),
EmberENV: {},
plugins: {},
})
Expand Down
2 changes: 1 addition & 1 deletion packages/compat/src/v1-app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export default class V1App {
private _implicitScripts: string[] = [];
private _implicitStyles: string[] = [];

protected constructor(protected app: EmberApp, protected packageCache: PackageCache) {}
protected constructor(public app: EmberApp, protected packageCache: PackageCache) {}

// always the name from package.json. Not the one that apps may have weirdly
// customized.
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export interface AppAdapter<TreeNames> {
rootURL(): string;

// The path to ember's template compiler source
templateCompilerPath(): string;
resolveTemplateCompilerPath(): string;

// Path to a build-time Resolver module to be used during template
// compilation.
Expand Down Expand Up @@ -891,7 +891,7 @@ export class AppBuilder<TreeNames> {

return {
plugins,
compilerPath: resolve.sync(this.adapter.templateCompilerPath(), { basedir: this.root }),
compilerPath: this.adapter.resolveTemplateCompilerPath(),
resolver: this.adapter.templateResolver(),
EmberENV: config,
};
Expand Down