webpack-contrib/expose-loader

Cannot expose ts module since 1.0.0

MhMadHamster opened this issue · 4 comments

  • Operating System: Windows 10
  • Node Version: 12.13
  • NPM Version: yarn 1.12.3
  • webpack Version: 4.44.2
  • expose-loader Version: 1.0.0

Expected Behavior

No errors when building project.

Actual Behavior

Error: Cannot read property 'hooks' of undefined occures when building project with exposed ts modules.

Code

// index.ts
function foo() {};

export default foo;

How Do We Reproduce?

Repo with example: https://github.com/MhMadHamster/webpack-expose-ts-modules

module.exports = {
  entry: "expose-loader?exposes=index!./index.ts",
  mode: "development",
  module: {
    rules: [
      {
        test: /\.ts$/,
        use: [
          "thread-loader",
          {
            loader: "ts-loader",
            options: {
              happyPackMode: true
            },
          },
        ],
      },
    ],
  },
}

Do not use loader in entry, it will be error in webpack@5

@evilebottnawi It works currently for js files, so it dosent really make sense to me why js works just fine and ts is not working because of the changes in the next webpack major version. Also there was nothing about "consider not using loader for entries" in the changelog of 1.0.0.

Anyway bug in thread-loader, you can remove thread-loader and all works fine, can you open new issue in thread-loader?

Sure, thanks.