Skip to content

Update JavaScript codebase to use ESM and vite #451

Draft
Abijeet wants to merge 1 commit intouse-localecomparefrom
esm-module
Draft

Update JavaScript codebase to use ESM and vite #451
Abijeet wants to merge 1 commit intouse-localecomparefrom
esm-module

Conversation

@Abijeet
Copy link
Copy Markdown
Member

@Abijeet Abijeet commented Oct 14, 2025

Dropped support for Node.js 16, 18.
Updated ESLint to v9 since assert is not supported in v8. See:
eslint/eslint#15305

Dropping support for Node v16, v18 should be fine as they are both EOL.

Consequently had to drop support for Wikimedia/eslint rules as it
doesn't yet support ESLint v9.

Used vite to bundle the library for browser usage.

Bug: https://phabricator.wikimedia.org/T407180
Change-Id: I44dee29b49804da5a13d986352148931baf7cb34

@Abijeet Abijeet requested review from hueitan and santhoshtr October 14, 2025 08:23
@Abijeet Abijeet self-assigned this Oct 14, 2025
@Abijeet Abijeet requested a review from Nikerabbit October 14, 2025 08:24
@Abijeet Abijeet force-pushed the esm-module branch 4 times, most recently from e2ea721 to 0ea91ee Compare October 14, 2025 10:04
Comment thread src/index.js
Dropped support for Node.js 16, 18.
Updated ESLint to v9 since assert is not supported in v8. See:
eslint/eslint#15305

Dropping support for Node v16, v18 should be fine as they are both EOL.

Consequently had to drop support for Wikimedia/eslint rules as it
doesn't yet support ESLint v9.

Used vite to bundle the library for browser usage.

Bug: https://phabricator.wikimedia.org/T407180
Change-Id: I44dee29b49804da5a13d986352148931baf7cb34
@Abijeet Abijeet changed the base branch from use-localecompare to master October 15, 2025 07:07
@Abijeet Abijeet changed the base branch from master to use-localecompare October 15, 2025 07:07
@Abijeet Abijeet changed the title Update JavaScript codebase to use ESM module Update JavaScript codebase to use ESM and vite Oct 15, 2025
@Abijeet Abijeet requested a review from santhoshtr October 15, 2025 07:08
@Abijeet
Copy link
Copy Markdown
Member Author

Abijeet commented Oct 15, 2025

Tested this using npm pack (docs).If package type is module, ESM can be used, otherwise CommonJS require works.

@Abijeet Abijeet marked this pull request as draft December 3, 2025 17:05
Comment thread package.json
"eslint-config-wikimedia": "0.31.0",
"mocha": "10.6.0"
"globals": "16.4.0",
"mocha": "10.6.0",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Now that node has native test runner , I would drop mocha dependency. in npm ecosystem, any removal of depdencies are always good

Comment thread package.json
},
"engine": {
"node": ">=16.0.0"
"node": ">=20.10.0"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Since we are using vite, we can use current lts version of node here. v24 is good. https://nodejs.org/en/about/previous-releases
Node 20 is already end of life

Comment thread package.json
"mocha": "10.6.0"
"globals": "16.4.0",
"mocha": "10.6.0",
"vite": "6.3.7"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

vites latest version is 8.0.

Comment thread package.json
},
"license": "GPL-2.0-or-later",
"scripts": {
"test": "mocha tests/js/*.js",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

"test": "node --test tests/js/*.js"

will do the testing

strategy:
matrix:
node-v: [16.x, 18.x, 20.x]
node-v: [20.x, 22.x, 24.x]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

26 is also available now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

2 participants