svelte-gantt icon indicating copy to clipboard operation
svelte-gantt copied to clipboard

after svelteKit update to .480 getting error

Open Avi-ADAM opened this issue 3 years ago • 6 comments
trafficstars

after updating to [email protected] i get this error on page that have the gantt `Unexpected token 'export' C:\node_modules\svelte-gantt\index.js:7180 export { MomentSvelteGanttDateAdapter, SvelteGantt, SvelteGanttDependencies, SvelteGanttExternal, SvelteGanttTable }; ^^^^^^

SyntaxError: Unexpected token 'export' at Object.compileFunction (node:vm:352:18) at wrapSafe (node:internal/modules/cjs/loader:1027:15) at Module._compile (node:internal/modules/cjs/loader:1063:27) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10) at Module.load (node:internal/modules/cjs/loader:975:32) at Function.Module._load (node:internal/modules/cjs/loader:822:12) at ModuleWrap. (node:internal/modules/esm/translators:170:29) at ModuleJob.run (node:internal/modules/esm/module_job:198:25) at async Promise.all (index 0) at async ESMLoader.import (node:internal/modules/esm/loader:409:24)` may be would be helpful to know that if after page load i uncomment the gantt component its working until page reload

Avi-ADAM avatar Sep 12 '22 12:09 Avi-ADAM

I'll give it a look asap, until then go back to the previous version, thanks for the feedback !

V-Py avatar Sep 12 '22 12:09 V-Py

maby has something to do with node version, I updated to v16.14.2 for the svelteKit update

Avi-ADAM avatar Sep 13 '22 08:09 Avi-ADAM

Definitely about the SvelteKit update and the node version coming with it. I searched a bit last night and got the error in one of my project with the latest SveltKit version, and didn't have the error in another project with an older one. Looks to be a build problem, currently reading some docs about the differences between CommonJS vs ES6 module. I'm not a specialist of this subject, so it might take a while, if someone read this and has time to give it a look and submit a PR would be awesome.

V-Py avatar Sep 13 '22 08:09 V-Py

I ask on sveltekit discord Got some questions that I don't know how to answer, maybe can you?

Avi-ADAM avatar Sep 14 '22 13:09 Avi-ADAM

Great idea, I'll have some time to answer on the discord and try to tackle this problem tomorrow and this weekend. Will keep you informed asap

V-Py avatar Sep 15 '22 05:09 V-Py

It may be a hint when i move to the page with goto() its working only on reloading or on navigation directly to the gantt page i get this Error

Avi-ADAM avatar Sep 20 '22 12:09 Avi-ADAM

It may be a hint when i move to the page with goto() its working only on reloading or on navigation directly to the gantt page i get this Error

this is true for 4.0.7beta , on 4.0.8beta also goto() give me this error [plugin:vite:import-analysis] Failed to resolve entry for package "svelte-gantt". The package may have incorrect main/module/exports specified in its package.json. C:/./src/lib/components/xx/gantt/gant.svelte at packageEntryFailure (file:///C:/./node_modules/vite/dist/node/chunks/dep-db16f19c.js:34841:11) at resolvePackageEntry (file:///C:/node_modules/vite/dist/node/chunks/dep-db16f19c.js:34838:5) at tryNodeResolve (file:///C:/./node_modules/vite/dist/node/chunks/dep-db16f19c.js:34584:20) at Context.resolveId (file:///C:/./node_modules/vite/dist/node/chunks/dep-db16f19c.js:34357:28) at async Object.resolveId (file:///C:/./node_modules/vite/dist/node/chunks/dep-db16f19c.js:41039:32) at async TransformContext.resolve (file:///C:/./node_modules/vite/dist/node/chunks/dep-db16f19c.js:40808:23) at async normalizeUrl (file:///C:/./node_modules/vite/dist/node/chunks/dep-db16f19c.js:37589:34) at async TransformContext.transform (file:///C:/./node_modules/vite/dist/node/chunks/dep-db16f19c.js:37728:47) at async Object.transform (file:///C:/./node_modules/vite/dist/node/chunks/dep-db16f19c.js:41111:30) at async loadAndTransform (file:///C:/./node_modules/vite/dist/node/chunks/dep-db16f19c.js:37373:29 Click outside or fix the code to dismiss. You can also disable this overlay by setting server.hmr.overlay to false in vite.config.js.

Avi-ADAM avatar Oct 06 '22 15:10 Avi-ADAM

It may be a hint when i move to the page with goto() its working only on reloading or on navigation directly to the gantt page i get this Error

also now (svelteKit .510) this is added to the error (node:11604) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.

Avi-ADAM avatar Oct 06 '22 15:10 Avi-ADAM

manage to solve by using import inside onMount let SvelteGantt, SvelteGanttTable, MomentSvelteGanttDateAdapter; let data; onMount(async() => { SvelteGantt = (await import ('svelte-gantt')).SvelteGantt SvelteGanttTable = (await import ('svelte-gantt')).SvelteGanttTable MomentSvelteGanttDateAdapter = (await import ('svelte-gantt')).MomentSvelteGanttDateAdapter data = generate(); let options = {...} })

Avi-ADAM avatar Oct 09 '22 11:10 Avi-ADAM

For the next guy passing by :laughing:

<script>
let SvelteGantt;
let SvelteGanttTable;
let MomentSvelteGanttDateAdapter; 
let data; 

onMount(async() => { 
  SvelteGantt = (await import ('svelte-gantt')).SvelteGantt 

  SvelteGanttTable = (await import ('svelte-gantt')).SvelteGanttTable 

  MomentSvelteGanttDateAdapter = (await import ('svelte-gantt')).MomentSvelteGanttDateAdapter 

  data = generate();
  let options = {...} ;
})
</script>

trasherdk avatar Jan 24 '23 07:01 trasherdk