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

package that uses buffer as dependency fails #49

Closed
wighawag opened this issue Sep 21, 2021 · 5 comments
Closed

package that uses buffer as dependency fails #49

wighawag opened this issue Sep 21, 2021 · 5 comments

Comments

@wighawag
Copy link

Error

[mf:err] MiniflareError: Unable to resolve "dist/index.mjs" dependency "buffer": no matching module rules
[mf:err] MiniflareError: Unable to resolve "dist/index.mjs" dependency "buffer": no matching module rules
    at ScriptLinker._linker (/home/wighawag/dev/wighawag/etherplay/conquest-agent-service/node_modules/miniflare/src/scripts.ts:126:13)
    at ModuleWrap.<anonymous> (internal/vm/module.js:321:30)
    at SourceTextModule.<computed> (internal/vm/module.js:320:36)
    at SourceTextModule.link (internal/vm/module.js:198:22)
    at ScriptBlueprint.buildModule (/home/wighawag/dev/wighawag/etherplay/conquest-agent-service/node_modules/miniflare/src/scripts.ts:42:18)
    at Miniflare._Miniflare_reloadWorker (/home/wighawag/dev/wighawag/etherplay/conquest-agent-service/node_modules/miniflare/src/index.ts:180:26)
    at Miniflare._Miniflare_watchCallback (/home/wighawag/dev/wighawag/etherplay/conquest-agent-service/node_modules/miniflare/src/index.ts:124:29)
    at OptionsWatcher._init (/home/wighawag/dev/wighawag/etherplay/conquest-agent-service/node_modules/miniflare/src/options/watcher.ts:100:16)
    at Miniflare.getOptions (/home/wighawag/dev/wighawag/etherplay/conquest-agent-service/node_modules/miniflare/src/index.ts:292:5)
@mrbbot
Copy link
Contributor

mrbbot commented Sep 21, 2021

Hey! 👋 It looks like you're trying to import an npm module without a build-step. Workers only natively support modules that are located in your upload directory, not node_modules. Check out https://miniflare.dev/recipes/esbuild.html for an example of using esbuild to bundle your code first. Let me know if you have any issues with this. 👍

@wighawag
Copy link
Author

Hey @mrbbot thanks for the quick answer

I am using the rollup configuration from cloudflare typescript template here : https://github.com/cloudflare/durable-objects-typescript-rollup-esm

I guess the rollup config is missing some option ?

I ll investigate more and might as well switch to esbuild that I am using for my frontend through vite anyway.

@janat08
Copy link

janat08 commented Sep 24, 2021

close?

@mrbbot mrbbot closed this as completed Sep 24, 2021
@faisalil
Copy link

@janat08 , @wighawag, @mrbbot , I am having the same problem with a different package. I am getting
MiniflareError: Unable to resolve "dist/index.mjs" dependency "perf_hooks": no matching module rules
and I am using the rollback template setup. Any hints for what would fix it?

@janat08
Copy link

janat08 commented Jan 18, 2022

Hey! 👋 It looks like you're trying to import an npm module without a build-step. Workers only natively support modules that are located in your upload directory, not node_modules. Check out https://miniflare.dev/recipes/esbuild.html for an example of using esbuild to bundle your code first. Let me know if you have any issues with this.

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

4 participants