Skip to content

Commit

Permalink
build UMD bundle and polyfill language features (#4366)
Browse files Browse the repository at this point in the history
- use rollup's `umd` bundle instead of `iife`
    - consume Rollup config's `output` prop in `karma-rollup-plugin`
    - simplify `rollup.config.js` `output` prop
    - fix invalid `script` tag `src` attrib in `lib/browser/template.html` (& reformat)
    - use core-js polyfills
- remove old ESlint rule to disallow `Object.assign` (it's now allowed... but so is object rest/spread, which works in many  cases)
- fix travis script
- karma-related:
    - update Symbol test for IE11, as the polyfill is just a polyfill.
    - add a proper RequireJS integration test
    - remove the old `bundle/amd.spec.js` test
    - try to make `karma.conf.js` less intimidating
    - allow custom externals/globals in karma rollup plugin
    - `unexpected`, `unexpected-eventemitter`, and `unexpected-sinon` are now external (not bundled) and loaded via their globals
    - modified `test/browser-specific/setup.js` to use `require()` since we can do that now
    - bundle now has an inline source map since I couldn't figure out any other way to load it
    - removed duplication of work in the karma plugin; no call to `bundle.generate()` is needed. furthermore the `code` prop did not include the inline source maps. so we just write the file and read the result. could probably avoid reading the file by manually stitching the `code` and `map` props together, but I'm unsure how
    - loads `mocha.js.map` for debugging
  • Loading branch information
boneskull committed Jul 28, 2020
1 parent 02bdb6b commit ad03d29
Show file tree
Hide file tree
Showing 16 changed files with 546 additions and 335 deletions.
5 changes: 0 additions & 5 deletions .eslintrc.yml
Expand Up @@ -15,11 +15,6 @@ rules:
strict:
- error
- safe
# disallow Object.assign
no-restricted-properties:
- error
- object: 'Object'
property: 'assign'
overrides:
- files:
- 'docs/js/**/*.js'
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -49,7 +49,7 @@ jobs:
node_js: '10'
name: 'Node.js v10'

- script: npm start test.bundle test.browser
- script: npm start test.browser
name: 'Browser'
node_js: 12
install: npm ci # we need the native modules here
Expand Down
6 changes: 3 additions & 3 deletions browser-entry.js
Expand Up @@ -210,10 +210,10 @@ Mocha.process = process;
* Expose mocha.
*/

global.Mocha = Mocha;
global.mocha = mocha;
mocha.Mocha = Mocha;
mocha.mocha = mocha;

// this allows test/acceptance/required-tokens.js to pass; thus,
// you can now do `const describe = require('mocha').describe` in a
// browser context (assuming browserification). should fix #880
module.exports = global;
module.exports = Object.assign(mocha, global);

0 comments on commit ad03d29

Please sign in to comment.