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

Ember: Module not found: Error: Can't resolve 'fs' in monorepo #9712

Closed
gossi opened this issue Feb 2, 2020 · 8 comments
Closed

Ember: Module not found: Error: Can't resolve 'fs' in monorepo #9712

gossi opened this issue Feb 2, 2020 · 8 comments

Comments

@gossi
Copy link
Contributor

gossi commented Feb 2, 2020

When using the new import module: import { hbs } from 'ember-cli-htmlbars;' it will fail when used in a monorepo. The upgrade was introduced with this PR: #9633

Module not found: Error: Can't resolve 'fs'

In short:

  • v5.3.10 - import { hbs } from 'ember-cli-htmlbars;' works, when the storyfile is in the same directory as the sb project
  • v6 - the above also works when the story is in another folder

Reproduction

https://github.com/gossi/hokulea - Check out run ember serve in the /explorer dir and yarn storybook parallel to (I run them in parallel atm)

If you move /explorer/stories/button.js to /components/buttons/addon/components/button/story.js it will fail when you execute the commands above

Analysis

My suggestion here is, that v6 has some changes that made it work with monorepos but that didn't got cherry-picked for 5.3.

Risk Assessment

At the moment, this is not a risk as this wasn't working before with the old syntax either.

@stale
Copy link

stale bot commented Feb 24, 2020

Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks!

@stale stale bot added the inactive label Feb 24, 2020
@stale
Copy link

stale bot commented Mar 26, 2020

Hey there, it's me again! I am going close this issue to help our maintainers focus on the current development roadmap instead. If the issue mentioned is still a concern, please open a new ticket and mention this old one. Cheers and thanks for using Storybook!

@stale stale bot closed this as completed Mar 26, 2020
@iamareebjamal
Copy link

Facing this issue. Any solutions?

I'm using import { hbs } from 'ember-cli-htmlbars';
Used this #4082 (comment), and got this error stefanpenner/username-sync#3, added it to config as well, and now the project runs but throws error at runtime at should-preserve-symlinks.js which is trying to access process args and they are undefined

@gossi
Copy link
Contributor Author

gossi commented Apr 16, 2020

import { hbs } from 'ember-cli-htmlbars'; works with storybook v5.3.10 in a manyrepo (but just one - ie no monorepo).

Ember and monorepo support is coming with v6. I'm using storybook@next in my ember monorepo and it is working quite well - if you wanna go adventureous

@iamareebjamal
Copy link

But this works in 5.3.18 as well. https://github.com/storybookjs/storybook/tree/v5.3.18/examples/ember-cli/
And we have the same setup. An ember app repo with storybook. But in my repo, I am getting these errors. Even after manually editing should-preserve-symlinks.js, it proceeds but I get another error

Object(...) is not a function
TypeError: Object(...) is not a function

I am surely missing something because everything works in the example repo
This is the PR for reference - fossasia/open-event-frontend#4325

@gossi
Copy link
Contributor Author

gossi commented Apr 17, 2020

The storybook examples:

  "dependencies": {
    "ember-template-compiler": "^1.9.0-alpha"
  }

I'm not sure here, but I use it with addons and ember-cli-htmlbars in dependencies - I'd try that with an app, too.

@iamareebjamal
Copy link

Still the same error. However I got the issue. It gets transpiled to

var ToStorybook = function ToStorybook() {
  return {
    template: Object(ember_cli_htmlbars__WEBPACK_IMPORTED_MODULE_3__["hbs"])(_templateObject()),
    context: {
      onClick: Object(_storybook_addon_links__WEBPACK_IMPORTED_MODULE_4__["linkTo"])('Button')
    }
  };
};

ember_cli_htmlbars__WEBPACK_IMPORTED_MODULE_3__ has no entry for 'hbs' and hence it turns to Object(undefined) which then throws Object is not a function. Wasn't super easy to debug because of webpack source maps throwing me back at source code again and again. Any idea what might be causing this?

@iamareebjamal
Copy link

iamareebjamal commented Apr 18, 2020

This is related to storybookjs/ember-cli-storybook#20
More info in upstream bug - ember-cli/ember-cli-htmlbars#524

Not sure what to do further

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

3 participants