Skip to content

Commit

Permalink
Publish from dist (#1323)
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilkisiela committed Apr 1, 2020
1 parent c0f6905 commit f39fc24
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 13 deletions.
10 changes: 4 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "graphql-tools",
"version": "5.0.0-alpha.0",
"version": "5.0.0-alpha.1",
"description": "Useful tools to create and manipulate GraphQL schemas.",
"sideEffects": false,
"main": "dist/index.cjs.js",
Expand All @@ -10,10 +10,6 @@
"typescript": {
"definition": "dist/index.d.ts"
},
"files": [
"/dist",
"!/dist/test"
],
"scripts": {
"clean": "rimraf dist",
"precompile": "npm run clean",
Expand All @@ -24,7 +20,8 @@
"watch": "npm run compile -- --watch",
"prepublishOnly": "npm run compile",
"format": "prettier --write src/**/*.ts",
"format:check": "prettier --check src/**/*.ts"
"format:check": "prettier --check src/**/*.ts",
"release": "npm run compile && npm publish dist"
},
"repository": {
"type": "git",
Expand Down Expand Up @@ -91,6 +88,7 @@
"rimraf": "3.0.2",
"rollup": "2.3.1",
"rollup-plugin-auto-external": "2.0.0",
"rollup-plugin-generate-package-json": "3.2.0",
"rollup-plugin-typescript2": "0.27.0",
"ts-jest": "25.3.0",
"typescript": "3.8.3",
Expand Down
55 changes: 48 additions & 7 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,70 @@
import autoExternal from 'rollup-plugin-auto-external';
import resolveNode from '@rollup/plugin-node-resolve';
import generatePackageJson from 'rollup-plugin-generate-package-json';
import rollupTypescript from 'rollup-plugin-typescript2';

const commonOutputOptions = {
preferConst: true,
sourcemap: true
sourcemap: true,
};

export default {
input: 'src/index.ts',
plugins: [
resolveNode(),
autoExternal({ builtins: true, dependencies: true, peerDependencies: true }),
rollupTypescript()
autoExternal({
builtins: true,
dependencies: true,
peerDependencies: true,
}),
generatePackageJson({
baseContents: rewritePackageJson,
}),
rollupTypescript(),
],
output: [
{
...commonOutputOptions,
file: 'dist/index.cjs.js',
format: 'cjs'
format: 'cjs',
},
{
...commonOutputOptions,
file: 'dist/index.esm.js',
format: 'esm'
}
]
format: 'esm',
},
],
};

function rewritePackageJson(pkg) {
const newPkg = {};
const fields = [
'name',
'version',
'description',
'sideEffects',
'peerDependencies',
'repository',
'homepage',
'keywords',
'author',
'license',
'engines',
];

fields.forEach((field) => {
if (pkg[field]) {
newPkg[field] = pkg[field];
}
});

newPkg.main = 'index.cjs.js';
newPkg.module = 'index.esm.js';
newPkg.typings = 'index.d.ts';
newPkg.types = 'index.d.ts';
newPkg.typescript = {
definition: newPkg.typings,
};

return newPkg;
}

0 comments on commit f39fc24

Please sign in to comment.