Skip to content

Babel-loader and typescriptΒ #34

@yovanoc

Description

@yovanoc

Actually I have these configs and it does not work, so can you tell me what I'm doing wrong (of course I have "module": "ESNext", in my tsconfig) big thanks

const { join } = require("path");
const { BannerPlugin } = require("webpack");
const ThreadsPlugin = require('threads-plugin');

module.exports = {
  mode: "production",
  devtool: "source-map",
  entry: {
    main: "./src/index.ts"
  },
  output: {
    path: join(__dirname, "lib"),
    filename: "index.js",
    library: "secrecy",
    libraryTarget: "umd"
  },
  target: "web",
  resolve: {
    extensions: [".ts", ".tsx", ".js"],
    fallback: {
      crypto: false,
      path: false
    }
  },
  module: {
    rules: [{ test: /\.tsx?$/, loader: "babel-loader" }]
  },
  plugins: [
    new ThreadsPlugin(),
    new BannerPlugin({
      entryOnly: true,
      raw: true,
      banner: 'typeof window !== "undefined" &&'
    }) // SSR/Node.js guard
  ]
};
{
  "presets": [
    "@babel/preset-typescript",
    [
      "@babel/preset-env",
      {
        "loose": true,
        "modules": false,
        "targets": "defaults"
      }
    ]
  ],
  "plugins": [
    "@babel/plugin-proposal-class-properties",
    "@babel/proposal-object-rest-spread",
    [
      "@babel/plugin-transform-runtime",
      {
        "regenerator": true
      }
    ]
  ]
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions