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

Move template compiler creation to a method on the addon #527

Merged
Merged
Show file tree
Hide file tree
Changes from 3 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
9 changes: 6 additions & 3 deletions lib/ember-addon-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ module.exports = {
return this._cachedShouldColocateTemplates;
},

getTemplateCompiler(inputTree, htmlbarsOptions) {
chriseppstein marked this conversation as resolved.
Show resolved Hide resolved
const TemplateCompiler = require('./template-compiler-plugin');
return new TemplateCompiler(inputTree, htmlbarsOptions);
},
chriseppstein marked this conversation as resolved.
Show resolved Hide resolved

setupPreprocessorRegistry(type, registry) {
// ensure that broccoli-ember-hbs-template-compiler is not processing hbs files
registry.remove('template', 'broccoli-ember-hbs-template-compiler');
Expand All @@ -82,9 +87,7 @@ module.exports = {

inputTree = debugTree(new ColocatedTemplateProcessor(inputTree), '02-colocated-output');
}

const TemplateCompiler = require('./template-compiler-plugin');
return debugTree(new TemplateCompiler(inputTree, htmlbarsOptions), '03-output');
return debugTree(this._addon.getTemplateCompiler(inputTree, htmlbarsOptions), '03-output');
},

precompile(string, options) {
Expand Down
17 changes: 17 additions & 0 deletions lib/template-compiler-plugin.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import type Plugin from "broccoli-plugin";
import type { ASTPluginBuilder } from "@glimmer/syntax";
import type { InputNode } from "broccoli-node-api";
type PluginOptions = ConstructorParameters<typeof Plugin>[1]; // this should be exported by the main import.
declare namespace TemplateCompiler {
interface HtmlBarsOptions extends PluginOptions {
plugins?: {
ast?: Array<ASTPluginBuilder>
};
}
}
declare class TemplateCompiler extends Plugin {
public extensions: Array<string>;
public targetExtension: string;
constructor(inputTree: InputNode, options: TemplateCompiler.HtmlBarsOptions);
}
export = TemplateCompiler;