Skip to content
This repository has been archived by the owner on Feb 16, 2022. It is now read-only.

Commit

Permalink
chore: add "files" field to the package.json to limit size
Browse files Browse the repository at this point in the history
  • Loading branch information
piotr-oles committed Oct 9, 2019
1 parent 0e6fcdb commit 497233c
Show file tree
Hide file tree
Showing 3 changed files with 515 additions and 473 deletions.
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
"main": "lib/index.js",
"module": "lib/index.es.js",
"typings": "lib/index.d.ts",
"files": [
"lib"
],
"scripts": {
"build": "rollup -c",
"precommit": "lint-staged && yarn build && yarn test",
Expand Down
28 changes: 13 additions & 15 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,47 +4,45 @@ const cleaner = require("rollup-plugin-cleaner");
const path = require("path");
const process = require("process");

const pkg = {
path: process.cwd(),
meta: require(path.join(process.cwd(), "package.json"))
};
const pkg = require(path.join(process.cwd(), "package.json"));

if (!pkg.meta.main) {
if (!pkg.main) {
throw new Error(
'Missing "main" key in package.json - cannot compile CommonJS module.'
);
}

if (!pkg.meta.module) {
if (!pkg.module) {
throw new Error(
'Missing "module" key in package.json - cannot compile ES6 module.'
);
}

export default {
input: pkg.path + "/src/index.ts",
input: process.cwd() + "/src/index.ts",
output: [
{
file: pkg.path + "/" + pkg.meta.main,
format: "cjs"
file: process.cwd() + "/" + pkg.main,
format: "cjs",
exports: "named"
},
{
file: pkg.path + "/" + pkg.meta.module,
format: "esm"
file: process.cwd() + "/" + pkg.module,
format: "esm",
exports: "named"
}
],
external: Object.keys(
Object.assign(pkg.meta.peerDependencies || {}, pkg.meta.dependencies || {})
Object.assign({}, pkg.peerDependencies || {}, pkg.dependencies || {})
),
plugins: [
cleaner({
targets: [
path.dirname(pkg.path + "/" + pkg.meta.main),
path.dirname(pkg.path + "/" + pkg.meta.module)
path.dirname(process.cwd() + "/" + pkg.main),
path.dirname(process.cwd() + "/" + pkg.module)
]
}),
typescript({
objectHashIgnoreUnknownHack: true,
clean: true,
tsconfigOverride: {
include: ["./src/**/*"],
Expand Down

0 comments on commit 497233c

Please sign in to comment.