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

Core separate manager from preview #4590

Merged
merged 37 commits into from
Nov 12, 2018
Merged

Conversation

ndelangen
Copy link
Member

I've separated the manager from the preview webpack build.

The manager is now build in a separate child process.

this better isolates the user's code, because the webpack config is no longer shared between manager & preview.

This makes it possible for 2 versions of react to exist: 1 in preview, 1 in manager.
Or the preview react to be swapped with a react compatible lib like preact.

Also, previously conflicting webpack loaders are now possible.
We no longer need to blacklist/whitelist modules in loaders to make sure they do not double apply.

In essence: the users can now be given far more control of the webpack config.


This ties into presets.

Preset have the ability to add babel|webpack config to the preview and manager separately.

# Conflicts:
#	addons/storyshots/storyshots-core/package.json
#	lib/core/package.json
igor-dv and others added 5 commits November 5, 2018 19:15
…-from-preview

# Conflicts:
#	lib/core/src/server/config/webpack.config.dev.js
#	lib/core/src/server/config/webpack.config.prod.js
…-from-preview

# Conflicts:
#	addons/ondevice-knobs/package.json
#	addons/storyshots/storyshots-puppeteer/package.json
#	lib/cli/test/fixtures/react_babel_config_js/package.json
#	lib/cli/test/fixtures/react_babel_custom_preset/package.json
#	lib/cli/test/fixtures/react_babel_pkg_json/package.json
#	lib/cli/test/fixtures/react_babelrc/package.json
#	lib/cli/test/fixtures/react_babelrc_js/package.json
#	lib/core/package.json
#	yarn.lock
…-from-preview

# Conflicts:
#	lib/core/package.json
@ndelangen ndelangen force-pushed the core/separate-manager-from-preview branch 4 times, most recently from 6b0a885 to 8c5be8f Compare November 9, 2018 09:50
@ndelangen ndelangen force-pushed the core/separate-manager-from-preview branch from 8c5be8f to 31e46a3 Compare November 9, 2018 10:43
@libetl libetl self-requested a review November 9, 2018 11:11
@@ -0,0 +1,46 @@
module.exports = {
Copy link
Member

Choose a reason for hiding this comment

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

should not it be babel.config.js ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Got this from here:
https://babeljs.io/docs/en/config-files

Seems to work..

@ndelangen
Copy link
Member Author

@tmeasday @shilman any idea what's wrong with chromatic here?

It seems consistent, but I can't reproduce locally

@tmeasday
Copy link
Member

tmeasday commented Nov 10, 2018

@norbert the issue is that (on the build machine at least) the index for the cra-kitchen-sink app doesn't include any JS. It looks like a template? Here's the file, cached by our tunnel:

https://stmeqlknrx.tunnel.chromaticqa.com/cra-kitchen-sink/index.html

Here's the contents:

<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
    <!--
      Notice the use of %PUBLIC_URL% in the tag above.
      It will be replaced with the URL of the `public` folder during the build.
      Only files inside the `public` folder can be referenced from the HTML.

      Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
      work correctly both with client-side routing and a non-root public URL.
      Learn how to configure a non-root public URL by running `npm run build`.
    -->
    <title>React App</title>
  </head>
  <body>
    <div id="root"></div>
    <!--
      This HTML file is a template.
      If you open it directly in the browser, you will see an empty page.

      You can add webfonts, meta tags, or analytics to this file.
      The build step will place the bundled scripts into the <body> tag.

      To begin the development, run `npm start`.
      To create a production bundle, use `npm run build`.
    -->
  </body>
</html>

Are you sure storybook-build is working properly for the apps on the branch? Perhaps you have artifacts left on your machine from other branches?

@ndelangen
Copy link
Member Author

When I build storybook in the cra example, this is the html of the index:

<!doctype html><html><head><meta charset="utf-8"><title>Storybook</title><style>html, body {
    overflow: hidden;
    height: 100%;
    width: 100%;
    margin: 0;
    padding: 0;
  }</style><script>/* globals window */
  /* eslint-disable no-underscore-dangle */
  try {
    if (window.parent !== window) {
      window.__REACT_DEVTOOLS_GLOBAL_HOOK__ = window.parent.__REACT_DEVTOOLS_GLOBAL_HOOK__;
      window.__VUE_DEVTOOLS_GLOBAL_HOOK__ = window.parent.__VUE_DEVTOOLS_GLOBAL_HOOK__;
    }
  } catch (e) {
    console.warn('unable to connect to parent frame for connecting dev tools');
  }</script></head><body><div id="root"></div><script src="static/runtime~manager.1be4c9c775fb85324315.bundle.js"></script><script src="static/manager.d4d9ee0e6999e2cbffca.bundle.js"></script></body></html>

.split(process.platform === 'win32' ? ';' : ':')
.filter(Boolean)
.map(p => path.resolve('./', p));
export const excludePaths = [nodeModulesPaths];
Copy link
Member

@igor-dv igor-dv Nov 10, 2018

Choose a reason for hiding this comment

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

Can we revert these changes in favor of #4706 ?

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, sounds good to me. Are you able to do it?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm unsure exactly what it'd be that I'd have to change here.

import HtmlWebpackHarddiskPlugin from '@ndelangen/html-webpack-harddisk-plugin';
import CaseSensitivePathsPlugin from 'case-sensitive-paths-webpack-plugin';

import { version } from '../../../package.json';
Copy link
Member

Choose a reason for hiding this comment

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

we should provide the version to the child process.

@igor-dv
Copy link
Member

igor-dv commented Nov 11, 2018

@ndelangen, I will revert all the NODE_PATH changes today.
Anyway, there is also this - #4590 (comment) comment.

@igor-dv
Copy link
Member

igor-dv commented Nov 11, 2018

@ndelangen, I will revert all the NODE_PATH changes today

Actually I think it will be easier to just merge the #4706 before

# Conflicts:
#	lib/core/src/server/config/utils.js
#	lib/core/src/server/config/webpack.config.dev.js
#	lib/core/src/server/config/webpack.config.prod.js
@ndelangen
Copy link
Member Author

Should be good now

@ndelangen ndelangen merged commit 4da246b into next Nov 12, 2018
@ndelangen ndelangen deleted the core/separate-manager-from-preview branch November 12, 2018 12:32
@libetl
Copy link
Member

libetl commented Nov 12, 2018

Congratulations

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.

5 participants