-
Notifications
You must be signed in to change notification settings - Fork 364
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
CJS to ESM #7311
base: main
Are you sure you want to change the base?
CJS to ESM #7311
Conversation
These are files from TerriaJS V7 not referenced anywhere else. Some of these might be useful if we want to port them to v8 in the future. If that's the case please refer to https://github.com/terriajs/terriajs/tree/terriajs7
This requires, in some places: - simply swapping require with import - creating a stub .d.ts module definition in lib/ThirdParty - updating the library to get new bundled type definitions - file-saver - react-responsive - or adding @types/x as dependency - @types/proj4 Remaining require() imports are all for static assets or web workers which can be fixed when upgrading to webpack 5.
It is redundant when using typescript.
@@ -0,0 +1,50 @@ | |||
import defined from "terriajs-cesium/Source/Core/defined"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this file restored because the git auto-merge didn't realize it was renamed when being TSified?
const source = new proj4.Proj((proj4definitions as any)[wkid]); | ||
// @ts-expect-error @types/proj4 doesn't define a constructor type |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure about this? https://github.com/DefinitelyTyped/DefinitelyTyped/blob/a7b4fad09a7a1309d0fa9a1ec22c57720bf5d02a/types/proj4/index.d.ts#L71 and https://github.com/DefinitelyTyped/DefinitelyTyped/blob/a7b4fad09a7a1309d0fa9a1ec22c57720bf5d02a/types/proj4/proj4-tests.ts#L65 looks like it should work?
@@ -257,7 +256,9 @@ class FeatureServerStratum extends LoadableStratum( | |||
return undefined; | |||
} | |||
|
|||
// @ts-expect-error @types/proj4 doesn't define a constructor type |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can see why the type checker might not be able to infer that the argument is a string for the next line. I just threw together #7344 to try to make it slightly less confused.
@@ -168,6 +167,7 @@ class SharePanel extends React.Component<PropTypes, SharePanelState> { | |||
viewState={this.props.viewState} | |||
btnTitle={btnTitle} | |||
isOpen={this.state.isOpen} | |||
//@ts-expect-error - not yet ready to tackle tsfying StorySharePanel |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be 5 lines earlier (before the <StorySharePanel
) so it is consistent with the placement for the ts-expect-error for MenuPanel?
@@ -31,7 +31,7 @@ export const TourExplanationBox = styled(Box)` | |||
h1, | |||
h2, | |||
h3 { | |||
margin-bottom: ${(p) => p.theme.spacing * 3}px; | |||
margin-bottom: ${(p) => (p.theme.spacing as any) * 3}px; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can spacing be as number
instead of any, or is that wrong?
I'm not qualified to comment on the removed files, but I found a few minor nits that I commented about, The rest of this PR is "just" mechanical changes and they look consistent to me, so they are either all wrong or they are all right. Considering how many files this PR touches, I think it would be great to get this merged soon. |
What this PR does
Convert CJS modules to ESM.
Required for #6998
Depends on: https://github.com/terriajs/terriamap/tree/cjs-to-esm
TODO:
What this PR does:
Removes stale CJS files that are no longer used (395d3b9)
Convert CJS style
module.exports
to ESM styleexport default ...
(7129b24)Convert CJS require() to ESM import statements. (30654f1)
This requires, in some places:
file-saver
react-responsive
@types/proj4
Remaining require() imports are all for static assets or web workers which can be fixed when upgrading to webpack 5.
Remove
use strict
declaration for.tsx?
files.Test me
Test http://ci.terria.io/cjs-to-esm
Checklist
doc/
.