Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for references #44

Open
sassanh opened this issue Feb 9, 2020 · 5 comments
Open

Support for references #44

sassanh opened this issue Feb 9, 2020 · 5 comments

Comments

@sassanh
Copy link

sassanh commented Feb 9, 2020

It seems like this plugin doesn't support paths defined in references, so I'm suggesting adding this feature to the plugin.

@johnnyreilly
Copy link
Contributor

Sounds good! Fancy submitting a PR?

@sassanh
Copy link
Author

sassanh commented Feb 19, 2020

I tried to find some time to do it but unfortunately no luck so far :(

@chanced
Copy link

chanced commented Aug 11, 2020

ts-loader has support for references:

const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin')

module.exports = {
  entry: './src/index.ts',
  mode: 'development',
  output: {
    filename: 'bundle.js',
  },
  resolve: {
    extensions: ['.ts', '.tsx', '.js'],
    plugins: [new TsconfigPathsPlugin()],
  },
  module: {
    rules: [
      {
        test: /\.tsx?$/,
        loader: 'ts-loader',
        options: { projectReferences: true },
      },
    ],
  },
}

@OliverJAsh
Copy link

OliverJAsh commented Jun 9, 2021

When webpack resolves modules, it should use the paths from these TS projects but only for the modules which belong to the project they're defined for.

To illustrate this, here's an example:

Project shared has these paths:

  "paths": {
    "helpers/*": ["./my-helpers/*"]
  }

Project app references project shared and has these paths:

  "paths": {
    "components/*": ["./my-components/*"]
  }

The components/* path defined by the app project should not be used for modules inside of the referenced project shared.

@OliverJAsh
Copy link

Here is a reduced test case to demonstrate the problem: https://github.com/OliverJAsh/tsconfig-paths-project-references-bug

The paths inside the referenced project shared/tsconfig.json are not picked up at all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants