├── .editorconfig ├── .ember-cli ├── .eslintignore ├── .eslintrc.js ├── .github └── workflows │ └── nodejs.yml ├── .gitignore ├── .npmignore ├── .template-lintrc.js ├── .watchmanconfig ├── CHANGELOG.md ├── LICENSE.md ├── README.md ├── RELEASE.md ├── config ├── ember-try.js └── environment.js ├── ember-cli-build.js ├── index.js ├── lib ├── ast-plugins.js └── require-from-worker.js ├── node-tests ├── fixtures │ ├── compiler.js │ └── package.json ├── purge-module-test.js └── test.js ├── package.json ├── testem.js ├── tests ├── .jshintrc ├── dummy │ ├── app │ │ ├── app.js │ │ ├── components │ │ │ ├── .gitkeep │ │ │ ├── comment-redact.js │ │ │ ├── days-ago.js │ │ │ ├── inline-precompilation.js │ │ │ ├── multiline-string.js │ │ │ └── string-parameter.js │ │ ├── controllers │ │ │ └── .gitkeep │ │ ├── helpers │ │ │ └── .gitkeep │ │ ├── index.html │ │ ├── models │ │ │ └── .gitkeep │ │ ├── resolver.js │ │ ├── router.js │ │ ├── routes │ │ │ └── .gitkeep │ │ ├── styles │ │ │ └── app.css │ │ ├── templates │ │ │ ├── application.hbs │ │ │ └── components │ │ │ │ ├── .gitkeep │ │ │ │ └── days-ago.hbs │ │ └── views │ │ │ └── .gitkeep │ ├── config │ │ ├── environment.js │ │ ├── optional-features.json │ │ └── targets.js │ └── public │ │ └── robots.txt ├── helpers │ ├── .gitkeep │ └── start-app.js ├── index.html ├── test-helper.js └── unit │ ├── .gitkeep │ └── components │ ├── coffeescript-support-test.coffee │ ├── comment-redact-test.js │ ├── days-ago-test.js │ ├── inline-precompilation-test.js │ ├── multiline-string-test.js │ └── string-parameter-test.js └── yarn.lock /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig helps developers define and maintain consistent 2 | # coding styles between different editors and IDEs 3 | # editorconfig.org 4 | 5 | root = true 6 | 7 | 8 | [*] 9 | end_of_line = lf 10 | charset = utf-8 11 | trim_trailing_whitespace = true 12 | insert_final_newline = true 13 | indent_style = space 14 | indent_size = 2 15 | 16 | [*.hbs] 17 | insert_final_newline = false 18 | 19 | [*.{diff,md}] 20 | trim_trailing_whitespace = false 21 | -------------------------------------------------------------------------------- /.ember-cli: -------------------------------------------------------------------------------- 1 | { 2 | /** 3 | Ember CLI sends analytics information by default. The data is completely 4 | anonymous, but there are times when you might want to disable this behavior. 5 | 6 | Setting `disableAnalytics` to true will prevent any data from being sent. 7 | */ 8 | "disableAnalytics": false 9 | } 10 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | # unconventional js 2 | /blueprints/*/files/ 3 | /vendor/ 4 | 5 | # compiled output 6 | /dist/ 7 | /tmp/ 8 | 9 | # dependencies 10 | /bower_components/ 11 | 12 | # misc 13 | /coverage/ 14 | !.* 15 | 16 | # ember-try 17 | /.node_modules.ember-try/ 18 | /bower.json.ember-try 19 | /package.json.ember-try 20 | -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | parserOptions: { 4 | ecmaVersion: 2017, 5 | sourceType: 'module' 6 | }, 7 | plugins: [ 8 | 'ember' 9 | ], 10 | extends: [ 11 | 'eslint:recommended', 12 | 'plugin:ember/recommended' 13 | ], 14 | env: { 15 | browser: true, 16 | node: true, 17 | mocha: true 18 | }, 19 | rules: { 20 | }, 21 | overrides: [ 22 | // node files 23 | { 24 | files: [ 25 | '.template-lintrc.js', 26 | 'ember-cli-build.js', 27 | 'index.js', 28 | 'testem.js', 29 | 'blueprints/*/index.js', 30 | 'config/**/*.js', 31 | 'tests/dummy/config/**/*.js' 32 | ], 33 | excludedFiles: [ 34 | 'addon/**', 35 | 'addon-test-support/**', 36 | 'app/**', 37 | 'tests/dummy/app/**' 38 | ], 39 | parserOptions: { 40 | sourceType: 'script', 41 | ecmaVersion: 2015 42 | }, 43 | env: { 44 | browser: false, 45 | node: true 46 | }, 47 | plugins: ['node'], 48 | rules: Object.assign({}, require('eslint-plugin-node').configs.recommended.rules, { 49 | // add your custom rules and overrides for node files here 50 | }) 51 | } 52 | ] 53 | }; 54 | -------------------------------------------------------------------------------- /.github/workflows/nodejs.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | - 'v*' # older version branches 8 | tags: 9 | - '*' 10 | pull_request: {} 11 | schedule: 12 | - cron: '0 6 * * 0' # weekly, on sundays 13 | 14 | jobs: 15 | test: 16 | name: Tests 17 | runs-on: ubuntu-latest 18 | 19 | steps: 20 | - uses: actions/checkout@v1 21 | - uses: actions/setup-node@v1 22 | with: 23 | node-version: 8.x 24 | - name: install yarn 25 | run: npm install -g yarn 26 | - name: install dependencies 27 | run: yarn install 28 | - name: lint 29 | run: yarn lint:js 30 | - name: test 31 | run: yarn test 32 | 33 | try-scenarios: 34 | name: ember-try 35 | 36 | runs-on: ubuntu-latest 37 | 38 | needs: test 39 | 40 | strategy: 41 | fail-fast: true 42 | matrix: 43 | ember-try-scenario: 44 | - ember-lts-2.12 45 | - ember-lts-2.16 46 | - ember-lts-2.18 47 | - ember-lts-3.4 48 | - ember-lts-3.8 49 | - ember-lts-3.12 50 | - ember-release 51 | - ember-beta 52 | - ember-canary 53 | - ember-default 54 | 55 | steps: 56 | - uses: actions/checkout@v1 57 | - uses: actions/setup-node@v1 58 | with: 59 | node-version: 12.x 60 | - name: install yarn 61 | run: npm install -g yarn 62 | - name: install dependencies 63 | run: yarn install 64 | - name: test 65 | env: 66 | EMBER_TRY_SCENARIO: ${{ matrix.ember-try-scenario }} 67 | run: node_modules/.bin/ember try:one $EMBER_TRY_SCENARIO 68 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See http://help.github.com/ignore-files/ for more about ignoring files. 2 | 3 | # compiled output 4 | /dist/ 5 | /tmp/ 6 | 7 | # dependencies 8 | /node_modules/ 9 | 10 | # misc 11 | /.sass-cache 12 | /connect.lock 13 | /coverage/ 14 | /libpeerconnection.log 15 | /npm-debug.log* 16 | /testem.log 17 | /yarn-error.log 18 | 19 | # ember-try 20 | /.node_modules.ember-try/ 21 | /package.json.ember-try 22 | /bower.json 23 | /bower_components/ 24 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | # compiled output 2 | /dist/ 3 | /tmp/ 4 | 5 | # misc 6 | /.editorconfig 7 | /.ember-cli 8 | /.eslintignore 9 | /.eslintrc.js 10 | /.gitignore 11 | /.template-lintrc.js 12 | /.travis.yml 13 | /.watchmanconfig 14 | /config/ember-try.js 15 | /ember-cli-build.js 16 | /testem.js 17 | /tests/ 18 | /yarn.lock 19 | .gitkeep 20 | bower.json 21 | /bower_components/ 22 | 23 | # ember-try 24 | /.node_modules.ember-try/ 25 | /package.json.ember-try 26 | -------------------------------------------------------------------------------- /.template-lintrc.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = { 4 | extends: 'recommended' 5 | }; 6 | -------------------------------------------------------------------------------- /.watchmanconfig: -------------------------------------------------------------------------------- 1 | { 2 | "ignore_dirs": ["tmp", "dist"] 3 | } 4 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## v3.0.2 (2021-02-05) 2 | 3 | #### :rocket: Enhancement 4 | * [#408](https://github.com/ember-cli/ember-cli-htmlbars-inline-precompile/pull/408) Make cacheKey calculation lazy ([@rwjblue](https://github.com/rwjblue)) 5 | 6 | #### Committers: 2 7 | - Robert Jackson ([@rwjblue](https://github.com/rwjblue)) 8 | - [@dependabot-preview[bot]](https://github.com/apps/dependabot-preview) 9 | 10 | ## v3.0.1 (2019-10-01) 11 | 12 | #### :memo: Documentation 13 | * [#320](https://github.com/ember-cli/ember-cli-htmlbars-inline-precompile/pull/320) Deprecate ember-cli-htmlbars-inline-precompiler. ([@rwjblue](https://github.com/rwjblue)) 14 | * [#305](https://github.com/ember-cli/ember-cli-htmlbars-inline-precompile/pull/305) Fix import in README example ([@houli](https://github.com/houli)) 15 | 16 | #### :house: Internal 17 | * [#321](https://github.com/ember-cli/ember-cli-htmlbars-inline-precompile/pull/321) Re-roll yarn.lock to avoid errors with yarn 1.19.0 ([@rwjblue](https://github.com/rwjblue)) 18 | 19 | #### Committers: 3 20 | - Eoin Houlihan ([@houli](https://github.com/houli)) 21 | - Robert Jackson ([@rwjblue](https://github.com/rwjblue)) 22 | - [@dependabot-preview[bot]](https://github.com/apps/dependabot-preview) 23 | 24 | ## v3.0.0 (2019-08-31) 25 | 26 | #### :boom: Breaking Change 27 | * [#292](https://github.com/ember-cli/ember-cli-htmlbars-inline-precompile/pull/292) Drop support for Ember < 2.12. ([@rwjblue](https://github.com/rwjblue)) 28 | * [#290](https://github.com/ember-cli/ember-cli-htmlbars-inline-precompile/pull/290) Drop Babel 6 support. ([@rwjblue](https://github.com/rwjblue)) 29 | * [#288](https://github.com/ember-cli/ember-cli-htmlbars-inline-precompile/pull/288) Drop Node 6 and 11 support. ([@rwjblue](https://github.com/rwjblue)) 30 | 31 | #### :rocket: Enhancement 32 | * [#291](https://github.com/ember-cli/ember-cli-htmlbars-inline-precompile/pull/291) Update babel-plugin-htmlbars-inline-precompile to 2.0.0. ([@rwjblue](https://github.com/rwjblue)) 33 | 34 | #### :memo: Documentation 35 | * [#295](https://github.com/ember-cli/ember-cli-htmlbars-inline-precompile/pull/295) Modernize README. ([@rwjblue](https://github.com/rwjblue)) 36 | 37 | #### :house: Internal 38 | * [#294](https://github.com/ember-cli/ember-cli-htmlbars-inline-precompile/pull/294) Remove TravisCI. ([@rwjblue](https://github.com/rwjblue)) 39 | * [#289](https://github.com/ember-cli/ember-cli-htmlbars-inline-precompile/pull/289) Add GH Actions Workflow ([@rwjblue](https://github.com/rwjblue)) 40 | * [#163](https://github.com/ember-cli/ember-cli-htmlbars-inline-precompile/pull/163) package.json: Remove obsolete `resolutions` ([@Turbo87](https://github.com/Turbo87)) 41 | 42 | #### Committers: 3 43 | - Robert Jackson ([@rwjblue](https://github.com/rwjblue)) 44 | - Tobias Bieniek ([@Turbo87](https://github.com/Turbo87)) 45 | - [@dependabot-preview[bot]](https://github.com/apps/dependabot-preview) 46 | 47 | # Change Log 48 | 49 | ## v2.1.0 (2018-12-13) 50 | 51 | #### :rocket: Enhancement 52 | * [#156](https://github.com/ember-cli/ember-cli-htmlbars-inline-precompile/pull/156) Bring back support for Ember prior to 2.12 support (aka "bower support"). ([@rwjblue](https://github.com/rwjblue)) 53 | 54 | #### :bug: Bug Fix 55 | * [#148](https://github.com/ember-cli/ember-cli-htmlbars-inline-precompile/pull/148) Prevent duplicating inline precompile babel plugin ([@arthirm](https://github.com/arthirm)) 56 | 57 | #### :house: Internal 58 | * [#150](https://github.com/ember-cli/ember-cli-htmlbars-inline-precompile/pull/150) TravisCI: Remove deprecated `sudo: false` option ([@Turbo87](https://github.com/Turbo87)) 59 | 60 | #### Committers: 3 61 | - Arthi ([@arthirm](https://github.com/arthirm)) 62 | - Robert Jackson ([@rwjblue](https://github.com/rwjblue)) 63 | - Tobias Bieniek ([@Turbo87](https://github.com/Turbo87)) 64 | 65 | ## v2.0.0 (2018-11-07) 66 | 67 | #### :boom: Breaking Change 68 | * [#120](https://github.com/ember-cli/ember-cli-htmlbars-inline-precompile/pull/120) Upgrade to ember-cli@3.5 blueprint. ([@arthirm](https://github.com/arthirm)) 69 | * [#126](https://github.com/ember-cli/ember-cli-htmlbars-inline-precompile/pull/126) Remove Bower and run node-tests in CI ([@arthirm](https://github.com/arthirm)) 70 | * [#119](https://github.com/ember-cli/ember-cli-htmlbars-inline-precompile/pull/119) Drop Node.js 4 support ([@Turbo87](https://github.com/Turbo87)) 71 | 72 | #### :rocket: Enhancement 73 | * [#118](https://github.com/ember-cli/ember-cli-htmlbars-inline-precompile/pull/118) Update `.npmignore` file ([@Turbo87](https://github.com/Turbo87)) 74 | 75 | #### :bug: Bug Fix 76 | * [#114](https://github.com/ember-cli/ember-cli-htmlbars-inline-precompile/pull/114) Avoid setting up plugins per template (setup once per worker) ([@arthirm](https://github.com/arthirm)) 77 | 78 | #### Committers: 2 79 | - Arthi ([@arthirm](https://github.com/arthirm)) 80 | - Tobias Bieniek ([@Turbo87](https://github.com/Turbo87)) 81 | 82 | ## v1.0.5 (2018-10-12) 83 | 84 | #### :rocket: Enhancement 85 | * [#115](https://github.com/ember-cli/ember-cli-htmlbars-inline-precompile/pull/115) Update `ember-cli-babel` peer dependency to support Babel 7 too. ([@Turbo87](https://github.com/Turbo87)) 86 | 87 | #### Committers: 1 88 | - Tobias Bieniek ([Turbo87](https://github.com/Turbo87)) 89 | 90 | 91 | ## v1.0.4 (2018-10-04) 92 | 93 | #### :bug: Bug Fix 94 | * [#112](https://github.com/ember-cli/ember-cli-htmlbars-inline-precompile/pull/112) Fix for Memory leak. ([@arthirm](https://github.com/arthirm)) 95 | 96 | #### Committers: 1 97 | - Arthi ([arthirm](https://github.com/arthirm)) 98 | 99 | 100 | ## v1.0.3 (2018-06-02) 101 | 102 | #### :rocket: Enhancement 103 | * [#106](https://github.com/ember-cli/ember-cli-htmlbars-inline-precompile/pull/106) Update minimum versions of dependencies.. ([@rwjblue](https://github.com/rwjblue)) 104 | * [#102](https://github.com/ember-cli/ember-cli-htmlbars-inline-precompile/pull/102) Add support for importing from `ember-cli-htmlbars-inline-precompile`. ([@Turbo87](https://github.com/Turbo87)) 105 | 106 | #### Committers: 2 107 | - Robert Jackson ([rwjblue](https://github.com/rwjblue)) 108 | - Tobias Bieniek ([Turbo87](https://github.com/Turbo87)) 109 | 110 | 111 | ## v1.0.2 (2017-08-09) 112 | 113 | #### :bug: Bug Fix 114 | * [#97](https://github.com/ember-cli/ember-cli-htmlbars-inline-precompile/pull/97) Fix caching for parallel plugin objects. ([@mikrostew](https://github.com/mikrostew)) 115 | 116 | #### Committers: 2 117 | - Kelly Selden ([kellyselden](https://github.com/kellyselden)) 118 | - Michael Stewart ([mikrostew](https://github.com/mikrostew)) 119 | 120 | 121 | ## v1.0.1 (2017-08-05) 122 | 123 | #### :rocket: Enhancement 124 | * [#93](https://github.com/ember-cli/ember-cli-htmlbars-inline-precompile/pull/93) update `ember-cli-babel` version check and dependencies. ([@mikrostew](https://github.com/mikrostew)) 125 | 126 | #### :bug: Bug Fix 127 | * [#91](https://github.com/ember-cli/ember-cli-htmlbars-inline-precompile/pull/91) Adjust "ember-cli-babel" version check. ([@Turbo87](https://github.com/Turbo87)) 128 | 129 | #### Committers: 2 130 | - Michael Stewart ([mikrostew](https://github.com/mikrostew)) 131 | - Tobias Bieniek ([Turbo87](https://github.com/Turbo87)) 132 | 133 | 134 | ## v1.0.0 (2017-08-01) 135 | 136 | #### :rocket: Enhancement 137 | * [#83](https://github.com/ember-cli/ember-cli-htmlbars-inline-precompile/pull/83) Enable parallel transpile using API in broccoli-babel-transpiler. ([@mikrostew](https://github.com/mikrostew)) 138 | 139 | #### Committers: 1 140 | - Michael Stewart ([mikrostew](https://github.com/mikrostew)) 141 | 142 | 143 | ## v0.4.4 (2017-07-29) 144 | 145 | #### :bug: Bug Fix 146 | * [#88](https://github.com/ember-cli/ember-cli-htmlbars-inline-precompile/pull/88) Ensure ember-template-compiler does not mutate shared config object.. ([@rwjblue](https://github.com/rwjblue)) 147 | 148 | #### Committers: 1 149 | - Robert Jackson ([rwjblue](https://github.com/rwjblue)) 150 | 151 | 152 | ## v0.4.3 (2017-05-10) 153 | 154 | #### :rocket: Enhancement 155 | * [#81](https://github.com/ember-cli/ember-cli-htmlbars-inline-precompile/pull/81) Update ember-cli-version-checker to be aware of nested packages.. ([@rwjblue](https://github.com/rwjblue)) 156 | 157 | #### Committers: 1 158 | - Robert Jackson ([rwjblue](https://github.com/rwjblue)) 159 | 160 | 161 | ## v0.4.2 (2017-05-03) 162 | 163 | #### :bug: Bug Fix 164 | * [#76](https://github.com/ember-cli/ember-cli-htmlbars-inline-precompile/pull/76) Fixes init call so this works in older versions of ember-cli. ([@MiguelMadero](https://github.com/MiguelMadero)) 165 | 166 | #### Committers: 2 167 | - Miguel Madero ([MiguelMadero](https://github.com/MiguelMadero)) 168 | - Tobias Bieniek ([Turbo87](https://github.com/Turbo87)) 169 | 170 | 171 | ## v0.4.1 (2017-05-02) 172 | 173 | #### :rocket: Enhancement 174 | * [#72](https://github.com/ember-cli/ember-cli-htmlbars-inline-precompile/pull/72) Add helpful messaging when used in the wrong context.. ([@rwjblue](https://github.com/rwjblue)) 175 | 176 | #### Committers: 1 177 | - Robert Jackson ([rwjblue](https://github.com/rwjblue)) 178 | 179 | 180 | ## v0.4.0 (2017-04-22) 181 | 182 | #### :rocket: Enhancement 183 | * [#69](https://github.com/ember-cli/ember-cli-htmlbars-inline-precompile/pull/69) Make it work with ember-cli-babel@6 + ember-cli ^2.. ([@rwjblue](https://github.com/rwjblue)) 184 | 185 | #### :bug: Bug Fix 186 | * [#68](https://github.com/ember-cli/ember-cli-htmlbars-inline-precompile/pull/68) Ensure super call is bounded. ([@samselikoff](https://github.com/samselikoff)) 187 | 188 | #### Committers: 4 189 | - Ricardo Mendes ([locks](https://github.com/locks)) 190 | - Robert Jackson ([rwjblue](https://github.com/rwjblue)) 191 | - Sam Selikoff ([samselikoff](https://github.com/samselikoff)) 192 | - Tobias Bieniek ([Turbo87](https://github.com/Turbo87)) 193 | 194 | 195 | ## v0.4.0-beta.1 (2017-03-11) 196 | 197 | #### :rocket: Enhancement 198 | * [#69](https://github.com/ember-cli/ember-cli-htmlbars-inline-precompile/pull/69) Make it work with ember-cli-babel@6 + ember-cli ^2.. ([@rwjblue](https://github.com/rwjblue)) 199 | 200 | #### :bug: Bug Fix 201 | * [#68](https://github.com/ember-cli/ember-cli-htmlbars-inline-precompile/pull/68) Ensure super call is bounded. ([@samselikoff](https://github.com/samselikoff)) 202 | 203 | #### Committers: 4 204 | - Ricardo Mendes ([locks](https://github.com/locks)) 205 | - Robert Jackson ([rwjblue](https://github.com/rwjblue)) 206 | - Sam Selikoff ([samselikoff](https://github.com/samselikoff)) 207 | - Tobias Bieniek ([Turbo87](https://github.com/Turbo87)) 208 | 209 | 210 | ## v0.3.6 (2016-11-04) 211 | 212 | #### :bug: Bug Fix 213 | * [#57](https://github.com/ember-cli/ember-cli-htmlbars-inline-precompile/pull/57) Use ember-source instead of ember-core. ([@josemarluedke](https://github.com/josemarluedke)) 214 | 215 | #### Committers: 3 216 | - Greenkeeper ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) 217 | - Josemar Luedke ([josemarluedke](https://github.com/josemarluedke)) 218 | - Ricardo Mendes ([locks](https://github.com/locks)) 219 | 220 | 221 | ## v0.3.5 (2016-08-11) 222 | 223 | #### :bug: Bug Fix 224 | * [#37](https://github.com/ember-cli/ember-cli-htmlbars-inline-precompile/pull/37) Fix AST plugin usage with inline precompiler.. ([@rwjblue](https://github.com/rwjblue)) 225 | 226 | #### Committers: 2 227 | - Greenkeeper ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) 228 | - Robert Jackson ([rwjblue](https://github.com/rwjblue)) 229 | 230 | 231 | ## v0.3.4 (2016-08-10) 232 | 233 | #### :rocket: Enhancement 234 | * [#34](https://github.com/ember-cli/ember-cli-htmlbars-inline-precompile/pull/34) Provide template compiler cache key to babel plugin.. ([@rwjblue](https://github.com/rwjblue)) 235 | * [#31](https://github.com/ember-cli/ember-cli-htmlbars-inline-precompile/pull/31) Noop if ember-cli-htmlbars has already registered the precompiler. ([@offirgolan](https://github.com/offirgolan)) 236 | 237 | #### Committers: 3 238 | - Greenkeeper ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) 239 | - Offir Golan ([offirgolan](https://github.com/offirgolan)) 240 | - Robert Jackson ([rwjblue](https://github.com/rwjblue)) 241 | 242 | 243 | ## v0.3.3 (2016-07-27) 244 | 245 | #### :rocket: Enhancement 246 | * [#30](https://github.com/ember-cli/ember-cli-htmlbars-inline-precompile/pull/30) Make sure feature flags are available. ([@chadhietala](https://github.com/chadhietala)) 247 | 248 | #### Committers: 2 249 | - Chad Hietala ([chadhietala](https://github.com/chadhietala)) 250 | - Clemens M�ller ([pangratz](https://github.com/pangratz)) 251 | 252 | 253 | ## v0.3.2 (2016-05-22) 254 | 255 | #### :rocket: Enhancement 256 | * [#28](https://github.com/ember-cli/ember-cli-htmlbars-inline-precompile/pull/28) add support for ember-core npm module. ([@stefanpenner](https://github.com/stefanpenner)) 257 | 258 | #### Committers: 2 259 | - Clemens M�ller ([pangratz](https://github.com/pangratz)) 260 | - Stefan Penner ([stefanpenner](https://github.com/stefanpenner)) 261 | 262 | 263 | ## 0.3.1 (2015-09-12) 264 | 265 | #### :rocket: Enhancement 266 | * [#23](https://github.com/ember-cli/ember-cli-htmlbars-inline-precompile/pull/23) Upgrade to ember-cli-htmlbars ^1.0.0. ([@joliss](https://github.com/joliss)) 267 | 268 | #### Committers: 1 269 | - Jo Liss ([joliss](https://github.com/joliss)) 270 | 271 | 272 | ## 0.3.0 (2015-08-31) 273 | 274 | #### :rocket: Enhancement 275 | * [#21](https://github.com/ember-cli/ember-cli-htmlbars-inline-precompile/pull/21) Fix usage within multi-EmberApp builds. ([@ef4](https://github.com/ef4)) 276 | 277 | #### :bug: Bug Fix 278 | * [#5](https://github.com/ember-cli/ember-cli-htmlbars-inline-precompile/pull/5) app.options doesn't exist when used in addons. ([@wagenet](https://github.com/wagenet)) 279 | 280 | #### Committers: 2 281 | - Edward Faulkner ([ef4](https://github.com/ef4)) 282 | - Peter Wagenet ([wagenet](https://github.com/wagenet)) 283 | 284 | 285 | ## v0.1.2 (2015-06-26) 286 | 287 | #### :rocket: Enhancement 288 | * [#12](https://github.com/ember-cli/ember-cli-htmlbars-inline-precompile/pull/12) Bump babel-plugin-htmlbars-inline-precompile to v0.0.3. ([@pangratz](https://github.com/pangratz)) 289 | 290 | #### Committers: 1 291 | - Clemens M�ller ([pangratz](https://github.com/pangratz)) 292 | 293 | 294 | ## v0.1.1 (2015-06-13) 295 | 296 | #### :rocket: Enhancement 297 | * [#10](https://github.com/ember-cli/ember-cli-htmlbars-inline-precompile/pull/10) Pump babel-plugin-htmlbars-inline-precompile to 0.0.2. ([@pangratz](https://github.com/pangratz)) 298 | 299 | #### Committers: 1 300 | - Clemens M�ller ([pangratz](https://github.com/pangratz)) 301 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2018 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ember-cli-htmlbars-inline-precompile 2 | 3 | ## **Deprecated** 4 | 5 | Usage of this project is deprecated, its functionality has been migrated into 6 | [ember-cli-htmlbars](https://github.com/ember-cli/ember-cli-htmlbars) directly. 7 | Please upgrade to `ember-cli-htmlbars@4.0.3` or higher. 8 | -------------------------------------------------------------------------------- /RELEASE.md: -------------------------------------------------------------------------------- 1 | # Release 2 | 3 | Releases are mostly automated using 4 | [release-it](https://github.com/release-it/release-it/) and 5 | [lerna-changelog](https://github.com/lerna/lerna-changelog/). 6 | 7 | 8 | ## Preparation 9 | 10 | Since the majority of the actual release process is automated, the primary 11 | remaining task prior to releasing is confirming that all pull requests that 12 | have been merged since the last release have been labeled with the appropriate 13 | `lerna-changelog` labels and the titles have been updated to ensure they 14 | represent something that would make sense to our users. Some great information 15 | on why this is important can be found at 16 | [keepachangelog.com](https://keepachangelog.com/en/1.0.0/), but the overall 17 | guiding principles here is that changelogs are for humans, not machines. 18 | 19 | When reviewing merged PR's the labels to be used are: 20 | 21 | * breaking - Used when the PR is considered a breaking change. 22 | * enhancement - Used when the PR adds a new feature or enhancement. 23 | * bug - Used when the PR fixes a bug included in a previous release. 24 | * documentation - Used when the PR adds or updates documentation. 25 | * internal - Used for internal changes that still require a mention in the 26 | changelog/release notes. 27 | 28 | 29 | ## Release 30 | 31 | Once the prep work is completed, the actual release is straight forward: 32 | 33 | * First ensure that you have `release-it` installed globally, generally done by 34 | using one of the following commands: 35 | 36 | ``` 37 | # using https://volta.sh 38 | volta install release-it 39 | 40 | # using Yarn 41 | yarn global add release-it 42 | 43 | # using npm 44 | npm install --global release-it 45 | ``` 46 | 47 | * Second, ensure that you have installed your projects dependencies: 48 | 49 | ``` 50 | # using yarn 51 | yarn install 52 | 53 | # using npm 54 | npm install 55 | ``` 56 | 57 | * And last (but not least 😁) do your release: 58 | 59 | ``` 60 | release-it 61 | ``` 62 | 63 | [release-it](https://github.com/release-it/release-it/) manages the actual 64 | release process. It will prompt you through the process of choosing the version 65 | number, tagging, pushing the tag and commits, etc. 66 | -------------------------------------------------------------------------------- /config/ember-try.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const getChannelURL = require('ember-source-channel-url'); 4 | 5 | module.exports = function() { 6 | return Promise.all([ 7 | getChannelURL('release'), 8 | getChannelURL('beta'), 9 | getChannelURL('canary') 10 | ]).then((urls) => { 11 | return { 12 | useYarn: true, 13 | scenarios: [ 14 | { 15 | name: 'ember-lts-2.12', 16 | env: { 17 | EMBER_OPTIONAL_FEATURES: JSON.stringify({ 'jquery-integration': true }), 18 | }, 19 | npm: { 20 | devDependencies: { 21 | '@ember/jquery': '^0.5.1', 22 | 'ember-source': '~2.12.0' 23 | } 24 | } 25 | }, 26 | { 27 | name: 'ember-lts-2.16', 28 | env: { 29 | EMBER_OPTIONAL_FEATURES: JSON.stringify({ 'jquery-integration': true }), 30 | }, 31 | npm: { 32 | devDependencies: { 33 | '@ember/jquery': '^0.5.1', 34 | 'ember-source': '~2.16.0' 35 | } 36 | } 37 | }, 38 | { 39 | name: 'ember-lts-2.18', 40 | env: { 41 | EMBER_OPTIONAL_FEATURES: JSON.stringify({ 'jquery-integration': true }), 42 | }, 43 | npm: { 44 | devDependencies: { 45 | '@ember/jquery': '^0.5.1', 46 | 'ember-source': '~2.18.0' 47 | } 48 | } 49 | }, 50 | { 51 | name: 'ember-lts-3.4', 52 | npm: { 53 | devDependencies: { 54 | 'ember-source': '~3.4.0' 55 | } 56 | } 57 | }, 58 | { 59 | name: 'ember-lts-3.8', 60 | npm: { 61 | devDependencies: { 62 | 'ember-source': '~3.8.0' 63 | } 64 | } 65 | }, 66 | { 67 | name: 'ember-lts-3.12', 68 | npm: { 69 | devDependencies: { 70 | 'ember-source': '~3.12.0' 71 | } 72 | } 73 | }, 74 | { 75 | name: 'ember-release', 76 | npm: { 77 | devDependencies: { 78 | 'ember-source': urls[0] 79 | } 80 | } 81 | }, 82 | { 83 | name: 'ember-beta', 84 | npm: { 85 | devDependencies: { 86 | 'ember-source': urls[1] 87 | } 88 | } 89 | }, 90 | { 91 | name: 'ember-canary', 92 | npm: { 93 | devDependencies: { 94 | 'ember-source': urls[2] 95 | } 96 | } 97 | }, 98 | { 99 | name: 'ember-default', 100 | npm: { 101 | devDependencies: {} 102 | } 103 | }, 104 | { 105 | name: 'ember-default-with-jquery', 106 | env: { 107 | EMBER_OPTIONAL_FEATURES: JSON.stringify({ 108 | 'jquery-integration': true 109 | }) 110 | }, 111 | npm: { 112 | devDependencies: { 113 | '@ember/jquery': '^0.5.1' 114 | } 115 | } 116 | } 117 | ] 118 | }; 119 | }); 120 | }; 121 | -------------------------------------------------------------------------------- /config/environment.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = function(/* environment, appConfig */) { 4 | return { }; 5 | }; 6 | -------------------------------------------------------------------------------- /ember-cli-build.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const EmberAddon = require('ember-cli/lib/broccoli/ember-addon'); 4 | 5 | module.exports = function(defaults) { 6 | let app = new EmberAddon(defaults, { 7 | // Add options here 8 | }); 9 | 10 | /* 11 | This build file specifies the options for the dummy test app of this 12 | addon, located in `/tests/dummy` 13 | This build file does *not* influence how the addon or the app using it 14 | behave. You most likely want to be modifying `./index.js` or app's build file 15 | */ 16 | 17 | return app.toTree(); 18 | }; 19 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const path = require('path'); 4 | const AstPlugins = require('./lib/ast-plugins'); 5 | const VersionChecker = require('ember-cli-version-checker'); 6 | const SilentError = require('silent-error'); 7 | const debugGenerator = require('heimdalljs-logger'); 8 | const semver = require('semver'); 9 | 10 | const _logger = debugGenerator('ember-cli-htmlbars-inline-precompile'); 11 | 12 | module.exports = { 13 | name: 'ember-cli-htmlbars-inline-precompile', 14 | 15 | init() { 16 | this._super.init && this._super.init.apply(this, arguments); 17 | 18 | let checker = new VersionChecker(this); 19 | let hasIncorrectBabelVersion = checker.for('ember-cli-babel', 'npm').lt('6.7.1'); 20 | 21 | if (hasIncorrectBabelVersion) { 22 | throw new SilentError(`ember-cli-htmlbars-inline-precompile v1.0.0 and above require the ember-cli-babel v6.7.1 or above. To use ember-cli-babel v5.x please downgrade ember-cli-htmlbars-inline-precompile to v0.3.`); 23 | } 24 | }, 25 | 26 | setupPreprocessorRegistry(type, registry) { 27 | if (type === 'parent') { 28 | this.parentRegistry = registry; 29 | } 30 | }, 31 | 32 | included() { 33 | this._super.included.apply(this, arguments); 34 | 35 | let projectEmberCliHtmlbars = this.project.findAddonByName('ember-cli-htmlbars'); 36 | if(projectEmberCliHtmlbars && projectEmberCliHtmlbars.inlinePrecompilerRegistered) { 37 | return; 38 | } 39 | 40 | let parentEmberCliHtmlbars = this.parent.addons.find(a => a.name === 'ember-cli-htmlbars'); 41 | if (parentEmberCliHtmlbars && semver.gt(parentEmberCliHtmlbars.pkg.version, '4.0.2')) { 42 | // ember-cli-htmlbars will issue a deprecation message, but we need to 43 | // ensure that we don't attempt to add the babel plugin 44 | return; 45 | } 46 | 47 | let checker = new VersionChecker(this); 48 | 49 | let emberCLIUsesSharedBabelPlugins = checker.for('ember-cli', 'npm').lt('2.13.0-alpha.1'); 50 | let addonOptions = this._getAddonOptions(); 51 | let isProjectDependency = this.parent === this.project; 52 | let babelPlugins; 53 | 54 | if (emberCLIUsesSharedBabelPlugins && isProjectDependency) { 55 | addonOptions.babel6 = addonOptions.babel6 || {}; 56 | babelPlugins = addonOptions.babel6.plugins = addonOptions.babel6.plugins || []; 57 | } else { 58 | addonOptions.babel = addonOptions.babel || {}; 59 | babelPlugins = addonOptions.babel.plugins = addonOptions.babel.plugins || []; 60 | } 61 | 62 | let pluginWrappers = this.parentRegistry.load('htmlbars-ast-plugin'); 63 | 64 | // add the HTMLBarsInlinePrecompilePlugin to the list of plugins used by 65 | // the `ember-cli-babel` addon 66 | if (!this._isBabelPluginRegistered(babelPlugins)) { 67 | let templateCompilerPath = this.templateCompilerPath(); 68 | let parallelConfig = this.getParallelConfig(pluginWrappers); 69 | let pluginInfo = AstPlugins.setupDependentPlugins(pluginWrappers); 70 | 71 | if (this.canParallelize(pluginWrappers)) { 72 | _logger.debug('using parallel API with broccoli-babel-transpiler'); 73 | let parallelBabelInfo = { 74 | requireFile: path.resolve(__dirname, 'lib/require-from-worker'), 75 | buildUsing: 'build', 76 | params: { 77 | templateCompilerPath, 78 | parallelConfig 79 | } 80 | }; 81 | 82 | let cacheKey; 83 | babelPlugins.push({ 84 | _parallelBabel: parallelBabelInfo, 85 | baseDir: () => __dirname, 86 | cacheKey: () => { 87 | if (cacheKey === undefined) { 88 | // parallelBabelInfo will not be used in the cache unless it is explicitly included 89 | cacheKey = AstPlugins.makeCacheKey(templateCompilerPath, pluginInfo, JSON.stringify(parallelBabelInfo)); 90 | } 91 | 92 | return cacheKey; 93 | }, 94 | }); 95 | } 96 | else { 97 | _logger.debug('NOT using parallel API with broccoli-babel-transpiler'); 98 | let blockingPlugins = pluginWrappers.map((wrapper) => { 99 | if (wrapper.parallelBabel === undefined) { 100 | return wrapper.name; 101 | } 102 | }).filter(Boolean); 103 | _logger.debug('Prevented by these plugins: ' + blockingPlugins); 104 | let htmlBarsPlugin = AstPlugins.setup(pluginInfo, { 105 | projectConfig: this.projectConfig(), 106 | templateCompilerPath: this.templateCompilerPath(), 107 | }); 108 | babelPlugins.push(htmlBarsPlugin); 109 | } 110 | } 111 | }, 112 | 113 | /** 114 | * This function checks if 'ember-cli-htmlbars-inline-precompile' is already present in babelPlugins. 115 | * The plugin object will be different for non parallel API and parallel API. 116 | * For parallel api, check the `baseDir` of a plugin to see if it has current dirname 117 | * For non parallel api, check the 'modulePaths' to see if it contains 'ember-cli-htmlbars-inline-precompile' 118 | * @param {*} plugins 119 | */ 120 | _isBabelPluginRegistered(plugins) { 121 | return plugins.some(plugin => { 122 | if (Array.isArray(plugin)) { 123 | return plugin[0] === require.resolve('babel-plugin-htmlbars-inline-precompile'); 124 | } else if (plugin !== null && typeof plugin === 'object' && plugin._parallelBabel !== undefined) { 125 | return plugin._parallelBabel.requireFile === path.resolve(__dirname, 'lib/require-from-worker'); 126 | } else { 127 | return false; 128 | } 129 | }); 130 | }, 131 | 132 | _getAddonOptions() { 133 | return (this.parent && this.parent.options) || (this.app && this.app.options) || {}; 134 | }, 135 | 136 | // verify that each registered ast plugin can be parallelized 137 | canParallelize(pluginWrappers) { 138 | return pluginWrappers.every((wrapper) => wrapper.parallelBabel !== undefined); 139 | }, 140 | 141 | // return an array of the 'parallelBabel' object for each registered htmlbars-ast-plugin 142 | getParallelConfig(pluginWrappers) { 143 | return pluginWrappers.map((wrapper) => wrapper.parallelBabel); 144 | }, 145 | 146 | // borrowed from ember-cli-htmlbars http://git.io/vJDrW 147 | projectConfig() { 148 | return this.project.config(process.env.EMBER_ENV); 149 | }, 150 | 151 | // borrowed from ember-cli-htmlbars http://git.io/vJDrw 152 | templateCompilerPath() { 153 | let config = this.projectConfig(); 154 | let templateCompilerPath = config['ember-cli-htmlbars'] && config['ember-cli-htmlbars'].templateCompilerPath; 155 | 156 | let ember = this.project.findAddonByName('ember-source'); 157 | if (ember) { 158 | return ember.absolutePaths.templateCompiler; 159 | } else if (!templateCompilerPath) { 160 | templateCompilerPath = this.project.bowerDirectory + '/ember/ember-template-compiler'; 161 | } 162 | 163 | return path.resolve(this.project.root, templateCompilerPath); 164 | } 165 | }; 166 | -------------------------------------------------------------------------------- /lib/ast-plugins.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const fs = require('fs'); 4 | const path = require('path'); 5 | const HTMLBarsInlinePrecompilePlugin = require.resolve('babel-plugin-htmlbars-inline-precompile'); 6 | const hashForDep = require('hash-for-dep'); 7 | const debugGenerator = require('heimdalljs-logger'); 8 | const _logger = debugGenerator('ember-cli-htmlbars-inline-precompile'); 9 | 10 | module.exports = { 11 | purgeModule(templateCompilerPath) { 12 | // ensure we get a fresh templateCompilerModuleInstance per ember-addon 13 | // instance NOTE: this is a quick hack, and will only work as long as 14 | // templateCompilerPath is a single file bundle 15 | // 16 | // (╯°□°)╯︵ ɹǝqɯǝ 17 | // 18 | // we will also fix this in ember for future releases 19 | 20 | // Module will be cached in .parent.children as well. So deleting from require.cache alone is not sufficient. 21 | let mod = require.cache[templateCompilerPath]; 22 | if (mod && mod.parent) { 23 | let index = mod.parent.children.indexOf(mod); 24 | if (index >= 0) { 25 | mod.parent.children.splice(index, 1); 26 | } else { 27 | throw new TypeError(`ember-cli-htmlbars-inline-precompile attempted to purge '${templateCompilerPath}' but something went wrong.`); 28 | } 29 | } 30 | 31 | delete require.cache[templateCompilerPath]; 32 | }, 33 | 34 | setup(pluginInfo, options) { 35 | // borrowed from ember-cli-htmlbars http://git.io/vJDrW 36 | let projectConfig = options.projectConfig || {}; 37 | let templateCompilerPath = options.templateCompilerPath; 38 | 39 | let EmberENV = projectConfig.EmberENV || {}; 40 | // ensure we get a fresh templateCompilerModuleInstance per ember-addon 41 | // instance NOTE: this is a quick hack, and will only work as long as 42 | // templateCompilerPath is a single file bundle 43 | // 44 | // (╯°□°)╯︵ ɹǝqɯǝ 45 | // 46 | // we will also fix this in ember for future releases 47 | this.purgeModule(templateCompilerPath); 48 | 49 | // do a full clone of the EmberENV (it is guaranteed to be structured 50 | // cloneable) to prevent ember-template-compiler.js from mutating 51 | // the shared global config 52 | let clonedEmberENV = JSON.parse(JSON.stringify(EmberENV)); 53 | global.EmberENV = clonedEmberENV; 54 | 55 | let Compiler = require(templateCompilerPath); 56 | let cacheKey; 57 | 58 | let precompileInlineHTMLBarsPlugin; 59 | 60 | pluginInfo.plugins.forEach((plugin) => Compiler.registerPlugin('ast', plugin)); 61 | 62 | let precompile = Compiler.precompile; 63 | precompile.baseDir = () => path.resolve(__dirname, '..'); 64 | precompile.cacheKey = () => { 65 | if (cacheKey === undefined) { 66 | cacheKey = this.makeCacheKey(templateCompilerPath, pluginInfo); 67 | } 68 | 69 | return cacheKey; 70 | }; 71 | 72 | let modulePaths = ['ember-cli-htmlbars-inline-precompile', 'htmlbars-inline-precompile']; 73 | precompileInlineHTMLBarsPlugin = [HTMLBarsInlinePrecompilePlugin, { precompile, modulePaths }]; 74 | 75 | this.purgeModule(templateCompilerPath); 76 | 77 | delete global.Ember; 78 | delete global.EmberENV; 79 | 80 | return precompileInlineHTMLBarsPlugin; 81 | }, 82 | 83 | makeCacheKey(templateCompilerPath, pluginInfo, extra) { 84 | let templateCompilerFullPath = require.resolve(templateCompilerPath); 85 | let templateCompilerCacheKey = fs.readFileSync(templateCompilerFullPath, { encoding: 'utf-8' }); 86 | let cacheItems = [templateCompilerCacheKey, extra].concat(pluginInfo.cacheKeys.sort()); 87 | // extra may be undefined 88 | return cacheItems.filter(Boolean).join('|'); 89 | }, 90 | 91 | setupDependentPlugins(wrappers) { 92 | const plugins = []; 93 | const cacheKeys = []; 94 | 95 | wrappers.forEach((item) => { 96 | let buildInfo; 97 | if (item.requireFile) { 98 | const plugin = require(item.requireFile); 99 | buildInfo = plugin[item.buildUsing](item.params); 100 | } else { 101 | buildInfo = item; 102 | } 103 | 104 | plugins.push(buildInfo.plugin); 105 | 106 | let providesBaseDir = typeof buildInfo.baseDir === 'function'; 107 | let augmentsCacheKey = typeof buildInfo.cacheKey === 'function'; 108 | 109 | if (providesBaseDir || augmentsCacheKey) { 110 | if (providesBaseDir) { 111 | let pluginHashForDep = hashForDep(buildInfo.baseDir()); 112 | cacheKeys.push(pluginHashForDep); 113 | } 114 | if (augmentsCacheKey) { 115 | cacheKeys.push(buildInfo.cacheKey()); 116 | } 117 | } else { 118 | _logger.debug('ember-cli-htmlbars-inline-precompile is opting out of caching due to an AST plugin that does not provide a caching strategy: `' + buildInfo.name + '`.'); 119 | cacheKeys.push((new Date()).getTime() + '|' + Math.random()); 120 | } 121 | }); 122 | 123 | return { 124 | plugins, 125 | cacheKeys 126 | }; 127 | } 128 | }; 129 | -------------------------------------------------------------------------------- /lib/require-from-worker.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const AstPlugins = require('./ast-plugins'); 4 | let astPlugin = {}; 5 | 6 | module.exports = { 7 | build(options, cacheKey) { 8 | // Caching the plugin info so that call to setUp functions will be made once per worker 9 | // and not once per module tranformation 10 | let plugin = astPlugin[cacheKey]; 11 | if (!plugin) { 12 | const pluginInfo = AstPlugins.setupDependentPlugins(options.parallelConfig); 13 | plugin = AstPlugins.setup(pluginInfo, { 14 | templateCompilerPath: options.templateCompilerPath, 15 | }); 16 | // if cacheKey is not undefined cache it. 17 | if(cacheKey) { 18 | astPlugin[cacheKey] = plugin; 19 | } 20 | } 21 | return plugin; 22 | } 23 | } -------------------------------------------------------------------------------- /node-tests/fixtures/compiler.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = function() { 4 | return 'I AM MODULE OF COMPILER'; 5 | }; 6 | -------------------------------------------------------------------------------- /node-tests/fixtures/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "developing-addon", 3 | "version": "0.0.1", 4 | "keywords": [ 5 | "ember-addon" 6 | ], 7 | "dependencies": { 8 | "ember-cli-htmlbars": "latest" 9 | } 10 | } -------------------------------------------------------------------------------- /node-tests/purge-module-test.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const purgeModule = require('../lib/ast-plugins').purgeModule; 4 | const expect = require('chai').expect; 5 | 6 | describe('purgeModule', function() { 7 | const FIXTURE_COMPILER_PATH = require.resolve('./fixtures/compiler'); 8 | 9 | it('it works correctly', function() { 10 | expect(purgeModule('asdfasdfasdfaf-unknown-file')).to.eql(undefined); 11 | 12 | expect(require.cache[FIXTURE_COMPILER_PATH]).to.eql(undefined); 13 | 14 | require(FIXTURE_COMPILER_PATH); 15 | 16 | const mod = require.cache[FIXTURE_COMPILER_PATH]; 17 | 18 | expect(mod.parent).to.eql(module); 19 | expect(mod.parent.children).to.include(mod); 20 | 21 | purgeModule(FIXTURE_COMPILER_PATH); 22 | 23 | expect(require.cache[FIXTURE_COMPILER_PATH]).to.eql(undefined); 24 | expect(mod.parent.children).to.not.include(mod); 25 | 26 | require(FIXTURE_COMPILER_PATH); 27 | 28 | const freshModule = require.cache[FIXTURE_COMPILER_PATH]; 29 | 30 | expect(freshModule.parent).to.eql(module); 31 | expect(freshModule.parent.children).to.include(freshModule); 32 | 33 | purgeModule(FIXTURE_COMPILER_PATH); 34 | 35 | expect(require.cache[FIXTURE_COMPILER_PATH]).to.eql(undefined); 36 | expect(freshModule.parent.children).to.not.include(mod); 37 | }); 38 | }); 39 | -------------------------------------------------------------------------------- /node-tests/test.js: -------------------------------------------------------------------------------- 1 | /* jshint node: true */ 2 | 'use strict'; 3 | 4 | const expect = require('chai').expect; 5 | const fs = require('fs'); 6 | const path = require('path'); 7 | const Registry = require('ember-cli-preprocess-registry'); 8 | const HTMLBarsInlinePrecompilePlugin = require.resolve('babel-plugin-htmlbars-inline-precompile'); 9 | const hashForDep = require('hash-for-dep'); 10 | const pluginHashForDep = hashForDep(path.resolve(__dirname, './fixtures')); 11 | const InlinePrecompile = require('../'); 12 | const defaultsDeep = require('ember-cli-lodash-subset').defaultsDeep; 13 | 14 | describe('canParallelize()', function() { 15 | it('returns true for 0 plugins', function() { 16 | const pluginWrappers = []; 17 | expect(InlinePrecompile.canParallelize(pluginWrappers)).to.eql(true); 18 | }); 19 | 20 | it('returns true for 1+ plugins with "parallelBabel" property', function() { 21 | const pluginWrappers1 = [ 22 | { parallelBabel: 'something' } 23 | ]; 24 | const pluginWrappers2 = [ 25 | { parallelBabel: 'something' }, 26 | { parallelBabel: 'something else' }, 27 | ]; 28 | expect(InlinePrecompile.canParallelize(pluginWrappers1)).to.eql(true); 29 | expect(InlinePrecompile.canParallelize(pluginWrappers2)).to.eql(true); 30 | }); 31 | 32 | it('returns false for 1+ plugins without "parallelBabel" property', function() { 33 | const pluginWrappers1 = [ 34 | { name: 'something' } 35 | ]; 36 | const pluginWrappers2 = [ 37 | { name: 'something' }, 38 | { name: 'something else' }, 39 | ]; 40 | expect(InlinePrecompile.canParallelize(pluginWrappers1)).to.eql(false); 41 | expect(InlinePrecompile.canParallelize(pluginWrappers2)).to.eql(false); 42 | }); 43 | 44 | it('returns false for mix of plugins with & without "parallelBabel" property', function() { 45 | const pluginWrappersMix = [ 46 | { name: 'something', parallelBabel: 'ok' }, 47 | { name: 'something else' }, 48 | ]; 49 | expect(InlinePrecompile.canParallelize(pluginWrappersMix)).to.eql(false); 50 | }); 51 | }); 52 | 53 | describe('getParallelConfig()', function() { 54 | it('returns the "parallelBabel" property of the plugins', function() { 55 | const pluginWrappers = [ 56 | { parallelBabel: { requireFile: 'some/file' } }, 57 | { parallelBabel: { requireFile: 'another/file' } }, 58 | ]; 59 | const expected = [ 60 | { requireFile: 'some/file'}, 61 | { requireFile: 'another/file' }, 62 | ]; 63 | expect(InlinePrecompile.getParallelConfig(pluginWrappers)).to.eql(expected); 64 | }); 65 | }); 66 | 67 | describe('included()', function() { 68 | let parent; 69 | let registry; 70 | let expectedRequireFilePath = path.resolve(__dirname, '../lib/require-from-worker'); 71 | let expectedTemplateCompilerPath = path.resolve(__dirname, '../node_modules/ember-source/dist/ember-template-compiler.js'); 72 | if (!fs.existsSync(expectedTemplateCompilerPath)) { 73 | expectedTemplateCompilerPath = path.resolve(__dirname, '../bower_components/ember/ember-template-compiler.js'); 74 | } 75 | let templateCompilerContents = fs.readFileSync(`${expectedTemplateCompilerPath}`, { encoding: 'utf-8' }); 76 | let testBaseDir = () => path.resolve(__dirname, '..'); 77 | let FixtureBaseDir = () => path.resolve(__dirname, './fixtures'); 78 | let configuredPlugins; 79 | let dependentParallelInfo = { 80 | requireFile: 'some/file/path', 81 | buildUsing: 'whatever', 82 | params: {} 83 | }; 84 | let parallelPlugin = { 85 | name: 'some-parallel-plugin', 86 | plugin: 'some object', 87 | baseDir: FixtureBaseDir, 88 | parallelBabel: dependentParallelInfo, 89 | }; 90 | let nonParallelPlugin = { 91 | name: 'some-regular-plugin', 92 | plugin: 'some object', 93 | baseDir: FixtureBaseDir, 94 | }; 95 | let parallelBabelInfo0Plugin = { 96 | requireFile: expectedRequireFilePath, 97 | buildUsing: 'build', 98 | params: { 99 | templateCompilerPath: expectedTemplateCompilerPath, 100 | parallelConfig: [] 101 | } 102 | }; 103 | let parallelBabelInfo1Plugin = { 104 | requireFile: expectedRequireFilePath, 105 | buildUsing: 'build', 106 | params: { 107 | templateCompilerPath: expectedTemplateCompilerPath, 108 | parallelConfig: [ dependentParallelInfo ] 109 | } 110 | }; 111 | 112 | beforeEach(function() { 113 | // mocks and settings for testing 114 | registry = new Registry(); 115 | parent = { options: { babel: { plugins: [] } } }; 116 | InlinePrecompile.setupPreprocessorRegistry('parent', registry); 117 | InlinePrecompile._super = { 118 | included: { apply() {} } 119 | }; 120 | InlinePrecompile.project = { 121 | findAddonByName(addon) { 122 | return { 123 | 'ember-cli-htmlbars': { inlinePrecompilerRegistered: false }, 124 | 'ember-source': { absolutePaths: { templateCompiler: expectedTemplateCompilerPath }}, 125 | }[addon]; 126 | }, 127 | config() { 128 | return { 129 | 'ember-cli-htmlbars': { templateCompilerPath: undefined } 130 | }; 131 | }, 132 | root: __dirname, 133 | }; 134 | InlinePrecompile.parent = parent; 135 | InlinePrecompile._registeredWithBabel = false; 136 | }); 137 | 138 | describe('0 plugins', function() { 139 | beforeEach(function() { 140 | // no plugins registered 141 | InlinePrecompile.included(); 142 | configuredPlugins = parent.options.babel.plugins; 143 | }); 144 | 145 | it('should have _parallelBabel object', function() { 146 | expect(configuredPlugins.length).to.eql(1); 147 | expect(typeof configuredPlugins[0]._parallelBabel).to.eql('object'); 148 | let _parallelBabel = configuredPlugins[0]._parallelBabel; 149 | expect(_parallelBabel.requireFile).to.eql(expectedRequireFilePath); 150 | expect(_parallelBabel.buildUsing).to.eql('build'); 151 | expect(typeof _parallelBabel.params).to.eql('object'); 152 | expect(_parallelBabel.params.parallelConfig).to.eql([]); 153 | expect(_parallelBabel.params.templateCompilerPath).to.eql(expectedTemplateCompilerPath); 154 | }); 155 | 156 | it('should have baseDir()', function() { 157 | expect(configuredPlugins.length).to.eql(1); 158 | expect(typeof configuredPlugins[0].baseDir).to.eql('function'); 159 | expect(configuredPlugins[0].baseDir()).to.eql(testBaseDir()); 160 | }); 161 | 162 | it('should have cacheKey()', function() { 163 | let expectedCacheKey = [templateCompilerContents, JSON.stringify(parallelBabelInfo0Plugin)].join('|'); 164 | expect(configuredPlugins.length).to.eql(1); 165 | expect(typeof configuredPlugins[0].cacheKey).to.eql('function'); 166 | let cacheKey = configuredPlugins[0].cacheKey(); 167 | expect(cacheKey.length).to.eql(expectedCacheKey.length, 'cacheKey is the correct length'); 168 | expect(cacheKey).to.equal(expectedCacheKey); 169 | }); 170 | }); 171 | 172 | describe('1 parallel plugin', function() { 173 | beforeEach(function() { 174 | registry.add('htmlbars-ast-plugin', parallelPlugin); 175 | InlinePrecompile.included(); 176 | configuredPlugins = parent.options.babel.plugins; 177 | }); 178 | 179 | it('should have _parallelBabel object', function() { 180 | expect(configuredPlugins.length).to.eql(1); 181 | expect(typeof configuredPlugins[0]._parallelBabel).to.eql('object'); 182 | let _parallelBabel = configuredPlugins[0]._parallelBabel; 183 | expect(_parallelBabel.requireFile).to.eql(expectedRequireFilePath); 184 | expect(_parallelBabel.buildUsing).to.eql('build'); 185 | expect(typeof _parallelBabel.params).to.eql('object'); 186 | expect(_parallelBabel.params.parallelConfig).to.eql([ dependentParallelInfo ]); 187 | expect(_parallelBabel.params.templateCompilerPath).to.eql(expectedTemplateCompilerPath); 188 | }); 189 | 190 | it('should have baseDir()', function() { 191 | expect(configuredPlugins.length).to.eql(1); 192 | expect(typeof configuredPlugins[0].baseDir).to.eql('function'); 193 | expect(configuredPlugins[0].baseDir()).to.eql(testBaseDir()); 194 | }); 195 | 196 | it('should have cacheKey()', function() { 197 | let expectedCacheKey = [templateCompilerContents, JSON.stringify(parallelBabelInfo1Plugin)].concat(pluginHashForDep).join('|'); 198 | expect(configuredPlugins.length).to.eql(1); 199 | expect(typeof configuredPlugins[0].cacheKey).to.eql('function'); 200 | let cacheKey = configuredPlugins[0].cacheKey(); 201 | expect(cacheKey.length).to.eql(expectedCacheKey.length, 'cacheKey is the correct length'); 202 | expect(cacheKey).to.equal(expectedCacheKey); 203 | }); 204 | }); 205 | 206 | describe('1 non-parallel plugin', function() { 207 | beforeEach(function() { 208 | registry.add('htmlbars-ast-plugin', nonParallelPlugin); 209 | InlinePrecompile.included(); 210 | configuredPlugins = parent.options.babel.plugins; 211 | }); 212 | 213 | it('should not have _parallelBabel object', function() { 214 | expect(configuredPlugins.length).to.eql(1); 215 | expect(configuredPlugins[0]._parallelBabel).to.eql(undefined); 216 | }); 217 | 218 | it('should have plugin object', function() { 219 | let expectedCacheKey = [templateCompilerContents].concat([pluginHashForDep]).join('|'); 220 | expect(Array.isArray(configuredPlugins[0])).to.eql(true); 221 | expect(configuredPlugins[0].length).to.eql(2); 222 | let pluginObject = configuredPlugins[0][0]; 223 | expect(pluginObject).to.eql(HTMLBarsInlinePrecompilePlugin); 224 | let pluginParams = configuredPlugins[0][1]; 225 | expect(typeof pluginParams.precompile).to.eql('function'); 226 | expect(typeof pluginParams.precompile.baseDir).to.eql('function'); 227 | expect(pluginParams.precompile.baseDir()).to.eql(testBaseDir()); 228 | expect(typeof pluginParams.precompile.cacheKey).to.eql('function'); 229 | let cacheKey = pluginParams.precompile.cacheKey(); 230 | expect(cacheKey.length).to.equal(expectedCacheKey.length); 231 | expect(cacheKey).to.equal(expectedCacheKey); 232 | }); 233 | }); 234 | 235 | describe('mix of parallel & non-parallel plugins', function() { 236 | beforeEach(function() { 237 | registry.add('htmlbars-ast-plugin', parallelPlugin); 238 | registry.add('htmlbars-ast-plugin', nonParallelPlugin); 239 | InlinePrecompile.included(); 240 | configuredPlugins = parent.options.babel.plugins; 241 | }); 242 | 243 | it('should not have _parallelBabel object', function() { 244 | expect(configuredPlugins.length).to.eql(1); 245 | expect(configuredPlugins[0]._parallelBabel).to.eql(undefined); 246 | }); 247 | 248 | it('should have plugin object', function() { 249 | let expectedCacheKey = [templateCompilerContents].concat([pluginHashForDep, pluginHashForDep]).join('|'); 250 | expect(Array.isArray(configuredPlugins[0])).to.eql(true); 251 | expect(configuredPlugins[0].length).to.eql(2); 252 | let pluginObject = configuredPlugins[0][0]; 253 | expect(pluginObject).to.eql(HTMLBarsInlinePrecompilePlugin); 254 | let pluginParams = configuredPlugins[0][1]; 255 | expect(typeof pluginParams.precompile).to.eql('function'); 256 | expect(typeof pluginParams.precompile.baseDir).to.eql('function'); 257 | expect(pluginParams.precompile.baseDir()).to.eql(testBaseDir()); 258 | expect(typeof pluginParams.precompile.cacheKey).to.eql('function'); 259 | let cacheKey = pluginParams.precompile.cacheKey(); 260 | expect(cacheKey.length).to.equal(expectedCacheKey.length); 261 | expect(cacheKey).to.equal(expectedCacheKey); 262 | }); 263 | }); 264 | 265 | describe('different instances of inline precompile for the same parent', function() { 266 | it('should have only 1 inlinePrecompile registered for parallel babel', function() { 267 | let InlinePrecompile1 = defaultsDeep( {}, require('../')) 268 | let InlinePrecompile2 = defaultsDeep( {}, require('../')) 269 | parent = { options: { babel: { plugins: [] } } }; 270 | InlinePrecompile1.parent = parent; 271 | InlinePrecompile2.parent = parent; 272 | 273 | InlinePrecompile1.included(); 274 | configuredPlugins = parent.options.babel.plugins; 275 | expect(configuredPlugins.length).to.eql(1); 276 | InlinePrecompile2.included(); 277 | configuredPlugins = parent.options.babel.plugins; 278 | expect(configuredPlugins.length).to.eql(1); 279 | }); 280 | 281 | it('should have only 1 inlinePrecompile registered for non parallel babel', function() { 282 | registry.add('htmlbars-ast-plugin', nonParallelPlugin); 283 | let InlinePrecompile1 = defaultsDeep( {}, require('../')) 284 | let InlinePrecompile2 = defaultsDeep( {}, require('../')) 285 | parent = { options: { babel: { plugins: [] } } }; 286 | InlinePrecompile1.parent = parent; 287 | InlinePrecompile2.parent = parent; 288 | 289 | InlinePrecompile1.included(); 290 | configuredPlugins = parent.options.babel.plugins; 291 | expect(configuredPlugins.length).to.eql(1); 292 | InlinePrecompile2.included(); 293 | configuredPlugins = parent.options.babel.plugins; 294 | expect(configuredPlugins.length).to.eql(1); 295 | }); 296 | 297 | }); 298 | }); 299 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ember-cli-htmlbars-inline-precompile", 3 | "version": "3.0.2", 4 | "description": "Precompile inline HTMLBars templates via ES6 tagged template strings", 5 | "keywords": [ 6 | "ember-addon", 7 | "ember-cli" 8 | ], 9 | "repository": "https://github.com/ember-cli/ember-cli-htmlbars-inline-precompile", 10 | "license": "MIT", 11 | "author": "Clemens Müller ", 12 | "directories": { 13 | "doc": "doc", 14 | "test": "tests" 15 | }, 16 | "scripts": { 17 | "build": "ember build", 18 | "changelog": "lerna-changelog", 19 | "lint:hbs": "ember-template-lint .", 20 | "lint:js": "eslint .", 21 | "start": "ember serve", 22 | "test": "ember test", 23 | "test:all": "ember try:each", 24 | "test:ember": "ember test", 25 | "test:node": "mocha node-tests/*.js", 26 | "test:node:debug": "mocha debug node-tests/*.js" 27 | }, 28 | "dependencies": { 29 | "babel-plugin-htmlbars-inline-precompile": "^2.1.0", 30 | "ember-cli-version-checker": "^3.1.3", 31 | "hash-for-dep": "^1.5.1", 32 | "heimdalljs-logger": "^0.1.9", 33 | "semver": "^6.3.0", 34 | "silent-error": "^1.1.0" 35 | }, 36 | "devDependencies": { 37 | "@ember/optional-features": "^1.3.0", 38 | "chai": "^4.1.0", 39 | "ember-cli": "~3.9.0", 40 | "ember-cli-babel": "^7.14.1", 41 | "ember-cli-coffeescript": "github:rwjblue/ember-cli-coffeescript#update-version-checker-api", 42 | "ember-cli-dependency-checker": "^3.2.0", 43 | "ember-cli-htmlbars": "^4.0.8", 44 | "ember-cli-inject-live-reload": "^2.0.1", 45 | "ember-cli-lodash-subset": "^2.0.1", 46 | "ember-cli-preprocess-registry": "^3.3.0", 47 | "ember-cli-template-lint": "^1.0.0-beta.3", 48 | "ember-cli-test-loader": "^2.2.0", 49 | "ember-disable-prototype-extensions": "^1.1.3", 50 | "ember-load-initializers": "^2.1.0", 51 | "ember-maybe-import-regenerator": "^0.1.6", 52 | "ember-qunit": "^4.5.1", 53 | "ember-resolver": "^5.3.0", 54 | "ember-source": "~3.12.0", 55 | "ember-source-channel-url": "^2.0.1", 56 | "ember-try": "^1.3.0", 57 | "eslint": "^6.6.0", 58 | "eslint-plugin-ember": "^7.5.0", 59 | "eslint-plugin-node": "^11.1.0", 60 | "htmlbars-comment-redactor": "^0.0.4", 61 | "lerna-changelog": "^0.8.3", 62 | "loader.js": "^4.7.0", 63 | "mocha": "^6.2.2", 64 | "qunit-dom": "^0.9.2", 65 | "release-it": "^12.4.3", 66 | "release-it-lerna-changelog": "^1.0.3", 67 | "username-sync": "^1.0.2" 68 | }, 69 | "peerDependencies": { 70 | "ember-cli-babel": "^7.0.0" 71 | }, 72 | "engines": { 73 | "node": "8.* || 10.* || >= 12.*" 74 | }, 75 | "publishConfig": { 76 | "registry": "https://registry.npmjs.org" 77 | }, 78 | "ember-addon": { 79 | "configPath": "tests/dummy/config", 80 | "after": "ember-cli-htmlbars" 81 | }, 82 | "release-it": { 83 | "plugins": { 84 | "release-it-lerna-changelog": { 85 | "infile": "CHANGELOG.md" 86 | } 87 | }, 88 | "git": { 89 | "tagName": "v${version}" 90 | }, 91 | "github": { 92 | "release": true 93 | } 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /testem.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | test_page: 'tests/index.html?hidepassed', 3 | disable_watching: true, 4 | launch_in_ci: [ 5 | 'Chrome' 6 | ], 7 | launch_in_dev: [ 8 | 'Chrome' 9 | ], 10 | browser_args: { 11 | Chrome: { 12 | ci: [ 13 | // --no-sandbox is needed when running Chrome inside a container 14 | process.env.CI ? '--no-sandbox' : null, 15 | '--headless', 16 | '--disable-dev-shm-usage', 17 | '--mute-audio', 18 | '--remote-debugging-port=0', 19 | '--window-size=1440,900' 20 | ].filter(Boolean) 21 | } 22 | } 23 | }; 24 | -------------------------------------------------------------------------------- /tests/.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "predef": [ 3 | "document", 4 | "window", 5 | "location", 6 | "setTimeout", 7 | "$", 8 | "-Promise", 9 | "define", 10 | "console", 11 | "visit", 12 | "exists", 13 | "fillIn", 14 | "click", 15 | "keyEvent", 16 | "triggerEvent", 17 | "find", 18 | "findWithAssert", 19 | "wait", 20 | "DS", 21 | "andThen", 22 | "currentURL", 23 | "currentPath", 24 | "currentRouteName" 25 | ], 26 | "node": false, 27 | "browser": false, 28 | "boss": true, 29 | "curly": true, 30 | "debug": false, 31 | "devel": false, 32 | "eqeqeq": true, 33 | "evil": true, 34 | "forin": false, 35 | "immed": false, 36 | "laxbreak": false, 37 | "newcap": true, 38 | "noarg": true, 39 | "noempty": false, 40 | "nonew": false, 41 | "nomen": false, 42 | "onevar": false, 43 | "plusplus": false, 44 | "regexp": false, 45 | "undef": true, 46 | "sub": true, 47 | "strict": false, 48 | "white": false, 49 | "eqnull": true, 50 | "esversion": 6, 51 | "unused": true 52 | } 53 | -------------------------------------------------------------------------------- /tests/dummy/app/app.js: -------------------------------------------------------------------------------- 1 | import Application from '@ember/application'; 2 | import Resolver from './resolver'; 3 | import loadInitializers from 'ember-load-initializers'; 4 | import config from './config/environment'; 5 | 6 | const App = Application.extend({ 7 | modulePrefix: config.modulePrefix, 8 | podModulePrefix: config.podModulePrefix, 9 | Resolver 10 | }); 11 | 12 | loadInitializers(App, config.modulePrefix); 13 | 14 | export default App; 15 | -------------------------------------------------------------------------------- /tests/dummy/app/components/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ember-cli/ember-cli-htmlbars-inline-precompile/398686f91132026d66b802687c1eb1f5d1322d9c/tests/dummy/app/components/.gitkeep -------------------------------------------------------------------------------- /tests/dummy/app/components/comment-redact.js: -------------------------------------------------------------------------------- 1 | import Component from '@ember/component'; 2 | import hbs from 'htmlbars-inline-precompile'; 3 | 4 | export default Component.extend({ 5 | layout: hbs('

