diff --git a/package.json b/package.json index bdc7d2a..7873915 100644 --- a/package.json +++ b/package.json @@ -34,16 +34,21 @@ "types": "src/cjs/index.d.ts", "exports": { ".": { - "import": "./src/esm/index.js", - "require": "./src/cjs/index.cjs", - "types": "./src/cjs/index.d.ts" + "import": { + "types": "./src/esm/index.d.ts", + "default": "./src/esm/index.js" + }, + "require": { + "types": "./src/cjs/index.d.cts", + "default": "./src/cjs/index.cjs" + } } }, "scripts": { "build": "npm run clean && tsc -p ./tsconfig.json && tsc -p ./tsconfig.cjs.json", "clean": "rimraf src", "gitdiff": "npm run build && git diff --exit-code", - "postbuild": "find src/cjs -type f -name \"*.js\" -exec bash -c 'mv \"$0\" \"${0%.js}.cjs\"' {} \\;", + "postbuild": "find src/cjs -type f \\( -name \"*.js\" -o -name \"*.ts\" \\) -exec bash -c 'ext=\"${0##*.}\"; mv \"$0\" \"${0%.$ext}.c$ext\"' {} \\;", "standard": "ts-standard --ignore src --ignore test", "test": "npm run standard && npm run unit", "unit": "tape test/index.js" diff --git a/src/cjs/index.d.ts b/src/cjs/index.d.cts similarity index 100% rename from src/cjs/index.d.ts rename to src/cjs/index.d.cts diff --git a/src/esm/index.d.ts b/src/esm/index.d.ts new file mode 100644 index 0000000..6aeee88 --- /dev/null +++ b/src/esm/index.d.ts @@ -0,0 +1,3 @@ +import basex from 'base-x'; +declare const _default: basex.BaseConverter; +export default _default; diff --git a/tsconfig.base.json b/tsconfig.base.json index d10d8ce..6d3a3c0 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -1,24 +1,24 @@ { - "compilerOptions": { - "target": "ES5", - "module": "commonjs", - "outDir": "./src", - "rootDir": "./ts_src", - "types": ["node"], - "allowJs": false, - "strict": true, - "noImplicitAny": true, - "strictNullChecks": true, - "strictFunctionTypes": true, - "strictBindCallApply": true, - "strictPropertyInitialization": true, - "noImplicitThis": true, - "alwaysStrict": true, - "esModuleInterop": true, - "noUnusedLocals": true, - "noUnusedParameters": true - }, - "include": ["ts_src/**/*.ts"], - "exclude": ["node_modules/**/*"] - } - \ No newline at end of file + "compilerOptions": { + "target": "ES5", + "module": "commonjs", + "outDir": "./src", + "rootDir": "./ts_src", + "types": ["node"], + "declaration": true, + "allowJs": false, + "strict": true, + "noImplicitAny": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "strictBindCallApply": true, + "strictPropertyInitialization": true, + "noImplicitThis": true, + "alwaysStrict": true, + "esModuleInterop": true, + "noUnusedLocals": true, + "noUnusedParameters": true + }, + "include": ["ts_src/**/*.ts"], + "exclude": ["node_modules/**/*"] +} diff --git a/tsconfig.cjs.json b/tsconfig.cjs.json index 1417240..afd6b72 100644 --- a/tsconfig.cjs.json +++ b/tsconfig.cjs.json @@ -1,10 +1,7 @@ { - "extends": "./tsconfig.base.json", - "compilerOptions": { - "declaration": true, - "emitDeclarationOnly": false, - "outDir": "src/cjs", - "module": "commonjs" - } + "extends": "./tsconfig.base.json", + "compilerOptions": { + "outDir": "src/cjs", + "module": "commonjs" } - \ No newline at end of file +}