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

TypeScript files are not minified during build (gatsby-plugin-typescript) #3022

Closed
tomazy opened this issue Nov 24, 2017 · 5 comments
Closed

Comments

@tomazy
Copy link
Contributor

tomazy commented Nov 24, 2017

When running npm run build all typescript files are converted into non-minified javascript files in the public folder.

Example based on Gatsby default starter: https://github.com/tomazy/gatsby-site-typescript-issue (see the public folder)

Environment:

  • gatsby@1.9.119
  • node v8.2.1
  • macOS Sierra 10.12.6

gatsby-config.js

module.exports = {
  siteMetadata: {
    title: `Gatsby Default Starter`,
  },
  plugins: [
    `gatsby-plugin-react-helmet`,
    `gatsby-plugin-typescript`,
  ],

package.json

{
  "name": "gatsby-starter-default",
  "description": "Gatsby default starter",
  "version": "1.0.0",
  "author": "Kyle Mathews <mathews.kyle@gmail.com>",
  "dependencies": {
    "@types/node": "8.0.53",
    "@types/prop-types": "15.5.2",
    "@types/react": "16.0.25",
    "@types/react-dom": "16.0.3",
    "@types/react-helmet": "5.0.3",
    "@types/react-router-dom": "4.2.2",
    "gatsby": "^1.9.119",
    "gatsby-link": "^1.6.28",
    "gatsby-plugin-react-helmet": "^1.0.8",
    "gatsby-plugin-typescript": "1.4.10"
  },
  "keywords": [
    "gatsby"
  ],
  "license": "MIT",
  "main": "n/a",
  "scripts": {
    "build": "gatsby build",
    "develop": "gatsby develop",
    "format": "prettier --trailing-comma es5 --no-semi --single-quote --write \"src/**/*.js\"",
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "devDependencies": {
    "prettier": "^1.8.2"
  }
}
@mattferderer
Copy link
Contributor

Check out #3369

@jurosh
Copy link
Contributor

jurosh commented Jan 31, 2018

After update to gatsby@1.9.175 minification works for me fine. So yea, looks like fixes in #3369 helped.

@tomazy
Copy link
Contributor Author

tomazy commented Jan 31, 2018

I've just tried with the above mentioned project.
I upgraded all the packages first (yarn upgrade).
Then I ran npm run build and I got following error:

error Generating JavaScript bundles failed


  Error: component---src-layouts-index-tsx-f35f261d51b686413c6f.js from UglifyJs
  SyntaxError: Unexpected token: punc ()) [./src/layouts/index.tsx:8,21]

@jurosh
Copy link
Contributor

jurosh commented Jan 31, 2018

Hm.. it might be issue with tsconfig.

For me it's working fine with:

"module": "commonjs",
"target": "esnext",

@tomazy
Copy link
Contributor Author

tomazy commented Feb 1, 2018

My fault - I updated gatsby but not gatsby-plugin-typescript.

Confirming that it works as expected with

  • gatsby 1.9.175
  • gatsby-plugin-typescript 1.4.15

@tomazy tomazy closed this as completed Feb 1, 2018
This was referenced Jan 12, 2022
This was referenced Feb 9, 2022
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

No branches or pull requests

3 participants