Skip to content

Commit

Permalink
feat: enable rollup bundle without runtime deps
Browse files Browse the repository at this point in the history
  • Loading branch information
3cp committed Apr 18, 2019
1 parent a3302eb commit fa32b55
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 10 deletions.
2 changes: 1 addition & 1 deletion bin/makes.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/* eslint-disable no-console */
'use strict';

const makes = require('../lib');
const makes = require('../dist');
const {warn, error} = require('../lib/log');
const minimist = require("minimist");
const options = minimist(process.argv.slice(2), {
Expand Down
24 changes: 15 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"description": "A tool to scaffold new projects, simple enough that you would want to define your own generators.",
"main": "lib/index.js",
"files": [
"dist",
"lib",
"bin"
],
Expand All @@ -17,7 +18,9 @@
"preversion": "npm test",
"version": "standard-changelog && git add CHANGELOG.md",
"postversion": "git push && git push --tags && npm publish",
"pretest": "npm run lint"
"pretest": "npm run lint",
"build": "rollup -c",
"prepare": "npm run build"
},
"repository": {
"type": "git",
Expand All @@ -34,22 +37,25 @@
"url": "https://github.com/huochunpeng/makes/issues"
},
"homepage": "https://github.com/huochunpeng/makes#readme",
"dependencies": {
"devDependencies": {
"ansi-colors": "^3.2.4",
"ava": "^1.4.1",
"eslint": "^5.16.0",
"gunzip-maybe": "^1.4.1",
"hosted-git-info": "^2.7.1",
"isutf8": "^2.0.3",
"minimist": "^1.2.0",
"mock-fs": "^4.8.0",
"nyc": "^14.0.0",
"rollup": "^1.10.0",
"rollup-plugin-commonjs": "^9.3.4",
"rollup-plugin-json": "^4.0.0",
"rollup-plugin-node-resolve": "^4.2.3",
"rollup-plugin-replace": "^2.2.0",
"sisteransi": "^1.0.0",
"standard-changelog": "^2.0.7",
"tar-fs": "^2.0.0",
"vinyl": "^2.2.0",
"xregexp": "^4.2.4"
},
"devDependencies": {
"ava": "^1.4.1",
"eslint": "^5.16.0",
"mock-fs": "^4.8.0",
"nyc": "^14.0.0",
"standard-changelog": "^2.0.7"
}
}
43 changes: 43 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import resolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
import json from 'rollup-plugin-json';
import replace from 'rollup-plugin-replace';

export default {
input: 'lib/index.js',
external: [
'fs',
'path',
'https',
'crypto',
'os',
'string_decoder',
'readline',
'child_process',
'stream',
'events',
'zlib',
'url',
'util',
'constants',
'buffer'
],
output: {
file: 'dist/index.js',
format: 'cjs'
},
plugins: [
resolve({preferBuiltins: true}),
replace({
delimiters: ['', ''],
values: {
'require(\'readable-stream/transform\')': 'require(\'stream\').Transform',
'require("readable-stream/transform")': 'require(\'stream\').Transform',
'require(\'readable-stream\')': 'require(\'stream\')',
'require("readable-stream")': 'require(\'stream\')'
}
}),
commonjs(),
json()
]
};

0 comments on commit fa32b55

Please sign in to comment.