Skip to content

Build: Simplify Dashboard Build Toolchain#12127

Closed
ockham wants to merge 25 commits intomasterfrom
update/simplify-jetpack-build-system
Closed

Build: Simplify Dashboard Build Toolchain#12127
ockham wants to merge 25 commits intomasterfrom
update/simplify-jetpack-build-system

Conversation

@ockham
Copy link
Copy Markdown
Contributor

@ockham ockham commented Apr 23, 2019

WIP. Prep work for #12072.

One core thing I've identified is that tools/builder/react.js uses static.jsx to produce minimal static markup (HTML) versions of the dashboard (really just "Turn on your JavaScript" notices). It require()s the webpack-bundled version of static.jsx to that end, and attaches renderToStaticMarkup()-produced strings to window, which it then writes to HTML files.

Getting rid of the complexity added by passing information by attaching to window (and thus requiring jsdom etc) is the main objective of this PR.

Maybe we can instead produce those HTML files as by-products of the bundling, i.e. through a Webpack plugin or loader? https://github.com/GoogleChromeLabs/prerender-loader#string-prerendering looks very promising!

Alternatively, we shouldn't bundle but just transpile static.jsx so we can simply require() it from tools/builder/react.js.

Changes proposed in this Pull Request:

Don't use window/jsdom in build system.

Testing instructions:

yarn distclean && yarn
yarn build-client
yarn docker:up
  • Navigate to /wp-admin/admin.php?page=jetpack_modules
  • Disable JavaScript
  • See this message?

image

Proposed changelog entry for your changes:

Build: Simplify Dashboard Build Toolchain

@ockham ockham requested a review from a team April 23, 2019 13:00
@ockham ockham self-assigned this Apr 23, 2019
@jetpackbot
Copy link
Copy Markdown
Collaborator

jetpackbot commented Apr 23, 2019

Thank you for the great PR description!

When this PR is ready for review, please apply the [Status] Needs Review label. If you are an a11n, please have someone from your team review the code if possible. The Jetpack team will also review this PR and merge it to be included in the next Jetpack release.

Scheduled Jetpack release: June 4, 2019.
Scheduled code freeze: May 28, 2019

Generated by 🚫 dangerJS against a251422

@matticbot
Copy link
Copy Markdown
Contributor

Caution: This PR has changes that must be merged to WordPress.com
Hello ockham! These changes need to be synced to WordPress.com - If you 're an a11n, please commandeer, review, and approve D27270-code before merging this PR. Thank you!

@matticbot
Copy link
Copy Markdown
Contributor

ockham, Your synced wpcom patch D27270-code has been updated.

1 similar comment
@matticbot
Copy link
Copy Markdown
Contributor

ockham, Your synced wpcom patch D27270-code has been updated.

};
export const setInitialState = () => ( {
type: JETPACK_SET_INITIAL_STATE,
initialState: window.Initial_State,
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We should probably parametrize the action for initialState to put the burden of instantiating it with window.Initial_State on the consumer.

Comment thread _inc/client/static.jsx Outdated
<StaticMain />
</Provider>
</div>
);
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Comment thread _inc/client/static.jsx Outdated
);

window.versionNotice = Server.renderToStaticMarkup(
window.versionNotice = renderToStaticMarkup(
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Will probably need to move noscriptNotice and versionNotice to separate files,

@matticbot
Copy link
Copy Markdown
Contributor

ockham, Your synced wpcom patch D27270-code has been updated.

@ockham ockham force-pushed the update/simplify-jetpack-build-system branch from 54de292 to 3aa10e9 Compare April 24, 2019 07:22
@matticbot
Copy link
Copy Markdown
Contributor

ockham, Your synced wpcom patch D27270-code has been updated.

Comment thread tools/builder/react.js Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Prolly just onBuild.bind( this, done ) would work here but good also as-is.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@simison simison force-pushed the update/simplify-jetpack-build-system branch from 73cff5d to f269d39 Compare April 26, 2019 16:02
@matticbot
Copy link
Copy Markdown
Contributor

ockham, Your synced wpcom patch D27270-code has been updated.

@simison
Copy link
Copy Markdown
Member

simison commented Apr 26, 2019

Rebased

@ockham ockham force-pushed the update/simplify-jetpack-build-system branch from f269d39 to 3a2ec1b Compare May 14, 2019 19:53
@matticbot
Copy link
Copy Markdown
Contributor

ockham, Your synced wpcom patch D27270-code has been updated.

@matticbot
Copy link
Copy Markdown
Contributor

ockham, Your synced wpcom patch D27270-code has been updated.

ockham added 2 commits May 15, 2019 13:48
This was solely meant to facilitate migration from Webpack v1 to v2. The debug option specifically was dropped by Webpack 3.

https://webpack.js.org/plugins/loader-options-plugin/
@ockham ockham force-pushed the update/simplify-jetpack-build-system branch from 2a806f7 to ef045b8 Compare May 15, 2019 12:27
@ockham
Copy link
Copy Markdown
Contributor Author

ockham commented May 15, 2019

Closing in favor of #12381.

@ockham ockham closed this May 15, 2019
@ockham ockham deleted the update/simplify-jetpack-build-system branch May 15, 2019 13:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants