Skip to content

Commit

Permalink
Update the build structure (#1122)
Browse files Browse the repository at this point in the history
* Update the build structure

* Make sure we're publishing the dist folder

* Fix the versioning

* Add the missing command

* Update publish in CONTRIBUTING.md

Co-authored-by: Kristian Djaković <[email protected]>
  • Loading branch information
DarkoKukovec and Kristian Djaković authored Nov 14, 2022
1 parent 1222163 commit 9640192
Show file tree
Hide file tree
Showing 11 changed files with 212 additions and 82 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ When writing docs, make sure your updates are writtern in `versioned_docs/{versi

## Publishing

1. `lerna publish`
1. `npm run publish`
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"scripts": {
"lint": "eslint packages/**/*.ts",
"postinstall": "npm run prepare",
"prepare": "husky install"
"prepare": "husky install",
"publish": "lerna publish --contents dist"
},
"private": true,
"workspaces": [
Expand Down
2 changes: 2 additions & 0 deletions packages/datx-jsonapi/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@
"jest": "^28.1.1",
"lodash": "^4.17.21",
"rollup": "^2.75.6",
"rollup-plugin-copy": "^3.4.0",
"rollup-plugin-exclude-dependencies-from-bundle": "^1.1.22",
"rollup-plugin-generate-package-json": "^3.2.0",
"rollup-plugin-terser": "^7.0.2",
"ts-jest": "^28.0.4",
"tslib": "~2.4.0",
Expand Down
40 changes: 21 additions & 19 deletions packages/datx-jsonapi/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,18 @@ import { terser } from 'rollup-plugin-terser';
import commonjs from '@rollup/plugin-commonjs';
import resolve from '@rollup/plugin-node-resolve';
import excludeDependenciesFromBundle from 'rollup-plugin-exclude-dependencies-from-bundle';
import generatePackageJson from 'rollup-plugin-generate-package-json';
import copy from 'rollup-plugin-copy';

import pkg from './package.json';

export default [
{
input: './src/index.ts',
output: [{ file: pkg.main, format: 'cjs' }],
output: [
{ file: pkg.main, format: 'cjs', sourcemap: true },
{ file: pkg.module, format: 'es', sourcemap: true },
],
plugins: [
resolve(),
commonjs(),
Expand All @@ -28,24 +33,21 @@ export default [
comments: false,
},
}),
],
onwarn(warning, rollupWarn) {
if (warning.code !== 'CIRCULAR_DEPENDENCY') {
rollupWarn(warning);
}
},
},
{
input: './src/index.ts',
output: [{ file: pkg.module, format: 'es' }],
plugins: [
resolve(),
commonjs(),
excludeDependenciesFromBundle(),
typescript({
typescript: require('typescript'),
tslib: require('tslib'),
tsconfig: './tsconfig.build.json',
generatePackageJson({
outputFolder: 'dist',
baseContents: (pack) => ({
...pack,
main: './index.cjs.js',
module: './index.esm.js',
typings: './index.d.ts',
jest: undefined,
scripts: undefined,
devDependencies: {},
husky: undefined,
}),
}),
copy({
targets: [{ src: 'README.md', dest: 'dist' }],
}),
],
onwarn(warning, rollupWarn) {
Expand Down
2 changes: 2 additions & 0 deletions packages/datx-network/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@
"@types/react": "^18.0.12",
"jest": "^28.1.1",
"rollup": "^2.75.6",
"rollup-plugin-copy": "^3.4.0",
"rollup-plugin-exclude-dependencies-from-bundle": "^1.1.22",
"rollup-plugin-generate-package-json": "^3.2.0",
"rollup-plugin-terser": "^7.0.2",
"ts-jest": "^28.0.4",
"tslib": "~2.4.0",
Expand Down
40 changes: 21 additions & 19 deletions packages/datx-network/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,18 @@ import { terser } from 'rollup-plugin-terser';
import commonjs from '@rollup/plugin-commonjs';
import resolve from '@rollup/plugin-node-resolve';
import excludeDependenciesFromBundle from 'rollup-plugin-exclude-dependencies-from-bundle';
import generatePackageJson from 'rollup-plugin-generate-package-json';
import copy from 'rollup-plugin-copy';

import pkg from './package.json';

export default [
{
input: './src/index.ts',
output: [{ file: pkg.main, format: 'cjs' }],
output: [
{ file: pkg.main, format: 'cjs', sourcemap: true },
{ file: pkg.module, format: 'es', sourcemap: true },
],
plugins: [
resolve(),
commonjs(),
Expand All @@ -28,24 +33,21 @@ export default [
comments: false,
},
}),
],
onwarn(warning, rollupWarn) {
if (warning.code !== 'CIRCULAR_DEPENDENCY') {
rollupWarn(warning);
}
},
},
{
input: './src/index.ts',
output: [{ file: pkg.module, format: 'es' }],
plugins: [
resolve(),
commonjs(),
excludeDependenciesFromBundle(),
typescript({
typescript: require('typescript'),
tslib: require('tslib'),
tsconfig: './tsconfig.build.json',
generatePackageJson({
outputFolder: 'dist',
baseContents: (pack) => ({
...pack,
main: './index.cjs.js',
module: './index.esm.js',
typings: './index.d.ts',
jest: undefined,
scripts: undefined,
devDependencies: {},
husky: undefined,
}),
}),
copy({
targets: [{ src: 'README.md', dest: 'dist' }],
}),
],
onwarn(warning, rollupWarn) {
Expand Down
1 change: 1 addition & 0 deletions packages/datx-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"mobx": "^6.6.0",
"rollup": "^2.75.6",
"rollup-plugin-exclude-dependencies-from-bundle": "^1.1.22",
"rollup-plugin-generate-package-json": "^3.2.0",
"rollup-plugin-terser": "^7.0.2",
"ts-jest": "^28.0.4",
"tslib": "~2.4.0",
Expand Down
36 changes: 17 additions & 19 deletions packages/datx-utils/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@ import { terser } from 'rollup-plugin-terser';
import commonjs from '@rollup/plugin-commonjs';
import resolve from '@rollup/plugin-node-resolve';
import excludeDependenciesFromBundle from 'rollup-plugin-exclude-dependencies-from-bundle';
import generatePackageJson from 'rollup-plugin-generate-package-json';

import pkg from './package.json';

export default [
{
input: './src/index.ts',
output: [{ file: pkg.main, format: 'cjs' }],
output: [
{ file: pkg.main, format: 'cjs', sourcemap: true },
{ file: pkg.module, format: 'es', sourcemap: true },
],
plugins: [
resolve(),
commonjs(),
Expand All @@ -28,24 +32,18 @@ export default [
comments: false,
},
}),
],
onwarn(warning, rollupWarn) {
if (warning.code !== 'CIRCULAR_DEPENDENCY') {
rollupWarn(warning);
}
},
},
{
input: './src/index.ts',
output: [{ file: pkg.module, format: 'es' }],
plugins: [
resolve(),
commonjs(),
excludeDependenciesFromBundle(),
typescript({
typescript: require('typescript'),
tslib: require('tslib'),
tsconfig: './tsconfig.build.json',
generatePackageJson({
outputFolder: 'dist',
baseContents: (pack) => ({
...pack,
main: './index.cjs.js',
module: './index.esm.js',
typings: './index.d.ts',
jest: undefined,
scripts: undefined,
devDependencies: {},
husky: undefined,
}),
}),
],
onwarn(warning, rollupWarn) {
Expand Down
2 changes: 2 additions & 0 deletions packages/datx/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@
"@types/node": "^18.7.6",
"jest": "^28.1.1",
"rollup": "^2.75.6",
"rollup-plugin-copy": "^3.4.0",
"rollup-plugin-exclude-dependencies-from-bundle": "^1.1.22",
"rollup-plugin-generate-package-json": "^3.2.0",
"ts-jest": "^28.0.4",
"tslib": "~2.4.0",
"typescript": "~4.7.3"
Expand Down
42 changes: 22 additions & 20 deletions packages/datx/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,18 @@ import { terser } from 'rollup-plugin-terser';
import commonjs from '@rollup/plugin-commonjs';
import resolve from '@rollup/plugin-node-resolve';
import excludeDependenciesFromBundle from 'rollup-plugin-exclude-dependencies-from-bundle';
import generatePackageJson from 'rollup-plugin-generate-package-json';
import copy from 'rollup-plugin-copy';

import pkg from './package.json';

export default [
{
input: './src/index.ts',
output: [{ file: pkg.main, format: 'cjs' }],
output: [
{ file: pkg.main, format: 'cjs', sourcemap: true },
{ file: pkg.module, format: 'es', sourcemap: true },
],
plugins: [
resolve(),
commonjs(),
Expand All @@ -28,24 +33,21 @@ export default [
comments: false,
},
}),
],
onwarn(warning, rollupWarn) {
if (warning.code !== 'CIRCULAR_DEPENDENCY') {
rollupWarn(warning);
}
},
},
{
input: './src/index.ts',
output: [{ file: pkg.module, format: 'es' }],
plugins: [
resolve(),
commonjs(),
excludeDependenciesFromBundle(),
typescript({
typescript: require('typescript'),
tslib: require('tslib'),
tsconfig: './tsconfig.build.json',
generatePackageJson({
outputFolder: 'dist',
baseContents: (pack) => ({
...pack,
main: './index.cjs.js',
module: './index.esm.js',
typings: './index.d.ts',
jest: undefined,
scripts: undefined,
devDependencies: {},
husky: undefined,
}),
}),
copy({
targets: [{ src: 'README.md', dest: 'dist' }],
}),
],
onwarn(warning, rollupWarn) {
Expand All @@ -56,7 +58,7 @@ export default [
},
{
input: './src/disable-mobx.ts',
output: [{ file: './disable-mobx.js', format: 'cjs' }],
output: [{ file: './dist/disable-mobx.js', format: 'cjs' }],
plugins: [
resolve(),
commonjs(),
Expand Down
Loading

0 comments on commit 9640192

Please sign in to comment.