Skip to content

Doesn't work with webpack, ts-loader, babel with tsconfig.json > target: "es5" configuration. #147

@chulman444

Description

@chulman444
// webpack.confg.js snippet:
rules: [
  {
    test: /\.tsx?$/,
    exclude: /node_modules/,
    use: [
      {
        loader: "babel-loader",
        options: {
          presets: ["@babel/preset-react"],
          plugins: [
            "transform-react-pug",
            // "@babel/transform-react-jsx"
          ]
        }
      },
      {
        loader: 'ts-loader'
      }
    ]
  }
]

With target: "es6" it works whether "@babel/transform-react-jsx" plugin is used or not.

// tsconfig.json
{
  "compilerOptions": {
    "jsx": "preserve", // works whether `preserve` or `react`
    "target": "es5", // es5 doesn't work
    "strict": true,
    "module": "es2015",
    "moduleResolution": "node",
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true,
    "sourceMap": true,
    "allowJs": true,
    "baseUrl": ".",
    "paths": {
      "~/*": ["./*"]
    },
  },
  "exclude": ["./node_modules"]
}

Is this an issue with babel or this plugin?

Document this maybe?

If there is a workaround, I would love to know. Spent some time trying to fix this one character issue of changing 5 to 6...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions