-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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 build fails to minify js if typescript is used, doesn't show the error #3356
Comments
Looks like that's a Typescript file? Do you have the typescript plugin installed? |
Yep, it's in the Here's the tsconfig.json if you wonder:
|
Here's a simple way to reproduce: $ gatsby new https://github.com/haysclark/gatsby-starter-typescript
$ cd gts ; gatsby build The generated webpackJsonp([178469467687848],{
/***/ 181:
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const React = __webpack_require__(4);
const NotFoundPage = () => React.createElement("div", null, React.createElement("h1", null, "NOT FOUND"), React.createElement("p", null, "You just hit a route that doesn't exist... the sadness."));
exports.default = NotFoundPage;
/***/ })
});
//# sourceMappingURL=component---src-pages-404-tsx-90a04ce7bd4d55a03791.js.map Now, if you change webpackJsonp([0xa25129398ba8],{181:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const u=n(4),l=function(){return u.createElement("div",null,u.createElement("h1",null,"NOT FOUND"),u.createElement("p",null,"You just hit a route that doesn't exist... the sadness."))};t.default=l}});
//# sourceMappingURL=component---src-pages-404-tsx-8800a323347868ec6a23.js.map |
I think I've figured the source of the problem. In here: https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby-plugin-typescript/src/gatsby-node.js#L35 the loaders are set to loaders: [
`babel?${JSON.stringify({ plugins: [extractQueryPlugin] })}`,
`ts-loader?${JSON.stringify(opts)}`,
], instead of the js pipeline: config.loader(`js`, {
test: /\.jsx?$/, // Accept either .js or .jsx files.
exclude: /(node_modules|bower_components)/,
loader: `babel`,
query: babelConfig,
}) By skipping full babel run there the uglify gets a raw unprocessed output from TS. I'd send you a patch to fix this, if I knew how to get the |
A PR would be great! Contribution instructions are at https://www.gatsbyjs.org/docs/how-to-contribute/#contributing |
Hello @farcaller . Did you manage to solve this problem? Because I'm having the same problem.
tsconfig.json
I have |
I'm still having some problems with the async/await. I return to the old callbacks for now 👍 |
Description
Note: this issue was reported elsewhere at least once (#1887). It's still broken in the current gatsby version.
gatsby build
leaves thecomponent---src-pages-index-tsx-***.js
file unminified, because of theSyntaxError: Unexpected token: operator (>)
in a=>
.Environment
Gatsby version: 1.9.149
Node.js version: v8.1.3
Operating System: OSX
File contents (if changed):
gatsby-config.js
:Actual result
gatsby build
silently fails to minify a js file.Expected behavior
gatsby build
properly minifies the file. If it fails to do so it at the very least must show lots of red bold alerts.Steps to reproduce
Given the following index.tsx:
Run gatsby build.
Result:
component---src-pages-index-tsx-***.js
file isn't minified.If I instrument node_modules/webpack/lib/optimize/UglifyJsPlugin.js (around line 122), I can see the following error:
The text was updated successfully, but these errors were encountered: