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

Fix broken GraphiQL minified build #982

Merged
merged 5 commits into from
Oct 19, 2019
Merged

Fix broken GraphiQL minified build #982

merged 5 commits into from
Oct 19, 2019

Conversation

imolorhe
Copy link
Contributor

@imolorhe imolorhe commented Oct 18, 2019

The current source used for minifying graphiql in the build script is wrong. Therefore the build is broken. After debugging for the reason while the build was failing, I figured out that in order to use the correct source for the build, we need all the packages used in the build to be transpiled to their es5 equivalents for the build process to work. Main reason being that uglify doesn't support es6 syntax and requires es5 to minify the file. Given that the tsconfig specified the target as esnext, the builds were transpiled to their es6/es7 equivalents, which is required by graphiql as a dependency, and so uglify breaks.

I'm not sure why we decided to set the tsconfig to esnext, but this question should be answered before merging this PR.

This closes #976

The builds across the packages currently depend on the transpiled files to be in es5 (for example uglify is used to minify graphiql and it doesn't support es6).
The source for the minify operation should be graphiql.js for it to work properly.
@codecov
Copy link

codecov bot commented Oct 18, 2019

Codecov Report

Merging #982 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #982   +/-   ##
=======================================
  Coverage   43.14%   43.14%           
=======================================
  Files          64       64           
  Lines        2934     2934           
  Branches      635      635           
=======================================
  Hits         1266     1266           
  Misses       1400     1400           
  Partials      268      268

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 7efed6c...f7895f6. Read the comment docs.

@acao
Copy link
Member

acao commented Oct 18, 2019 via email

@imolorhe
Copy link
Contributor Author

Babel doesn't because it only transpiles from the src to dist and didn't create the bundle. The bundle is created by browserify after babel transpiles

@imolorhe
Copy link
Contributor Author

Babelify should help in this case

To ensure babelify transforms files in node_modules.
@imolorhe
Copy link
Contributor Author

imolorhe commented Oct 19, 2019

Adding the browserify transform config for babelify works for bundling graphiql without changing the target from esnext. This however means that all the browserify operations (currently bundling to graphiql.js and minifying to graphiql.min.js) would apply the babelify transform as well, but this shouldn't be a problem and works at the moment.

@imolorhe
Copy link
Contributor Author

The reason why this is the solution I am proposing is this: https://github.com/babel/babelify#why-arent-files-in-node_modules-being-transformed

Since the problematic package is gls-interface (which is in the node_modules), the browserify transform wouldn't transpile those by default.

@acao
Copy link
Member

acao commented Oct 19, 2019 via email

@imolorhe
Copy link
Contributor Author

Yeah, not a big fan of browserify myself 😅

If there are no other concerns, perhaps you can take a look at this PR locally to verify the implementation. For me, it seems to work fine.

@acao acao merged commit d6d0a68 into graphql:master Oct 19, 2019
@acao
Copy link
Member

acao commented Oct 19, 2019

thanks so much @imolorhe !! going to cut another release of graphiql here now

@jbblanchet
Copy link
Contributor

@acao Was this fix supposed to be part or version 0.16? Seems to still be broken for me. Only the non-minified version is working.

@acao
Copy link
Member

acao commented Nov 7, 2019 via email

@jbblanchet
Copy link
Contributor

From jsdelivr. Switching over from cdnjs since it's been dead for a month. Using https://cdn.jsdelivr.net/npm/graphiql@0.16.0/graphiql.js works as expected, using https://cdn.jsdelivr.net/npm/graphiql@0.16.0/graphiql.min.js gives an error ReferenceError: GraphiQL is not defined

@acao
Copy link
Member

acao commented Nov 7, 2019

@jbblanchet i'll see if I can't kick out a quick fix for this tonight, but otherwise the existing PR #973 will address this. terribly sorry. the netlify preview build and e2e tests as of this new PR #973 will use the minified bundle as well. I had set them to use graphiql.js for debugging :( my bad!

@jbblanchet
Copy link
Contributor

@acao No worries, it happens. Thanks for taking care of it, appreciate the hard work.

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.

Broken minified build for graphiql 0.16.0
3 participants