Skip to content

Commit

Permalink
Merge pull request #65 from Rich-Harris/update-dependencies
Browse files Browse the repository at this point in the history
update dependencies
  • Loading branch information
Rich-Harris authored Jan 18, 2019
2 parents ea28a5c + 1fc0292 commit c14d17d
Show file tree
Hide file tree
Showing 4 changed files with 1,413 additions and 671 deletions.
20 changes: 10 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,29 +24,29 @@
},
"homepage": "https://github.com/Rich-Harris/packd#readme",
"dependencies": {
"browserify": "^14.1.0",
"browserify": "^16.2.3",
"compression": "^1.7.0",
"etag": "^1.8.0",
"express": "^4.15.2",
"is-module": "^1.0.0",
"lru-cache": "^4.0.2",
"lru-cache": "^5.1.1",
"minilog": "^3.1.0",
"npm": "^5.3.0",
"pretty-bytes": "^4.0.2",
"npm": "^6.6.0",
"pretty-bytes": "^5.1.0",
"request": "^2.81.0",
"request-promise": "^4.2.1",
"rollup": "^0.45.2",
"rollup-plugin-node-resolve": "^3.0.0",
"rollup-plugin-uglify": "^2.0.1",
"rollup": "^1.1.0",
"rollup-plugin-node-resolve": "^4.0.0",
"rollup-plugin-uglify": "^6.0.1",
"sander": "^0.6.0",
"semver": "^5.3.0",
"serve-favicon": "^2.4.2",
"sha1": "^1.1.1",
"tar": "^3.2.1",
"uglify-js": "^3.0.25"
"tar": "^4.4.8",
"terser": "^3.14.1"
},
"devDependencies": {
"eslint": "^4.3.0"
"eslint": "^5.12.0"
},
"now": {
"alias": "packd",
Expand Down
2 changes: 1 addition & 1 deletion server/cache.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const LRU = require( 'lru-cache' );

module.exports = LRU({
module.exports = new LRU({
max: 128 * 1024 * 1024,
length: src => src.length
});
40 changes: 22 additions & 18 deletions server/child-processes/create-bundle.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const fs = require( 'fs' );
const path = require( 'path' );
const sander = require( 'sander' );
const child_process = require( 'child_process' );
Expand All @@ -6,7 +7,7 @@ const request = require( 'request' );
const browserify = require( 'browserify' );
const rollup = require( 'rollup' );
const resolve = require( 'rollup-plugin-node-resolve' );
const UglifyJS = require( 'uglify-js' );
const Terser = require( 'terser' );
const isModule = require( 'is-module' );
const makeLegalIdentifier = require( '../utils/makeLegalIdentifier' );

Expand All @@ -29,12 +30,12 @@ async function createBundle ({ hash, pkg, version, deep, query }) {
await fetchAndExtract( pkg, version, dir );
await sanitizePkg( cwd );
await installDependencies( cwd );

const code = await bundle( cwd, deep, query );

info( `[${pkg.name}] minifying` );

const result = UglifyJS.minify( code );
const result = Terser.minify( code );

if ( result.error ) {
info( `[${pkg.name}] minification failed: ${result.error.message}` );
Expand Down Expand Up @@ -149,36 +150,39 @@ function findEntry ( file ) {
}
}

async function bundleWithRollup ( cwd, pkg, moduleEntry, moduleName ) {
async function bundleWithRollup ( cwd, pkg, moduleEntry, name ) {
const bundle = await rollup.rollup({
entry: path.resolve( cwd, moduleEntry ),
input: path.resolve( cwd, moduleEntry ),
plugins: [
resolve({ module: true, jsnext: true, main: false, modulesOnly: true })
]
});

info( `[${pkg.name}] bundled using Rollup` );
const result = await bundle.generate({
format: 'umd',
name
});

if ( bundle.imports.length > 0 ) {
if ( result.output.length > 1 ) {
info( `[${pkg.name}] generated multiple chunks, trying Browserify instead` );
return bundleWithBrowserify( pkg, moduleEntry, name );
}

if ( result.output[0].imports.length > 0 ) {
info( `[${pkg.name}] non-ES2015 dependencies found, handing off to Browserify` );

const intermediate = `${cwd}/__intermediate.js`;
return bundle.write({
dest: intermediate,
const { code } = await bundle.generate({
format: 'cjs'
}).then( () => {
return bundleWithBrowserify( pkg, intermediate, moduleName );
});

fs.writeFileSync( intermediate, code );
return bundleWithBrowserify( pkg, intermediate, name );
}

else {
const { code } = await bundle.generate({
format: 'umd',
moduleName
});
info( `[${pkg.name}] bundled using Rollup` );

return code;
}
return result.output[0].code;
}

function bundleWithBrowserify ( pkg, main, moduleName ) {
Expand Down
Loading

0 comments on commit c14d17d

Please sign in to comment.