') 6 | }); 7 | -------------------------------------------------------------------------------- /tests/dummy/app/components/days-ago.js: -------------------------------------------------------------------------------- 1 | import Component from '@ember/component'; 2 | 3 | export default Component.extend({ 4 | daysAgo: 42 5 | }); 6 | -------------------------------------------------------------------------------- /tests/dummy/app/components/inline-precompilation.js: -------------------------------------------------------------------------------- 1 | import Component from '@ember/component'; 2 | import hbs from 'htmlbars-inline-precompile'; 3 | 4 | export default Component.extend({ 5 | greeting: "hello from view", 6 | layout: hbs`greeting: {{greeting}}` 7 | }); 8 | -------------------------------------------------------------------------------- /tests/dummy/app/components/multiline-string.js: -------------------------------------------------------------------------------- 1 | import Component from '@ember/component'; 2 | import hbs from 'htmlbars-inline-precompile'; 3 | 4 | export default Component.extend({ 5 | greeting: "hello from view", 6 | layout: hbs` 7 | greeting: {{greeting}} 8 | ` 9 | }); 10 | -------------------------------------------------------------------------------- /tests/dummy/app/components/string-parameter.js: -------------------------------------------------------------------------------- 1 | import Component from '@ember/component'; 2 | import hbs from 'htmlbars-inline-precompile'; 3 | 4 | export default Component.extend({ 5 | greeting: "hello", 6 | layout: hbs('

