Skip to content

Commit

Permalink
feat: change output directory to build, use package.json files to spe…
Browse files Browse the repository at this point in the history
…cify artifacts
  • Loading branch information
Harrison Ifeanyichukwu authored and Harrison Ifeanyichukwu committed Apr 22, 2023
1 parent 80f796d commit fcf72b5
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 23 deletions.
Binary file added .DS_Store
Binary file not shown.
5 changes: 1 addition & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,4 @@
/coverage
/build
/temp
/cjs
/esm
/iife
/umd
/package
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

**@teclone/rollup-all** is a package for generating javascript/typescript library builds with typescript definition file support.

This package does the heavy lifting and builds on top of [Rollupjs](https://rollupjs.org/) and [Babel](https://babeljs.io/) making it possible to generate `cjs`, `esm`, `umd` and `iife` builds at once.
This package does the heavy lifting and builds on top of [Rollupjs](https://rollupjs.org/) and [Babel](https://babeljs.io/) making it possible to generate `cjs`, `es`, `umd` and `iife` builds at once.

## Motivation for this package

Expand Down Expand Up @@ -63,7 +63,7 @@ yarn rollup-all
The following build formats are supported:

- `cjs`: Commonjs build, this output of this build is compatible with Nodejs.
- `esm`: Es module build, the output of this build is compatibile with modern bundle tools such as webpack
- `es`: Es module build, the output of this build is compatibile with modern bundle tools such as webpack
- `umd`: Browser bundle compatible with umd loaders,
- `iife`: Browser bundle

Expand All @@ -79,7 +79,7 @@ module.exports = createConfig({
/**
* build formats to generate
*/
formats: ['cjs', 'esm', 'iife', 'umd'],
formats: ['cjs', 'es', 'iife', 'umd'],

src: 'src',

Expand All @@ -88,7 +88,7 @@ module.exports = createConfig({
*
* for instance cjs builds will be put inside ${out}/cjs/
*/
out: './',
out: './build',

/**
* extra rollup js plugins
Expand Down
10 changes: 7 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,14 @@
"publishConfig": {
"access": "public"
},
"main": "cjs/index",
"module": "esm/index",
"typings": "cjs/index",
"main": "build/cjs/index",
"module": "build/es/index",
"typings": "build/cjs/index",
"bin": "./bin/index.js",
"files": [
"build",
"bin"
],
"scripts": {
"compile": "tsc --noEmit",
"commit": "git-cz",
Expand Down
2 changes: 1 addition & 1 deletion src/@types/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { GlobalsOption, Plugin } from 'rollup';

export type BuildFormat = 'cjs' | 'esm' | 'iife' | 'umd';
export type BuildFormat = 'cjs' | 'es' | 'iife' | 'umd';

export type BuildEnvironment = 'development' | 'production' | 'uni';

Expand Down
4 changes: 2 additions & 2 deletions src/config.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Config } from './@types';

export const config: Config = {
formats: ['cjs', 'esm'],
formats: ['cjs', 'es'],

src: 'src',

out: './',
out: './build',

plugins: [],

Expand Down
4 changes: 2 additions & 2 deletions src/modules/Bundler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ class Bundler {

switch (format) {
case 'cjs':
case 'esm':
case 'es':
externals = allExternal;
break;

Expand Down Expand Up @@ -417,7 +417,7 @@ class Bundler {
// remove build out folder
rimrafSync(outFolder);

if (format === 'cjs' || format === 'esm') {
if (format === 'cjs' || format === 'es') {
await Promise.all([
this.copyFiles(outFolder, copyFiles, format),
this.buildFiles(outFolder, buildFiles, {
Expand Down
2 changes: 1 addition & 1 deletion src/modules/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export const getRollupPlugins = (opts: {
'@babel/plugin-transform-runtime'
),
{
useESModules: format === 'esm',
useESModules: format === 'es',
regenerator: true,
},
]
Expand Down
6 changes: 0 additions & 6 deletions tsconfig.build.json

This file was deleted.

0 comments on commit fcf72b5

Please sign in to comment.