import fabric using externals vs from node_modules #10380
Shashank-Bhatt1
started this conversation in
General
Replies: 2 comments 2 replies
-
There’s always one that suits you. import * as fabric from 'fabric' const f = require('fabric') window.fabric.fabric = window.fabric; |
Beta Was this translation helpful? Give feedback.
2 replies
-
I have been trying to import fabric as an external dependency in a bundler and i had some issues as well. I didn't come back to it yet. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I got into one issue and found similar problem here when trying to use fabric as modular vs global way.
i am working on package and i need to import fabric, but i need to be able to do so that for any of bundler/global way it should be correct, as i am not sure whether parent app /package have it already available in global scope or not.
import fabric from 'fabric'
statement while using modular way, it expects to destructure like{fabric}
umd
way by keepingfabric
as externals in vite.config (or webpack.config) thenimport {fabric} from 'fabric'
creates an issue because at that time fabric is global and directly needed as fabric and not {fabric}.Is there any common workaround for this so that using it in any way does not require code modification? I also tried using es build entry of vite bundler instead of umd but still same problem occurs.
Beta Was this translation helpful? Give feedback.
All reactions