question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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"
  }
}

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:2
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
tomazycommented, 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
0reactions
juroshcommented, Jan 31, 2018

Hm… it might be issue with tsconfig.

For me it’s working fine with:

"module": "commonjs",
"target": "esnext",
Read more comments on GitHub >

github_iconTop Results From Across the Web

Is it possible to compile TypeScript into minified code?
The TypeScript compiler does not support the generation of minifies or obfuscated code. you will need to use another tool against the JavaScript...
Read more >
gatsby-plugin-minify
A Gatsby plugin to easily minify all output HTML files. Installation. $ npm install gatsby-plugin-minify # or yarn $ ...
Read more >
Gatsby Changelog | 5.3.0
In PR #36623 we fixed this behavior and any node changes (either by changing local files or through webhook updates) will be reflected...
Read more >
Create Source Maps in TypeScript: Inline or File
So we'll need to debug what those original files look like, and where. This is not something you'd create yourself, we would use...
Read more >
The great gatsby upgrade - Scott Nonnenberg
In the past year I've upgraded this blog's version of Gatsby not ... Gatsby 3.0 made this easier: gatsby-plugin-typescript plugin is now ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found