How to import the module using Webpack?
See original GitHub issueHow do I import the module for use with a webpack dev server? Where do I put the magick.wasm
and magick.js
files? I’m using preact and start the dev server with preact watch
. Can I edit webpack.config.js
to include the files somehow?
edit: I’ve tried using copy-webpack-plugin
, which seems to work if I build the project, but in the development server I get errors:
Uncaught (in promise) DOMException: Failed to register a ServiceWorker for scope ('https://localhost:8080/') with script ('https://localhost:8080/sw-debug.js'): An unknown error occurred when fetching the script.
DOMException: Failed to construct 'Worker': Script at 'webpack-internal:///../node_modules/wasm-imagemagick/dist/src/magick.js' cannot be accessed from origin 'https://localhost:8080'.
Uncaught (in promise) DOMException: Failed to construct 'Worker': Script at 'webpack-internal:///../node_modules/wasm-imagemagick/dist/src/magick.js' cannot be accessed from origin 'https://localhost:8080'.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:6
Top Results From Across the Web
Module Methods - webpack
Version 2 of webpack supports ES6 module syntax natively, meaning you can use import and export without a tool like babel to handle...
Read more >How to import bundle created in webpack? - Stack Overflow
My requirement is that this bundle.js will be put on a CDN so that I can use the modules exported in Project 1...
Read more >Webpack and Dynamic Imports: Doing it Right - Medium
In Webpack normally we load images as modules using the file loader. The file loader will basically map the emitted file path inside...
Read more >How to use an ES module and webpack - Educative.io
Step 1: Create a project directory · Step 2: Go to the project's root folder · Step 3: Create a package.json file ·...
Read more >A Guide to Managing Webpack Dependencies - Toptal
The Webpack module bundler processes JavaScript code and all static assets, ... For this purpose, we can use require.ensure or System.import functions, ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I tried to modify the bundled output
.js
file, use a hack way of loading the Web worker in webpack.image-magick
Unfortunately it takes a little longer to load the
.js
file (5 MB) for the first time in the page 😣hope this helps
i have gotten this to work by including this script directly in my html
as you can see, it imports the lib from a remote source and then puts it on the window object. I still include the wasm files in the public directory. I still include the node module in my dependencies so that I can grab the typescript types and use them to extend window.
it’s not ideal, but i also was not successful in any of my attempts to just use the npm module.
hope this helps!