Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
Steel Brain committed Sep 10, 2018
1 parent 7f6f00c commit d2acd5c
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 12 deletions.
4 changes: 0 additions & 4 deletions packages/pundle-job-transformer-js-common/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ function createComponent({ name = '_common_' }: { name?: string } = {}) {
name: manifest.name,
version: manifest.version,
async callback({ context, job }) {
if (context.config.target === 'node') {
return null
}

const chunkToFiles = new Map()

job.chunks.forEach(chunk => {
Expand Down
2 changes: 2 additions & 0 deletions packages/pundle-job-transformer-js-dedupe/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
src/
*.flow
22 changes: 22 additions & 0 deletions packages/pundle-job-transformer-js-dedupe/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "pundle-job-transformer-js-dedupe",
"version": "3.0.0-beta8",
"description": "TODO",
"repository": {
"type": "git",
"url": "git+https://github.com/steelbrain/pundle.git"
},
"main": "lib/index.js",
"flow:main": "src/index.js",
"scripts": {},
"dependencies": {
},
"peerDependencies": {
"pundle-api": "3.0.0-beta8"
},
"author": "steelbrain",
"license": "MIT",
"devDependencies": {
"pundle-api": "^3.0.0-beta8"
}
}
17 changes: 17 additions & 0 deletions packages/pundle-job-transformer-js-dedupe/src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// @flow

import { createJobTransformer } from 'pundle-api'
import { name, version } from '../package.json'

function createComponent() {
return createJobTransformer({
name,
version,
callback({ context, worker, job }) {
console.log('dedupe transformer')
return null
},
})
}

module.exports = createComponent
1 change: 1 addition & 0 deletions packages/pundle-preset-default/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"pundle-chunk-transformer-cssnano": "^3.0.0-beta9",
"pundle-chunk-transformer-uglify": "^3.0.0-beta9",
"pundle-job-transformer-js-common": "^3.0.0-beta9",
"pundle-job-transformer-js-dedupe": "^3.0.0-beta9",
"pundle-reporter-cli": "^3.0.0-beta9",
"pundle-resolver-default": "^3.0.0-beta9",
"pundle-transformer-babel": "^3.0.0-beta9",
Expand Down
28 changes: 20 additions & 8 deletions packages/pundle-preset-default/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ function getPresetComponents({
html?: boolean,
},
optimize?: {
js?: boolean | { uglify?: boolean | Object },
js?: boolean | { uglify?: boolean | Object, common?: boolean | Object, dedupe?: boolean | Object },
css?: boolean | { cssnano?: boolean | Object },
html?: boolean,
},
Expand Down Expand Up @@ -258,14 +258,26 @@ function getPresetComponents({
components.push(require('pundle-chunk-generator-html')())
}
components.push(require('pundle-chunk-generator-static')())

if (optimizeJS) {
components.push(require('pundle-job-transformer-js-common')())
components.push(
require('pundle-chunk-transformer-uglify')({
uglifier: 'terser',
...(optimizeJS && optimizeJS.uglify),
}),
)
if (typeof optimizeJS === 'boolean' || optimizeJS.common) {
components.push(require('pundle-job-transformer-js-common')())
}
if (typeof optimizeJS === 'boolean' || optimizeJS.uglify) {
components.push(
require('pundle-chunk-transformer-uglify')({
uglifier: 'terser',
...(optimizeJS && optimizeJS.uglify),
}),
)
}
if (typeof optimizeJS === 'boolean' || optimizeJS.dedupe) {
components.push(
require('pundle-job-transformer-js-dedupe')({
...(optimizeJS && optimizeJS.dedupe),
}),
)
}
}
if (optimizeCSS) {
components.push(
Expand Down

0 comments on commit d2acd5c

Please sign in to comment.