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

Switch style-spec scripts to native ESM #11538

Merged
merged 11 commits into from
Feb 22, 2022
Merged

Conversation

stepankuzmin
Copy link
Contributor

This PR converts style-spec scripts to native ESM and checks these scripts happy-path as a part of CI.

Closes #10965

Launch Checklist

  • briefly describe the changes in this PR
  • write tests for all new functionality
  • apply changelog label ('bug', 'feature', 'docs', etc) or use the label 'skip changelog'
  • add an entry inside this element for inclusion in the mapbox-gl-js changelog: <changelog>fix: convert style-spec scripts to native ESM</changelog>

Copy link
Member

@mourner mourner left a comment

Choose a reason for hiding this comment

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

Great to see this neglected part of the code being addressed! One thing that doesn't feel quite right to me in this approach is copying the scripts from GL JS to run the binaries — it's fragile and complicated. Could we simplify this somehow? Perhaps rely on the built version of the style spec instead so that we don't have to use the loader?

@stepankuzmin stepankuzmin requested a review from mourner February 21, 2022 15:30
package.json Outdated Show resolved Hide resolved
src/style-spec/bin/gl-style-composite.js Outdated Show resolved Hide resolved
src/style-spec/package.json Outdated Show resolved Hide resolved
@@ -0,0 +1,20 @@
#!/usr/bin/env node
/* eslint-disable import/no-unresolved, no-process-exit */
Copy link
Member

Choose a reason for hiding this comment

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

Nit: import/no-unresolved no longer needed

Copy link
Contributor Author

@stepankuzmin stepankuzmin Feb 22, 2022

Choose a reason for hiding this comment

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

Unfortunately in that case we need to add the @mapbox/mapbox-gl-style-spec as a dependency to itself, or silence ESLint with

/* eslint import/no-unresolved: [error, { ignore: ['^@mapbox/mapbox-gl-style-spec$'] }] */

I've updated the PR to ignore the unresolved @mapbox/mapbox-gl-style-spec import

@stepankuzmin stepankuzmin merged commit 938f1f8 into main Feb 22, 2022
@stepankuzmin stepankuzmin deleted the style-spec/esm-support branch February 22, 2022 12:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

gl-style-validate script throws TypeError [ERR_UNKNOWN_FILE_EXTENSION]
2 participants