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

Fixed date/color knobs by forcing a single version of react #1345

Closed
wants to merge 5 commits into from

Conversation

ndelangen
Copy link
Member

Issue: broken UI widgets caused by multiple instances of react during development

What I did

Add a webpack resolve for react so it's always loaded from a single place

How to test

  • bootstrap
  • run storybook kitchensink
  • open button knobs story
  • use color and datetime picker

@ndelangen ndelangen requested a review from shilman June 22, 2017 23:28
@ndelangen ndelangen self-assigned this Jun 22, 2017
@codecov
Copy link

codecov bot commented Jun 22, 2017

Codecov Report

Merging #1345 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #1345   +/-   ##
=======================================
  Coverage   13.76%   13.76%           
=======================================
  Files         202      202           
  Lines        4621     4621           
  Branches      598      618   +20     
=======================================
  Hits          636      636           
+ Misses       3473     3462   -11     
- Partials      512      523   +11
Impacted Files Coverage Δ
app/react/src/server/config/webpack.config.prod.js 0% <ø> (ø) ⬆️
app/react/src/server/config/webpack.config.js 0% <ø> (ø) ⬆️
app/react-native/src/bin/storybook-build.js 0% <0%> (ø) ⬆️
lib/ui/src/modules/api/configs/init_api.js 40.47% <0%> (ø) ⬆️
addons/info/src/components/markdown/htags.js 0% <0%> (ø) ⬆️
app/react/src/demo/Welcome.js 0% <0%> (ø) ⬆️
...src/server/config/WatchMissingNodeModulesPlugin.js 0% <0%> (ø) ⬆️
.../ui/src/modules/ui/components/left_panel/header.js 27.58% <0%> (ø) ⬆️
addons/info/src/components/Node.js 0% <0%> (ø) ⬆️
addons/storyshots/src/require_context.js 0% <0%> (ø) ⬆️
... and 18 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bf6faea...a81c2d4. Read the comment docs.

@@ -58,6 +58,7 @@ storiesOf('Button', module)

// NOTE: color picker is currently broken
Copy link
Member

@shilman shilman Jun 22, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ndelangen if it's fixed, please remove this 😄

@@ -20,9 +20,6 @@
"type": "git",
"url": "https://github.com/storybooks/storybook.git"
},
"scripts": {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ndelangen remove opencollective deps?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah the postinstall was messing with hoisting which I experimented with, When refactoring the cli I will add a opencollective notice during first run or something like it.

@@ -9,11 +9,15 @@ shell.echo(chalk.bold(`${packageJson.name}@${packageJson.version}`));
shell.echo(chalk.gray('\n=> Clean dist.'));
shell.rm('-rf', 'dist');

const pwd = shell.pwd();
shell.echo(`pwd = ${pwd}`);
shell.cd(path.join(__dirname, '..'));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ndelangen what's this for?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Babel WAS run inside each folder, using the babel binary from root, but presets from package folders.

This changes so the directory where babel is run from IS root, so presets are taken from there. This will allow us to clean up the babel presets dependencies in packages a bit.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain this a bit more? Doesn't babel end up looking for the preset in root if it doesn't find it in the package anyway (w/ standard node_modules resolution algorithm).

@storybookbot
Copy link
Collaborator

Fails
🚫

PR is not labeled with one of: ["cleanup","breaking","feature","bug","documentation","maintenance","greenkeeper","other"]

Generated by 🚫 dangerJS

Copy link
Member

@shilman shilman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ndelangen this is beautiful. i don't understand what's going on, so some comments would help, and see my other comments as well, but this is a great fix. thanks for figuring it out! WIZARD.

@shilman shilman added the bug label Jun 22, 2017
@shilman shilman changed the title Unbreak npm Fixed broken date and color knobs by forcing a single version of react Jun 22, 2017
@shilman shilman changed the title Fixed broken date and color knobs by forcing a single version of react Fixed date and color knobs by forcing a single version of react Jun 22, 2017
@shilman shilman changed the title Fixed date and color knobs by forcing a single version of react Fixed date/color knobs by forcing a single version of react Jun 22, 2017
@tmeasday
Copy link
Member

Wouldn't it be better to sort out the actual problem? Why are there multiple instances of React?

Copy link
Member

@tmeasday tmeasday left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this PR should be split up into different parts, it seems to be doing a few things at once that should be discussed separately

@@ -1,17 +1,20 @@
node_modules
*.log
.idea

package-lock.json
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should be ignoring these files (also yarn.lock)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tmeasday see my PR here: #1338

We tried merging in the package lock, but it broke everything, and I pulled it out. I think until somebody figures out what to do here, we are better off not checking them in and ignoring them so that they don't accidentally get checked in.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess that makes sense but it certainly feels weird to be ignoring a file that npm tells you to check in. We should open an issue about this I guess

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -9,11 +9,15 @@ shell.echo(chalk.bold(`${packageJson.name}@${packageJson.version}`));
shell.echo(chalk.gray('\n=> Clean dist.'));
shell.rm('-rf', 'dist');

const pwd = shell.pwd();
shell.echo(`pwd = ${pwd}`);
shell.cd(path.join(__dirname, '..'));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain this a bit more? Doesn't babel end up looking for the preset in root if it doesn't find it in the package anyway (w/ standard node_modules resolution algorithm).

@tmeasday
Copy link
Member

If my understanding is correct, this issue is caused by multiple loading problems due to npm linking.

Is it an issue that affects actual apps (i.e. w/o linking)? If not, we should NOT be changing the behaviour of the library to serve our testing purposes IMO.

There are two ways forward w/o this change:

  1. Use test-cra which thanks to Setup test-cra to use tarballs #1331 doesn't use linking and so should be immune to this kind of issue.
  2. Think about ways to solve the multiple loading problem. Can lerna help us here? For instance, can we hoist the react dependency up to the top-level so all packages end up using that?

@shilman
Copy link
Member

shilman commented Jul 15, 2017

@ndelangen Date/color knobs seem to be working again, independent of this change. OK if I close this?

@shilman
Copy link
Member

shilman commented Jul 22, 2017

@ndelangen can we close this now?

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

Successfully merging this pull request may close these issues.

4 participants