Skip to content
This repository has been archived by the owner on Feb 25, 2023. It is now read-only.

Latest commit

 

History

History
63 lines (49 loc) · 1.47 KB

File metadata and controls

63 lines (49 loc) · 1.47 KB

Glob pattern use of rollup-plugin-jsy-babel

Configuration for using JSY in RollupJS via Babel 6.x.

NPM Install
# optional; could also use `npm init .`
$ echo '{"private": true}' > package.json.

# install devDependencies for JSY and RollupJS
$ npm install -D \
    babel-core babel-cli \
    rollup rollup-plugin-jsy-babel \
    babel-preset-jsy
Add rollup.config.js with:
import {parse as path_parse} from 'path'
import rpi_jsy from 'rollup-plugin-jsy-babel'

const configs = []
export default configs

const sourcemap = 'inline'
const plugins = [rpi_jsy()]
const external = []


import {sync as glob_sync} from 'glob'
glob_sync('code/*.jsy')
  .forEach(add_jsy)


function add_jsy(src_filename) {
  const {name} = path_parse(src_filename)
  configs.push({
    input: src_filename,
    output: [
      { file: `cjs/${name}.js`, format: 'cjs', exports:'named', sourcemap },
      { file: `umd/${name}.js`, format: 'umd', name, exports:'named', sourcemap },
      { file: `esm/${name}.js`, format: 'es', sourcemap },
    ],
    plugins, external })
}
Add files and scripts to package.json :
{
  "files": [ "cjs/", "esm/", "umd/" ],
  "scripts": {
    "clean": "rm -rf ./cjs/* ./esm/* ./umd/*",
    "build": "rollup --config",
    "watch": "npm -s run build -- --watch",
    "pretest": "npm -s run build",
    "test": "true"
  }
}