jupyterlab / jupyterlab

JupyterLab computational environment.
https://jupyterlab.readthedocs.io/
Other
13.82k stars 3.12k forks source link

coreutils and post-ES2018 Intl API features #16283

Open Renegade334 opened 1 week ago

Renegade334 commented 1 week ago

Description

Since the removal of the moment library in #13469, the Time functions in coreutils now depend on the ECMA-402 internationalization APIs, namely DateTimeFormat and RelativeTimeFormat. As spotted recently when changes were made to time.ts in #15948, this starts to run into ES2018 compatibility issues.

In fact, RelativeTimeFormat doesn't exist at all under ES2018, nor do the dateStyle and timeStyle options passed to DateTimeFormat. The reason those features currently don't cause build errors is due to "types": ["node"] in the coreutils tsconfig, which as a side-effect pulls in the es2020.intl library definitions via the triple-slash directives at the top of index.d.ts in @types/node, suppressing the errors that would appear otherwise.

In addition, DateTimeFormat's dateStyle and timeStyle options were actually only added in the ES2021 standard, and there is a current proposal for these to be moved to the es2021.intl library accordingly. If and when this happens, those properties will no longer be defined in es2020.intl, and the coreutils build will subsequently break.

Expected behavior

If the decision is that JupyterLab should continue to use these post-ES2018 features, then the coreutils tsconfig should probably explicitly add the es2020.intl library to make this intention clear (and potentially es2021.intl to pre-empt the above), and/or implement a polyfill for users running on true ES2018 environments.

welcome[bot] commented 1 week ago

Thank you for opening your first issue in this project! Engagement like this is essential for open source projects! :hugs:
If you haven't done so already, check out Jupyter's Code of Conduct. Also, please try to follow the issue template as it helps other other community members to contribute more effectively. welcome You can meet the other Jovyans by joining our Discourse forum. There is also an intro thread there where you can stop by and say Hi! :wave:
Welcome to the Jupyter community! :tada:

jtpio commented 1 week ago

Thanks @Renegade334 for the report :+1:

If the decision is that JupyterLab should continue to use these post-ES2018 features

Yes, these features are likely to stay.

As spotted recently when changes were made to time.ts in https://github.com/jupyterlab/jupyterlab/pull/15948,

Looks like there were some discussions about this in this comment: https://github.com/jupyterlab/jupyterlab/pull/15948#pullrequestreview-1967441077, with the suggestion of bumping to ES2020 here:

https://github.com/jupyterlab/jupyterlab/blob/8a17ca61cf0943225ddc4506763228dd21c90dab/tsconfigbase.json#L19

Not sure this could go in the 4.2 release, but probably in 4.3. Would you like to open a (draft) PR to start looking into it? Thanks!

Renegade334 commented 1 week ago

Sounds good. 👍

Looks like there were some discussions about this in this comment: https://github.com/jupyterlab/jupyterlab/pull/15948#pullrequestreview-1967441077, with the suggestion of bumping to ES2020 here: https://github.com/jupyterlab/jupyterlab/blob/8a17ca61cf0943225ddc4506763228dd21c90dab/tsconfigbase.json#L19

I assume this refers to bumping "lib" rather than the build target?

JasonWeill commented 1 week ago

@Renegade334 Thank you for opening this! I had previously tried upgrading the library locally, but I ran into other compatibility issues. I appreciate you working on this.