GithubHelp home page GithubHelp logo

Comments (3)

resir014 avatar resir014 commented on August 10, 2024 2

My current workaround is to add this to gatsby-node.js:

const path = require('path')

const extractQueryPlugin = path.resolve(
  __dirname,
  `node_modules/gatsby/dist/utils/babel-plugin-extract-graphql.js`
)

exports.modifyWebpackConfig = ({ config, stage }) => {
  if (stage === 'build-javascript') {
    // Temporary workaround.
    // Here we override the Webpack plugin during the `build-javascript` stage to make everything
    // compile down to es5 - turns out Webpack 1's UglifyJsPlugin doesn't like that we have some
    // ES6 stuff littered in our final bundle...
    config.loader('typescript', {
      test: /\.tsx?$/,
      loaders: [
        `babel-loader?${JSON.stringify({ presets: ['babel-preset-env'], plugins: [extractQueryPlugin] })}`,
        'ts-loader'
      ]
    })
  }
}

from gatsby-starter.

fabien0102 avatar fabien0102 commented on August 10, 2024

Interesting! No reason, it's a real bug 😉 I will try to check this tomorrow!

from gatsby-starter.

resir014 avatar resir014 commented on August 10, 2024

@fabien0102 Hey, this happens to me as well - I'm not using this starter kit, since I have my own, TypeScript-based setup, but it seems like it's a common issue among TypeScript at the moment.

My current hunch is that there's something that prevents gatsby-plugin-typescript to be perfectly chained with Webpack's UglifyJS plugin, so many files come out unminified (see also: gatsbyjs/gatsby#2771)

Here's an example of the output bundle that Gatsby generates. If you have some ES6 stuff like this, Webpack 1's UglifyJsPlugin will run into problems when trying to minify.

image

from gatsby-starter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.