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

generate sourcemaps #1630

Open
dansrogers opened this issue Sep 6, 2024 · 1 comment
Open

generate sourcemaps #1630

dansrogers opened this issue Sep 6, 2024 · 1 comment
Labels
enhancement New feature or request generation help wanted Extra attention is needed

Comments

@dansrogers
Copy link

Feature Request

Is your feature request related to a problem? Please describe:

kcl can be used to trivially generate yaml files and other structured data. For any given yaml file that lives as part of another ecosystem (e.g. kubernetes manifests, or ansible playbooks), there exist linters that are able to describe errors with the output yaml. While it's straightforward to 'kcl run' then run the output through the linter, to resolve linter errors, I then must then determine the kcl file line number that generated a particular output file line number. Additionally, if I'm using an IDE, the IDE won't be able to display any errors on the line number of the generated source file.

Describe the feature you'd like:

While an end to end solution requires more ecosystem changes, the first step is to have kcl be able to output sourcemaps in addition to it's normal output. Sourcemaps, while part of the ES standard, are language and platform agnostic ways of describing original source locations from generated code.

This could potentially look like:

$ kcl run -o outputfile.yaml --sourcemap outputfile.map

Or using the file api:

file.writemap("outputfile.yaml", yaml.encode(fooboject), "outputfile.map")

After sourcemaps are available, upstream tools can be modified to accept map files, which can be used to print errors that reference the kcl line numbers, or highlight generated file linter errors. This approach is common in the transpiled javascript world.

Describe alternatives you've considered:

The alternative is to generate the files, run tools over the generated files, and map the line number messages back to the generated kcl code manually.

Teachability, Documentation, Adoption, Migration Strategy:

@Peefy Peefy added the enhancement New feature or request label Sep 7, 2024
@Peefy
Copy link
Contributor

Peefy commented Sep 9, 2024

Thank you for opening the issue. I believe this is an important improvement for configuring the ecosystem. 👍

@Peefy Peefy added this to the v0.11.0 Release milestone Sep 10, 2024
@Peefy Peefy added the help wanted Extra attention is needed label Oct 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request generation help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants