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

Webpack build #101

Open
Thomas-git opened this issue Sep 21, 2020 · 2 comments
Open

Webpack build #101

Thomas-git opened this issue Sep 21, 2020 · 2 comments

Comments

@Thomas-git
Copy link

I can't have your lib working with webpack.
I've got this message in dev console :

Error: Failed to resolve async component default: SecurityError: Worker constructor: Failed to load worker script at "webpack-internal:///./node_modules/wasm-imagemagick/dist/src/magick.js"

Where does magick.js and magick.wasm should go for webpack to found them ?

@KnicKnic
Copy link
Owner

I have never used webpack so I do not know.
Currently the code that tries to find magick.js is at

currentJavascriptURL = GetCurrentFileURL();
const magickWorkerUrl = GetCurrentUrlDifferentFilename(currentJavascriptURL, 'magick.js');
function GenerateMagickWorkerText(magickUrl){
// generates code for the following
// var magickJsCurrentPath = 'magickUrl';
// importScripts(magickJsCurrentPath);
return "var magickJsCurrentPath = '" + magickUrl +"';\n" +
'importScripts(magickJsCurrentPath);'
}
let magickWorker;
if(currentJavascriptURL.startsWith('http'))
{
// if worker is in a different domain fetch it, and run it
magickWorker = new Worker(window.URL.createObjectURL(new Blob([GenerateMagickWorkerText(magickWorkerUrl)])));
}
else{
magickWorker = new Worker(magickWorkerUrl);
}

@Thomas-git
Copy link
Author

I managed to pass this step using Webpack dynamic import feature. But it fails later. I ended doing what I need in JS canvas at the moment.

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

2 participants