Skip to content

Commit ffa9947

Browse files
authored
Properly include and export TypeScript types (#248)
We need to copy the entrypoing typings file, as described in [the TypeScript docs]: > It’s important to note that the CommonJS entrypoint and the ES > module entrypoint each needs its own declaration file, even if the > contents are the same between them. Every declaration file is > interpreted either as a CommonJS module or as an ES module, based on > its file extension and the `"type"` field of the `package.json`, and > this detected module kind must match the module kind that Node will > detect for the corresponding JavaScript file for type checking to be > correct. Attempting to use a single `.d.ts` file to type both an ES > module entrypoint and a CommonJS entrypoint will cause TypeScript to > think only one of those entrypoints exists, causing compiler errors > for users of the package. [the TypeScript docs]: https://www.typescriptlang.org/docs/handbook/esm-node.html Closes #247
1 parent f7509e6 commit ffa9947

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

package.json

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
{
22
"name": "sass-embedded",
3-
"version": "1.67.0",
3+
"version": "1.67.1-dev",
44
"protocol-version": "2.1.0",
55
"compiler-version": "1.67.0",
66
"description": "Node.js library that communicates with Embedded Dart Sass using the Embedded Sass protocol",
77
"repository": "sass/embedded-host-node",
88
"author": "Google Inc.",
99
"license": "MIT",
1010
"exports": {
11-
"import": "./dist/lib/index.mjs",
11+
"import": {
12+
"types": "./dist/lib/index.m.d.ts",
13+
"default": "./dist/lib/index.mjs"
14+
},
15+
"types": "./dist/lib/index.d.ts",
1216
"default": "./dist/lib/index.js"
1317
},
1418
"main": "dist/lib/index.js",
@@ -25,7 +29,7 @@
2529
"check:gts": "gts check",
2630
"check:tsc": "tsc --noEmit",
2731
"clean": "gts clean",
28-
"compile": "tsc && cp lib/index.mjs dist/lib/index.mjs",
32+
"compile": "tsc && cp lib/index.mjs dist/lib/index.mjs && cp -r lib/src/vendor/sass/ dist/lib/src/vendor/sass && cp dist/lib/src/vendor/sass/index.d.ts dist/lib/src/vendor/sass/index.m.d.ts",
2933
"fix": "gts fix",
3034
"prepublishOnly": "npm run clean && ts-node ./tool/prepare-release.ts",
3135
"test": "jest"

0 commit comments

Comments
 (0)