Closed maxevilmind closed 3 years ago
What bundler are you using? I rely on the "browser"
key of package.json
to replace the import in the browser.
@101arrowz we don't have any bundler 🙈
We have a build-less open-wc setup (more on that https://modern-web.dev/guides/going-buildless/es-modules). That's pretty much what brought us to use fflate as it provides ESM exports and other similar libraries are common js
. I am not sure if it is somehow possible to utilize this key while using no bundler.
If that's the case, I will change the build script to add a version that supports true ESM. Is there nothing in that guide that allows custom module resolution?
@101arrowz wow that would be really amazing to get the true ESM
version.
Is there nothing in that guide that allows custom module resolution?
I think unless I write my own tool for it - there is no way...
@maxevilmind I've pushed v0.3.6 with commit 214ec2f645b3195390f95abd0c0925609e28d9bd. Try the import again. Thanks for the feature request!
@101arrowz amazing! thank you for pushing it quickly! I will test it out today
Did it end up working for you?
yep, import works perfectly now thank you for adding the changes!
No idea how useful this is for you at this point @maxevilmind, but you probably would have been able to get the package working like this:
web-dev-server --config config.wds.mjs
In config.wds.mjs
:
export default {
nodeResolve: {
browser: true
}
}
Obviously I'm not going to revert the package to before this bugfix, just thought it may be useful to know.
Hi everyone, I am trying to use the library as an ESM module like that:
import * as fflate from 'fflate';
But I am gettingError: Could not resolve import "worker_threads" in "../../../node_modules/fflate/esm/node-worker.js".
Inesm/index.js
I see the following lineimport wk from './node-worker';
and if I change it toimport wk from './worker';
it works fine.As I understand it tries to run node version worker in web for some reason. Does it miss some sort of condition to import proper worker?
I really need this so I am ready to work out a PR for that.