|
1 |
| -import typescript from "rollup-plugin-typescript2"; |
2 |
| -import dts from "rollup-plugin-dts"; |
| 1 | +import typescript from 'rollup-plugin-typescript2' |
| 2 | +import dts from 'rollup-plugin-dts' |
3 | 3 |
|
4 | 4 | /**
|
5 | 5 | * Just a few details about this build implementation:
|
6 |
| - * - Uses `rollup` along with `rollup-plugin-typescript2` to build to two target files |
7 |
| - * (`index.es.js` and `index.cjs.js`). This means that there is only a *single* file now for each |
| 6 | + * - Uses `rollup` along with `rollup-plugin-typescript2` to build to two target files |
| 7 | + * (`index.es.js` and `index.cjs.js`). This means that there is only a *single* file now for each |
8 | 8 | * target rather than 4 files (ie. `index.js`, `chain.js`, etc.).
|
9 |
| - * - Rollup has their own official @rollup/plugin-typescript plugin but it does not have the best |
10 |
| - * TS declarations support atm (see https://github.com/rollup/plugins/issues/394, |
| 9 | + * - Rollup has their own official @rollup/plugin-typescript plugin but it does not have the best |
| 10 | + * TS declarations support atm (see https://github.com/rollup/plugins/issues/394, |
11 | 11 | * https://github.com/rollup/plugins/issues/254, https://github.com/rollup/plugins/issues/243).
|
12 | 12 | * Until these are resolved, I choose to just use `rollup-plugin-typescript2`.
|
13 |
| - * - `rollup-plugin-typescript2` generates `index.d.ts`, `chain.d.ts`, `result.d.ts` and |
14 |
| - * `result-async.d.ts` but this is inconsistent with the generated JavaScript files. This isn't a |
15 |
| - * huge issues unless someone tries to import `neverthrow/dist/chain` which would error |
16 |
| - * because the underlying `.js` doesn't exist. To remedy this issue, I used `rollup-plugin-dts` to |
| 13 | + * - `rollup-plugin-typescript2` generates `index.d.ts`, `chain.d.ts`, `result.d.ts` and |
| 14 | + * `result-async.d.ts` but this is inconsistent with the generated JavaScript files. This isn't a |
| 15 | + * huge issues unless someone tries to import `neverthrow/dist/chain` which would error |
| 16 | + * because the underlying `.js` doesn't exist. To remedy this issue, I used `rollup-plugin-dts` to |
17 | 17 | * merge `*.d.ts` files into a single `index.d.ts`.
|
18 |
| - * - It's unfortunately a bit complicated to generate two build outputs but once some of the |
| 18 | + * - It's unfortunately a bit complicated to generate two build outputs but once some of the |
19 | 19 | * issues I've linked to above are resolved this process will become much easier :)
|
20 |
| - * - Because the build process is kinda two steps (first using `rollup-plugin-typescript2` and then |
21 |
| - * using `rollup-plugin-dts`), I first write to `tmp/`, then write the merged `index.d.ts` to |
| 20 | + * - Because the build process is kinda two steps (first using `rollup-plugin-typescript2` and then |
| 21 | + * using `rollup-plugin-dts`), I first write to `tmp/`, then write the merged `index.d.ts` to |
22 | 22 | * `dist/` and then moved `index.es.js` and `index.cjs.js` to `dist/`.
|
23 | 23 | */
|
24 | 24 |
|
25 | 25 | export default [
|
26 | 26 | {
|
27 |
| - input: "src/index.ts", |
| 27 | + input: 'src/index.ts', |
28 | 28 | output: {
|
29 |
| - file: "tmp/index.es.js", |
30 |
| - format: "es", |
| 29 | + file: 'tmp/index.es.js', |
| 30 | + format: 'es', |
31 | 31 | },
|
32 | 32 | plugins: [typescript()],
|
33 | 33 | },
|
34 | 34 | {
|
35 |
| - input: "src/index.ts", |
| 35 | + input: 'src/index.ts', |
36 | 36 | output: {
|
37 |
| - file: "tmp/index.cjs.js", |
38 |
| - format: "cjs", |
| 37 | + file: 'tmp/index.cjs.js', |
| 38 | + format: 'cjs', |
39 | 39 | },
|
40 | 40 | plugins: [typescript()],
|
41 | 41 | },
|
42 | 42 | {
|
43 |
| - input: "tmp/index.d.ts", |
44 |
| - output: [{ file: "dist/index.d.ts", format: "es" }], |
| 43 | + input: 'tmp/index.d.ts', |
| 44 | + output: [{ file: 'dist/index.d.ts', format: 'es' }], |
45 | 45 | plugins: [dts()],
|
46 | 46 | },
|
47 |
| -]; |
| 47 | +] |
0 commit comments