Skip to content

Commit

Permalink
Update Webpack to v4.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaydenseric authored and ai committed Feb 23, 2018
1 parent 6d8b98f commit aca11bf
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 196 deletions.
2 changes: 1 addition & 1 deletion index.js
Expand Up @@ -13,7 +13,7 @@ const os = require('os')

const promisify = require('./promisify')

const WEBPACK_EMPTY_PROJECT = 291
const WEBPACK_EMPTY_PROJECT = 310

const STATIC =
/\.(eot|woff2?|ttf|otf|svg|png|jpe?g|gif|webp|mp4|mp3|ogg|pdf|html|ico)$/
Expand Down
8 changes: 4 additions & 4 deletions package.json
Expand Up @@ -18,7 +18,7 @@
"bytes": "^3.0.0",
"chalk": "^2.3.1",
"ci-job-number": "^0.3.0",
"compression-webpack-plugin": "^1.1.7",
"compression-webpack-plugin": "^1.1.8",
"cosmiconfig": "^4.0.0",
"css-loader": "^0.28.10",
"escape-string-regexp": "^1.0.5",
Expand All @@ -28,9 +28,9 @@
"memory-fs": "^0.4.1",
"read-pkg-up": "^3.0.0",
"style-loader": "^0.20.2",
"uglifyjs-webpack-plugin": "^1.2.0",
"webpack": "^3.11.0",
"webpack-bundle-analyzer": "^2.10.0",
"uglifyjs-webpack-plugin": "^1.2.1",
"webpack": "^4.0.0-beta.2",
"webpack-bundle-analyzer": "^2.10.1",
"yargs": "^11.0.0"
},
"devDependencies": {
Expand Down
18 changes: 9 additions & 9 deletions test/cli.test.js
Expand Up @@ -184,21 +184,21 @@ it('supports glob patterns', () => {

it('supports ES2016', () => {
return run([], { cwd: fixture('es2016') }).then(result => {
expect(result.out).toContain('33 B\n')
expect(result.out).toContain('34 B\n')
expect(result.code).toEqual(0)
})
})

it('supports multiple files', () => {
return run([], { cwd: fixture('multiple') }).then(result => {
expect(result.out).toContain('24 B\n')
expect(result.out).toContain('25 B\n')
expect(result.code).toEqual(0)
})
})

it('checks limits', () => {
return run([], { cwd: fixture('bad') }).then(result => {
expect(result.out).toContain('exceeded by 367 B')
expect(result.out).toContain('exceeded by 204 B')
expect(result.code).toEqual(3)
})
})
Expand Down Expand Up @@ -246,7 +246,7 @@ it('returns size', () => {

it('uses different units', () => {
return run(['test/fixtures/bad/index.js']).then(result => {
expect(result.out).toContain('2.36 KB\n')
expect(result.out).toContain('2.2 KB\n')
expect(result.code).toEqual(0)
})
})
Expand All @@ -261,7 +261,7 @@ it('supports absolute path', () => {

it('ignores peerDependencies', () => {
return run([], { cwd: fixture('peer') }).then(result => {
expect(result.out).toContain('93 B\n')
expect(result.out).toContain('97 B\n')
expect(result.code).toEqual(0)
})
})
Expand All @@ -282,14 +282,14 @@ it('disables webpack by option', () => {

it('disables gzip by argument', () => {
return run(['--no-gzip', 'test/fixtures/bad/index.js']).then(result => {
expect(result.out).toContain('7.36 KB\n')
expect(result.out).toContain('6.52 KB\n')
expect(result.code).toEqual(0)
})
})

it('disables gzip by option', () => {
return run([], { cwd: fixture('gzip') }).then(result => {
expect(result.out).toContain('249 B\n')
expect(result.out).toContain('296 B\n')
expect(result.code).toEqual(0)
})
})
Expand All @@ -303,7 +303,7 @@ it('throws on --why with disabled webpack', () => {

it('uses custom webpack', () => {
return run([], { cwd: fixture('webpack-config') }).then(result => {
expect(result.out).toContain('Package size: 2.2 KB')
expect(result.out).toContain('Package size: 2.55 KB')
expect(result.code).toEqual(0)
})
})
Expand All @@ -313,7 +313,7 @@ it('uses custom webpack when specified via --config', () => {
'--config', fixture('webpack-config/webpack.config.js'),
fixture('webpack-config/index.js')
]).then(result => {
expect(result.out).toContain('Package size: 2.2 KB')
expect(result.out).toContain('Package size: 2.72 KB')
expect(result.code).toEqual(0)
})
})
3 changes: 2 additions & 1 deletion test/fixtures/webpack-config/webpack.config.js
Expand Up @@ -6,5 +6,6 @@ module.exports = {
entry: path.join(__dirname, 'index.js'),
output: {
filename: 'out.js'
}
},
mode: 'development'
}
18 changes: 9 additions & 9 deletions test/index.test.js
Expand Up @@ -20,13 +20,13 @@ it('returns 0 for empty project', () => {

it('shows project size', () => {
return getSize(fixture('bad/index')).then(size => {
expect(size).toEqual(2415)
expect(size).toEqual(2252)
})
})

it('accepts array', () => {
return getSize([fixture('bad/index'), fixture('good/index')]).then(size => {
expect(size).toEqual(2432)
expect(size).toEqual(2267)
})
})

Expand All @@ -38,25 +38,25 @@ it('returns error', () => {

it('supports ES2016', () => {
return getSize(fixture('es2016/index')).then(size => {
expect(size).toEqual(33)
expect(size).toEqual(34)
})
})

it('support images', () => {
return getSize(fixture('img/index')).then(size => {
expect(size).toEqual(52)
expect(size).toEqual(53)
})
})

it('supports CSS', () => {
return getSize(fixture('css/index')).then(size => {
expect(trim(size)).toEqual(2340)
expect(trim(size)).toEqual(2320)
})
})

it('supports CSS modules', () => {
return getSize(fixture('cssmodules/index')).then(size => {
expect(trim(size)).toEqual(2370)
expect(trim(size)).toEqual(2360)
})
})

Expand All @@ -68,7 +68,7 @@ it('removes non-production code', () => {

it('ignores dependencies on request', () => {
return getSize(fixture('peer/index'), { ignore: ['redux'] }).then(size => {
expect(size).toEqual(93)
expect(size).toEqual(97)
})
})

Expand All @@ -82,7 +82,7 @@ it('disables webpack on request', () => {

it('disables gzip on request', () => {
return getSize([fixture('bad/index')], { gzip: false }).then(size => {
expect(size).toEqual(7541)
expect(size).toEqual(6674)
})
})

Expand All @@ -98,6 +98,6 @@ it('uses custom webpack config', () => {
return getSize(fixture('webpack-config/index'), {
config: fixture('webpack-config/webpack.config')
}).then(size => {
expect(size).toEqual(2254)
expect(size).toEqual(2790)
})
})

0 comments on commit aca11bf

Please sign in to comment.