diff --git a/.npmignore b/.npmignore index dcaf8d6aca054f..1398bd4c996209 100644 --- a/.npmignore +++ b/.npmignore @@ -4,6 +4,11 @@ .prettierrc .vscode build +!/build/data.json +!/build/import.d.mts +!/build/legacynode.mjs +!/build/require.d.ts +!/build/types.d.ts docs test schemas diff --git a/package.json b/package.json index 99da6414f639dc..3f17fab89013e5 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,23 @@ "description": "Browser compatibility data provided by MDN Web Docs", "main": "index.ts", "type": "module", + "exports": { + ".": { + "require": { + "types": "./build/require.d.ts", + "default": "./build/data.json" + }, + "import": { + "types": "./build/import.d.mts", + "default": "./build/data.json" + } + }, + "./forLegacyNode": { + "types": "./build/import.d.mts", + "default": "./build/legacynode.mjs" + } + }, + "types": "./build/require.d.ts", "engines": { "node": ">=18.0.0" }, @@ -75,7 +92,7 @@ "yargs": "~17.7.0" }, "scripts": { - "prepare": "husky install && npm run gentypes", + "prepare": "husky install && npm run gentypes && npm run build", "diff": "node --loader=ts-node/esm --no-warnings=ExperimentalWarning scripts/diff.ts", "unittest": "NODE_ENV=test c8 mocha index.test.ts --recursive \"{,!(node_modules)/**}/*.test.ts\"", "coverage": "c8 report -r lcov && open-cli coverage/lcov-report/index.html",