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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a test that covers addon templates and fix ember-try to include correct ember-cli versions #755

Merged
merged 5 commits into from
Sep 8, 2022
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
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ jobs:
runs-on: ${{ matrix.os }}-latest

strategy:
fail-fast: false
matrix:
os: [ubuntu, windows]
node-version: [12.x, 14.x]
Expand Down Expand Up @@ -73,9 +74,12 @@ jobs:
needs: [test, lint]

strategy:
fail-fast: false
matrix:
ember-try-scenario:
- ember-lts-3.8
- ember-lts-3.12
- ember-lts-3.16
- ember-lts-3.20
- ember-lts-3.24
- ember-lts-3.28
Expand Down
22 changes: 22 additions & 0 deletions config/ember-try.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,25 @@ module.exports = async function () {
npm: {
devDependencies: {
'ember-source': '~3.8.0',
'ember-cli': '~3.8.0',
},
},
},
{
name: 'ember-lts-3.12',
npm: {
devDependencies: {
'ember-source': '~3.12.0',
'ember-cli': '~3.12.0',
},
},
},
{
name: 'ember-lts-3.16',
npm: {
devDependencies: {
'ember-source': '~3.16.0',
'ember-cli': '~3.16.0',
},
},
},
Expand All @@ -20,6 +39,7 @@ module.exports = async function () {
npm: {
devDependencies: {
'ember-source': '~3.20.5',
'ember-cli': '~3.20.0',
},
},
},
Expand All @@ -28,6 +48,7 @@ module.exports = async function () {
npm: {
devDependencies: {
'ember-source': '~3.24.3',
'ember-cli': '~3.24.0',
},
},
},
Expand All @@ -36,6 +57,7 @@ module.exports = async function () {
npm: {
devDependencies: {
'ember-source': '~3.28.0',
'ember-cli': '~3.28.0',
},
},
},
Expand Down
25 changes: 24 additions & 1 deletion lib/ember-addon-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,36 @@ module.exports = {
}

this._addon.logger.debug(`setup *.hbs compiler with ${htmlbarsOptions.pluginNames}`);
return debugTree(
let output = debugTree(
this._addon.transpileTree(inputTree, {
isProduction,
...htmlbarsOptions,
}),
'03-output'
);

let checker = new VersionChecker(this._addon.project).for('ember-cli', 'npm');
let requiresBabelTree = checker.lt('3.13.0');
let isAddon = this._addon.parent !== this._addon.project;

// as a result of https://github.com/ember-cli/ember-cli-htmlbars/pull/749 we are relying
// on babel for all template comilation. This works fine since ember-cli@3.13 but before
// that there was a different path for **addon** templates and they would not be compiled
// correctly. This change wraps the output of addons in a babel tree since ember-cli
// isn't doing that properly.
if (requiresBabelTree && isAddon) {
let babelAddon = this._addon.parent.addons.find(
(addon) => addon.name === 'ember-cli-babel'
);
output = babelAddon.transpileTree(output, {
babel: this._addon.parent.options.babel,
'ember-cli-babel': {
compileModules: false,
},
});
}

return output;
},

precompile(string, _options) {
Expand Down
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
"ember-resolver": "^8.0.2",
"ember-source": "~3.28.0",
"ember-source-channel-url": "^3.0.0",
"ember-styleguide": "^5.0.0",
"ember-template-lint": "^3.6.0",
"ember-try": "^1.4.0",
"eslint": "^7.32.0",
Expand Down Expand Up @@ -109,6 +110,9 @@
"main": "lib/ember-addon-main.js",
"configPath": "tests/dummy/config"
},
"resolutions": {
"ember-cli-htmlbars": "link:."
},
"release-it": {
"plugins": {
"release-it-lerna-changelog": {
Expand Down
15 changes: 15 additions & 0 deletions tests/acceptance/styleguide-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { module, test } from 'qunit';
import { visit, currentURL } from '@ember/test-helpers';
import { setupApplicationTest } from 'ember-qunit';

module('Acceptance | styleguide', function (hooks) {
setupApplicationTest(hooks);

test('visiting /styleguide', async function (assert) {
await visit('/styleguide');

assert.equal(currentURL(), '/styleguide');

assert.dom('[data-test-es-note-heading]').containsText('says...');
});
});
4 changes: 3 additions & 1 deletion tests/dummy/app/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ const Router = EmberRouter.extend({
rootURL: config.rootURL,
});

Router.map(function () {});
Router.map(function () {
this.route('styleguide');
});

export default Router;
1 change: 1 addition & 0 deletions tests/dummy/app/templates/styleguide.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<EsNote>You should try out this cool note component</EsNote>
Loading