{{greeting}}

') 7 | }); 8 | -------------------------------------------------------------------------------- /tests/dummy/app/controllers/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ember-cli/ember-cli-htmlbars-inline-precompile/398686f91132026d66b802687c1eb1f5d1322d9c/tests/dummy/app/controllers/.gitkeep -------------------------------------------------------------------------------- /tests/dummy/app/helpers/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ember-cli/ember-cli-htmlbars-inline-precompile/398686f91132026d66b802687c1eb1f5d1322d9c/tests/dummy/app/helpers/.gitkeep -------------------------------------------------------------------------------- /tests/dummy/app/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Dummy 7 | 8 | 9 | 10 | {{content-for "head"}} 11 | 12 | 13 | 14 | 15 | {{content-for "head-footer"}} 16 | 17 | 18 | {{content-for "body"}} 19 | 20 | 21 | 22 | 23 | {{content-for "body-footer"}} 24 | 25 | 26 | -------------------------------------------------------------------------------- /tests/dummy/app/models/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ember-cli/ember-cli-htmlbars-inline-precompile/398686f91132026d66b802687c1eb1f5d1322d9c/tests/dummy/app/models/.gitkeep -------------------------------------------------------------------------------- /tests/dummy/app/resolver.js: -------------------------------------------------------------------------------- 1 | import Resolver from 'ember-resolver'; 2 | 3 | export default Resolver; 4 | -------------------------------------------------------------------------------- /tests/dummy/app/router.js: -------------------------------------------------------------------------------- 1 | import EmberRouter from '@ember/routing/router'; 2 | import config from './config/environment'; 3 | 4 | const Router = EmberRouter.extend({ 5 | location: config.locationType, 6 | rootURL: config.rootURL 7 | }); 8 | 9 | Router.map(function() { 10 | }); 11 | 12 | export default Router; 13 | -------------------------------------------------------------------------------- /tests/dummy/app/routes/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ember-cli/ember-cli-htmlbars-inline-precompile/398686f91132026d66b802687c1eb1f5d1322d9c/tests/dummy/app/routes/.gitkeep -------------------------------------------------------------------------------- /tests/dummy/app/styles/app.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ember-cli/ember-cli-htmlbars-inline-precompile/398686f91132026d66b802687c1eb1f5d1322d9c/tests/dummy/app/styles/app.css -------------------------------------------------------------------------------- /tests/dummy/app/templates/application.hbs: -------------------------------------------------------------------------------- 1 |

