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

Use require.resolve for modules #15

Merged
merged 2 commits into from
May 20, 2022
Merged

Conversation

greym0uth
Copy link
Contributor

@greym0uth greym0uth commented May 20, 2022

Instead of hard coding the pkg path for the moduleCrates this plugin should use require.resolve to get the location of the wasm-pack bundle files. This is useful for projects that have a static package.json at the root of the crate the defines its entry point with main. It allows for the wasm-pack bundle to live in any directory in the module (i.e dist, lib, pkg, etc.) as well.

I ran into this issue in my project which is lain out like so:

├── README.md
├── package.json
├── packages
│   ├── web
│   └── webgl
│       ├── Cargo.lock
│       ├── Cargo.toml
│       ├── README.md
│       ├── package.json
│       ├── pkg
│       │   ├── webgl.d.ts
│       │   ├── webgl.js
│       │   ├── webgl_bg.d.ts
│       │   └── webgl_bg.wasm
│       └── src
├── pnpm-lock.yaml
└── pnpm-workspace.yaml

Copy link
Owner

@nshen nshen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! learned how to use require.resolve, seems this will resolve #14.

@nshen nshen merged commit e8016a3 into nshen:main May 20, 2022
@greym0uth greym0uth deleted the jg/use-resolver branch May 21, 2022 00:56
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

Successfully merging this pull request may close these issues.

2 participants