You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
However, as soon as I updated to Astro 3.0 with the same code, the following error screen appeared.
SyntaxError: /home/tadashi/dev/astro_test/new_blog/src/library/microcms.ts: Support for the experimental syntax 'decorators' isn't currently enabled (72:3):
71 | class CMSBlog {
> 72 | @Cache(userCache, { ttl: 300 })
| ^
73 | // export const getBlogs = async (queries?: MicroCMSQueries) => {
74 | public async getBlogs(queries?: MicroCMSQueries) {
75 | const data = await client.get<BlogResponse>({ endpoint: "blogs", queries });
Add @babel/plugin-proposal-decorators (https://github.com/babel/babel/tree/main/packages/babel-plugin-proposal-decorators) to the 'plugins' section of your Babel config to enable transformation.
If you want to leave it as-is, add @babel/plugin-syntax-decorators (https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-decorators) to the 'plugins' section to enable parsing.
at constructor (/home/tadashi/dev/astro_test/new_blog/node_modules/@babel/parser/lib/index.js:345:19)
at TypeScriptParserMixin.raise (/home/tadashi/dev/astro_test/new_blog/node_modules/@babel/parser/lib/index.js:3199:19)
at TypeScriptParserMixin.expectOnePlugin (/home/tadashi/dev/astro_test/new_blog/node_modules/@babel/parser/lib/index.js:3245:18)
at TypeScriptParserMixin.parseDecorator (/home/tadashi/dev/astro_test/new_blog/node_modules/@babel/parser/lib/index.js:12739:10)
at /home/tadashi/dev/astro_test/new_blog/node_modules/@babel/parser/lib/index.js:13322:32
at TypeScriptParserMixin.withSmartMixTopicForbiddingContext (/home/tadashi/dev/astro_test/new_blog/node_modules/@babel/parser/lib/index.js:12203:14)
at TypeScriptParserMixin.parseClassBody (/home/tadashi/dev/astro_test/new_blog/node_modules/@babel/parser/lib/index.js:13311:10)
at TypeScriptParserMixin.parseClass (/home/tadashi/dev/astro_test/new_blog/node_modules/@babel/parser/lib/index.js:13289:22)
at TypeScriptParserMixin.parseClass (/home/tadashi/dev/astro_test/new_blog/node_modules/@babel/parser/lib/index.js:9917:20)
at TypeScriptParserMixin.parseStatementContent (/home/tadashi/dev/astro_test/new_blog/node_modules/@babel/parser/lib/index.js:12559:21)
at TypeScriptParserMixin.parseStatementContent (/home/tadashi/dev/astro_test/new_blog/node_modules/@babel/parser/lib/index.js:9323:18)
at TypeScriptParserMixin.parseStatementLike (/home/tadashi/dev/astro_test/new_blog/node_modules/@babel/parser/lib/index.js:12530:17)
at TypeScriptParserMixin.parseModuleItem (/home/tadashi/dev/astro_test/new_blog/node_modules/@babel/parser/lib/index.js:12507:17)
at TypeScriptParserMixin.parseBlockOrModuleBlockBody (/home/tadashi/dev/astro_test/new_blog/node_modules/@babel/parser/lib/index.js:13131:36)
at TypeScriptParserMixin.parseBlockBody (/home/tadashi/dev/astro_test/new_blog/node_modules/@babel/parser/lib/index.js:13124:10)
at TypeScriptParserMixin.parseProgram (/home/tadashi/dev/astro_test/new_blog/node_modules/@babel/parser/lib/index.js:12406:10)
at TypeScriptParserMixin.parseTopLevel (/home/tadashi/dev/astro_test/new_blog/node_modules/@babel/parser/lib/index.js:12396:25)
at TypeScriptParserMixin.parse (/home/tadashi/dev/astro_test/new_blog/node_modules/@babel/parser/lib/index.js:14292:10)
at TypeScriptParserMixin.parse (/home/tadashi/dev/astro_test/new_blog/node_modules/@babel/parser/lib/index.js:9965:18)
at parse (/home/tadashi/dev/astro_test/new_blog/node_modules/@babel/parser/lib/index.js:14333:38)
at parser (/home/tadashi/dev/astro_test/new_blog/node_modules/@babel/core/lib/parser/index.js:41:34)
at parser.next (<anonymous>)
at normalizeFile (/home/tadashi/dev/astro_test/new_blog/node_modules/@babel/core/lib/transformation/normalize-file.js:64:38)
at normalizeFile.next (<anonymous>)
at run (/home/tadashi/dev/astro_test/new_blog/node_modules/@babel/core/lib/transformation/index.js:21:50)
at run.next (<anonymous>)
at transform (/home/tadashi/dev/astro_test/new_blog/node_modules/@babel/core/lib/transform.js:22:41)
at transform.next (<anonymous>)
at step (/home/tadashi/dev/astro_test/new_blog/node_modules/gensync/index.js:261:32)
at /home/tadashi/dev/astro_test/new_blog/node_modules/gensync/index.js:273:13
at async.call.result.err.err (/home/tadashi/dev/astro_test/new_blog/node_modules/gensync/index.js:223:11)
at /home/tadashi/dev/astro_test/new_blog/node_modules/gensync/index.js:189:28
at /home/tadashi/dev/astro_test/new_blog/node_modules/@babel/core/lib/gensync-utils/async.js:68:7
at /home/tadashi/dev/astro_test/new_blog/node_modules/gensync/index.js:113:33
at step (/home/tadashi/dev/astro_test/new_blog/node_modules/gensync/index.js:287:14)
at /home/tadashi/dev/astro_test/new_blog/node_modules/gensync/index.js:273:13
at async.call.result.err.err (/home/tadashi/dev/astro_test/new_blog/node_modules/gensync/index.js:223:11)
What's the expected result?
To be able to use decorators.
To be able to use "node-ts-cache" Cache with decorators.
I am willing to submit a pull request for this issue.
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/[email protected]/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/[email protected]/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/[email protected]/node_modules/microcms-js-sdk/dist/cjs/microcms-js-sdk.js:1:2523)
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/[email protected]/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/[email protected]/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/[email protected]/node_modules/microcms-js-sdk/dist/cjs/microcms-js-sdk.js:1:2523)
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!
Thanks! It is working for me now. For reference, this is the changes I made to the astro.config.mjs file, as suggested above.
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