Skip to content

Commit 0ec9b3b

Browse files
committed
chore: es module
1 parent 0feabc8 commit 0ec9b3b

14 files changed

+1245
-1228
lines changed

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# 3.0.0 (2022-12-11)
2+
3+
- Move to being an ES Module
4+
- Update dependencies
5+
16
# 2.0.2 (2022-11-22)
27

38
- Move back to Evil Kiwi (`@evilkiwi/astar`)

README.md

+21-21
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<div align="center">
2-
<a href="https://www.npmjs.com/package/@evilkiwi/astar" target="_blank">
3-
<img src="https://img.shields.io/npm/v/@evilkiwi/astar?style=flat-square" alt="NPM" />
4-
</a>
5-
<a href="https://discord.gg/3S6AKZ2GR9" target="_blank">
6-
<img src="https://img.shields.io/discord/1000565079789535324?color=7289DA&label=discord&logo=discord&logoColor=FFFFFF&style=flat-square" alt="Discord" />
7-
</a>
8-
<img src="https://img.shields.io/npm/l/@evilkiwi/astar?style=flat-square" alt="GPL-3.0-only" />
9-
<h3>Synchronous A* pathfinding for TypeScript</h3>
2+
<a href="https://www.npmjs.com/package/@evilkiwi/astar" target="_blank">
3+
<img src="https://img.shields.io/npm/v/@evilkiwi/astar?style=flat-square" alt="NPM" />
4+
</a>
5+
<a href="https://discord.gg/3S6AKZ2GR9" target="_blank">
6+
<img src="https://img.shields.io/discord/1000565079789535324?color=7289DA&label=discord&logo=discord&logoColor=FFFFFF&style=flat-square" alt="Discord" />
7+
</a>
8+
<img src="https://img.shields.io/npm/l/@evilkiwi/astar?style=flat-square" alt="GPL-3.0-only" />
9+
<h3>Synchronous A* pathfinding for TypeScript</h3>
1010
</div>
1111

1212
`@evilkiwi/astar` is an synchronous A* pathfinding implementation in TypeScript.
@@ -43,26 +43,26 @@ import { search } from '@evilkiwi/astar';
4343
* 0 = walkable, optionally any integer above 0 for elevation support
4444
*/
4545
const grid: Grid = [
46-
[ 0, 5, -1, 0, 0, -1, 0, 0],
47-
[ 0, 4, -1, 0, 0, -1, 0, 0],
48-
[ 0, 3, -1, 0, 0, -1, 0, 0],
49-
[ 0, 2, -1, 0, 0, 0, 0, 0],
50-
[ 0, 1, -1, 0, 0, -1, 0, 0],
51-
[ 0, 0, -1, 0, 0, -1, 0, 0],
52-
[ 0, 0, 0, 0, 0, -1, 0, 0],
53-
[ 0, 0, -1, 0, 0, -1, 0, 0],
46+
[ 0, 5, -1, 0, 0, -1, 0, 0],
47+
[ 0, 4, -1, 0, 0, -1, 0, 0],
48+
[ 0, 3, -1, 0, 0, -1, 0, 0],
49+
[ 0, 2, -1, 0, 0, 0, 0, 0],
50+
[ 0, 1, -1, 0, 0, -1, 0, 0],
51+
[ 0, 0, -1, 0, 0, -1, 0, 0],
52+
[ 0, 0, 0, 0, 0, -1, 0, 0],
53+
[ 0, 0, -1, 0, 0, -1, 0, 0],
5454
];
5555

5656
/**
5757
* Once you have a Grid, you can find an efficient tile-based path
5858
* from one vector to another.
5959
*/
6060
const path = search({
61-
cutCorners: false,
62-
diagonal: true,
63-
from: [0, 0],
64-
to: [7, 6],
65-
grid,
61+
cutCorners: false,
62+
diagonal: true,
63+
from: [0, 0],
64+
to: [7, 6],
65+
grid,
6666
});
6767

6868
// Path is either an array of vectors or null (could not find a path)

build.mjs

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { nodeExternalsPlugin } from 'esbuild-node-externals';
2+
import { build } from 'esbuild';
3+
4+
/** @type {import('esbuild').BuildOptions} */
5+
const options = {
6+
sourcemap: process.env.NODE_ENV === 'development',
7+
plugins: [nodeExternalsPlugin()],
8+
entryPoints: ['./src/index.ts'],
9+
logLevel: 'debug',
10+
platform: 'node',
11+
target: 'node18',
12+
outdir: 'build',
13+
format: 'esm',
14+
bundle: true,
15+
minify: true,
16+
};
17+
18+
await build({
19+
...options,
20+
outExtension: { '.js': '.mjs' },
21+
format: 'esm',
22+
});

package.json

+55-54
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,57 @@
11
{
2-
"name": "@evilkiwi/astar",
3-
"version": "2.0.2",
4-
"description": "Synchronous A* pathfinding for TypeScript",
5-
"files": [
6-
"build"
7-
],
8-
"sideEffects": false,
9-
"main": "./build/index.js",
10-
"module": "./build/index.mjs",
11-
"types": "./build/index.d.ts",
12-
"license": "GPL-3.0-only",
13-
"author": {
14-
"name": "Evil Kiwi Limited",
15-
"url": "https://evil.kiwi",
16-
"email": "[email protected]"
17-
},
18-
"homepage": "https://github.com/evilkiwi/astar",
19-
"bugs": {
20-
"url": "https://github.com/evilkiwi/astar/issues"
21-
},
22-
"repository": {
23-
"type": "git",
24-
"url": "git+https://github.com/evilkiwi/astar.git"
25-
},
26-
"keywords": [
27-
"a",
28-
"star",
29-
"path",
30-
"finding",
31-
"typescript"
32-
],
33-
"scripts": {
34-
"clean": "rimraf build",
35-
"prepack": "pnpm run build",
36-
"build": "pnpm run clean && pnpm run compile",
37-
"compile": "vite build",
38-
"dev": "vite build --watch",
39-
"test:coverage": "vitest run --coverage",
40-
"test:watch": "vitest watch",
41-
"test": "vitest run"
42-
},
43-
"devDependencies": {
44-
"@vitest/coverage-c8": "^0.25.2",
45-
"c8": "^7.12.0",
46-
"jest": "^29.3.1",
47-
"jest-mock-extended": "^3.0.1",
48-
"rimraf": "^3.0.2",
49-
"terser": "^5.15.1",
50-
"tslib": "^2.4.1",
51-
"typescript": "^4.9.3",
52-
"vite": "^3.2.4",
53-
"vite-plugin-dts": "^1.7.1",
54-
"vitest": "^0.25.2"
55-
}
2+
"type": "module",
3+
"name": "@evilkiwi/astar",
4+
"version": "3.0.0",
5+
"description": "Synchronous A* pathfinding for TypeScript",
6+
"files": [
7+
"build"
8+
],
9+
"sideEffects": false,
10+
"main": "./build/index.mjs",
11+
"types": "./build/index.d.ts",
12+
"license": "GPL-3.0-only",
13+
"author": {
14+
"name": "Evil Kiwi Limited",
15+
"url": "https://evil.kiwi",
16+
"email": "[email protected]"
17+
},
18+
"homepage": "https://github.com/evilkiwi/astar",
19+
"bugs": {
20+
"url": "https://github.com/evilkiwi/astar/issues"
21+
},
22+
"repository": {
23+
"type": "git",
24+
"url": "git+https://github.com/evilkiwi/astar.git"
25+
},
26+
"keywords": [
27+
"a",
28+
"star",
29+
"path",
30+
"finding",
31+
"typescript"
32+
],
33+
"scripts": {
34+
"prepack": "pnpm run build",
35+
"build": "cross-env NODE_ENV=production node build.mjs && tsc",
36+
"dev": "cross-env NODE_ENV=development node build.mjs && tsc",
37+
"lint": "eslint --ext .ts --ignore-path .gitignore src",
38+
"test:coverage": "vitest run --coverage",
39+
"test:watch": "vitest watch",
40+
"test": "vitest run"
41+
},
42+
"devDependencies": {
43+
"@vitest/coverage-c8": "^0.25.7",
44+
"c8": "^7.12.0",
45+
"cross-env": "^7.0.3",
46+
"esbuild": "^0.16.4",
47+
"esbuild-node-externals": "^1.5.0",
48+
"eslint": "^8.29.0",
49+
"jest": "^29.3.1",
50+
"jest-mock-extended": "^3.0.1",
51+
"rimraf": "^3.0.2",
52+
"terser": "^5.16.1",
53+
"tslib": "^2.4.1",
54+
"typescript": "^4.9.4",
55+
"vitest": "^0.25.7"
56+
}
5657
}

0 commit comments

Comments
 (0)