Skip to content

Absolute module imports through node_modules symlinks with Plug'n'Play #6616

Description

@msokk

Do you want to request a feature or report a bug?
bug?

What is the current behavior?
We are using node_modules inside src folder for symlinking to have short absolute imports for commonly used folders:

src/
  types/
  node_modules/
    types/ (symlink)
    ...
  ...

With PnP this behaviour is lost:
Error: You cannot require a package ("types") that is not declared in your dependencies (via "src/api/client.ts")

Symlinks are a nice tool-agnostic way of enabling this, see Dan's comment - react/create-react-app#5136 (comment)

If the current behavior is a bug, please provide the steps to reproduce.

  1. Symlink some source file or folder to any node_modules folder
  2. Import that folder using absolute import
  3. Run the code

What is the expected behavior?
PnP should either provide a way to allow locally symlinked source folders through or
document migration path / alternatives.

One option would be to write all those imports to relative, as they are a bit magic - making it a bit hard to distinguish between published modules and local. Although in the project I'm testing PnP, there are a few thousand absolute imports.

@arcanis Any ideas?

Please mention your node.js, yarn and operating system version.
Node.js v10.13.0
Yarn v1.12.1 with --pnp enabled
macOS 10.12.6
Webpack 4.20.2
pnp-webpack-plugin 1.2.0
ts-loader 5.3.0

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions