You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to write a custom element that can be given an src attribute, which points to a module to be imported and used by the program. However, I keep on getting the error Cannot find module '/<filename>.js' when I try to use Parcel.
I've made sure to specify the file being imported as an entry point, and I've confirmed that it is being bundled. I've thought that it might be possible that Parcel is removing the export statements or replacing them with Common JS module exports, but I'm not sure. Besides, if that was the problem I would think that it would still be able to find the file, it just wouldn't be able to get the exports.
Also, just in case this effects anything the file is being imported from a worker thread.
// custom-element.js
const worker = new Worker(new URL("worker.js", import.meta.url), { type: "module" });
// still doesn't work even if you say href instead of pathname
worker.postMessage({ src: new URL(this.getAttribute("src"), location.href).pathname });
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I'm trying to write a custom element that can be given an
src
attribute, which points to a module to be imported and used by the program. However, I keep on getting the errorCannot find module '/<filename>.js'
when I try to use Parcel.I've made sure to specify the file being imported as an entry point, and I've confirmed that it is being bundled. I've thought that it might be possible that Parcel is removing the export statements or replacing them with Common JS module exports, but I'm not sure. Besides, if that was the problem I would think that it would still be able to find the file, it just wouldn't be able to get the exports.
Also, just in case this effects anything the file is being imported from a worker thread.
My code looks something like this:
Beta Was this translation helpful? Give feedback.
All reactions