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

npm-crate-example appears to be broken #20

Open
mtizim opened this issue Aug 31, 2022 · 3 comments
Open

npm-crate-example appears to be broken #20

mtizim opened this issue Aug 31, 2022 · 3 comments

Comments

@mtizim
Copy link

mtizim commented Aug 31, 2022

Commands and outputs to reproduce:

$ git clone  https://github.com/nshen/vite-plugin-wasm-pack.git && cd vite-plugin-wasm-pack/npm-crate-example
...
$ node --version && wasm-pack --version
v16.17.0
wasm-pack 0.10.3
$ yarn install && yarn dev
yarn install v1.22.19
info No lockfile found.
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Saved lockfile.
Done in 3.81s.
yarn run v1.22.19
$ vite
▲ [WARNING] Cannot find base config file "@tsconfig/node12/tsconfig.json" [tsconfig.json]

    ../tsconfig.json:2:15:
      2 │     "extends": "@tsconfig/node12/tsconfig.json",
        ╵                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

failed to load config from /home/mtizim/testing/vite-plugin-wasm-pack/npm-crate-example/vite.config.ts
error when starting dev server:
Error: Cannot find module 'test-npm-crate'
Require stack:
- /home/mtizim/testing/vite-plugin-wasm-pack/npm-crate-example/node_modules/vite-plugin-wasm-pack/dist/index.js
- /home/mtizim/testing/vite-plugin-wasm-pack/npm-crate-example/vite.config.ts
- /home/mtizim/testing/vite-plugin-wasm-pack/npm-crate-example/node_modules/vite/dist/node/chunks/dep-689425f3.js
- /home/mtizim/testing/vite-plugin-wasm-pack/npm-crate-example/node_modules/vite/dist/node/cli.js
- /home/mtizim/testing/vite-plugin-wasm-pack/npm-crate-example/node_modules/vite/bin/vite.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:956:15)
    at Function.resolve (node:internal/modules/cjs/helpers:108:19)
    at /home/mtizim/testing/vite-plugin-wasm-pack/npm-crate-example/node_modules/vite-plugin-wasm-pack/dist/index.js:58:62
    at Array.forEach (<anonymous>)
    at vitePluginWasmPack (/home/mtizim/testing/vite-plugin-wasm-pack/npm-crate-example/node_modules/vite-plugin-wasm-pack/dist/index.js:56:17)
    at Object.<anonymous> (/home/mtizim/testing/vite-plugin-wasm-pack/npm-crate-example/vite.config.ts:37:54)
    at Module._compile (node:internal/modules/cjs/loader:1126:14)
    at Object.require.extensions.<computed> [as .ts] (/home/mtizim/testing/vite-plugin-wasm-pack/npm-crate-example/node_modules/vite/dist/node/chunks/dep-689425f3.js:62006:20)
    at Module.load (node:internal/modules/cjs/loader:1004:32)
    at Function.Module._load (node:internal/modules/cjs/loader:839:12)�[39m
Command failed with exit code 1.

I ran into the same problem with finding the module with my own package, so I tried to reproduce the example - and it fails on my machine.

@mtizim
Copy link
Author

mtizim commented Aug 31, 2022

This is a regression in 0.1.12 - the example works after changing to 0.1.11

@idkiller
Copy link

Currently, wasm-pack does not create main property in pacakge.json
0.1.12 use require.resolve to get path of module path but require.resolve can not find module that does not have main property in there package.json.
I think it can be fixed with it.

const wasmDirectory = path.dirname(require.resolve(path.join(cratePath, 'package.json'));

go back last 0.1.11 is only solution because it does not use require.resolve.

dabreegster added a commit to dabreegster/svelte_playground that referenced this issue Dec 21, 2022
nshen/vite-plugin-wasm-pack#20 was the cause
of prior confusion.
@kristireispass
Copy link

Had a similar issue with my own package, I also just went back to the older version 0.1.11 and now everything works.

ccarral added a commit to ccarral/schedit-client that referenced this issue May 18, 2023
We lock vite-plugin-wasm-pack to 0.1.11 given that the newest can't
resolve old version of package.json

nshen/vite-plugin-wasm-pack#20
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

3 participants