Skip to content

Commit

Permalink
fix: export individual modules with package.json
Browse files Browse the repository at this point in the history
  • Loading branch information
andipaetzold committed Oct 14, 2021
1 parent 412011c commit 18ab7e3
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 7 deletions.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
/docs/
/lib/
/node_modules/
/test-results/
/test-results/

# modules
/firestore/
/storage/
14 changes: 8 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@
"name": "react-firehooks",
"version": "1.1.1",
"description": "Lightweight dependency-free collection of React hooks for Firebase",
"main": "lib/cjs/index.js",
"browser": "lib/cjs/index.js",
"module": "lib/esm/index.js",
"types": "lib/types/index.d.ts",
"main": "./lib/cjs/index.js",
"module": "./lib/esm/index.js",
"types": "./lib/types/index.d.ts",
"exports": {
".": {
"require": "./lib/cjs/index.js",
Expand All @@ -21,7 +20,9 @@
}
},
"files": [
"lib"
"lib",
"firestore",
"storage"
],
"repository": {
"type": "git",
Expand Down Expand Up @@ -67,9 +68,10 @@
},
"scripts": {
"prepublishOnly": "npm run build",
"build": "rimraf lib && npm run build:cjs && npm run build:esm",
"build": "rimraf lib && npm run build:cjs && npm run build:esm && npm run build:modules",
"build:cjs": "rimraf lib/cjs && tsc --module commonjs --outDir lib/cjs",
"build:esm": "rimraf lib/esm && tsc --module ES2015 --outDir lib/esm",
"build:modules": "node ./scripts/create-modules.js",
"test": "jest",
"semantic-release": "semantic-release",
"typedoc": "typedoc"
Expand Down
13 changes: 13 additions & 0 deletions scripts/create-modules.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const fs = require("fs");

const modules = ["firestore", "storage"];
for (const module of modules) {
const packageJson = {
main: `../lib/cjs/${module}/index.js`,
module: `../lib/esm/${module}/index.js`,
types: `../lib/types/${module}/index.d.ts`,
};

fs.mkdirSync(module);
fs.writeFileSync(`${module}/package.json`, JSON.stringify(packageJson, undefined, 4));
}

0 comments on commit 18ab7e3

Please sign in to comment.