Skip to content
This repository has been archived by the owner on Mar 26, 2024. It is now read-only.

Commit

Permalink
fix: add babel plugins for vite import.meta compat (#279)
Browse files Browse the repository at this point in the history
Co-authored-by: Rico Kahler <[email protected]>
  • Loading branch information
ricokahler and Rico Kahler authored Jan 21, 2023
1 parent 09ab3b7 commit 2df465e
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 9 deletions.
51 changes: 43 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/cli/src/commands/codegen.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ describe('codegen command', () => {
"Converting queries to typescript…",
"Converted 2 queries to TypeScript",
"Writing query types output…",
"Wrote query types output to <PATH>",
"Wrote types to <PATH>",
]
`);

Expand Down
2 changes: 2 additions & 0 deletions packages/extractor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
"@sanity-codegen/types": "^1.0.0-alpha.34",
"babel-merge": "^3.0.0",
"babel-plugin-css-modules-transform": "^1.6.2",
"babel-plugin-transform-import-meta": "^2.2.0",
"babel-plugin-transform-vite-meta-env": "^1.0.3",
"jsdom": "^21.0.0",
"jsdom-global": "^3.0.2",
"prettier": "^2.8.3"
Expand Down
4 changes: 4 additions & 0 deletions packages/extractor/src/default-babel-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ export const defaultBabelOptions = {
plugins: [
// used to resolve css module imports that are allowed in sanity projects
'css-modules-transform',
// used to convert import.meta.env.VAR
'babel-plugin-transform-vite-meta-env',
// used to convert `import.meta.url`
'babel-plugin-transform-import-meta',
'@babel/plugin-proposal-class-properties',
'@babel/plugin-proposal-numeric-separator',
'@babel/plugin-proposal-optional-chaining',
Expand Down

1 comment on commit 2df465e

@vercel
Copy link

@vercel vercel bot commented on 2df465e Jan 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.