Skip to content

Commit 6bd6ae3

Browse files
committed
Added build options for umd and cjs with json support
1 parent e962e4d commit 6bd6ae3

File tree

5 files changed

+84
-10
lines changed

5 files changed

+84
-10
lines changed

packages/timezone-data/index.js

Lines changed: 0 additions & 2 deletions
This file was deleted.

packages/timezone-data/lib/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import timezones from './timezones.json';
2+
export default timezones;

packages/timezone-data/package.json

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,44 @@
44
"repository": "https://github.com/TryGhost/Ghost-SDKs/tree/master/packages/timezone-data",
55
"author": "Ghost Foundation",
66
"license": "MIT",
7-
"main": "index.js",
7+
"main": "cjs/timezone-data.js",
8+
"umd:main": "umd/timezone-data.min.js",
9+
"unpkg": "umd/timezone-data.min.js",
10+
"module": "lib/index.js",
11+
"source": "lib/index.js",
12+
"files": [
13+
"LICENSE",
14+
"README.md",
15+
"cjs/",
16+
"lib/",
17+
"umd/"
18+
],
819
"scripts": {
920
"dev": "echo \"Implement me!\"",
21+
"pretest": "yarn build",
1022
"test": "NODE_ENV=testing mocha './test/**/*.test.js'",
23+
"build": "rollup -c",
1124
"lint": "eslint . --ext .js --cache",
25+
"prepare": "NODE_ENV=production yarn build",
1226
"posttest": "yarn lint"
1327
},
14-
"files": [
15-
"index.js",
16-
"lib"
17-
],
1828
"publishConfig": {
1929
"access": "public"
2030
},
2131
"devDependencies": {
32+
"@babel/core": "^7.2.2",
33+
"@babel/preset-env": "^7.2.3",
2234
"mocha": "6.0.1",
35+
"rollup": "^1.0.1",
36+
"rollup-plugin-babel": "^4.2.0",
37+
"rollup-plugin-commonjs": "^9.2.0",
38+
"rollup-plugin-json": "^3.1.0",
39+
"rollup-plugin-node-resolve": "^4.0.0",
40+
"rollup-plugin-replace": "^2.1.0",
41+
"rollup-plugin-terser": "^4.0.1",
2342
"should": "13.2.3",
2443
"sinon": "7.2.4"
2544
},
2645
"dependencies": {
27-
"bluebird": "^3.5.3",
28-
"ghost-ignition": "^3.0.2",
29-
"lodash": "^4.17.11"
3046
}
3147
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/* eslint-env node */
2+
import resolve from 'rollup-plugin-node-resolve';
3+
import babel from 'rollup-plugin-babel';
4+
import commonjs from 'rollup-plugin-commonjs';
5+
import {terser} from 'rollup-plugin-terser';
6+
import replace from 'rollup-plugin-replace';
7+
import json from 'rollup-plugin-json';
8+
import pkg from './package.json';
9+
10+
const dependencies = Object.keys(pkg.dependencies);
11+
12+
export default [
13+
// Node build.
14+
// No transpilation or bundling other than converstion from es modules to cjs
15+
{
16+
input: pkg.source,
17+
output: {
18+
file: pkg.main,
19+
format: 'cjs',
20+
interop: false
21+
},
22+
plugins: [
23+
json(),
24+
commonjs({
25+
include: ['node_modules/**', '../../node_modules/**']
26+
})
27+
],
28+
external: dependencies
29+
},
30+
31+
// Standalone UMD browser build (minified).
32+
// Transpiles to es5 and bundles all dependencies.
33+
{
34+
input: pkg.source,
35+
output: {
36+
file: pkg['umd:main'],
37+
format: 'umd',
38+
name: 'GhostTimezoneData'
39+
},
40+
plugins: [
41+
json(),
42+
resolve({
43+
browser: true,
44+
preferBuiltins: false
45+
}),
46+
commonjs({
47+
include: ['node_modules/**', '../../node_modules/**']
48+
}),
49+
babel({
50+
exclude: ['node_modules/**', '../../node_modules/**']
51+
}),
52+
replace({
53+
'process.env.NODE_ENV': `"${process.env.NODE_ENV}"`
54+
}),
55+
terser()
56+
]
57+
}
58+
];

0 commit comments

Comments
 (0)