|
12 | 12 | "type": "module",
|
13 | 13 | "// The 'main' and 'unpkg' fields will remain as legacy for backwards compatibility for now. We will add deprectaion warnings to these outputs to give people time to see the warnings in their apps in a non-breaking way, and eventually we can remove the legacy stuff.": "",
|
14 | 14 | "main": "lib/docsify.js",
|
| 15 | + "types": "dist/core/Docsify.d.ts", |
15 | 16 | "unpkg": "lib/docsify.min.js",
|
16 | 17 | "// We're using the 'exports' field as an override of the 'main' field to provide the new ESM setup. Once we remove legacy 'main', we will remove the 'exports' field and have a simple ESM setup with only a 'main' field.": "",
|
| 18 | + "// These exports require moduleResolution:NodeNext to be enabled in the consumer.": "", |
| 19 | + "// TODO native ESM (in browsers) does not work yet because prismjs is not ESM and Docsify source imports it as CommonJS": "", |
17 | 20 | "exports": {
|
18 |
| - ".": "./src/Docsify.js", |
19 |
| - "./*": "./*" |
| 21 | + "./*": "./*", |
| 22 | + ".": { |
| 23 | + "types": "./dist/core/Docsify.d.ts", |
| 24 | + "default": "./src/core/Docsify.js" |
| 25 | + } |
20 | 26 | },
|
21 | 27 | "files": [
|
22 | 28 | "lib",
|
23 | 29 | "themes"
|
24 | 30 | ],
|
| 31 | + "// Using 'typesVersions' here is the only way we could figure out how to get types working for imports of any subpath without any of the problems other approaches have when not using modeResolution:NodeNext (listed in https://stackoverflow.com/questions/77856692/how-to-publish-plain-jsjsdoc-library-for-typescript-consumers)": "", |
| 32 | + "typesVersions": { |
| 33 | + "*": { |
| 34 | + "src/*": [ |
| 35 | + "dist/*" |
| 36 | + ] |
| 37 | + } |
| 38 | + }, |
25 | 39 | "scripts": {
|
26 | 40 | "build:cover": "node build/cover.js",
|
27 | 41 | "build:css:min": "node build/mincss.js",
|
28 | 42 | "build:css": "mkdirp lib/themes && node build/css -o lib/themes",
|
29 | 43 | "build:emoji": "node ./build/emoji.js",
|
30 |
| - "build:js": "cross-env NODE_ENV=production node build/build.js", |
| 44 | + "build:js": "npm run build:types && cross-env NODE_ENV=production node build/build.js", |
| 45 | + "build:types": "tsc -p tsconfig.json || true", |
31 | 46 | "build:test": "npm run build && npm test",
|
32 | 47 | "build": "rimraf lib themes && run-s build:js build:css build:css:min build:cover build:emoji",
|
33 | 48 | "dev": "run-p serve:dev watch:*",
|
|
0 commit comments