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

Sourcemap generation #3

Open
tonyketcham opened this issue May 21, 2022 · 6 comments
Open

Sourcemap generation #3

tonyketcham opened this issue May 21, 2022 · 6 comments
Labels
enhancement New feature or request

Comments

@tonyketcham
Copy link
Collaborator

On build, the plugin yields this warning:

[warn] Sourcemap is likely to be incorrect: a plugin (vite:transform-yaml) was used to transform files, 
but didn't generate a sourcemap for the transformation. Consult the plugin documentation for help

We should add sourcemap generation around the yaml file -> ESM conversion. A potentially useful resource to base this on could be: https://github.com/amireh/yaml-source-map

@tonyketcham tonyketcham added the enhancement New feature or request label May 21, 2022
@tonyketcham
Copy link
Collaborator Author

Found these resources useful:

@silverwind
Copy link
Contributor

Is there a way to avoid having vite log this warning? I personally don't care about source maps for YAML files but I do care about warnings in the build 😉.

@silverwind
Copy link
Contributor

silverwind commented Nov 30, 2022

I don't think sourcemaps are useful for this plugin because it outputs JS objects, where there is no way to reference a line back to the source file because JS objects have no concept of a line.

So I think this plugin should somehow indicate back to vite that it will not generate a sourcemap and hopefully that will make vite shut up.

@tonyketcham
Copy link
Collaborator Author

I think the sourcemap would be useful for mapping back through the conversion to which line in the original YAML file is incorrect, however the YAML processor essentially does that already with a well-formatted error displaying exactly which part of the file is causing an issue. Perhaps providing a null-ish source map would satisfy Vite's wants

@silverwind
Copy link
Contributor

silverwind commented Dec 1, 2022

Of note is that the warning does not originate in vite itself, but in rollup.

Edit: also see https://rollupjs.org/guide/en/#warning-sourcemap-is-likely-to-be-incorrect

silverwind added a commit to silverwind/vite-plugin-yaml that referenced this issue Dec 20, 2022
Provide an empty source map to Rollup to avoid it warning on missing
sourcemap.

Ref: https://rollupjs.org/guide/en/#source-code-transformations
Related: Modyfi#3
@silverwind
Copy link
Contributor

#9 will suppress the warning until it is figured out how to actually generate a sourcemap.

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

No branches or pull requests

2 participants