Open michelheusschen opened 1 year ago
i got same err
I also encountered this problem. I think you should add "type" : "module"
in package.json
publint is really helpful for catching errors like these: https://publint.dev/copy-image-clipboard
This was fixed in https://github.com/LuanEdCosta/copy-image-clipboard/pull/45 by adding the missing "type": "module"
, but hasn't been released yet
@LuanEdCosta do you think we could get a new release?
@LuanEdCosta it'd be super helpful to us if we could get a new release. Would you be able to help us out?
Describe the bug
Importing this package in SvelteKit leads to warnings in development and to errors in production builds related to ES modules.
I've set up a demo where I've made the following changes from a new SvelteKit project:
npm install copy-image-clipboard
src/routes/+page.svelte
I've added basic code to check for image copy support:onMount(() => { const canCopy = canCopyImagesToClipboard();
});
(node:13) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension. (Use
node --trace-warnings ...
to show where the warning was created) /home/projects/sveltejs-kit-template-default-8qhsvf/node_modules/copy-image-clipboard/dist/index.js:175 export { canCopyImagesToClipboard, convertBlobToPng, copyBlobToClipboard, copyImageToClipboard, createImageElement, getBlobFromImageElement, getBlobFromImageSource, isJpegBlob, isPngBlob, requestClipboardWritePermission }; ^^^^^^SyntaxError: export declarations may only appear at top level of a module at compileFunction (https://sveltejskittemplatedefault8qhs-lxfs.w-corp.staticblitz.com/blitz.927bd077ab89da68c6338c4363cc22e79cccb4ef.js:6:341450) at wrapSafe (https://sveltejskittemplatedefault8qhs-lxfs.w-corp.staticblitz.com/blitz.927bd077ab89da68c6338c4363cc22e79cccb4ef.js:6:218347) at Module.prototype._compile (https://sveltejskittemplatedefault8qhs-lxfs.w-corp.staticblitz.com/blitz.927bd077ab89da68c6338c4363cc22e79cccb4ef.js:6:218723) at Module._extensions[".js"] (https://sveltejskittemplatedefault8qhs-lxfs.w-corp.staticblitz.com/blitz.927bd077ab89da68c6338c4363cc22e79cccb4ef.js:6:219743) at Module.prototype.load (https://sveltejskittemplatedefault8qhs-lxfs.w-corp.staticblitz.com/blitz.927bd077ab89da68c6338c4363cc22e79cccb4ef.js:6:217769) at Module._load (https://sveltejskittemplatedefault8qhs-lxfs.w-corp.staticblitz.com/blitz.927bd077ab89da68c6338c4363cc22e79cccb4ef.js:6:215340) at (https://sveltejskittemplatedefault8qhs-lxfs.w-corp.staticblitz.com/blitz.927bd077ab89da68c6338c4363cc22e79cccb4ef.js:6:983454)
at _evaluate (https://sveltejskittemplatedefault8qhs-lxfs.w-corp.staticblitz.com/blitz.927bd077ab89da68c6338c4363cc22e79cccb4ef.js:15:300439)
at _evaluate (https://sveltejskittemplatedefault8qhs-lxfs.w-corp.staticblitz.com/blitz.927bd077ab89da68c6338c4363cc22e79cccb4ef.js:15:300563)
at ()
Error: 500 /
at normalise_error_handler/<@file://file:///home/projects/sveltejs-kit-template-default-8qhsvf/node_modules/ (sveltejs/kit/src/core/postbuild/prerender.js:68:12)
at save@file://file:///home/projects/sveltejs-kit-template-default-8qhsvf/node_modules/ (sveltejs/kit/src/core/postbuild/prerender.js:370:21)
at visit@file://file:///home/projects/sveltejs-kit-template-default-8qhsvf/node_modules/ (sveltejs/kit/src/core/postbuild/prerender.js:219:7)
at ()
[vite-plugin-sveltekit-compile] Failed with code 1
error during build:
Error: Failed with code 1
at fn/</<@file://file:///home/projects/sveltejs-kit-template-default-8qhsvf/node_modules/ (sveltejs/kit/src/utils/fork.js:83:13)
at EventEmitter.prototype.emit (https://sveltejskittemplatedefault8qhs-lxfs.w-corp.staticblitz.com/blitz.927bd077ab89da68c6338c4363cc22e79cccb4ef.js:6:155574)
at ChildProcess/this._handle.onexit (https://sveltejskittemplatedefault8qhs-lxfs.w-corp.staticblitz.com/blitz.927bd077ab89da68c6338c4363cc22e79cccb4ef.js:6:956239)
at _onChildExit/< (https://sveltejskittemplatedefault8qhs-lxfs.w-corp.staticblitz.com/blitz.927bd077ab89da68c6338c4363cc22e79cccb4ef.js:15:393246)
at _0x5d97a4 (https://sveltejskittemplatedefault8qhs-lxfs.w-corp.staticblitz.com/blitz.927bd077ab89da68c6338c4363cc22e79cccb4ef.js:15:150541)
at _0x2fb6cc/< (https://sveltejskittemplatedefault8qhs-lxfs.w-corp.staticblitz.com/blitz.927bd077ab89da68c6338c4363cc22e79cccb4ef.js:15:150281)
at ()