Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: better syntax support #939

Merged
merged 2 commits into from
Feb 6, 2024
Merged

fix: better syntax support #939

merged 2 commits into from
Feb 6, 2024

Conversation

lxsmnsyc
Copy link
Collaborator

@lxsmnsyc lxsmnsyc commented Feb 3, 2024

Makes it so that the babel plugin supports experimental syntax.

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Thanks for opening this pull request! A maintainer will review it soon.

Copy link

vercel bot commented Feb 3, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
million-kitchen-sink ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 6, 2024 7:42am
sink ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 6, 2024 7:42am

@coveralls
Copy link

coveralls commented Feb 3, 2024

Pull Request Test Coverage Report for Build 7796225717

  • -13 of 13 (0.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.002%) to 3.618%

Changes Missing Coverage Covered Lines Changed/Added Lines %
packages/compiler/plugin.ts 0 13 0.0%
Totals Coverage Status
Change from base Build 7796212315: -0.002%
Covered Lines: 884
Relevant Lines: 27065

💛 - Coveralls

@jahirfiquitiva
Copy link
Contributor

hey @lxsmnsyc , maybe importAssertions is needed too? I just got another error mentioning that one 🤔

⨯ unhandledRejection: SyntaxError: /Users/jahir/dev/jahir/website/.contentlayer/generated/Blog/_index.mjs: Support for the experimental syntax 'importAttributes' isn't currently enabled (3:67):

  1 | // NOTE This file is auto-generated by Contentlayer
  2 |
> 3 | import _23ChangesIn_2023Mdx from './_23-changes-in-2023.mdx.json' assert { type: 'json' }
    |                                                                   ^
  4 | import aFreshStartMdx from './a-fresh-start.mdx.json' assert { type: 'json' }
  5 | import aPrioriCareMdx from './a-priori-care.mdx.json' assert { type: 'json' }
  6 | import astroReadingTimeMdx from './astro-reading-time.mdx.json' assert { type: 'json' }

Add @babel/plugin-syntax-import-attributes (https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-import-attributes) to the 'plugins' section of your Babel config to enable parsing.
    at toParseError (/Users/jahir/dev/jahir/website/node_modules/@babel/parser/src/parse-error.ts:74:19)
    at JSXParserMixin.raise (/Users/jahir/dev/jahir/website/node_modules/@babel/parser/src/tokenizer/index.ts:1487:19)
    at JSXParserMixin.expectOnePlugin (/Users/jahir/dev/jahir/website/node_modules/@babel/parser/src/tokenizer/index.ts:1552:18)
    at JSXParserMixin.maybeParseImportAttributes (/Users/jahir/dev/jahir/website/node_modules/@babel/parser/src/parser/statement.ts:3284:14)
    at JSXParserMixin.parseImportSourceAndAttributes (/Users/jahir/dev/jahir/website/node_modules/@babel/parser/src/parser/statement.ts:3109:10)
    at JSXParserMixin.parseImportSpecifiersAndAfter (/Users/jahir/dev/jahir/website/node_modules/@babel/parser/src/parser/statement.ts:3100:17)
    at JSXParserMixin.parseImport (/Users/jahir/dev/jahir/website/node_modules/@babel/parser/src/parser/statement.ts:3066:17)
    at JSXParserMixin.parseStatementContent (/Users/jahir/dev/jahir/website/node_modules/@babel/parser/src/parser/statement.ts:578:25)
    at JSXParserMixin.parseStatementLike (/Users/jahir/dev/jahir/website/node_modules/@babel/parser/src/parser/statement.ts:417:17)
    at JSXParserMixin.parseModuleItem (/Users/jahir/dev/jahir/website/node_modules/@babel/parser/src/parser/statement.ts:354:17)
    at JSXParserMixin.parseBlockOrModuleBlockBody (/Users/jahir/dev/jahir/website/node_modules/@babel/parser/src/parser/statement.ts:1385:16)
    at JSXParserMixin.parseBlockBody (/Users/jahir/dev/jahir/website/node_modules/@babel/parser/src/parser/statement.ts:1359:10)
    at JSXParserMixin.parseProgram (/Users/jahir/dev/jahir/website/node_modules/@babel/parser/src/parser/statement.ts:213:10)
    at JSXParserMixin.parseTopLevel (/Users/jahir/dev/jahir/website/node_modules/@babel/parser/src/parser/statement.ts:195:25)
    at JSXParserMixin.parse (/Users/jahir/dev/jahir/website/node_modules/@babel/parser/src/parser/index.ts:45:10)
    at parse (/Users/jahir/dev/jahir/website/node_modules/@babel/parser/src/index.ts:66:38)
    at parser (/Users/jahir/dev/jahir/website/node_modules/@babel/core/src/parser/index.ts:28:19)
    at parser.next (<anonymous>)
    at normalizeFile (/Users/jahir/dev/jahir/website/node_modules/@babel/core/src/transformation/normalize-file.ts:50:24)
    at normalizeFile.next (<anonymous>)
    at run (/Users/jahir/dev/jahir/website/node_modules/@babel/core/src/transformation/index.ts:39:36)
    at run.next (<anonymous>)
    at transform (/Users/jahir/dev/jahir/website/node_modules/@babel/core/src/transform.ts:29:20)
    at transform.next (<anonymous>)
    at step (/Users/jahir/dev/jahir/website/node_modules/gensync/index.js:261:32)
    at /Users/jahir/dev/jahir/website/node_modules/gensync/index.js:273:13
    at async.call.result.err.err (/Users/jahir/dev/jahir/website/node_modules/gensync/index.js:223:11)
    at cb (/Users/jahir/dev/jahir/website/node_modules/gensync/index.js:189:28)
    at /Users/jahir/dev/jahir/website/node_modules/@babel/core/src/gensync-utils/async.ts:90:7
    at /Users/jahir/dev/jahir/website/node_modules/gensync/index.js:113:33
    at step (/Users/jahir/dev/jahir/website/node_modules/gensync/index.js:287:14)
    at /Users/jahir/dev/jahir/website/node_modules/gensync/index.js:273:13
    at async.call.result.err.err (/Users/jahir/dev/jahir/website/node_modules/gensync/index.js:223:11) {
  code: 'BABEL_PARSE_ERROR',
  reasonCode: 'MissingOneOfPlugins',
  loc: Position { line: 3, column: 66, index: 119 },
  pos: 119,
  missingPlugin: [ 'importAttributes', 'importAssertions' ]
}

@lxsmnsyc
Copy link
Collaborator Author

lxsmnsyc commented Feb 3, 2024

@jahirfiquitiva importAssertions is actually a deprecated syntax and the importAttributes is its successor. Is there any reason that it is still being used?

@jahirfiquitiva
Copy link
Contributor

@lxsmnsyc thanks for the info, the error mentions both missingPlugin: [ 'importAttributes', 'importAssertions' ], so I think having importAttributes only will be enough then 😅🙌

@lxsmnsyc
Copy link
Collaborator Author

lxsmnsyc commented Feb 3, 2024

seems to me that the cause of the issue was Contentlayer, perhaps it can be moved upstream?

@jahirfiquitiva
Copy link
Contributor

@lxsmnsyc unfortunately Contentlayer development is currently on pause, so it will be hard for this to get fixed there anytime soon. Besides, everything worked fine with million 2.6.4, it just got broken after the upgrade to 3.0.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for the experimental syntax 'importAttributes' isn't currently enabled
4 participants