diff --git a/packages/timezone-data/index.js b/packages/timezone-data/index.js deleted file mode 100644 index 580dfdafa..000000000 --- a/packages/timezone-data/index.js +++ /dev/null @@ -1,2 +0,0 @@ -import * as timezones from './timezones.json'; -export default timezones; diff --git a/packages/timezone-data/lib/index.js b/packages/timezone-data/lib/index.js new file mode 100644 index 000000000..79ba577c3 --- /dev/null +++ b/packages/timezone-data/lib/index.js @@ -0,0 +1,2 @@ +import timezones from './timezones.json'; +export default timezones; diff --git a/packages/timezone-data/timezones.json b/packages/timezone-data/lib/timezones.json similarity index 100% rename from packages/timezone-data/timezones.json rename to packages/timezone-data/lib/timezones.json diff --git a/packages/timezone-data/package.json b/packages/timezone-data/package.json index e25cad392..5c70dba5a 100644 --- a/packages/timezone-data/package.json +++ b/packages/timezone-data/package.json @@ -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" } } diff --git a/packages/timezone-data/rollup.config.js b/packages/timezone-data/rollup.config.js new file mode 100644 index 000000000..39e3e14cb --- /dev/null +++ b/packages/timezone-data/rollup.config.js @@ -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() + ] + } +];