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

gatsby-source-graphql: Add babel typescript plugin and specify ts extension in build #22804

Closed

Conversation

copperwall
Copy link
Contributor

Description

This adds the .ts extension to the npm run build command so that babel doesn't only transform .js files in the src directory.

This also adds the @babel/plugin-transform-typescript babel plugin in the .babelrc so that .ts files are parsed correctly by babel.

I ran npm publish --dry-run to make sure the out files from the batching/*.ts files ended up in the package.

npm publish --dry-run

> gatsby-source-graphql@2.3.1 prepare .
> cross-env NODE_ENV=production npm run build


> gatsby-source-graphql@2.3.1 build /Users/zolokar/projects/gatsby/packages/gatsby-source-graphql
> babel src --out-dir . --ignore **/__tests__ --extensions ".ts,.js"

Successfully compiled 11 files with Babel.
npm notice 
npm notice 📦  gatsby-source-graphql@2.3.1
npm notice === Tarball Contents === 
npm notice 178B   .babelrc                   
npm notice 2.7kB  batching/dataloader-link.js
npm notice 2.6kB  gatsby-node.js             
npm notice 13B    index.js                   
npm notice 10.7kB batching/merge-queries.js  
npm notice 1.0kB  transforms.js              
npm notice 1.4kB  package.json               
npm notice 16.1kB CHANGELOG.md               
npm notice 9.4kB  README.md                  
npm notice === Tarball Details === 
npm notice name:          gatsby-source-graphql                   
npm notice version:       2.3.1                                   
npm notice package size:  10.7 kB                                 
npm notice unpacked size: 44.1 kB                                 
npm notice shasum:        65d77890da6496a98a09a0300ee559afd550364c
npm notice integrity:     sha512-x3Ub+ztY+rGSt[...]i7RdX+lF5FuyA==
npm notice total files:   9                                       
npm notice 
+ gatsby-source-graphql@2.3.1

Documentation

This shouldn't require a docs update.

Related Issues

Fixes #22785

@copperwall copperwall requested a review from a team as a code owner April 3, 2020 20:58
This also adds a prefix / to the babel ignore flag, because the build
was still transforming and outputting files from __tests__ directories.
@copperwall copperwall force-pushed the add-babel-typescript-plugin branch from f2b430e to c704999 Compare April 4, 2020 01:08
@copperwall
Copy link
Contributor Author

Sorry for the force-push, it looked like the integration_tests_cache_resilience ran into an issue and I wanted to rerun the build so I amended the last commit to cause a new push event.

@vladar
Copy link
Contributor

vladar commented Apr 6, 2020

Thank you for the PR! 💜

It would have fixed the underlying problem with TS build. But the issue is that we were using Typescript prematurely in gatsby-source-graphql.

For now, Gatsby plugins should not be using Typescript. When we are ready for Typescript in plugins we will come up with a common configuration for all Gatsby plugins.

So thank you so much for a quick fix but we will have to choose a different approach and just convert TS files to vanilla JS for now. See #22848 for a follow-up PR.

@vladar vladar closed this Apr 6, 2020
@copperwall
Copy link
Contributor Author

No worries, thanks for letting me know!

Haha, I was trying to see if there was a more global setup in the gatsby repo for typescript builds, but I ended up just patching some thing together from another subpackage or two that was using TypeScript somehow.

Getting a more common configuration sounds good to me.

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.

gatsby-source-graphql fails
2 participants