Skip to content

Commit

Permalink
Added build options for umd and cjs with json support
Browse files Browse the repository at this point in the history
  • Loading branch information
naz committed Sep 24, 2020
1 parent a19d744 commit 0354ae3
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 10 deletions.
2 changes: 0 additions & 2 deletions packages/timezone-data/index.js

This file was deleted.

2 changes: 2 additions & 0 deletions packages/timezone-data/lib/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import timezones from './timezones.json';
export default timezones;
File renamed without changes.
32 changes: 24 additions & 8 deletions packages/timezone-data/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,44 @@
"repository": "https://github.com/TryGhost/Ghost-SDKs/tree/master/packages/timezone-data",
"author": "Ghost Foundation",
"license": "MIT",
"main": "index.js",
"main": "cjs/timezone-data.js",
"umd:main": "umd/timezone-data.min.js",
"unpkg": "umd/timezone-data.min.js",
"module": "lib/index.js",
"source": "lib/index.js",
"files": [
"LICENSE",
"README.md",
"cjs/",
"lib/",
"umd/"
],
"scripts": {
"dev": "echo \"Implement me!\"",
"pretest": "yarn build",
"test": "NODE_ENV=testing mocha './test/**/*.test.js'",
"build": "rollup -c",
"lint": "eslint . --ext .js --cache",
"prepare": "NODE_ENV=production yarn build",
"posttest": "yarn lint"
},
"files": [
"index.js",
"lib"
],
"publishConfig": {
"access": "public"
},
"devDependencies": {
"@babel/core": "^7.2.2",
"@babel/preset-env": "^7.2.3",
"mocha": "6.0.1",
"rollup": "^1.0.1",
"rollup-plugin-babel": "^4.2.0",
"rollup-plugin-commonjs": "^9.2.0",
"rollup-plugin-json": "^3.1.0",
"rollup-plugin-node-resolve": "^4.0.0",
"rollup-plugin-replace": "^2.1.0",
"rollup-plugin-terser": "^4.0.1",
"should": "13.2.3",
"sinon": "7.2.4"
},
"dependencies": {
"bluebird": "^3.5.3",
"ghost-ignition": "^3.0.2",
"lodash": "^4.17.11"
}
}
58 changes: 58 additions & 0 deletions packages/timezone-data/rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/* eslint-env node */
import resolve from 'rollup-plugin-node-resolve';
import babel from 'rollup-plugin-babel';
import commonjs from 'rollup-plugin-commonjs';
import {terser} from 'rollup-plugin-terser';
import replace from 'rollup-plugin-replace';
import json from 'rollup-plugin-json';
import pkg from './package.json';

const dependencies = Object.keys(pkg.dependencies);

export default [
// Node build.
// No transpilation or bundling other than converstion from es modules to cjs
{
input: pkg.source,
output: {
file: pkg.main,
format: 'cjs',
interop: false
},
plugins: [
json(),
commonjs({
include: ['node_modules/**', '../../node_modules/**']
})
],
external: dependencies
},

// Standalone UMD browser build (minified).
// Transpiles to es5 and bundles all dependencies.
{
input: pkg.source,
output: {
file: pkg['umd:main'],
format: 'umd',
name: 'GhostTimezoneData'
},
plugins: [
json(),
resolve({
browser: true,
preferBuiltins: false
}),
commonjs({
include: ['node_modules/**', '../../node_modules/**']
}),
babel({
exclude: ['node_modules/**', '../../node_modules/**']
}),
replace({
'process.env.NODE_ENV': `"${process.env.NODE_ENV}"`
}),
terser()
]
}
];

0 comments on commit 0354ae3

Please sign in to comment.