-
-
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
Changes from 17 commits
0c1438d
476a281
82180a7
eaa1ecd
e52ece9
6965c9a
3a18204
426aed1
66c0da8
fda4580
85cde90
00343e9
cec6654
7db835c
99ac74e
eb87fa8
7fa52e4
7f600f6
a1b31cc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,113 @@ | ||
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 ? `/* | ||
* SJS ${version} | ||
* Minimal SystemJS Build | ||
*/` : `/* | ||
* 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. |
||
comments(node, comment) { | ||
return /^\* SystemJS [0-9]\./.test(comment.value.trim()); | ||
}, | ||
safari10: true | ||
}, | ||
plugins: [replace({ | ||
TRACING: process.env.sjs ? 'false' : '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 | ||
}; | ||
|
||
export default [ | ||
mainConfig('system', true), | ||
mainConfig('system', false), | ||
mainConfig('s', true), | ||
mainConfig('s', false), | ||
...extrasConfig(true), | ||
...extrasConfig(false) | ||
]; | ||
|
||
function mainConfig(name, isDev) { | ||
const sjs = name === 's'; | ||
let banner; | ||
if (sjs) { | ||
banner = isDev ? `/* | ||
* SJS ${version} | ||
* Minimal SystemJS Build | ||
*/` : null; | ||
} else { | ||
banner = `/* | ||
* SystemJS ${version} | ||
*/`; | ||
} | ||
|
||
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) | ||
] | ||
}; | ||
}); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,7 @@ export { systemJSPrototype, REGISTRY } | |
const hasSymbol = typeof Symbol !== 'undefined'; | ||
const toStringTag = hasSymbol && Symbol.toStringTag; | ||
const REGISTRY = hasSymbol ? Symbol() : '@'; | ||
const __esModule = '__esModule'; | ||
|
||
function SystemJS () { | ||
this[REGISTRY] = {}; | ||
|
@@ -110,8 +111,8 @@ function getOrCreateLoad (loader, id, firstParentUrl) { | |
} | ||
} | ||
|
||
if (name.__esModule) { | ||
ns.__esModule = name.__esModule; | ||
if (name[__esModule]) { | ||
ns[__esModule] = name[__esModule]; | ||
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. This isn't necessary because it shouldn't affect the gzip size. |
||
} | ||
} | ||
if (changed) | ||
|
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