Skip to content

Commit

Permalink
Rollup all files into dist, package submit from dist directory
Browse files Browse the repository at this point in the history
  • Loading branch information
cykoder committed May 4, 2020
1 parent 4ef92a8 commit bbe433c
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 35 deletions.
7 changes: 3 additions & 4 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@ jobs:
registry-url: https://registry.npmjs.org/
- run: yarn install --frozen-lockfile --ignore-scripts
- run: yarn build
- run: cp -rf dist/index.cjs.js src
- run: cp -rf dist/index.esm.js src
- run: cp -rf package.json src
- run: cd src && npm publish --access public
- run: cp -rf package.json dist
- run: cp -rf src/types.json dist
- run: cd dist && npm publish --access public
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "@docknetwork/sdk",
"version": "0.0.4",
"main": "index.cjs.js",
"module": "index.esm.js",
"version": "0.0.5",
"main": "index.js",
"module": "index.mjs",
"license": "MIT",
"type": "module",
"repository": {
Expand All @@ -23,6 +23,7 @@
"eslint-plugin-import": "^2.20.2",
"eslint-plugin-jest": "^23.8.2",
"ethr-did-resolver": "^2.2.0",
"glob": "^7.1.6",
"jest": "24.5.0",
"jsdoc": "^3.6.3",
"rollup": "1.7.0",
Expand Down
67 changes: 39 additions & 28 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,35 +1,46 @@
// import resolve from 'rollup-plugin-node-resolve';
// import commonjs from 'rollup-plugin-commonjs';
// import babel from 'rollup-plugin-babel';
import json from 'rollup-plugin-json';
import pkg from './package.json';
import glob from 'glob';

export default async function() {
const input = {};

export default [
// {
// input: 'src/umd.js',
// output: {
// name: 'index',
// file: pkg.browser,
// format: 'umd',
// },
// plugins: [
// resolve(),
// commonjs(),
// babel({
// exclude: 'node_modules/**',
// }),
// ],
// },
{
await new Promise((resolve, reject) => {
const dir = 'src';
glob(dir + '/**/*.js', null, (er, files) => {
if (!er && files) {
for (let i = 0; i < files.length; i++) {
const fileName = files[i].substr(dir.length + 1);
if (fileName.substr(fileName.length - 3) === '.js') {
let id = fileName.substr(0, fileName.length - 3);
if (id === 'api') {
id = 'index';
}
input[id] = files[i];
}
}
console.log('input', input);
resolve(files);
} else {
throw new Error('Unable to list src files!');
}
});
});

return [{
plugins: [
json(),
],
input: 'src/api.js',
external: [],
output: [
{ file: 'dist/' + pkg.main, format: 'cjs' },
{ file: 'dist/' + pkg.module, format: 'es' },
],
},
];
input,
output: [{
dir: 'dist',
format: 'esm',
entryFileNames: '[name].mjs'
},
{
dir: 'dist',
format: 'cjs'
}
]
}];
};

0 comments on commit bbe433c

Please sign in to comment.