Skip to content

Commit

Permalink
Reproduce error when staticHelpers is false
Browse files Browse the repository at this point in the history
  • Loading branch information
balinterdi committed Nov 19, 2024
1 parent b0ba32e commit 0e6ac2e
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 53 deletions.
70 changes: 20 additions & 50 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,57 +1,27 @@
# class-based-helpers-disambiguation
# Helpers disambiguation for Embroider

This README outlines the details of collaborating on this Ember application.
A short introduction of this app could easily go here.
A minimal repro for the issue of class-based helpers breaking when called in the unambiguous way:

## Prerequisites
`{{(translate)}}

You will need the following things properly installed on your computer.
It turns out that no matter what kind of helper you have (class-based, functional or plain-function), they all break when called as above.

- [Git](https://git-scm.com/)
- [Node.js](https://nodejs.org/)
- [pnpm](https://pnpm.io/)
- [Ember CLI](https://cli.emberjs.com/release/)
- [Google Chrome](https://google.com/chrome/)
What matters is that `staticHelpers` be set to `false` in the config.

## Installation
If it is, it breaks with the following:

- `git clone <repository-url>` this repository
- `cd class-based-helpers-disambiguation`
- `pnpm install`
```
Uncaught TypeError: func is not a function
at Compilers.compile (opcode-compiler.js:417:1)
at expr (opcode-compiler.js:587:1)
at opcode-compiler.js:1799:1
at SwitchCases (opcode-compiler.js:943:1)
at opcode-compiler.js:1798:1
at Compilers.compile (opcode-compiler.js:417:1)
at compileStatements (opcode-compiler.js:2070:1)
at maybeCompile (opcode-compiler.js:2049:1)
at CompilableTemplateImpl.compile (opcode-compiler.js:2032:1)
at Object.evaluate (runtime.js:2973:1)
```

## Running / Development

- `pnpm start`
- Visit your app at [http://localhost:4200](http://localhost:4200).
- Visit your tests at [http://localhost:4200/tests](http://localhost:4200/tests).

### Code Generators

Make use of the many generators for code, try `ember help generate` for more details

### Running Tests

- `pnpm test`
- `pnpm test:ember --server`

### Linting

- `pnpm lint`
- `pnpm lint:fix`

### Building

- `pnpm ember build` (development)
- `pnpm build` (production)

### Deploying

Specify what it takes to deploy your app.

## Further Reading / Useful Links

- [ember.js](https://emberjs.com/)
- [ember-cli](https://cli.emberjs.com/release/)
- Development Browser Extensions
- [ember inspector for chrome](https://chrome.google.com/webstore/detail/ember-inspector/bmdblncegkenkacieihfhpjfppoconhi)
- [ember inspector for firefox](https://addons.mozilla.org/en-US/firefox/addon/ember-inspector/)
If the `staticHelpers` is set to `true`, it works fine.
7 changes: 7 additions & 0 deletions app/helpers/functional-translate.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { helper } from '@ember/component/helper';

export function functionalTranslate() {
return 'Papillon';
}

export default helper(functionalTranslate);
3 changes: 3 additions & 0 deletions app/helpers/plain-fn-translate.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function substring() {
return 'Papillon';
}
3 changes: 3 additions & 0 deletions app/templates/index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,7 @@
></path></svg>

{{(translate)}}
{{(functional-translate)}}
{{(plain-fn-translate)}}

</div>
6 changes: 3 additions & 3 deletions ember-cli-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ module.exports = function (defaults) {
return require('@embroider/compat').compatBuild(app, Webpack, {
staticAddonTestSupportTrees: true,
staticAddonTrees: true,
staticHelpers: true,
staticModifiers: true,
staticComponents: true,
staticHelpers: false,
staticModifiers: false,
staticComponents: false,
staticEmberSource: true,
skipBabel: [
{
Expand Down

0 comments on commit 0e6ac2e

Please sign in to comment.