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

Error on TS type packages #83

Closed
rubensworks opened this issue Dec 10, 2021 · 2 comments
Closed

Error on TS type packages #83

rubensworks opened this issue Dec 10, 2021 · 2 comments
Labels
bug Something isn't working

Comments

@rubensworks
Copy link
Member

When importing from packages without main entrypoint, such as TS types packages like @rdfjs/types, then the generator will fail with an error: Cannot find module @rdfjs/types

This is because the require.resolve logic depends on this main entrypoint.

We might have to dive into the codebase of tsc to see how they resolve this problem there.
But likely, we'll have to reimplement (parts of) require.resolve ourselves to be able to cope with these kinds of resolutions.

@adlerfaulkner
Copy link
Contributor

adlerfaulkner commented Aug 9, 2022

I'm getting Cannot find module path/to/my/project/node_modules/typeorm/package.json.js when running componentsjs-generator on my project.
The typeorm package has this as its exports in package.json:

"exports": {
    ".": {
      "types": "./index.d.ts",
      "node": {
        "import": "./index.mjs",
        "require": "./index.js",
        "types": "./index.d.ts"
      },
      "browser": {
        "require": "./index.js",
        "import": "./browser/index.js",
        "default": "./index.js"
      }
    },
    "./browser": {
      "types": "./index.d.ts",
      "default": "./browser/index.js"
    },
    "./*.js": "./*.js",
    "./*": {
      "require": "./*.js",
      "import": "./*"
    }
  }

If I add "./package.json": "./package.json", to the top of the exports the problem is fixed as found here typeorm/typeorm#9178

I'm on componentsjs-generator version 2.6.1

@rubensworks
Copy link
Member Author

@adlerfaulkner A workaround for such broken packages is being worked in here: #95

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants