diff --git a/README.md b/README.md index 9eb0349..2b5f63d 100644 --- a/README.md +++ b/README.md @@ -250,7 +250,7 @@ When using a build tool like WebPack, Babel, Rollup or the TypeScript compiler: ```javascript // Import the Web-eID library -import * as webeid from '@web-eid/web-eid-library/web-eid'; +import * as webeid from '@web-eid/web-eid-library'; // ...or only what you need import { @@ -258,7 +258,7 @@ import { authenticate, Action, ErrorCode -} from '@web-eid/web-eid-library/web-eid'; +} from '@web-eid/web-eid-library'; // If you need TypeScript interfaces, they are also available! @@ -914,12 +914,6 @@ npm link ~/workspace/web-eid-library - This option might be more convenient for active development. - After making changes to the Web-eID library source and rebuilding the library project, you don't need to reinstall the dependency in your other project. -**Cons** -- ES modules are located at `web-eid/dist/node/` instead of directly under `web-eid/`. - ```ts - import AuthenticateOptions from 'web-eid/dist/node/models/AuthenticateOptions'; - ``` - #### Using `npm pack` You can use `npm pack` to generate a package and install the package archive. diff --git a/package.json b/package.json index c8d0189..863ee97 100644 --- a/package.json +++ b/package.json @@ -17,8 +17,51 @@ "type": "git", "url": "git@github.com:web-eid/web-eid.js.git" }, - "module": "web-eid.js", + "type": "module", + "main": "dist/umd/web-eid.cjs", + "module": "dist/node/web-eid.js", + "types": "dist/node/web-eid.d.ts", + "exports": { + ".": { + "types": "./dist/node/web-eid.d.ts", + "import": "./dist/node/web-eid.js", + "require": "./dist/umd/web-eid.cjs", + "default": "./dist/umd/web-eid.cjs" + }, + "./config": { + "types": "./dist/node/config.d.ts", + "import": "./dist/node/config.js" + }, + "./errors/*": { + "types": "./dist/node/errors/*.d.ts", + "import": "./dist/node/errors/*.js" + }, + "./models/*": { + "types": "./dist/node/models/*.d.ts", + "import": "./dist/node/models/*.js" + }, + "./models/message/*": { + "types": "./dist/node/models/message/*.d.ts", + "import": "./dist/node/models/message/*.js" + }, + "./services/*": { + "types": "./dist/node/services/*.d.ts", + "import": "./dist/node/services/*.js" + }, + "./utils/*": { + "types": "./dist/node/utils/*.d.ts", + "import": "./dist/node/utils/*.js" + }, + "./dist/es/*": "./dist/es/*", + "./dist/iife/*": "./dist/iife/*", + "./dist/umd/*": "./dist/umd/*" + }, "files": [ + "src/**/*", + "dist/node/**/*", + "dist/es/*", + "dist/iife/*", + "dist/umd/*", "config.d.ts", "config.d.ts.map", "config.js", @@ -30,12 +73,8 @@ "errors/**/*", "models/**/*", "services/**/*", - "utils/**/*", - "dist/es/*", - "dist/iife/*", - "dist/umd/*" + "utils/**/*" ], - "types": "web-eid.d.ts", "author": "Tanel Metsar", "license": "MIT", "devDependencies": { diff --git a/rollup.config.mjs b/rollup.config.mjs index 9905f93..49c179e 100644 --- a/rollup.config.mjs +++ b/rollup.config.mjs @@ -34,13 +34,13 @@ export default { plugins: [terser()], }, { - file: "dist/umd/web-eid.js", + file: "dist/umd/web-eid.cjs", format: "umd", name: "webeid", sourcemap: true, }, { - file: "dist/umd/web-eid.min.js", + file: "dist/umd/web-eid.min.cjs", format: "umd", name: "webeid", sourcemap: false,