Skip to content

Commit

Permalink
Merge pull request #161 from Secreto31126/exports
Browse files Browse the repository at this point in the history
Exports fix
  • Loading branch information
Secreto31126 authored May 26, 2023
2 parents 6f5d250 + 8336305 commit 18fb860
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 17 deletions.
1 change: 1 addition & 0 deletions build.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const sharedConfig = {
// ESM
await build({
...sharedConfig,
format: "esm",
outdir: "lib/esm"
});

Expand Down
56 changes: 49 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,71 @@
"files": [
"lib/**/*"
],
"types": "lib/esm/index.d.ts",
"types": "lib/types/index.d.ts",
"module": "lib/esm/index.js",
"main": "lib/cjs/index.js",
"exports": {
".": {
"types": "./lib/types/index.d.ts",
"import": "./lib/esm/index.js",
"require": "./lib/cjs/index.js"
},
"./messages": {
"types": "./lib/types/messages/index.d.ts",
"import": "./lib/esm/messages/index.js",
"require": "./lib/cjs/messages/index.js"
},
"./*": {
"import": "./lib/esm/*.js",
"require": "./lib/cjs/*.js"
"./messages/*": {
"types": "./lib/types/messages/*.d.ts",
"import": "./lib/esm/messages/*.js",
"require": "./lib/cjs/messages/*.js"
},
"./setup": null,
"./setup/index": null,
"./setup/*": {
"types": "./lib/types/setup/*.d.ts",
"import": "./lib/esm/setup/*.js",
"require": "./lib/cjs/setup/*.js"
},
"./emitters": {
"types": "./lib/types/emitters.d.ts"
},
"./types": {
"types": "./lib/types/types.d.ts",
"import": "./lib/esm/types.js",
"require": "./lib/cjs/types.js"
}
},
"//": "https://github.com/andrewbranch/example-subpath-exports-ts-compat/blob/main/examples/node_modules/types-versions-wildcards/package.json",
"//": "Without this, IntelliSense will throw an error when importing subpaths ONLY on JS files, although it does run fine with Node.",
"//": "Even more stunishing: if included, IntelliSense works even BETTER than with TS.",
"typesVersions": {
"*": {
".": [
"lib/types/index.d.ts"
],
"messages": [
"lib/types/messages/index.d.ts"
],
"messages/*": [
"lib/types/messages/*.d.ts"
],
"setup/index": [],
"setup/*": [
"lib/types/setup/*.d.ts"
],
"emitters": [
"lib/types/emitters.d.ts"
],
"types": [
"lib/types/types.d.ts"
]
}
},
"scripts": {
"build": "npm run build:code && npm run build:types",
"build:code": "node -r dotenv/config build.js",
"build:types": "npm run build:types:esm && npm run build:types:cjs",
"build:types:esm": "tsc --outDir ./lib/esm && cp ./src/*.d.ts ./lib/esm",
"build:types:cjs": "tsc --outDir ./lib/cjs && cp ./src/*.d.ts ./lib/cjs",
"build:types": "tsc && cp ./src/*.d.ts ./lib/types",
"test": "mocha",
"test:build": "npm run build && npm run test",
"test:watch": "mocha --reporter min --watch",
Expand Down
21 changes: 11 additions & 10 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
{
"include": ["src/**/*"],
"compilerOptions": {
"lib": ["ESNext"], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
"types": ["node", "undici"], /* Specify type package names to be included without being referenced in a source file. */
"declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
"declarationMap": true, /* Create sourcemaps for d.ts files. */
"emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
"isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
"esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
"forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
"strict": true, /* Enable all strict type-checking options. */
"skipLibCheck": true /* Skip type checking all .d.ts files. */
"lib": ["ESNext"],
"outDir": "lib/types",
"types": ["node", "undici"],
"declaration": true,
"declarationMap": true,
"emitDeclarationOnly": true,
"isolatedModules": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"skipLibCheck": true
}
}

0 comments on commit 18fb860

Please sign in to comment.