Skip to content
This repository has been archived by the owner on Aug 7, 2024. It is now read-only.

Commit

Permalink
Merge pull request #11 from angeloashmore/rollup
Browse files Browse the repository at this point in the history
feat: add ES module support
  • Loading branch information
OliverJAsh authored May 4, 2020
2 parents 2a267b7 + bc1f4a0 commit 64cef3c
Show file tree
Hide file tree
Showing 4 changed files with 365 additions and 4 deletions.
9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
{
"name": "ts-imgix",
"main": "./target/index.js",
"main": "./target/index.cjs.js",
"module": "./target/index.esm.js",
"typings": "./target/index.d.ts",
"sideEffects": false,
"repository": {
"type": "git",
"url": "https://github.com/unsplash/ts-imgix.git"
},
"version": "0.0.11",
"scripts": {
"lint": "tslint --project ./tsconfig.json",
"compile": "rm -rf ./target/ && tsc",
"compile": "rm -rf ./target/ && rollup -c",
"test": "npm run compile && node --require source-map-support/register ./target/tests.js",
"format": "prettier --write './**/*.{ts,tsx,js,json,md}' '.prettierrc'",
"prepublishOnly": "npm run test && npm run lint && npm run compile"
Expand All @@ -22,6 +24,9 @@
},
"devDependencies": {
"prettier": "^1.15.3",
"rollup": "^2.7.2",
"rollup-plugin-auto-external": "^2.0.0",
"rollup-plugin-typescript2": "^0.27.0",
"source-map-support": "^0.5.9",
"tslint": "^5.11.0",
"tslint-language-service": "^0.9.9",
Expand Down
20 changes: 20 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import typescript from 'rollup-plugin-typescript2';
import autoExternal from 'rollup-plugin-auto-external';

import pkg from './package.json';

export default [
{
input: 'src/index.ts',
output: [
{ file: pkg.main, format: 'cjs', sourcemap: true },
{ file: pkg.module, format: 'es', sourcemap: true },
],
plugins: [autoExternal(), typescript()],
},
{
input: 'src/tests.ts',
output: { file: 'target/tests.js', format: 'cjs' },
plugins: [autoExternal(), typescript()],
},
];
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"compilerOptions": {
"module": "commonjs",
"module": "esnext",
"moduleResolution": "node",
// Assumption: most consumers of this lib will be using UglifyJS which does not support
// ES2015+ syntax, so we target ES5 instead.
"target": "es5",
Expand Down
Loading

0 comments on commit 64cef3c

Please sign in to comment.