Skip to content

Commit

Permalink
big cleanup
Browse files Browse the repository at this point in the history
Lots of code here isn't needed anymore because we dropped support for the last ember versions that needed moduleApiPolyfill, which means we can always use babel-plugin-ember-template-compilation, which is smart enough to handle its own parallelizability.
  • Loading branch information
ef4 committed Dec 22, 2023
1 parent 4721f12 commit 66b1a7a
Show file tree
Hide file tree
Showing 13 changed files with 141 additions and 1,691 deletions.
86 changes: 3 additions & 83 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,67 +4,9 @@

## Compatibility

* Ember.js v3.8 or above
* Ember CLI v3.8 or above
* Node.js v12 or above

## Tagged Template Usage / Migrating from `htmlbars-inline-precompile`

Starting with version 4.0, this addon now includes the testing helper from [ember-cli-htmlbars-inline-precompile](https://github.com/ember-cli/ember-cli-htmlbars-inline-precompile)

This will require an update to the imports of the `hbs` helper in your tests:

Prior syntax:

```
import hbs from 'htmlbars-inline-precompile';
...
await render(hbs`
<MyComponent />
`);
```

New syntax:

```
import { hbs } from 'ember-cli-htmlbars';
...
await render(hbs`
<MyComponent />
`);
```

There is a [codemod](https://github.com/ember-codemods/ember-cli-htmlbars-inline-precompile-codemod) available to automate this change.

## Additional Trees

For addons which want additional customizations, they are able to interact with
this addon directly.

```ts
interface EmberCLIHTMLBars {
/**
Supports easier transpilation of non-standard input paths (e.g. to transpile
a non-addon NPM dependency) while still leveraging the logic within
ember-cli-htmlbars for transpiling (e.g. custom AST transforms, colocation, etc).
*/
transpileTree(inputTree: BroccoliTree): BroccoliTree;
}
```

### `transpileTree` usage

```js
// find the ember-cli-htmlbars addon
let htmlbarsAddon = this.addons.find(addon => addon.name === 'ember-cli-htmlbars');

// invoke .transpileTree passing in the custom input tree
let transpiledCustomTree = htmlbarsAddon.transpileTree(someCustomTree);
```
* Ember.js v4.12 or above
* Ember CLI v4.12 or above
* Node.js v18 or above

## Adding Custom Plugins

Expand Down Expand Up @@ -141,28 +83,6 @@ export interface ASTPluginWithDeps extends ASTPlugin {
}
```

## Precompile HTMLBars template strings within other addons

```javascript
module.exports = {
name: 'my-addon-name',

setupPreprocessorRegistry: function(type, registry) {
var htmlbarsPlugin = registry.load('template').find(function(plugin) {
return plugin.name === 'ember-cli-htmlbars';
});

// precompile any htmlbars template string via the precompile method on the
// ember-cli-htmlbars plugin wrapper; `precompiled` will be a string of the
// form:
//
// Ember.HTMLBars.template(function() {...})
//
var precompiled = htmlbarsPlugin.precompile("{{my-component}}");
}
};
```

### Custom Template Compiler

You can still provide a custom path to the template compiler (e.g. to test
Expand Down
71 changes: 0 additions & 71 deletions lib/addDependencyTracker.js

This file was deleted.

13 changes: 3 additions & 10 deletions lib/colocated-babel-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,9 @@ module.exports = function (babel) {
let t = babel.types;

function makeSetComponentTemplateExpression(state) {
if (!state.opts.requiresModuleApiPolyfill) {
return state._colocationEnsureImport(
'setComponentTemplate',
'@ember/component',
);
}

return t.memberExpression(
t.identifier('Ember'),
t.identifier('_setComponentTemplate'),
return state._colocationEnsureImport(
'setComponentTemplate',
'@ember/component',
);
}

Expand Down
Loading

0 comments on commit 66b1a7a

Please sign in to comment.