-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Upgrading dependencies and switching build to all rollup #2149
Merged
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
0c1438d
Build
joeldenning 476a281
Things
joeldenning 82180a7
Stuff
joeldenning eaa1ecd
Change
joeldenning e52ece9
More stuff
joeldenning 6965c9a
Things
joeldenning 3a18204
Stuff
joeldenning 426aed1
Review
joeldenning 66c0da8
Self review
joeldenning fda4580
Review
joeldenning 85cde90
Self review
joeldenning 00343e9
Self review
joeldenning cec6654
Self review
joeldenning 7db835c
Self review
joeldenning 99ac74e
Self review
joeldenning eb87fa8
Self review
joeldenning 7fa52e4
Updating footprint script
joeldenning 7f600f6
Guy's feedback
joeldenning a1b31cc
Adding support for running test-browser-watch on Windows
joeldenning File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,123 @@ | ||
import replace from 'rollup-plugin-replace'; | ||
import replace from '@rollup/plugin-replace'; | ||
import fs from 'fs'; | ||
import path from 'path'; | ||
import { terser } from 'rollup-plugin-terser'; | ||
|
||
const version = JSON.parse(fs.readFileSync('package.json')).version; | ||
const name = process.env.sjs ? 's' : 'system'; | ||
const extras = fs.readdirSync(path.resolve(__dirname, 'src/extras')); | ||
|
||
export default { | ||
input: `src/${name}.js`, | ||
const terserOptions = { | ||
mangle: { | ||
eval: true, | ||
module: true, | ||
safari10: true, | ||
toplevel: true | ||
}, | ||
parse: { | ||
}, | ||
compress: { | ||
unsafe: true, | ||
arguments: true, | ||
hoist_funs: true, | ||
hoist_props: true, | ||
keep_fargs: false, | ||
negate_iife: true, | ||
module: true, | ||
pure_getters: true, | ||
passes: 2, | ||
sequences: 400, | ||
toplevel: true, | ||
unsafe_proto: true, | ||
unsafe_regexp: true, | ||
unsafe_math: true, | ||
unsafe_symbols: true, | ||
unsafe_comps: true, | ||
unsafe_Function: true, | ||
unsafe_undefined: true | ||
}, | ||
output: { | ||
format: 'iife', | ||
strict: false, | ||
file: `dist/${name}.js`, | ||
banner: process.env.sjs ? `/* | ||
comments(node, comment) { | ||
return /^\* SystemJS [0-9]\./.test(comment.value.trim()); | ||
}, | ||
safari10: true | ||
}, | ||
ecma: 5, // specify one of: 5, 2015, 2016, 2017 or 2018 | ||
keep_classnames: false, | ||
keep_fnames: false, | ||
ie8: false, | ||
module: true, | ||
nameCache: null, // or specify a name cache object | ||
safari10: true, | ||
toplevel: true, | ||
warnings: false | ||
}; | ||
|
||
const buildProd = !process.env.dev; | ||
|
||
export default [ | ||
mainConfig('system', true), | ||
buildProd && mainConfig('system', false), | ||
mainConfig('s', true), | ||
buildProd && mainConfig('s', false), | ||
...extrasConfig(true), | ||
...prodExtras(), | ||
].filter(Boolean); | ||
|
||
function prodExtras() { | ||
if (buildProd) { | ||
return extrasConfig(false); | ||
} else { | ||
return []; | ||
} | ||
} | ||
|
||
function mainConfig(name, isDev) { | ||
const sjs = name === 's'; | ||
let banner; | ||
if (sjs) { | ||
banner = isDev ? `/* | ||
* SJS ${version} | ||
* Minimal SystemJS Build | ||
*/` : `/* | ||
*/` : null; | ||
} else { | ||
banner = `/* | ||
* SystemJS ${version} | ||
*/` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Indentation here needs to shift back two spaces. |
||
}, | ||
plugins: [replace({ | ||
TRACING: process.env.sjs ? 'false' : 'true' | ||
})] | ||
}; | ||
*/`; | ||
} | ||
|
||
return { | ||
input: `src/${name}.js`, | ||
output: { | ||
file: `dist/${name}${isDev ? '' : '.min'}.js`, | ||
format: 'iife', | ||
strict: false, | ||
sourcemap: !isDev, | ||
banner | ||
}, | ||
plugins: [ | ||
replace({ | ||
TRACING: sjs ? 'false' : 'true', | ||
}), | ||
!isDev && terser(terserOptions) | ||
] | ||
}; | ||
} | ||
|
||
function extrasConfig(isDev) { | ||
return extras.map(extra => { | ||
extra = extra.replace('.js', ''); | ||
return { | ||
input: `src/extras/${extra}.js`, | ||
output: { | ||
file: `dist/extras/${extra}${isDev ? '' : '.min'}.js`, | ||
format: 'iife', | ||
strict: false, | ||
compact: true, | ||
sourcemap: !isDev | ||
}, | ||
plugins: [ | ||
!isDev && terser(terserOptions) | ||
] | ||
}; | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should retain a build mode / option that allows skipping minification here for quick builds in development.
I seem to recall there may even be a way with RollupJS to pass options, but can't remember if that is correct. Otherwise environment variables can work too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can with rollup's
--environment
flag