Skip to content

Commit

Permalink
Switch to ESM and ECMA2022 (#178)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexrudd2 committed Mar 3, 2025
1 parent 6454b66 commit c174fa8
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js → .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module.exports = {
'plugin:@typescript-eslint/recommended',
],
parserOptions: {
ecmaVersion: 2018,
ecmaVersion: 2022,
sourceType: 'module',
},
root: true,
Expand Down
4 changes: 2 additions & 2 deletions build.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const buildOptions = {
entryPoints: ['src/ui.tsx'],
bundle: true,
platform: 'browser',
target: 'es2020',
target: 'es2022',
minify: true,
sourcemap: true,
metafile: true,
Expand All @@ -27,7 +27,7 @@ const buildOptions = {
}]
})
],
resolveExtensions: ['.js', '.ts', '.tsx', '.svg', '.worker.js'],
resolveExtensions: ['.mjs', '.js', '.ts', '.tsx', '.svg', '.worker.js'],
};

(async () => {
Expand Down
2 changes: 0 additions & 2 deletions cli.js

This file was deleted.

3 changes: 3 additions & 0 deletions cli.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env node
import { cli } from './dist/server/cli.js';
cli();
3 changes: 0 additions & 3 deletions index.js

This file was deleted.

2 changes: 2 additions & 0 deletions index.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import server from './dist/server/server.js';
export { server };
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
"hardware",
"robot"
],
"main": "index.js",
"main": "index.mjs",
"bin": {
"saxi": "cli.js"
"saxi": "cli.mjs"
},
"scripts": {
"prebuild": "npm run lint",
Expand All @@ -25,7 +25,7 @@
"build:server": "tsc",
"build:ui": "node --experimental-modules build.mjs",
"prepare": "rimraf dist && npm run build",
"start": "npm run build && node cli.js",
"start": "npm run build && node cli.mjs",
"dev": "BUILD_MODE=development npm start",
"deploy": "rimraf dist/ui && IS_WEB=1 npm run build:ui && gh-pages --dist dist/ui",
"test": "jest"
Expand Down Expand Up @@ -79,12 +79,13 @@
"engines": {
"node": ">=18.0.0"
},
"type": "module",
"jest": {
"preset": "ts-jest"
},
"files": [
"/dist",
"cli.js"
"cli.mjs"
],
"optionalDependencies": {
"@esbuild/linux-arm": "^0.25.0",
Expand Down
4 changes: 2 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"compilerOptions": {
"module": "commonjs",
"module": "ES2022",
"esModuleInterop": true,
"target": "es6",
"target": "ES2022",
"noImplicitAny": true,
"moduleResolution": "node",
"sourceMap": true,
Expand Down
4 changes: 2 additions & 2 deletions tsconfig.web.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"compilerOptions": {
"esModuleInterop": true,
"noImplicitAny": true,
"module": "es6",
"target": "es6",
"module": "es2022",
"target": "es2022",
"moduleResolution": "node",
"jsx": "react",
"allowJs": true
Expand Down

0 comments on commit c174fa8

Please sign in to comment.