Skip to content

Commit bbe433c

Browse files
committed
Rollup all files into dist, package submit from dist directory
1 parent 4ef92a8 commit bbe433c

File tree

3 files changed

+46
-35
lines changed

3 files changed

+46
-35
lines changed

.github/workflows/npm-publish.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,8 @@ jobs:
1515
registry-url: https://registry.npmjs.org/
1616
- run: yarn install --frozen-lockfile --ignore-scripts
1717
- run: yarn build
18-
- run: cp -rf dist/index.cjs.js src
19-
- run: cp -rf dist/index.esm.js src
20-
- run: cp -rf package.json src
21-
- run: cd src && npm publish --access public
18+
- run: cp -rf package.json dist
19+
- run: cp -rf src/types.json dist
20+
- run: cd dist && npm publish --access public
2221
env:
2322
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"name": "@docknetwork/sdk",
3-
"version": "0.0.4",
4-
"main": "index.cjs.js",
5-
"module": "index.esm.js",
3+
"version": "0.0.5",
4+
"main": "index.js",
5+
"module": "index.mjs",
66
"license": "MIT",
77
"type": "module",
88
"repository": {
@@ -23,6 +23,7 @@
2323
"eslint-plugin-import": "^2.20.2",
2424
"eslint-plugin-jest": "^23.8.2",
2525
"ethr-did-resolver": "^2.2.0",
26+
"glob": "^7.1.6",
2627
"jest": "24.5.0",
2728
"jsdoc": "^3.6.3",
2829
"rollup": "1.7.0",

rollup.config.js

Lines changed: 39 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,46 @@
1-
// import resolve from 'rollup-plugin-node-resolve';
2-
// import commonjs from 'rollup-plugin-commonjs';
3-
// import babel from 'rollup-plugin-babel';
41
import json from 'rollup-plugin-json';
52
import pkg from './package.json';
3+
import glob from 'glob';
64

5+
export default async function() {
6+
const input = {};
77

8-
export default [
9-
// {
10-
// input: 'src/umd.js',
11-
// output: {
12-
// name: 'index',
13-
// file: pkg.browser,
14-
// format: 'umd',
15-
// },
16-
// plugins: [
17-
// resolve(),
18-
// commonjs(),
19-
// babel({
20-
// exclude: 'node_modules/**',
21-
// }),
22-
// ],
23-
// },
24-
{
8+
await new Promise((resolve, reject) => {
9+
const dir = 'src';
10+
glob(dir + '/**/*.js', null, (er, files) => {
11+
if (!er && files) {
12+
for (let i = 0; i < files.length; i++) {
13+
const fileName = files[i].substr(dir.length + 1);
14+
if (fileName.substr(fileName.length - 3) === '.js') {
15+
let id = fileName.substr(0, fileName.length - 3);
16+
if (id === 'api') {
17+
id = 'index';
18+
}
19+
input[id] = files[i];
20+
}
21+
}
22+
console.log('input', input);
23+
resolve(files);
24+
} else {
25+
throw new Error('Unable to list src files!');
26+
}
27+
});
28+
});
29+
30+
return [{
2531
plugins: [
2632
json(),
2733
],
28-
input: 'src/api.js',
29-
external: [],
30-
output: [
31-
{ file: 'dist/' + pkg.main, format: 'cjs' },
32-
{ file: 'dist/' + pkg.module, format: 'es' },
33-
],
34-
},
35-
];
34+
input,
35+
output: [{
36+
dir: 'dist',
37+
format: 'esm',
38+
entryFileNames: '[name].mjs'
39+
},
40+
{
41+
dir: 'dist',
42+
format: 'cjs'
43+
}
44+
]
45+
}];
46+
};

0 commit comments

Comments
 (0)