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

Migrate gp library to pure ESM #122

Closed
1 of 14 tasks
twelch opened this issue Nov 8, 2022 · 1 comment
Closed
1 of 14 tasks

Migrate gp library to pure ESM #122

twelch opened this issue Nov 8, 2022 · 1 comment
Assignees

Comments

@twelch
Copy link
Contributor

twelch commented Nov 8, 2022

GP library is starting to hit issues with still using Common JS. Notably modern flatgeobuf node client module is a pure ESM module and using it in CJS environment have struggled to make it work, so we are pinned to an older version of flatgeobuf. But the flatgeobuf format seems to have had a breaking change, GDAL 3.5 and up produces flatgeobuf files that flatgeobuf node module v3.17.4 cannot read, produces a "Not a flatgeobuf file" error. The solution is downgrading to GDAL 3.2.2 or below.

We might be able to solve getting latest flatgeobuf node module to load and kick the can down the road, but the longer we stick with CJS, the greater the pain will be. The question is are all the gp dependencies esm-ready? Is Jest? Webpack? Storybook?

The crux things to solve for gp are:

  • webpack still works for building and running/loading gp functions (node) and clients (browser)
  • Renaming files to .js and getting jest to still work with its separate transpiler
  • Local cog works with ts-node for precalc, but loading from seasketch geoprocessing does not
  • Flatgeobuf works
  • Ensuring the gp projects can use gp lib still, everything works.

Changes required

  • In CommonJS in node you can import a directory, and if a index.js exists in that directory, it will open that. ESM requires exact paths
  • Update package.json to include ”type”: “module” and correct exports field
  • Refactor all require statements to use import
  • Refactor all relative-path import statements to include .js file extension
  • Update Babel Configuration in React to support “import assertions”
  • __dirname doesn't exist, you only have import.meta

Requirements

  • add eslint
  • add webpack 5
  • upgrade to latest flatgeobuf
  • esModuleInterop, should it be true or become false?
  • Dependency upgrades #158

Approach

Geoprocessing library:

  • defined as esmodule
  • code written in typescript
  • src build transpiles to es2020
  • scripts build transpiles to es2020?

GP project:

  • defined as esmodule
  • code written in typescript
  • gp functions transpile to ?
  • clients transpile to ?
  • build transpiles to es2019 or later?

References

@twelch twelch moved this to Parking Lot / On Hold in Geoprocessing and Reports Work Board Jan 5, 2023
@twelch twelch moved this from Parking Lot / On Hold to Backlog in Geoprocessing and Reports Work Board Jul 7, 2023
@twelch twelch moved this from Backlog to In Progress in Geoprocessing and Reports Work Board Jul 10, 2023
@twelch twelch moved this from In Progress to Backlog in Geoprocessing and Reports Work Board Jul 31, 2023
@twelch twelch self-assigned this Mar 7, 2024
@twelch twelch moved this from Backlog to In Progress in Geoprocessing and Reports Work Board Mar 7, 2024
@twelch
Copy link
Contributor Author

twelch commented Jul 31, 2024

Resolved via #272

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

No branches or pull requests

1 participant