Welcome to Ember

2 | 3 | {{outlet}} -------------------------------------------------------------------------------- /tests/dummy/app/templates/components/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ember-cli/ember-cli-htmlbars-inline-precompile/398686f91132026d66b802687c1eb1f5d1322d9c/tests/dummy/app/templates/components/.gitkeep -------------------------------------------------------------------------------- /tests/dummy/app/templates/components/days-ago.hbs: -------------------------------------------------------------------------------- 1 | {{yield date daysAgo }} 2 | -------------------------------------------------------------------------------- /tests/dummy/app/views/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ember-cli/ember-cli-htmlbars-inline-precompile/398686f91132026d66b802687c1eb1f5d1322d9c/tests/dummy/app/views/.gitkeep -------------------------------------------------------------------------------- /tests/dummy/config/environment.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = function(environment) { 4 | let ENV = { 5 | modulePrefix: 'dummy', 6 | environment, 7 | rootURL: '/', 8 | locationType: 'auto', 9 | EmberENV: { 10 | FEATURES: { 11 | // Here you can enable experimental features on an ember canary build 12 | // e.g. 'with-controller': true 13 | }, 14 | EXTEND_PROTOTYPES: { 15 | // Prevent Ember Data from overriding Date.parse. 16 | Date: false 17 | } 18 | }, 19 | 20 | APP: { 21 | // Here you can pass flags/options to your application instance 22 | // when it is created 23 | } 24 | }; 25 | 26 | if (environment === 'development') { 27 | // ENV.APP.LOG_RESOLVER = true; 28 | // ENV.APP.LOG_ACTIVE_GENERATION = true; 29 | // ENV.APP.LOG_TRANSITIONS = true; 30 | // ENV.APP.LOG_TRANSITIONS_INTERNAL = true; 31 | // ENV.APP.LOG_VIEW_LOOKUPS = true; 32 | } 33 | 34 | if (environment === 'test') { 35 | // Testem prefers this... 36 | ENV.locationType = 'none'; 37 | 38 | // keep test console output quieter 39 | ENV.APP.LOG_ACTIVE_GENERATION = false; 40 | ENV.APP.LOG_VIEW_LOOKUPS = false; 41 | 42 | ENV.APP.rootElement = '#ember-testing'; 43 | ENV.APP.autoboot = false; 44 | } 45 | 46 | if (environment === 'production') { 47 | // here you can enable a production-specific feature 48 | } 49 | 50 | return ENV; 51 | }; 52 | -------------------------------------------------------------------------------- /tests/dummy/config/optional-features.json: -------------------------------------------------------------------------------- 1 | { 2 | "jquery-integration": false 3 | } 4 | -------------------------------------------------------------------------------- /tests/dummy/config/targets.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const browsers = [ 4 | 'last 1 Chrome versions', 5 | 'last 1 Firefox versions', 6 | 'last 1 Safari versions' 7 | ]; 8 | 9 | const isCI = !!process.env.CI; 10 | const isProduction = process.env.EMBER_ENV === 'production'; 11 | 12 | if (isCI || isProduction) { 13 | browsers.push('ie 11'); 14 | } 15 | 16 | module.exports = { 17 | browsers 18 | }; 19 | -------------------------------------------------------------------------------- /tests/dummy/public/robots.txt: -------------------------------------------------------------------------------- 1 | # http://www.robotstxt.org 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /tests/helpers/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ember-cli/ember-cli-htmlbars-inline-precompile/398686f91132026d66b802687c1eb1f5d1322d9c/tests/helpers/.gitkeep -------------------------------------------------------------------------------- /tests/helpers/start-app.js: -------------------------------------------------------------------------------- 1 | import Application from '../../app'; 2 | import config from '../../config/environment'; 3 | import { merge } from '@ember/polyfills'; 4 | import { run } from '@ember/runloop'; 5 | 6 | export default function startApp(attrs) { 7 | let application; 8 | 9 | let attributes = merge({}, config.APP); 10 | attributes = merge(attributes, attrs); // use defaults, but you can override; 11 | 12 | run(() => { 13 | application = Application.create(attributes); 14 | application.setupForTesting(); 15 | application.injectTestHelpers(); 16 | }); 17 | 18 | return application; 19 | } 20 | -------------------------------------------------------------------------------- /tests/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Dummy Tests 7 | 8 | 9 | 10 | {{content-for "head"}} 11 | {{content-for "test-head"}} 12 | 13 | 14 | 15 | 16 | 17 | {{content-for "head-footer"}} 18 | {{content-for "test-head-footer"}} 19 | 20 | 21 | {{content-for "body"}} 22 | {{content-for "test-body"}} 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | {{content-for "body-footer"}} 31 | {{content-for "test-body-footer"}} 32 | 33 | 34 | -------------------------------------------------------------------------------- /tests/test-helper.js: -------------------------------------------------------------------------------- 1 | import Application from '../app'; 2 | import config from '../config/environment'; 3 | import { setApplication } from '@ember/test-helpers'; 4 | import { start } from 'ember-qunit'; 5 | 6 | setApplication(Application.create(config.APP)); 7 | 8 | start(); 9 | -------------------------------------------------------------------------------- /tests/unit/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ember-cli/ember-cli-htmlbars-inline-precompile/398686f91132026d66b802687c1eb1f5d1322d9c/tests/unit/.gitkeep -------------------------------------------------------------------------------- /tests/unit/components/coffeescript-support-test.coffee: -------------------------------------------------------------------------------- 1 | `import hbs from 'htmlbars-inline-precompile';` 2 | `import { moduleForComponent, test } from 'ember-qunit';` 3 | 4 | moduleForComponent('days-ago', { 5 | integration: true 6 | }); 7 | 8 | test 'Invocation within Cofeescript works using single string argument', (assert) -> 9 | @render hbs """ 10 | {{#days-ago date=theDate as |date daysAgo| }} 11 | date='{{date}}' daysAgo={{daysAgo}} 12 | {{/days-ago}} 13 | """ 14 | 15 | assert.dom().hasText "date='' daysAgo=42" 16 | 17 | @set 'theDate', "the date" 18 | 19 | assert.dom().hasText "date='the date' daysAgo=42" 20 | -------------------------------------------------------------------------------- /tests/unit/components/comment-redact-test.js: -------------------------------------------------------------------------------- 1 | import hbs from 'htmlbars-inline-precompile'; 2 | import { moduleForComponent, test } from 'ember-qunit'; 3 | 4 | moduleForComponent('comment-redact', { 5 | integration: true 6 | }); 7 | 8 | test('htmlbars-ast-plugin addon redacts comment contents', function(assert) { 9 | this.render(hbs`{{comment-redact}}`); 10 | 11 | assert.dom('#comment').isNotVisible(); 12 | }); 13 | -------------------------------------------------------------------------------- /tests/unit/components/days-ago-test.js: -------------------------------------------------------------------------------- 1 | import hbs from 'htmlbars-inline-precompile'; 2 | import { moduleForComponent, test } from 'ember-qunit'; 3 | 4 | moduleForComponent('days-ago', { 5 | integration: true 6 | }); 7 | 8 | test('block params work', function(assert) { 9 | this.render(hbs` 10 | {{#days-ago date=theDate as |date daysAgo| }} 11 | date='{{date}}' daysAgo={{daysAgo}} 12 | {{/days-ago}} 13 | `); 14 | 15 | assert.dom().hasText("date='' daysAgo=42"); 16 | 17 | this.set('theDate', "the date"); 18 | 19 | assert.dom().hasText("date='the date' daysAgo=42"); 20 | }); 21 | -------------------------------------------------------------------------------- /tests/unit/components/inline-precompilation-test.js: -------------------------------------------------------------------------------- 1 | import hbs from 'htmlbars-inline-precompile'; 2 | import hbs2 from 'ember-cli-htmlbars-inline-precompile'; 3 | import { moduleForComponent, test } from 'ember-qunit'; 4 | 5 | moduleForComponent('inline-precompilation', { 6 | integration: true 7 | }); 8 | 9 | test('using `hbs` tagged string places the precompiled template', function(assert) { 10 | this.render(hbs`{{inline-precompilation}}`); 11 | 12 | assert.dom().hasText("greeting: hello from view", "inline precompile of the HTMLBars template works"); 13 | }); 14 | 15 | test('using `hbs` tagged string from `ember-cli-htmlbars-inline-precompile` replaces the precompiled template', function(assert) { 16 | this.render(hbs2`{{inline-precompilation}}`); 17 | 18 | assert.dom().hasText("greeting: hello from view", "inline precompile of the HTMLBars template works"); 19 | }); 20 | -------------------------------------------------------------------------------- /tests/unit/components/multiline-string-test.js: -------------------------------------------------------------------------------- 1 | import hbs from 'htmlbars-inline-precompile'; 2 | import { moduleForComponent, test } from 'ember-qunit'; 3 | 4 | moduleForComponent('multiline-string', { 5 | integration: true 6 | }); 7 | 8 | test('using `hbs` tagged string places the precompiled template', function(assert) { 9 | this.render(hbs`{{multiline-string}}`); 10 | 11 | assert.dom().hasText("greeting: hello from view", "multiline string works"); 12 | }); 13 | -------------------------------------------------------------------------------- /tests/unit/components/string-parameter-test.js: -------------------------------------------------------------------------------- 1 | import hbs from 'htmlbars-inline-precompile'; 2 | import { moduleForComponent, test } from 'ember-qunit'; 3 | 4 | moduleForComponent('string-parameter', { 5 | integration: true 6 | }); 7 | 8 | test('using `hbs` tagged string places the precompiled template', function(assert) { 9 | this.render(hbs`{{string-parameter}}`); 10 | 11 | assert.dom().hasText('hello'); 12 | }); 13 | --------------------------------------------------------------------------------