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

Update @automattic/calypso-build to v 5.0 #13854

Merged
merged 9 commits into from
Nov 8, 2019
Merged

Conversation

ockham
Copy link
Contributor

@ockham ockham commented Oct 28, 2019

Changes proposed in this Pull Request:

Manual attempt at upgrading @automattic/calypso-build to v5, to surface potential bugs.

Is this a new feature or does it add/remove features to an existing part of Jetpack?

Upgrading a build tool.

Testing instructions:

yarn distclean && yarn
yarn build
yarn test-extensions

Proposed changelog entry for your changes:

Update @automattic/calypso-build to v5.

TODO

@matticbot
Copy link
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 D34594-code before merging this PR. Thank you!

@jetpackbot
Copy link

jetpackbot commented Oct 28, 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: December 3, 2019.
Scheduled code freeze: November 26, 2019

Generated by 🚫 dangerJS against a97a407

ockham added a commit to Automattic/wp-calypso that referenced this pull request Oct 28, 2019
Turns out the `undefined` fallback doesn't work so well after all: See Automattic/jetpack#13854 which currently fails to find a PostCSS config.

I tried various other fixes (setting different levels of config options to `undefined` or empty object), but none seemed to work. The fix I ended up was the only reliable way I could find.
@ockham
Copy link
Contributor Author

ockham commented Oct 28, 2019

With Automattic/wp-calypso#37110 applied, this is still failing in yarn build stage. I've tracked down the issue (related to Automattic/wp-calypso#36230) and am working on a fix.

@ockham
Copy link
Contributor Author

ockham commented Oct 28, 2019

One possible fix is

diff --git a/babel.config.js b/babel.config.js
index ef8132aab..b3bcbb62e 100644
--- a/babel.config.js
+++ b/babel.config.js
@@ -5,6 +5,12 @@ const config = {
                        test: './extensions/',
                        presets: [ require.resolve( '@automattic/calypso-build/babel/wordpress-element' ) ],
                },
+               {
+                       test: [ './gulpfile.babel.js', './webpack.config.js', './tools/builder/' ],
+                       presets: [
+                               [ require.resolve( '@automattic/calypso-build/babel/default' ), { modules: 'commonjs' } ],
+                       ],
+               },
        ],
        env: {
                test: {

@ockham
Copy link
Contributor Author

ockham commented Oct 28, 2019

The simpler alternative is

diff --git a/package.json b/package.json
index d420c8c57..1287601a8 100644
--- a/package.json
+++ b/package.json
@@ -25,7 +25,7 @@
                "install-if-deps-outdated": "yarn check 2> /dev/null || yarn install --check-files --production=false",
                "distclean": "rm -rf node_modules && yarn clean",
                "build": "yarn install-if-deps-outdated && yarn clean && yarn build-client && yarn build-php && yarn build-extensions",
-               "build-client": "gulp",
+               "build-client": "MODULES=commonjs gulp",
                "build-extensions": "webpack --config ./webpack.config.extensions.js",
                "build-php": "composer install --ignore-platform-reqs",
                "build-production-php": "COMPOSER_MIRROR_PATH_REPOS=1 composer install -o --no-dev --classmap-authoritative --prefer-dist",

But I'm wondering if setting the env variable will cause all the code to be transpiled to CJS? (Though I'm not completely sure that that wouldn't be the case with #13854 (comment)).

/cc @sirreal

@matticbot
Copy link
Contributor

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

1 similar comment
@matticbot
Copy link
Contributor

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

@ockham
Copy link
Contributor Author

ockham commented Oct 28, 2019

I pushed 8cf9d13, which implements the more granular (per-file) option, which I'm pretty sure should only transpile import statements in the files listed.

The downside is that it needs to be manually maintained, if a new config file is added; I think it's reasonable to assume that that won't happen that often.

I'm pretty sure the other option (setting the MODULES env var, i.e. MODULES=commonjs gulp) would cause ES Modules (import statements) in all files to be transpiled to CommonJS (require).

@ockham ockham added [Status] Needs Review To request a review from Crew. Label will be renamed soon. and removed [Status] In Progress labels Oct 28, 2019
@ockham ockham requested a review from sirreal October 28, 2019 15:37
@ockham ockham marked this pull request as ready for review October 28, 2019 15:37
@ockham ockham requested a review from a team as a code owner October 28, 2019 15:37
@ockham ockham requested a review from jsnajdr October 28, 2019 15:37
@matticbot
Copy link
Contributor

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

@ockham
Copy link
Contributor Author

ockham commented Oct 28, 2019

jest is still failing to transpile imports in test files, which is weird, since we're using @automattic/calypso-build's Jest preset, which is supposed to do just that 😕

@matticbot
Copy link
Contributor

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

@matticbot
Copy link
Contributor

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

@zinigor
Copy link
Member

zinigor commented Nov 5, 2019

Tested the build, it seems to work as expected, plus it fixes the node-sass build error that breaks the build flow on Node 12, for example, in the GitHub action that we currently have for Jetpack.

@matticbot
Copy link
Contributor

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

@ockham
Copy link
Contributor Author

ockham commented Nov 8, 2019

Rebased (since there was a conflict) 😬

@ockham ockham added [Status] Needs Review To request a review from Crew. Label will be renamed soon. and removed [Status] Ready to Merge Go ahead, you can push that green button! labels Nov 8, 2019
@jeherve jeherve added [Status] Ready to Merge Go ahead, you can push that green button! and removed [Status] Needs Review To request a review from Crew. Label will be renamed soon. labels Nov 8, 2019
Copy link
Member

@jeherve jeherve left a comment

Choose a reason for hiding this comment

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

Still looks good to me. 🚢

@kraftbj kraftbj merged commit c2a1b28 into master Nov 8, 2019
@kraftbj kraftbj deleted the upgrade/calypso-build-5-0 branch November 8, 2019 22:07
@matticbot matticbot added [Status] Needs Changelog and removed [Status] Ready to Merge Go ahead, you can push that green button! labels Nov 8, 2019
@kraftbj
Copy link
Contributor

kraftbj commented Nov 8, 2019

r199225-wpcom

@simison
Copy link
Member

simison commented Nov 22, 2019

Looks like simple sites are missing the color still — if I understood correct, colors work in Jetpack dashboard just fine?

Screenshot 2019-11-22 at 13 07 12

Screenshot 2019-11-22 at 13 07 07

@simison
Copy link
Member

simison commented Nov 22, 2019

Looks like postcss.config.js wasn't synced in D34594-code. Adding it to wpcom in D35821-code; I think that should fix all this for simple sites.

module.exports = () => ( {
plugins: {
'postcss-custom-properties': {
importFrom: [ require.resolve( '@automattic/calypso-color-schemes' ) ],
Copy link
Member

Choose a reason for hiding this comment

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

I think it would make sense to use @automattic/color-studio directly here.

I don't really see Calypso colors bringing any additional value; it just has some extra Calypso specific things such as --sidebar-background, --masterbar-toggle-drafts-editor-background, etc...

Unless I'm missing something?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Was considering that, yeah. I think we'd have to rename a few colors though, since they're aliased in @automattic/calypso-color-schemes.

Furthermore, I think there's still some issue that prevents things from working entirely as they should, see #13854 (comment) 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we'd have to rename a few colors though, since they're aliased in @automattic/calypso-color-schemes.

That might not have been very clear; what I meant is that we're right now using the names as found in @automattic/calypso-color-schemes in Jetpack (not names from @automattic/color-studio).

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 really see Calypso colors bringing any additional value

calypso-color-schemes brings exactly the value that the package name promises: it defines a family of color schemes like Classic Blue, Midnight or Powder Snow that can be applied to UI that uses "semantic" names like color-primary, color-accent or masterbar-item.

color-studio is a generic set of named colors (somewhat similar to RAL or Pantone).

If you want to style your UI with a color scheme that was designed to work together, then you need one of the Calypso color schemes.

Copy link
Member

Choose a reason for hiding this comment

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

Thanks for clarification!

Sounds like @Automattic/jetpack-design could have final say which one they prefer to work with?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not entirely sure of the question. It seems a library choice question... what's the difference from a design perspective?

If it answer the question: going forward we'll use the latest color-studio colors, which includes the new Jetpack green and a gamut of colors agreed across all A8c.

Copy link
Member

Choose a reason for hiding this comment

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

@folletto I think the question is more like: does Jetpack have something like "color scheme" that is applied to the UI? And does it intend to share the default color scheme with Calypso, or does it define its own?

Color scheme defines approx 15-20 colors, all selected from the color-studio palette, while the whole color-studio has 170+ colors.

Copy link
Contributor

Choose a reason for hiding this comment

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

Not explicitly. I think the code we have already there is the closest thing we have to a color scheme.

For sure, we won't use all the colors in the color-studio, but right now there isn't a logical subset that has been extracted — again, except what's already there in code.

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.

None yet

10 participants