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

Webpack #202

Closed
wants to merge 18 commits into from
Closed

Webpack #202

wants to merge 18 commits into from

Conversation

MonkeyDo
Copy link
Member

Problem

Ticket BB-256: Use webpack for bundling

Solution

Running the project in development (npm run debug or npm run debug-watch-server) now uses webpack to load, transpile and bundle the client code, with hot module replacement active.
That means changes to the javascript or less client files will automatically change the browser page without need for reloading the page, thus conserving the application state.

Areas of Impact

Currently, this only impacts when running in development.
Production builds I have left as before until I figure out a few remaining kinks.

@coveralls
Copy link

coveralls commented Aug 21, 2018

Coverage Status

Coverage decreased (-0.05%) to 42.611% when pulling c192d64 on MonkeyDo:webpack into da362b4 on bookbrainz:master.

Copy link
Member

@LordSputnik LordSputnik left a comment

Choose a reason for hiding this comment

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

Looks good, seems to work - we can add production handling later, if you think it's best to merge this first. A few comments and possible things that need changing.

@@ -64,4 +65,5 @@ function RegistrationAuth() {

RegistrationAuth.displayName = 'RegistrationForm';

export default RegistrationAuth;
// Export as hot module (see https://github.com/gaearon/react-hot-loader)
export default hot(module)(RegistrationAuth);
Copy link
Member

Choose a reason for hiding this comment

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

Do this still need to be wrapped?

Copy link
Member Author

Choose a reason for hiding this comment

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

@@ -81,4 +82,5 @@ ErrorPage.propTypes = {
}).isRequired
};

export default ErrorPage;
// Export as hot module (see https://github.com/gaearon/react-hot-loader)
export default hot(module)(ErrorPage);
Copy link
Member

Choose a reason for hiding this comment

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

Do this still need to be wrapped?

Copy link
Member Author

Choose a reason for hiding this comment

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

<Layout {...extractLayoutProps(props)}>
<DeletionForm entity={props.entity}/>
</Layout>
<AppContainer>
Copy link
Member

Choose a reason for hiding this comment

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

https://github.com/gaearon/react-hot-loader#appcontainer says that hot is preferred to AppContainer - what was the issue with the hot helper wrapper that meant it couldn't be used?

Copy link
Member Author

Choose a reason for hiding this comment

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

With the way the entry points are set up with server-side rendering, we don't export a root app component.
That required me to wrap each imported module in each entry point with "hot", which isn't the best for extensibility. I'd much rather set it once in each entry point and not have to wrap any other child module.

Ultimately, the "hot" wrapper also wraps the component in and uses hot.module.accept, as the creator explains in this comment

The RegistrationAuth and ErrorPage components aren't loaded from the entry points, which is why I still export a hot-wrapped component. Some other components may still need to be hot-reloaded that I haven't stumbled upon, which I intend to keep an eye on as I get more acquainted with the codebase.

Copy link
Member

Choose a reason for hiding this comment

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

OK, IMO we should aim to make things simpler in the future if possible, and have a single root app component per "app", so that we can just use the preferred way of doing things. But this is fine for now 👍

@LordSputnik
Copy link
Member

Merged in ade20c5

@LordSputnik
Copy link
Member

Rebased to add a prefix to one of the last 4 commit messages - so closing this manually.

@LordSputnik LordSputnik closed this Sep 4, 2018
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 this pull request may close these issues.

3 participants