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

Step 3: convert browserify build to webpack, fixes #976 #1001

Merged
merged 8 commits into from
Dec 3, 2019

Conversation

acao
Copy link
Member

@acao acao commented Nov 18, 2019

the vast amount the added lines to this PR are via the yarn.lock file, FYI! this PR is mostly a 120 line webpack config file and some tooling and configuration changes.

  • browserify min and graphiql bundle replaced with webpack 3, retaining window.GraphiQL interface pattern
  • windows compatible tooling: replace bash scripts for babel, browserify, uglify, postcss/autoprefixer, etc 'build' turned into build 20s and build-bundle. This came with replacing browserify, as we no longer needed a bash script. Also added crossenv, rimraf, etc
  • use new webpack mincss plugin, and generate a nanocss build at graphiql.min.css too! (note: temporary til styled components)
  • update yarn dev server to mount webpack dev server with test GraphQL server, instead of the exact same pattern using browserify
  • fix some issues with cypress + jest battling over the linting of expect() in cypress specs that was failing lint
  • HUGE reduction in minified build size. I'm not kidding.

Screen Shot 2019-11-18 at 1 36 27 PM
(parsed size, from webpack output)

Screen Shot 2019-11-18 at 2 27 58 PM

here is proof (on the far right) that the file utility from the first PR in this series is working:
Screen Shot 2019-11-18 at 6 35 47 PM

@acao acao changed the title ci: convert browserify to webpack, fixes #976 Step 3: convert browserify to webpack, fixes #976 Nov 18, 2019
@acao acao changed the title Step 3: convert browserify to webpack, fixes #976 Step 3: convert browserify build to webpack, fixes #976 Nov 18, 2019
@acao acao force-pushed the chore/replace-browserify-webpack branch 3 times, most recently from 17e85c6 to 03bfcad Compare November 18, 2019 17:47
@acao acao changed the title Step 3: convert browserify build to webpack, fixes #976 [WIP] Step 3: convert browserify build to webpack, fixes #976 Nov 18, 2019
@acao acao force-pushed the chore/replace-browserify-webpack branch from 03bfcad to 48452c0 Compare November 18, 2019 19:51
@acao acao changed the title [WIP] Step 3: convert browserify build to webpack, fixes #976 Step 3: convert browserify build to webpack, fixes #976 Nov 18, 2019
@codecov
Copy link

codecov bot commented Nov 18, 2019

Codecov Report

Merging #1001 into master will increase coverage by 0.21%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1001      +/-   ##
==========================================
+ Coverage   43.52%   43.73%   +0.21%     
==========================================
  Files          66       65       -1     
  Lines        2996     3018      +22     
  Branches      649      656       +7     
==========================================
+ Hits         1304     1320      +16     
- Misses       1421     1425       +4     
- Partials      271      273       +2
Impacted Files Coverage Δ
packages/graphiql/src/components/QueryHistory.js 36.53% <ø> (ø) ⬆️
packages/graphiql/src/components/DocExplorer.js 38.29% <ø> (ø) ⬆️
packages/graphiql/src/components/QueryEditor.js 57.94% <0%> (+3.18%) ⬆️

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 0b93b55...4c46196. Read the comment docs.

@acao acao force-pushed the chore/replace-browserify-webpack branch 8 times, most recently from 0961e68 to e0a01ea Compare November 19, 2019 01:03
@acao acao force-pushed the chore/replace-browserify-webpack branch 3 times, most recently from 15df49b to 275a5f2 Compare November 19, 2019 17:32
@acao acao force-pushed the chore/esm-build branch 8 times, most recently from 1538a0c to 915a595 Compare November 20, 2019 03:23
@acao acao changed the base branch from chore/esm-build to master November 30, 2019 15:11
@acao acao force-pushed the chore/replace-browserify-webpack branch from 328a0b0 to fa5e372 Compare November 30, 2019 15:18
@acao acao requested review from benjie and orta December 2, 2019 01:12
@acao acao added this to To do in Housekeeping! Dec 2, 2019
@acao acao added this to Done in Webpack takeover Dec 2, 2019
@acao acao moved this from Done to To do in Webpack takeover Dec 2, 2019
@acao acao mentioned this pull request Dec 2, 2019
@acao acao added the graphiql label Dec 2, 2019
@@ -64,27 +67,32 @@
"react-dom": "^15.6.0 || ^16.0.0"
},
"devDependencies": {
Copy link
Member Author

Choose a reason for hiding this comment

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

replacing the entire bundling toolchain. thus the huge yarn lock diff

Copy link
Member

@benjie benjie left a comment

Choose a reason for hiding this comment

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

LGTM; if you're happy it builds correctly then I'm happy.

package.json Outdated Show resolved Hide resolved
cy.window().then(w => {
cy.expect(JSON.parse(w.g.resultComponent.viewer.getValue())).to.deep.equal(
mockSuccess,
);
});
})
Copy link
Member

Choose a reason for hiding this comment

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

Lint issue?

envConfig.modules = 'umd'
envConfig.targets = null
envConfig.ignoreBrowserslistConfig = false
}
Copy link
Member

Choose a reason for hiding this comment

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

I'd rather this used an if/elseif/else chain and instead of overwriting the initial properties of envConfig it set variables that were then used to create the envConfig object afterwards, but 🤷‍♂️

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 so averse to else it's problematic, haha! will take note for further iterations

Webpack takeover automation moved this from To do to Reviewer approved Dec 2, 2019
Co-Authored-By: Benjie Gillam <benjie@jemjie.com>
@acao acao merged commit 3caf041 into master Dec 3, 2019
Webpack takeover automation moved this from Reviewer approved to Done Dec 3, 2019
@acao acao moved this from To do to Done in Housekeeping! Dec 3, 2019
@@ -0,0 +1,4 @@
babel.config.js
.gitignore
resources
Copy link
Contributor

Choose a reason for hiding this comment

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

By not publishing resources here, the reference at

require('codemirror-graphql/results/mode');

is no longer valid. Either this line or that line should be removed.

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 confused? that import is from codemirror-graphql, which still exports that module. are you having issues? this PR was merged

Copy link
Member Author

Choose a reason for hiding this comment

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

if what you are saying is true, then the results viewer would fail to highlight jaon here in the current build of master:

https://graphiql-test.netlify.com

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry, I got resources and results confused so this isn't the direct issue. Regardless, there's still an issue with the latest codemirror-graphql package because the results folder, referenced in the line above, does not exist.

~ npm install codemirror-graphql@0.11.5
~ ls node_modules/codemirror-graphql/results
ls: node_modules/codemirror-graphql/results: No such file or directory

This broken link is causing my build to fail, so I've resorted back to graphiql@0.17.2 and manually pinning codemirror-graphql@0.11.4 (which does publish this folder) for now.

Copy link
Member Author

Choose a reason for hiding this comment

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

@caseywebdev try now with 0.11.6

Copy link
Member Author

Choose a reason for hiding this comment

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

https://unpkg.com/browse/codemirror-graphql@0.11.6/ my bad! we should be doing pre-releases for all these build changes.

Copy link
Contributor

Choose a reason for hiding this comment

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

Working again 👍🏻 Thanks for the quick turnaround!

@acao
Copy link
Member Author

acao commented Dec 9, 2019 via email

@acao acao deleted the chore/replace-browserify-webpack branch December 28, 2019 22:21
@acao acao added this to the GraphiQL-1.0.0-beta milestone Mar 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Housekeeping!
  
Done
Development

Successfully merging this pull request may close these issues.

None yet

4 participants