8000 Module resolution `npm:` alias mapping assumes `node_modules` and eleventy config exist in same directory · Issue #211 · 11ty/webc · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Module resolution npm: alias mapping assumes node_modules and eleventy config exist in same directory #211
Open
@filmaj

Description

@filmaj

First of all: you rock! Love the projects, excellent work, very grateful ❤️

I described my issue in a comment in some more detail over in the eleventy-plugin-webc repo.

I have an issue loading the is-land plugin in an 11ty webc project. I have a large, complicated webapp codebase, where eleventy is but a small part of a larger system. The eleventy bits are located in a subdirectory of this project, ./public, while the package.json for this project exists one directory up, in the root of the project. Thus, node_modules exists one parent directory above where the eleventy project exists.

My particular problem boils down to two issues, I think, which are related:

  1. The fsCache module seems (to me) unnecessarily restrictive re: requiring components to be subdirectories of the "working directory"
  2. npm: component loading aliasing assumes npm: maps to ./node_modules

Issue (1) effectively prevents setting webc component loading to any directory that is not an immediate subdirectory within the eleventy project. For a monorepo style setup, this seems like an unnecessarily restrictive constraint. As mentioned, since in my setup, node_modules is one level up above the eleventy project, that exception is troublesome. Could we consider dropping the code I linked to in (1)?

Issue (2) is related to the same problem: the npm: component loading alias assumes something about the location of the node_modules directory. There is a TODO here, tantalizingly hinting at perhaps the author foreseeing an issue similar to what I'm describing here. I was thinking one way to improve this would be to search up the file tree to find the npm project root first (by looking for the presence of a package.json file), and then joining that found project root with ./node_modules. I think that would solve this issue? What do you think?

I am happy to give a PR a go to try to fix this! I wanted first to check if my thinking is correct / is a PR worth it / would the project be responsive to the issue / provide guidance on how to go about improving the situation.

Thanks for any discussion and thank you once more for an amazing open source project!

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

      0