Skip to content

Commit

Permalink
Update build, test and sandbox to use pre-polyfilled Ractive
Browse files Browse the repository at this point in the history
  • Loading branch information
fskreuz committed Jul 5, 2017
1 parent 95cb6c5 commit 0b2cb95
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 27 deletions.
45 changes: 20 additions & 25 deletions gobblefile.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ const banner = `/*
License: MIT
*/`;

const runtimeModulesToIgnore = ['parse/_parse.js'].map(p => p.split('/').join(path.sep));
const placeholders = { BUILD_PLACEHOLDER_VERSION: version };

const src = gobble('src');
Expand All @@ -40,34 +39,32 @@ const sandbox = gobble('sandbox');

module.exports = ({
'dev:browser'() {
const lib = buildUmdLib('ractive.js', []);
const lib = buildUmdLib('ractive.js');
const tests = buildBrowserTests();
const polyfills = buildUmdPolyfill();
return gobble([lib, polyfills, tests, sandbox, qunit]);
return gobble([lib, tests, sandbox, qunit]);
},
'bundle:test'() {
const lib = buildUmdLib('ractive.js', [], [istanbul()]);
const lib = buildUmdLib('ractive.js', [istanbul()]);
const browserTests = buildBrowserTests();
const nodeTests = buildNodeTests();
const polyfills = buildUmdPolyfill();
return gobble([lib, polyfills, qunit, browserTests, nodeTests]);
return gobble([lib, qunit, browserTests, nodeTests]);
},
'bundle:release'() {
const libEsFull = buildESLib('ractive.mjs', []);
const libEsRuntime = buildESLib('runtime.mjs', runtimeModulesToIgnore);
const runtimeModulesToIgnore = ['parse/_parse.js'];

const libUmdFull = buildUmdLib('ractive.js', []);
const libUmdRuntime = buildUmdLib('runtime.js', runtimeModulesToIgnore);
const esRegular = buildESLib('ractive.mjs');
const esRuntime = buildESLib('runtime.mjs', [skipModule(runtimeModulesToIgnore)]);
const esPolyfill = buildESPolyfill();

const libEs = gobble([libEsFull, libEsRuntime]);
const libUmd = gobble([libUmdFull, libUmdRuntime]);
const libUmdMin = libUmd.transform('uglifyjs', { ext: '.min.js', preamble: banner });
const umdRegular = buildUmdLib('ractive.js');
const umdRuntime = buildUmdLib('runtime.js', [skipModule(runtimeModulesToIgnore)]);
const umdPolyfill = buildUmdPolyfill();

const polyfillEs = buildESPolyfill();
const polyfillUmd = buildUmdPolyfill();
const polyfillUmdMin = polyfillUmd.transform('uglifyjs', { ext: '.min.js' });
const libEs = gobble([esRegular, esRuntime, esPolyfill]);
const libUmd = gobble([umdRegular, umdRuntime, umdPolyfill]);
const libUmdMin = libUmd.transform('uglifyjs', { ext: '.min.js', preamble: banner });

return gobble([libEs, libUmd, libUmdMin, polyfillEs, polyfillUmd, polyfillUmdMin, bin, lib, typings, manifest]);
return gobble([libEs, libUmd, libUmdMin, bin, lib, typings, manifest]);
}
})[gobble.env()]();

Expand All @@ -76,9 +73,9 @@ module.exports = ({
/* Bundle builders */

// Builds a UMD bundle of Ractive
function buildUmdLib(dest, excludedModules, extraRollupPlugins) {
function buildUmdLib(dest, plugins = []) {
return src.transform(rollup, {
plugins: [skipModule(excludedModules)].concat(extraRollupPlugins || []),
plugins: plugins,
moduleName: 'Ractive',
format: 'umd',
entry: 'Ractive.js',
Expand All @@ -91,9 +88,9 @@ function buildUmdLib(dest, excludedModules, extraRollupPlugins) {
}

// Builds an ES bundle of Ractive
function buildESLib(dest, excludedModules) {
function buildESLib(dest, plugins = []) {
return src.transform(rollup, {
plugins: [skipModule(excludedModules)],
plugins: plugins,
format: 'es',
entry: 'Ractive.js',
dest: dest,
Expand Down Expand Up @@ -169,9 +166,7 @@ function skipModule(excludedModules) {
return {
name: 'skipModule',
transform: function (src, modulePath) {
// Gobble has a predictable directory structure of gobble/transform/number
// so we slice at 3 to slice relative to project root.
const moduleRelativePath = path.relative(__dirname, modulePath).split(path.sep).slice(3).join(path.sep);
const moduleRelativePath = path.relative(path.join(__dirname, 'src'), modulePath).split(path.sep).join('/');
const isModuleExcluded = excludedModules.indexOf(moduleRelativePath) > -1;

const source = new MagicString(src);
Expand Down
1 change: 0 additions & 1 deletion karma/phantom.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ module.exports = function (config) {
files: [
'qunit/qunit-html.js',
'qunit/simulant.js',
'polyfills.js',
'ractive.js',
'tests-browser.js',
{ pattern: 'qunit/*.gif', served: true, included: false, watched: false, nocache: false },
Expand Down
1 change: 0 additions & 1 deletion sandbox/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
<meta http-equiv='X-UA-Compatible' content='IE=edge'>
<meta charset='utf-8'>
<title>Ractive.js sandbox</title>
<script src='polyfills.js'></script>
<script src='ractive.js'></script>
</head>
<body>
Expand Down

0 comments on commit 0b2cb95

Please sign in to comment.