siriwave
siriwave copied to clipboard
Issues when using with sveltekit
I found some issues when trying to use siriwave with sveltekit.
It always throw this error.
export { SiriWave as default };
^^^^^^
SyntaxError: Unexpected token 'export'
at Object.compileFunction (node:vm:360:18)
at wrapSafe (node:internal/modules/cjs/loader:1055:15)
at Module._compile (node:internal/modules/cjs/loader:1090:27)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1180:10)
at Module.load (node:internal/modules/cjs/loader:1004:32)
at Function.Module._load (node:internal/modules/cjs/loader:839:12)
at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:170:29)
at ModuleJob.run (node:internal/modules/esm/module_job:193:25)
at async Promise.all (index 0)
at async ESMLoader.import (node:internal/modules/esm/loader:533:24)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
I manage to get around this by changing the siriwave package.json adding this line
type: 'modules'
{
"name": "siriwave",
"version": "2.3.0",
"description": "The Siri wave replicated in a JS library.",
"module": "./dist/siriwave.esm.js",
"main": "./dist/siriwave.esm.js",
"browser": "./dist/siriwave.umd.js",
"types": "./dist/types",
"type": "module", // <------- this line
"umdName": "SiriWave",
"files": [
"/dist",
"/src"
],
"scripts": {
"gh-pages": "git checkout master && git pull && git checkout gh-pages && git reset --hard master && git push -f origin gh-pages && git checkout master",
"build:declaration": "rm -rf ./dist/types && tsc --outDir ./dist/types --declaration && rm -rf ./dist/types/*.js",
"build": "yarn build:declaration && NODE_ENV=production rollup -c",
"dev": "BUILD=watch rollup -c -w"
},
"repository": {
"type": "git",
"url": "git+https://github.com/kopiro/siriwave.git"
},
"keywords": [
"siri",
"siriwave",
"ios"
],
"author": "Flavio De Stefano",
"license": "MIT",
"bugs": {
"url": "https://github.com/kopiro/siriwave/issues"
},
"homepage": "https://github.com/kopiro/siriwave#readme",
"devDependencies": {
"@rollup/plugin-typescript": "^6.1.0",
"eslint": "^7.14.0",
"eslint-plugin-prettier": "^3.1.3",
"prettier": "^2.0.5",
"rollup": "^2.7.6",
"rollup-plugin-livereload": "^2.0.0",
"rollup-plugin-serve": "^1.1.0",
"rollup-plugin-terser": "^7.0.2",
"tslib": "^2.0.0",
"typescript": "^4.1.2"
}
}
after that I run yarn again, and its working just fine, no problem at all.
but every time I install new packages in my project, the siriwave package.json
get override to the old one, and every time I need to re add the line to it.
type: 'modules'
I am not sure the implication of adding this line in pakcage.json to current siriwave project. but if there's no significant effect, then maybe you can consider adding this line ? (just my suggestions)
yup, this is the bug in this library. it should contain the type:module
in distributed package.json