Skip to content

Commit 0e6592a

Browse files
author
Arvid Nicolaas
committed
refactor: update list package for esm support
1 parent e35c842 commit 0e6592a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+285
-288
lines changed

packages/list/.denoifyrc.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
2-
"index": "src/main/index.ts",
2+
"index": "./_deno_prepare/src/main/index.ts",
33
"replacer": "../../config/denoify-rimbu-replacer.js",
4-
"includes": ["README.md", "LICENSE", "CHANGELOG.md"]
4+
"includes": ["README.md", "LICENSE", "CHANGELOG.md"],
5+
"out": "./deno_dist"
56
}

packages/list/.prettierrc.cjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
module.exports = require('../../config/.prettierrc');
1+
module.exports = require('../../config/.prettierrc.cjs');

packages/list/CHANGELOG.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,6 @@
33
All notable changes to this project will be documented in this file.
44
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
55

6-
## [0.12.3](https://github.com/rimbu-org/rimbu/compare/@rimbu/[email protected]...@rimbu/[email protected]) (2023-06-20)
7-
8-
### Reverts
9-
10-
- Revert "Increase version number" ([9c0b4ba](https://github.com/rimbu-org/rimbu/commit/9c0b4baa3f16f1dce4a8e276c0ec8c89ce1eb72c))
11-
126
## [0.12.2](https://github.com/rimbu-org/rimbu/compare/@rimbu/[email protected]...@rimbu/[email protected]) (2023-05-21)
137

148
**Note:** Version bump only for package @rimbu/list

packages/list/config/api-extractor.custom.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
33
"extends": "<projectFolder>/../../config/api-extractor.json",
4-
"mainEntryPointFilePath": "<projectFolder>/dist/types/custom/index.d.ts",
5-
"bundledPackages": [],
4+
"mainEntryPointFilePath": "<projectFolder>/dist/types/custom/index.d.mts",
5+
"bundledPackages": ["@rimbu/list"],
66
"docModel": {
77
"enabled": true,
88
"apiJsonFilePath": "<projectFolder>/../../doc-gen/input/<unscopedPackageName>!custom.api.json"

packages/list/config/api-extractor.main.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
33
"extends": "<projectFolder>/../../config/api-extractor.json",
4-
"mainEntryPointFilePath": "<projectFolder>/dist/types/main/index.d.ts",
4+
"mainEntryPointFilePath": "<projectFolder>/dist/types/main/index.d.mts",
55
"bundledPackages": [],
66
"docModel": {
77
"enabled": true,

packages/list/custom/package.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
{
22
"name": "custom",
33
"private": true,
4-
"source": "../src/custom/index.ts",
5-
"main": "../dist/main/custom/index.js",
6-
"module": "../dist/module/custom/index.js",
7-
"types": "../dist/types/custom/index.d.ts"
4+
"main": "../dist/cjs/custom/index.js",
5+
"module": "../dist/esm/custom/index.mjs",
6+
"types": "../dist/types/custom/index.d.mts"
87
}

packages/list/package.json

Lines changed: 50 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@rimbu/list",
3-
"version": "0.12.3",
3+
"version": "0.12.2",
44
"description": "An efficient immutable ordered sequence of elements akin to a Vector",
55
"keywords": [
66
"list",
@@ -32,24 +32,42 @@
3232
"url": "https://github.com/rimbu-org/rimbu.git",
3333
"directory": "packages/list"
3434
},
35-
"source": "./src/main/index.ts",
36-
"main": "./dist/main/main/index.js",
37-
"module": "./dist/module/main/index.js",
38-
"types": "./dist/types/main/index.d.ts",
35+
"type": "module",
36+
"main": "./dist/cjs/main/index.js",
37+
"module": "./dist/esm/main/index.mjs",
38+
"types": "./dist/types/main/index.d.mts",
3939
"exports": {
4040
".": {
41-
"types": "./dist/types/main/index.d.ts",
42-
"bun": "./src/main/index.ts",
43-
"import": "./dist/module/main/index.js",
44-
"require": "./dist/main/main/index.js",
45-
"default": "./dist/module/main/index.js"
41+
"types": "./dist/types/main/index.d.mts",
42+
"bun": "./dist/bun/main/index.mts",
43+
"import": "./dist/esm/main/index.mjs",
44+
"require": "./dist/cjs/main/index.js",
45+
"default": "./dist/esm/main/index.mjs"
4646
},
4747
"./custom": {
48-
"types": "./dist/types/custom/index.d.ts",
49-
"bun": "./src/custom/index.ts",
50-
"import": "./dist/module/custom/index.js",
51-
"require": "./dist/main/custom/index.js",
52-
"default": "./dist/main/custom/index.js"
48+
"types": "./dist/types/custom/index.d.mts",
49+
"bun": "./dist/bun/custom/index.mts",
50+
"import": "./dist/esm/custom/index.mjs",
51+
"require": "./dist/cjs/custom/index.js",
52+
"default": "./dist/cjs/custom/index.mjs"
53+
}
54+
},
55+
"imports": {
56+
"#list/*.mts": {
57+
"bun": "./dist/bun/*.mts"
58+
},
59+
"#list/*.mjs": {
60+
"types": "./dist/types/*.d.mts",
61+
"import": "./dist/esm/*.mjs",
62+
"require": "./dist/cjs/*.js",
63+
"default": "./dist/esm/*.mjs"
64+
},
65+
"#list/*": {
66+
"types": "./dist/types/*/index.d.mts",
67+
"bun": "./dist/bun/*/index.mts",
68+
"import": "./dist/esm/*/index.mjs",
69+
"require": "./dist/cjs/*/index.js",
70+
"default": "./dist/esm/*/index.mjs"
5371
}
5472
},
5573
"files": [
@@ -59,26 +77,32 @@
5977
],
6078
"scripts": {
6179
"build": "yarn clean && yarn bundle",
62-
"build:deno": "rimraf deno_dist ../../deno_dist/list && denoify && mv deno_dist ../../deno_dist/list",
63-
"bundle": "yarn bundle:types && yarn bundle:main && yarn bundle:module",
64-
"bundle:main": "tsc --p tsconfig.main.json",
65-
"bundle:module": "tsc --p tsconfig.module.json",
80+
"build:deno": "yarn bundle:deno-prepare && yarn bundle:deno-convert && yarn bundle:deno-move && yarn bundle:deno-clean",
81+
"bundle": "yarn bundle:cjs && yarn bundle:esm && yarn bundle:types && yarn bundle:bun",
82+
"bundle:bun": "node ../../config/bunnify.mjs",
83+
"bundle:cjs": "tsup src --format cjs --clean -d dist/cjs --loader '.mts=ts' --legacy-output",
84+
"bundle:deno-prepare": "node ../../config/prepare-denoify.mjs",
85+
"bundle:deno-convert": "denoify --src _deno_prepare/src",
86+
"bundle:deno-move": "rimraf ../../deno_dist/list && mv deno_dist ../../deno_dist/list",
87+
"bundle:deno-clean": "rimraf _deno_prepare",
88+
"bundle:esm": "tsc --p tsconfig.esm.json",
6689
"bundle:types": "tsc --p tsconfig.types.json",
6790
"clean": "rimraf dist",
6891
"circular": "npx -y madge --ts-config tsconfig.json --circular --extensions ts src/main/index.ts",
6992
"extract-api": "yarn extract-api:main && yarn extract-api:custom",
70-
"extract-api:custom": "api-extractor run --local --verbose --config config/api-extractor.custom.json",
71-
"extract-api:main": "api-extractor run --local --verbose --config config/api-extractor.main.json",
93+
"extract-api:custom": "ts-node ../../config/api-extractor.ts config/api-extractor.custom.json",
94+
"extract-api:main": "ts-node ../../config/api-extractor.ts config/api-extractor.main.json",
7295
"format": "yarn format:base --write",
73-
"format:base": "prettier \"{!CHANGELOG.md}|**/**/*.{ts,tsx,js,json,md}\"",
96+
"format:base": "prettier \"{!CHANGELOG.md}|**/**/*.{ts,tsx,js,mts,mjs,json,md}\"",
7497
"format:check": "yarn format:base --check",
7598
"lint": "eslint src",
76-
"test": "jest",
77-
"test:random": "jest --config jest-random.config.json --runInBand",
78-
"test:types": "tsd",
99+
"test": "vitest run",
100+
"test:cov": "vitest run --coverage",
101+
"test:watch": "vitest",
102+
"test:random": "vitest run --config vitest.random.config.ts",
103+
"test:types": "tsd --files test-d",
79104
"typecheck": "tsc"
80105
},
81-
"sideEffects": false,
82106
"dependencies": {
83107
"@rimbu/base": "^0.11.4",
84108
"@rimbu/collection-types": "^0.10.6",

packages/list/src/custom/builder/block-builder.mts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { OptLazy, TraverseState, Update } from '@rimbu/common';
22

3-
import type { BuilderBase } from '@rimbu/list/custom';
3+
import type { BuilderBase } from '#list/custom';
44

55
export interface BlockBuilder<T, C = unknown> extends BuilderBase<T, C> {
66
level: number;

packages/list/src/custom/builder/builder-base.mts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { OptLazy } from '@rimbu/common';
22

3-
import type { List } from '@rimbu/list';
4-
import type { NonLeaf } from '@rimbu/list/custom';
3+
import type { List } from '#list/main';
4+
import type { NonLeaf } from '#list/custom';
55

66
export interface BuilderBase<T, C = unknown> {
77
readonly length: number;

packages/list/src/custom/builder/gen-builder.mts

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { RimbuError } from '@rimbu/base';
22
import { OptLazy, TraverseState, Update } from '@rimbu/common';
3-
import { Stream, StreamSource } from '@rimbu/stream';
3+
import { Stream, type StreamSource } from '@rimbu/stream';
44

5-
import type { List } from '@rimbu/list';
6-
import type { LeafBuilder, ListContext } from '@rimbu/list/custom';
5+
import type { List } from '#list/main';
6+
import type { LeafBuilder, ListContext } from '#list/custom';
77

88
export class GenBuilder<T> implements List.Builder<T> {
99
constructor(readonly context: ListContext, public builder?: LeafBuilder<T>) {}
@@ -24,7 +24,8 @@ export class GenBuilder<T> implements List.Builder<T> {
2424
return this.length === 0;
2525
}
2626

27-
get = <O>(index: number, otherwise?: OptLazy<O>): T | O => {
27+
// prettier-ignore
28+
get = <O,>(index: number, otherwise?: OptLazy<O>): T | O => {
2829
if (
2930
undefined === this.builder ||
3031
index >= this.length ||
@@ -39,7 +40,8 @@ export class GenBuilder<T> implements List.Builder<T> {
3940
return this.builder.get(index, otherwise);
4041
};
4142

42-
updateAt = <O>(
43+
// prettier-ignore
44+
updateAt = <O,>(
4345
index: number,
4446
update: Update<T>,
4547
otherwise?: OptLazy<O>
@@ -60,7 +62,8 @@ export class GenBuilder<T> implements List.Builder<T> {
6062
return this.builder.updateAt(index, update);
6163
};
6264

63-
set = <O>(index: number, value: T, otherwise?: OptLazy<O>): T | O => {
65+
// prettier-ignore
66+
set = <O,>(index: number, value: T, otherwise?: OptLazy<O>): T | O => {
6467
return this.updateAt(index, value, otherwise);
6568
};
6669

@@ -181,7 +184,8 @@ export class GenBuilder<T> implements List.Builder<T> {
181184
}
182185
};
183186

184-
remove = <O>(index: number, otherwise?: OptLazy<O>): T | O => {
187+
// prettier-ignore
188+
remove = <O,>(index: number, otherwise?: OptLazy<O>): T | O => {
185189
this.checkLock();
186190

187191
if (
@@ -227,7 +231,8 @@ export class GenBuilder<T> implements List.Builder<T> {
227231
return result;
228232
};
229233

230-
buildMap = <T2>(f: (value: T) => T2): List<T2> => {
234+
// prettier-ignore
235+
buildMap = <T2,>(f: (value: T) => T2): List<T2> => {
231236
if (undefined === this.builder) {
232237
return this.context.empty();
233238
}

packages/list/src/custom/builder/leaf/block-builder.mts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import type {
66
BlockBuilder,
77
LeafBuilder,
88
ListContext,
9-
} from '@rimbu/list/custom';
9+
} from '#list/custom';
1010

1111
export class LeafBlockBuilder<T> implements LeafBuilder<T>, BlockBuilder<T> {
1212
constructor(

packages/list/src/custom/builder/leaf/leaf-builder.mts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { OptLazy, TraverseState, Update } from '@rimbu/common';
22

3-
import type { List } from '@rimbu/list';
4-
import type { BuilderBase } from '@rimbu/list/custom';
3+
import type { List } from '#list/main';
4+
import type { BuilderBase } from '#list/custom';
55

66
export interface LeafBuilder<T> extends BuilderBase<T, T> {
77
updateAt<O>(index: number, update: Update<T>, otherwise?: OptLazy<O>): T | O;

packages/list/src/custom/builder/leaf/tree-builder.mts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import type {
66
LeafTree,
77
ListContext,
88
NonLeafBuilder,
9-
} from '@rimbu/list/custom';
10-
import { TreeBuilderBase } from '../tree/tree-builder';
9+
} from '#list/custom';
10+
import { TreeBuilderBase } from '../tree/tree-builder.mjs';
1111

1212
export class LeafTreeBuilder<T>
1313
extends TreeBuilderBase<T, T>

packages/list/src/custom/builder/nonleaf/block-builder.mts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import { Arr, RimbuError } from '@rimbu/base';
22
import { OptLazy, TraverseState, Update } from '@rimbu/common';
33

4-
import type { List } from '@rimbu/list';
4+
import type { List } from '#list/main';
55
import type {
66
BlockBuilder,
77
ListContext,
88
NonLeaf,
99
NonLeafBlock,
1010
NonLeafBuilder,
11-
} from '@rimbu/list/custom';
11+
} from '#list/custom';
1212

1313
export class NonLeafBlockBuilder<T, C extends BlockBuilder<T>>
1414
implements BlockBuilder<T, C>

packages/list/src/custom/builder/nonleaf/nonleaf-builder.mts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type {
22
BlockBuilder,
33
NonLeafBlockBuilder,
44
NonLeafTreeBuilder,
5-
} from '@rimbu/list/custom';
5+
} from '#list/custom';
66

77
export type NonLeafBuilder<T, C extends BlockBuilder<T>> =
88
| NonLeafBlockBuilder<T, C>

packages/list/src/custom/builder/nonleaf/tree-builder.mts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import type {
77
NonLeafBlockBuilder,
88
NonLeafBuilder,
99
NonLeafTree,
10-
} from '@rimbu/list/custom';
11-
import { TreeBuilderBase } from '../tree/tree-builder';
10+
} from '#list/custom';
11+
import { TreeBuilderBase } from '../tree/tree-builder.mjs';
1212

1313
export class NonLeafTreeBuilder<T, C extends BlockBuilder<T>>
1414
extends TreeBuilderBase<T, C>

packages/list/src/custom/builder/tree/tree-builder.mts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
import { RimbuError } from '@rimbu/base';
22
import { OptLazy, TraverseState, Update } from '@rimbu/common';
33

4-
import type {
5-
BlockBuilder,
6-
ListContext,
7-
NonLeafBuilder,
8-
} from '@rimbu/list/custom';
4+
import type { BlockBuilder, ListContext, NonLeafBuilder } from '#list/custom';
95

106
export abstract class TreeBuilderBase<T, C> {
117
abstract get context(): ListContext;

0 commit comments

Comments
 (0)