-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Description
I have been loading S2JS into my browser app in the way it is suggested in the doc:
import { s2 } from 'https://esm.sh/s2js'
but I want to have a single ES module file that I can load from my own local directory or a server.
I cloned this repo, run npm i and npm run build and it fails with an error:
% npm run build
> s2js@0.0.0-development build
> npx --yes tsdx@^0 build --entry index.ts
@rollup/plugin-replace: 'preventAssignment' currently defaults to false. It is recommended to set this option to `true`, as the next major version will default this option to `true`.
@rollup/plugin-replace: 'preventAssignment' currently defaults to false. It is recommended to set this option to `true`, as the next major version will default this option to `true`.
⠙ Creating entry file 99% 344ms, estimated 342ms
✓ Creating entry file 346 ms
⠙ Building modules
⠹ Building modules
(babel plugin) SyntaxError: /Users/ohshima/src/vehicle/yoshiki/s2js/r1/Interval.ts: Unexpected token (7:4)
5 | */
6 | export class Interval {
> 7 | lo: number = 0.0
| ^
8 | hi: number = 0.0
9 |
10 | /**
at undefined:7:4
SyntaxError: /Users/ohshima/src/vehicle/yoshiki/s2js/r1/Interval.ts: Unexpected token (7:4)
5 | */
6 | export class Interval {
> 7 | lo: number = 0.0
| ^
8 | hi: number = 0.0
9 |
10 | /**
It indicates that its TypeScript syntax is not handled by roll up.
In any case, I tried to use vite to do the job, and with changes to two files (geojson/_index.ts and s2/_index.ts) I managed to make a single ES module file that works.
The change is like this:
diff --git a/geojson/_index.ts b/geojson/_index.ts
index b8f653f..0a6c516 100644
--- a/geojson/_index.ts
+++ b/geojson/_index.ts
@@ -2,8 +2,8 @@
* Module geojson implements types and functions for working with GeoJSON.
* @module geojson
*/
-export { Encodable, Decodable } from './geometry'
+export type { Encodable, Decodable } from './geometry'
export { toGeoJSON, fromGeoJSON } from './geometry'
-export { RegionCovererOptions } from './RegionCoverer'
-export { RegionCoverer } from './RegionCoverer'
+export type { RegionCovererOptions } from './RegionCoverer'
+export type { RegionCoverer } from './RegionCoverer'
So the interface exported cannot be mixed with actual classes/objects.
If you think this change is valuable, I can make a pull request.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels