0.79.1 • Published 4 days ago

@polkadot/dev-ts v0.79.1

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
4 days ago

@polkadot/dev-ts

This is an Node TS loader, specifically written to cater for the polkadot-js needs, aka it is meant to be used inside polkadot-js projects. It doesn't aim to be a catch-all resolver, although it does cover quite a large spectrum of functionality.

It caters for -

  1. Pass through resolution and compiling of .ts & .tsx sources
  2. Resolution of TS aliases
  3. Resolution of .json files (alongside aliases)
  4. Resolution of extensionless imports (basic, best-effort)

Usage

Just add the loader via the Node.js --loader option. The API supported here is only for Node 16.12+, so ensure a new-ish LTS version is used.

node --loader @polkadot/dev-ts ...

Internally to the polkadot-js libraries, loader caching is used. This means that compiled files are store on-disk alongside the /src/ folder in /build-loader/. To enable caching behavior, the loader endpoint is changed slightly,

node --loader @polkadot/dev-ts/cached ...

This is generally the suggested default, but it is only exposed via a different loader endpoint to ensure that users explicitly opt-in and not be suprised by "random output folders" being created.

Caveats

The Node.js loader API could change in the future (as it has in the Node.js 16.12 version), so it may break or stop working on newer versions, and obviously won't work at all on older versions. As of this writing (Node.js 18.14 being the most-recent LTS), using the --loader option will print a warning.

With all that said, it is used as-is for the polkadot-js test infrastructure and currently operates without issues in that environment.

TL;DR Different configs could yield some issues.

Why

Yes, there are other options available - @babel/register, @esbuild-kit/esm-loader, @swc/register, @swc-node/loader, ts-node/esm, ...

We started off with a basic swc loader (after swapping the infrastructure from Jest & Babel), just due to the fact that (at that time, and as of writing still) the base swc loader is still a WIP against the newer loader APIs. Since we didn't want to add more dependencies (and compile differently to our internal compiler infrastructure), we adapted our own.

Since then we just swapped to using base tsc everywhere (for all builds) and may look at changing again (swc, esbuild. etc...) in the future. So effectively having a single loader, while re-inventing the wheel somewhat (since there seems to be a lot of options available) allows us to just keep the loader compiling options fully aligned with what TS -> JS output approach we take.

It meets our requirements: aligns fully with the overall configs we accross polkadot-js, compiles to ESM (no CJS used when testing/running) and has minimal dependencies that doesn't add bloat. In most cases you would probably be better off with one of the loaders/registration approaches linked in the first paragraph.

0.79.1

4 days ago

0.78.13

1 month ago

0.78.12

2 months ago

0.78.11

3 months ago

0.78.10

3 months ago

0.78.9

4 months ago

0.78.8

4 months ago

0.78.7

4 months ago

0.78.6

4 months ago

0.78.5

5 months ago

0.78.4

5 months ago

0.78.3

5 months ago

0.78.2

5 months ago

0.78.1

5 months ago

0.77.4

5 months ago

0.77.3

5 months ago

0.77.2

5 months ago

0.75.26

10 months ago

0.75.27

10 months ago

0.76.26

8 months ago

0.76.25

8 months ago

0.76.28

7 months ago

0.76.27

7 months ago

0.76.22

8 months ago

0.76.21

8 months ago

0.76.24

8 months ago

0.76.23

8 months ago

0.76.29

7 months ago

0.76.20

9 months ago

0.76.15

9 months ago

0.76.14

9 months ago

0.76.17

9 months ago

0.76.16

9 months ago

0.76.11

9 months ago

0.76.10

9 months ago

0.76.13

9 months ago

0.76.12

9 months ago

0.76.19

9 months ago

0.76.18

9 months ago

0.76.6

10 months ago

0.76.5

10 months ago

0.76.8

9 months ago

0.76.7

10 months ago

0.76.2

10 months ago

0.76.1

10 months ago

0.76.4

10 months ago

0.76.3

10 months ago

0.76.9

9 months ago

0.76.37

6 months ago

0.76.36

6 months ago

0.76.38

6 months ago

0.76.33

6 months ago

0.76.32

7 months ago

0.76.35

6 months ago

0.76.34

6 months ago

0.76.31

7 months ago

0.76.30

7 months ago

0.77.1

6 months ago

0.75.25

11 months ago

0.75.24

11 months ago

0.75.23

11 months ago

0.73.14

1 year ago

0.73.13

1 year ago

0.73.12

1 year ago

0.73.11

1 year ago

0.73.10

1 year ago

0.73.19

12 months ago

0.73.18

12 months ago

0.73.17

12 months ago

0.73.16

1 year ago

0.73.15

1 year ago

0.74.4

12 months ago

0.74.3

12 months ago

0.75.22

11 months ago

0.75.20

11 months ago

0.75.21

11 months ago

0.74.2

12 months ago

0.74.1

12 months ago

0.75.7

12 months ago

0.75.6

12 months ago

0.75.9

12 months ago

0.75.8

12 months ago

0.75.3

12 months ago

0.75.2

12 months ago

0.75.5

12 months ago

0.75.4

12 months ago

0.73.24

12 months ago

0.73.23

12 months ago

0.73.22

12 months ago

0.73.21

12 months ago

0.73.20

12 months ago

0.75.1

12 months ago

0.75.15

11 months ago

0.75.16

11 months ago

0.75.13

11 months ago

0.75.14

11 months ago

0.75.11

12 months ago

0.75.12

12 months ago

0.75.10

12 months ago

0.75.19

11 months ago

0.75.17

11 months ago

0.75.18

11 months ago

0.73.9

1 year ago

0.73.8

1 year ago

0.73.7

1 year ago

0.72.46

1 year ago

0.72.45

1 year ago

0.72.44

1 year ago

0.72.43

1 year ago

0.72.42

1 year ago

0.72.41

1 year ago

0.72.40

1 year ago

0.72.48

1 year ago

0.72.47

1 year ago

0.72.39

1 year ago

0.72.38

1 year ago

0.72.37

1 year ago

0.72.36

1 year ago

0.73.5

1 year ago

0.73.4

1 year ago

0.73.6

1 year ago

0.73.1

1 year ago

0.73.3

1 year ago

0.73.2

1 year ago

0.72.29

1 year ago

0.72.28

1 year ago

0.72.35

1 year ago

0.72.34

1 year ago

0.72.33

1 year ago

0.72.32

1 year ago

0.72.31

1 year ago

0.72.30

1 year ago

0.72.27

1 year ago

0.72.26

1 year ago

0.72.25

1 year ago

0.72.24

1 year ago

0.72.23

1 year ago

0.72.22

1 year ago

0.72.21

1 year ago

0.72.20

1 year ago

0.72.19

1 year ago

0.72.18

1 year ago

0.72.17

1 year ago

0.72.16

1 year ago

0.72.15

1 year ago

0.72.14

1 year ago

0.72.13

1 year ago

0.72.12

1 year ago

0.72.11

1 year ago

0.72.10

1 year ago

0.72.9

1 year ago

0.72.8

1 year ago

0.72.7

1 year ago

0.72.6

1 year ago

0.72.5

1 year ago

0.72.4

1 year ago

0.72.3

1 year ago

0.72.2

1 year ago

0.72.1

1 year ago