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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transpiling error in Ember 4 without embroider #393

Closed
BryanCrotaz opened this issue Nov 7, 2022 · 3 comments · Fixed by #396
Closed

Transpiling error in Ember 4 without embroider #393

BryanCrotaz opened this issue Nov 7, 2022 · 3 comments · Fixed by #396

Comments

@BryanCrotaz
Copy link
Contributor

BryanCrotaz commented Nov 7, 2022

The below only happens when not using embroider.

Line 352 of radar.js

    assert('Must provide a `estimateHeight` value to vertical-collection', estimateHeight !== null);

is being transpiled to

      (!(estimateHeight !== null) && Ember.assert('Must provide a `estimateHeight` value to vertical-collection', estimateHeight !== null));

This causes the error Ember is not defined

package.json

@BryanCrotaz
Copy link
Contributor Author

BryanCrotaz commented Nov 9, 2022

Can reproduce with a new app:

ember new test-transpile --yarn
cd test-transpile
yarn
ember install @html-next/vertical-collection
ember g controller application
ember s

In application controller:

get items() {
  return ['a', 'b'];
}

In application template:

<VerticalCollection @items={{this.items}} as |item|>
  <div>{{item}}</div>
</VerticalCollection>
> ember --version
ember-cli: 4.8.0
node: 14.20.0
os: darwin x64

@BryanCrotaz
Copy link
Contributor Author

@BryanCrotaz BryanCrotaz changed the title Transpiling error in Ember 4 Transpiling error in Ember 4 without embroider Nov 9, 2022
@ef4
Copy link

ef4 commented Nov 10, 2022

I found the problem. vertical-collection's customized rollup-based build is not compatible with ember 4, because it uses compileModules: false here:

compileModules: false,

But in ember-cli-babel, that forces you into globals mode, meaning import { assert } from '@ember/debug' gets compiled to Ember.assert(), which doesn't exist anymore starting at Ember 4. See:

https://github.com/babel/ember-cli-babel/blob/3ce768ada9202c0455f87511ab95acf667d0c97e/lib/babel-options-util.js#L94-L98

The comment there suggests you can set disableDebugTooling to true to stop this behavior.

But really vertical-collection should absolutely just delete all this custom build code.

The reason it works on Embroider is that Embroider already ships with a compatibility rule that completely ignores vertical-collection's custom build, because that build is fragile and locked into the classic ember-cli 3.x way of doing things:

https://github.com/embroider-build/embroider/blob/d31bee3c8fafdea6308b80642b5e56971cfd0caa/packages/compat/src/compat-adapters/%40html-next/vertical-collection.ts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants