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: JSON import type assertion #1824

Merged
merged 3 commits into from Jan 19, 2023
Merged

fix: JSON import type assertion #1824

merged 3 commits into from Jan 19, 2023

Conversation

SheetJSDev
Copy link
Contributor

πŸ”— Linked issue

#1823

❓ Type of change

  • πŸ“– Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

See linked issue

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly. (n/a)

@netlify
Copy link

netlify bot commented Jan 14, 2023

βœ… Deploy Preview for nuxt-content ready!

Name Link
πŸ”¨ Latest commit 4e6292d
πŸ” Latest deploy log https://app.netlify.com/sites/nuxt-content/deploys/63c95056178c8500082e16e0
😎 Deploy Preview https://deploy-preview-1824--nuxt-content.netlify.app
πŸ“± Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@HigherOrderLogic
Copy link
Contributor

 WARN  rollup-plugin-inject: failed to parse /node_modules/@nuxt/content/dist/runtime/transformers/shiki/highlighter.mjs. Consider restricting the plugin to particular files via options.include           

 ERROR                                                                                                                                                                                                           

2: import consola from "consola";
3: import { createSingleton } from "../utils.mjs";
4: import mdcTMLanguage from "./languages/mdc.tmLanguage.json" assert { type: "json" };
                                                               ^
5: const logger = consola.withScope("@nuxt/content");
6: const resolveLang = (lang) => BUNDLED_LANGUAGES.find((l) => l.id === lang || l.aliases?.includes(lang))?.id || lang;

Do you get this error?

@SheetJSDev
Copy link
Contributor Author

That error shows up but oddly enough the pages are still built locally. This patch was the obvious one to resolve the esbuild issue.

There is a bypass without patching the library: change the defineTransformer import to use the version in utils. This change would be applied to the transformer script:

-import { defineTransformer } from '@nuxt/content/transformers'
+import { defineTransformer } from '@nuxt/content/transformers/utils'

@HigherOrderLogic
Copy link
Contributor

That error shows up but oddly enough the pages are still built locally. This patch was the obvious one to resolve the esbuild issue.

There is a bypass without patching the library: change the defineTransformer import to use the version in utils. This change would be applied to the transformer script:

-import { defineTransformer } from '@nuxt/content/transformers'
+import { defineTransformer } from '@nuxt/content/transformers/utils'

Thanks for the workaround.

@farnabaz
Copy link
Member

Import assertion is only supported in Node.js 17 or later (ref). And most of the users still use v16.

@farnabaz
Copy link
Member

Let's convert the json file into a JavaScript one. This will resolve the issue.

@pi0 WDYT?

@SheetJSDev
Copy link
Contributor Author

That approach is better. Patch updated.

There were type issues which prevented the use of the official IRawGrammar type, mainly around comments. For example:

{
  "repository": {
    "block": {
      "comment": "Same as `text.html.markdown#block`, but without `raw_block`",

Based on its usage:

  • the root object should be IRawGrammar
  • repository should be an object of type IRawRepository
  • block should be an object of type IRawRule.

Neither IRawRule nor its parent type ILocatable have a comment field. It's unclear whether this oversight is a bug in vscode-textmate or if it should be removed here.

Copy link
Member

@farnabaz farnabaz left a comment

Choose a reason for hiding this comment

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

Thanks

@farnabaz farnabaz merged commit 1cc86bd into nuxt:main Jan 19, 2023
@farnabaz farnabaz mentioned this pull request Jan 23, 2023
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.

None yet

3 participants