-
-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure inline precompile and colocated templates run template AS… (#309)
Ensure inline precompile and colocated templates run template AST plugins.
- Loading branch information
Showing
18 changed files
with
430 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Module: {{module-name-inliner}} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
{ | ||
"jquery-integration": false | ||
"application-template-wrapper": false, | ||
"jquery-integration": false, | ||
"template-only-glimmer-components": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
'use strict'; | ||
|
||
let VersionChecker = require('ember-cli-version-checker'); | ||
|
||
module.exports = { | ||
name: require('./package').name, | ||
|
||
isDevelopingAddon() { | ||
return true; | ||
}, | ||
|
||
setupPreprocessorRegistry(type, registry) { | ||
// can only add the plugin with this style on newer Ember versions | ||
let checker = new VersionChecker(this.project); | ||
if (checker.forEmber().gte('3.1.0')) { | ||
registry.add('htmlbars-ast-plugin', this.buildPlugin()); | ||
} | ||
}, | ||
|
||
buildPlugin() { | ||
// https://astexplorer.net/#/gist/7c8399056873e1ddbd2b1acf0a41592a/e08f2f850de449b77b8ad995085496a1100dfd1f | ||
return { | ||
name: 'module-name-inliner', | ||
baseDir() { | ||
return __dirname; | ||
}, | ||
parallelBabel: { | ||
requireFile: __filename, | ||
buildUsing: 'buildPlugin', | ||
params: {}, | ||
}, | ||
plugin(env) { | ||
let { builders } = env.syntax; | ||
|
||
return { | ||
name: 'module-name-inliner', | ||
|
||
visitor: { | ||
PathExpression(node) { | ||
if (node.original === 'module-name-inliner') { | ||
return builders.string(env.moduleName); | ||
} | ||
}, | ||
}, | ||
}; | ||
}, | ||
}; | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"name": "module-name-inliner", | ||
"version": "0.1.0", | ||
"keywords": [ | ||
"ember-addon" | ||
], | ||
"dependencies": { | ||
"ember-cli-version-checker": "*" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { module, test } from 'qunit'; | ||
import { setupRenderingTest } from 'ember-qunit'; | ||
import { render } from '@ember/test-helpers'; | ||
import { hbs } from 'ember-cli-htmlbars'; | ||
import { HAS_OCTANE } from '@ember/edition-fake-module'; | ||
|
||
module('tests/integration/components/test-inline-precompile', function(hooks) { | ||
if (!HAS_OCTANE) { | ||
// can only run against 3.13+ (due to colocation support) | ||
return; | ||
} | ||
|
||
setupRenderingTest(hooks); | ||
|
||
test('registered ast plugins run against colocated templates (template-only)', async function(assert) { | ||
await render(hbs`<Foo />`); | ||
|
||
assert.equal(this.element.textContent.trim(), 'Module: dummy/components/foo.hbs'); | ||
}); | ||
}); |
Oops, something went wrong.