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

Storybook broken in Ember 4.X #18028

Open
bakerac4 opened this issue Apr 22, 2022 · 8 comments
Open

Storybook broken in Ember 4.X #18028

bakerac4 opened this issue Apr 22, 2022 · 8 comments

Comments

@bakerac4
Copy link

Describe the bug
Storybook is completely broken when trying to use it in Ember 4.X
Ember 4 removes deprecated features, one of those being Global Ember usage.
See storybookjs/ember-cli-storybook#103 for more information

After doing a bit of research there are a few target areas that will need to be fixed.

  1. You'll need to use babel-plugin-ember-template-compilation here
var extraPlugins = [[require.resolve('babel-plugin-ember-template-compilation'), {
      precompile: precompileWithPlugins,
      outputModuleOverrides: {
            '@ember/template-factory': {
              createTemplateFactory: ['createTemplateFactory', '@glimmer/core'],
            }
          },
    enableLegacyModules: ['ember-cli-htmlbars', 'ember-cli-htmlbars-inline-precompile', 'htmlbars-inline-precompile']
  }]];
  1. You'll need to update

    Ember.Component.extend({
    to remove the global ember usage. There is a pull request for this already, but Im not quite sure if you will also have to update it to be a glimmer component and use setComponentTemplate.

  2. You might need Duplicate @glimmer/validator library blocks rendering glimmerjs/glimmer-vm#1252 to be fixed - because you'll run into that once you make the first change.

Even with all this, I still wasn't able to get it 100% working - but I was able to bypass the Ember is not defined error.

@dbendaou
Copy link
Member

dbendaou commented Apr 27, 2022

For the 2nd one there's a MR open already #17843

We could switch to glimmer but that should be enough for fixing the Ember is not defined wdyt?

@bakerac4
Copy link
Author

bakerac4 commented May 3, 2022

Im by no means an expert in the internals of ember, or storybook at all (I really just wanted to try storybook for the first time haha) but it seems like you would need to attack it from multiple sides due to how storybook renders.

It seems to take your template on client side and convert it via template compiler. Then it uses that compiled template on the server side. And both "sides" actually have an issue with using the global Ember variable.

@RobbieTheWagner
Copy link

Any updates here? I'm having a lot of Ember 4 / addon v2 issues.

@dbendaou
Copy link
Member

Can you copy past which errors you have? I have an ember addon working with Ember 4 & embroider safe
The only issue that I got was related to doc.json not working (API of component through YUIdoc)

@pomm0
Copy link

pomm0 commented Nov 25, 2022

I'm also not able to update my addon to Ember version 4. But I stuck at the very first step: installing node modules because storybooks' package.json only allows ember 3.x:

"ember-source": "^3.16.0"

@olyckne
Copy link

olyckne commented Nov 28, 2022

@pomm0
I've solved that by putting an override in package.json.

"overrides": {
    "@storybook/ember": {
      "ember-source": "~4.8.0"
    },
}

@jayjayjpg
Copy link

In an Ember 4 addon that I'm trying to upgrade with the respective new version of storybook@6.5.15, I can see that the missing Ember global error has disappeared, but I'm running into additional build issues when running npm run storybook:

99% done plugins webpack-hot-middlewarewebpack built preview dce4affe3ddb6eed9fb4 in 8894ms
ModuleNotFoundError: Module not found: Error: Can't resolve '@ember/component' in '/my/path/ember4-storybook-example-addon/node_modules/@storybook/ember/dist/esm/client/preview'

// ...

  Parsed request is a module
  using description file: /my/path/ember4-storybook-example-addon/node_modules/@storybook/ember/package.json (relative path: ./dist/esm/client/preview)
    Field 'browser' doesn't contain a valid alias configuration
    resolve as module

I also created a reproduction repository here in case it is helpful as a reference: https://github.com/jayjayjpg/ember4-storybook-example-addon

Is there a way to contribute to a fix in @storybook/ember for this issue?

@robclancy
Copy link

This @ember/component issue seems to be one that is being ignored. I downgraded because of it and then run into the issue with the Ember global.

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

No branches or pull requests

7 participants