ampt-templates / sveltekit

Starter template for using Svelte Kit on Ampt
0 stars 0 forks source link

ampt run build has error assetsDir?.includes is not a function #1

Closed dennistruemper closed 1 year ago

dennistruemper commented 1 year ago

Just checked out the repo, ran "ampt" to get the sandbox going. That gave me an error message of 'Error: Could not locate Svelte app - did you run ampt build?'

So I ran (npx) ampt run build. It produced some output and (npx) ampt run dev is working now, but still a big error message:

npx ampt run build

ampt ⚡(beta)

> ampt-sveltekit-starter-template@0.0.1 ampt:build
> vite build

vite v4.4.9 building SSR bundle for production...
✓ 76 modules transformed.

vite v4.4.9 building for production...
✓ 64 modules transformed.
.svelte-kit/output/client/_app/version.json                              0.03 kB │ gzip: 0.05 kB
.svelte-kit/output/client/vite-manifest.json                             2.56 kB │ gzip: 0.48 kB
.svelte-kit/output/client/_app/immutable/assets/ampt.661ce4a9.svg        2.61 kB │ gzip: 1.26 kB
.svelte-kit/output/client/_app/immutable/assets/2.4fc0a76f.css           1.64 kB │ gzip: 0.62 kB
.svelte-kit/output/client/_app/immutable/nodes/0.ba5897b3.js             0.60 kB │ gzip: 0.38 kB
.svelte-kit/output/client/_app/immutable/nodes/1.9f8e82d5.js             1.03 kB │ gzip: 0.59 kB
.svelte-kit/output/client/_app/immutable/chunks/scheduler.e108d1fd.js    2.16 kB │ gzip: 1.02 kB
.svelte-kit/output/client/_app/immutable/chunks/singletons.bcf80897.js   2.85 kB │ gzip: 1.46 kB
.svelte-kit/output/client/_app/immutable/nodes/2.80c6c86b.js             4.78 kB │ gzip: 1.92 kB
.svelte-kit/output/client/_app/immutable/chunks/index.7e6a41e6.js        5.66 kB │ gzip: 2.41 kB
.svelte-kit/output/client/_app/immutable/entry/app.dafa537a.js           5.85 kB │ gzip: 2.32 kB
.svelte-kit/output/client/_app/immutable/entry/start.a49b948c.js        24.15 kB │ gzip: 9.56 kB
✓ built in 331ms
.svelte-kit/output/server/vite-manifest.json                         1.96 kB
.svelte-kit/output/server/_app/immutable/assets/ampt.661ce4a9.svg    2.61 kB
.svelte-kit/output/server/_app/immutable/assets/_page.4fc0a76f.css   1.64 kB
.svelte-kit/output/server/entries/pages/_page.ts.js                  0.10 kB
.svelte-kit/output/server/entries/pages/_page.server.ts.js           0.12 kB
.svelte-kit/output/server/internal.js                                0.19 kB
.svelte-kit/output/server/entries/fallbacks/layout.svelte.js         0.24 kB
.svelte-kit/output/server/entries/fallbacks/error.svelte.js          0.89 kB
.svelte-kit/output/server/chunks/ssr.js                              3.59 kB
.svelte-kit/output/server/entries/pages/_page.svelte.js              4.45 kB
.svelte-kit/output/server/chunks/internal.js                         5.39 kB
.svelte-kit/output/server/index.js                                  89.22 kB

Run npm run preview to preview your production build locally.

> Using @ampt/sveltekit
error during build:
TypeError: assetsDir?.icludes is not a function
    at adapt (file:///Users/dennis/git/ampt-svelte-fullstack/node_modules/@ampt/sveltekit/dist/index.js:7:75)
    at adapt (file:///Users/dennis/git/ampt-svelte-fullstack/node_modules/@sveltejs/kit/src/core/adapt/index.js:26:8)
    at finalise (file:///Users/dennis/git/ampt-svelte-fullstack/node_modules/@sveltejs/kit/src/exports/vite/index.js:814:13)
    at async Object.handler (file:///Users/dennis/git/ampt-svelte-fullstack/node_modules/@sveltejs/kit/src/exports/vite/index.js:836:5)
    at async PluginDriver.hookParallel (file:///Users/dennis/git/ampt-svelte-fullstack/node_modules/rollup/dist/es/shared/node-entry.js:25341:17)
    at async Object.close (file:///Users/dennis/git/ampt-svelte-fullstack/node_modules/rollup/dist/es/shared/node-entry.js:26593:13)
    at async build (file:///Users/dennis/git/ampt-svelte-fullstack/node_modules/vite/dist/node/chunks/dep-df561101.js:48021:13)
    at async CAC.<anonymous> (file:///Users/dennis/git/ampt-svelte-fullstack/node_modules/vite/dist/node/cli.js:822:9)

So the reason might be this: assetsDir?.icludes("/static") where assetsDir is a string and includes is not supported.

I use node version v16.17.0 and tried v18.17.1

When I change assetsDir?.includes("/static") to assetsDir?.indexOf("/static") !== -1 there are no errors left.

benminer commented 1 year ago

Hey @dennistruemper - thanks for this. .includes is a valid function for Strings as well, I just made a typo and had .icludes. Need to figure out why my linting is not being applied for these packages. Fix being deployed now. Cheers 🍻