Closed excelsior091224 closed 1 year ago
Just checked your reproduction, and the console shows a different error (something about apiKey). Could you create a minimal reproduction?
14:08:57 [vite] Error when evaluating SSR module /src/library/microcms.ts:
|- Error: parameter is required (check serviceDomain and apiKey)
at exports.createClient (/home/projects/withastro-astro-nsscxq/node_modules/.pnpm/microcms-js-sdk@2.5.0/node_modules/microcms-js-sdk/dist/cjs/microcms-js-sdk.js:1:2523)
14:08:57 [vite] Error when evaluating SSR module /src/components/Header.astro: failed to import "/src/library/microcms.ts"
|- Error: parameter is required (check serviceDomain and apiKey)
at exports.createClient (/home/projects/withastro-astro-nsscxq/node_modules/.pnpm/microcms-js-sdk@2.5.0/node_modules/microcms-js-sdk/dist/cjs/microcms-js-sdk.js:1:2523)
14:08:57 [vite] Error when evaluating SSR module /home/projects/withastro-astro-nsscxq/src/pages/[...page].astro: failed to import "/src/components/Header.astro"
|- Error: parameter is required (check serviceDomain and apiKey)
at exports.createClient (/home/projects/withastro-astro-nsscxq/node_modules/.pnpm/microcms-js-sdk@2.5.0/node_modules/microcms-js-sdk/dist/cjs/microcms-js-sdk.js:1:2523)
Hello @excelsior091224. Please provide a minimal reproduction using a GitHub repository or StackBlitz. Issues marked with needs repro
will be closed if they have no activity within 3 days.
Just checked your reproduction, and the console shows a different error (something about apiKey). Could you create a minimal reproduction?
14:08:57 [vite] Error when evaluating SSR module /src/library/microcms.ts: |- Error: parameter is required (check serviceDomain and apiKey) at exports.createClient (/home/projects/withastro-astro-nsscxq/node_modules/.pnpm/microcms-js-sdk@2.5.0/node_modules/microcms-js-sdk/dist/cjs/microcms-js-sdk.js:1:2523) 14:08:57 [vite] Error when evaluating SSR module /src/components/Header.astro: failed to import "/src/library/microcms.ts" |- Error: parameter is required (check serviceDomain and apiKey) at exports.createClient (/home/projects/withastro-astro-nsscxq/node_modules/.pnpm/microcms-js-sdk@2.5.0/node_modules/microcms-js-sdk/dist/cjs/microcms-js-sdk.js:1:2523) 14:08:57 [vite] Error when evaluating SSR module /home/projects/withastro-astro-nsscxq/src/pages/[...page].astro: failed to import "/src/components/Header.astro" |- Error: parameter is required (check serviceDomain and apiKey) at exports.createClient (/home/projects/withastro-astro-nsscxq/node_modules/.pnpm/microcms-js-sdk@2.5.0/node_modules/microcms-js-sdk/dist/cjs/microcms-js-sdk.js:1:2523)
Sorry, I modified the original code to a format that doesn't use decorators to avoid errors, so that's reflected here as well. I think I was able to reproduce the error here. https://stackblitz.com/edit/withastro-astro-8yv6dv?file=src%2Fpages%2Fblog.astro
Why closed?? I made minimal reproduction!!
You can add include: ['**/*.[jt]sx']
to the preact integration to work around it.
Looks like the bug is coming from @preact/preset-vite
trying to parse .js,.ts files with babel too, I'm not sure why and looking at @vitejs/plugin-react
it seems to do the same too. I'll try to check this upstream.
You can add
include: ['**/*[jt]sx']
to the preact integration to work around it.Looks like the bug is coming from
@preact/preset-vite
trying to parse .js,.ts files with babel too, I'm not sure why and looking at@vitejs/plugin-react
it seems to do the same too. I'll try to check this upstream.
It seems works. Thanks!
@bluwy what's the the solution for fixing this bug? Do we have to do something from our end?
Closing since the issue was resolved.
I am facing the same issue while using the @astrojs/lit integration. May I know what is the solution to this issue?
I am new to the Astro framework. Which file should I edit?
I am new to the Astro framework. Which file should I edit?
astro.config.mjs
Thanks! It is working for me now. For reference, this is the changes I made to the astro.config.mjs
file, as suggested above.
export default defineConfig({
integrations: [
lit(),
preact({include: ['**/*[jt]sx']}), // <-- add {include:...}
]
});
EDIT: Nevermind, seems to be expected according to these docs: https://docs.astro.build/en/guides/integrations-guide/preact/#combining-multiple-jsx-frameworks
Closing since the issue was resolved.
A workaround exists but the issue is not resolved IMO - this should be reopened
Manually including jsx/tsx files when using both astro/preact
& astro/lit
shouldn't be required
Why? if you want to use multiple frameworks you need to specify which files are for which. Astro doesn't try to guess anymore, starting in 3.0, as it was buggy to do so.
Astro info
What browser are you using?
Chrome
Describe the Bug
The following code was used to cache data fetched from the headless CMS "microCMS". https://github.com/excelsior091224/new_blog/blob/b830ff0886a8de42dda90ad065d63cbc985b30c7/src/library/microcms.ts
However, as soon as I updated to Astro 3.0 with the same code, the following error screen appeared.
What's the expected result?
To be able to use decorators. To be able to use "node-ts-cache" Cache with decorators.
Link to Minimal Reproducible Example
https://stackblitz.com/edit/withastro-astro-8yv6dv?file=src%2Fpages%2Fblog.astro
Participation