Skip to content

Commit

Permalink
test rebase fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
guybedford committed Aug 12, 2018
1 parent 05ee58b commit 1045ed9
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 16 deletions.
10 changes: 9 additions & 1 deletion src/rollup/index.ts
@@ -1,4 +1,5 @@
import { EventEmitter } from 'events';
import { Asset } from '../../node_modules/rollup';
import { optimizeChunks } from '../chunk-optimization';
import Graph from '../Graph';
import { createAddons } from '../utils/addons';
Expand Down Expand Up @@ -316,7 +317,14 @@ export default function rollup(rawInputOptions: GenericConfigObject): Promise<Ro
});
}
return generate(outputOptions, true).then(bundle => {
if (Object.keys(bundle).length > 1) {
let chunkCnt = 0;
for (const fileName of Object.keys(bundle)) {
const file = bundle[fileName];
if ((<OutputAsset>file).isAsset) continue;
chunkCnt++;
if (chunkCnt > 1) break;
}
if (chunkCnt > 1) {
if (outputOptions.sourcemapFile)
error({
code: 'INVALID_OPTION',
Expand Down
1 change: 0 additions & 1 deletion src/rollup/types.d.ts
Expand Up @@ -196,7 +196,6 @@ export interface Plugin {
options: OutputOptions,
chunk: OutputChunk
) => void | Promise<void>;
/** @deprecated */
generateBundle?: (
this: PluginContext,
options: OutputOptions,
Expand Down
2 changes: 1 addition & 1 deletion test/function/index.js
Expand Up @@ -41,7 +41,7 @@ runTestSuiteWithSamples('function', path.resolve(__dirname, 'samples'), (dir, co
(config.options || {}).output || {}
)
)
.then(code => {
.then(({ output: [code] }) => {
if (config.generateError) {
unintendedError = new Error('Expected an error while generating output');
}
Expand Down
25 changes: 14 additions & 11 deletions test/hooks/index.js
Expand Up @@ -272,8 +272,9 @@ describe('hooks', () => {
return bundle.generate({ format: 'es' });
})
.then(({ output }) => {
assert.equal(output['assets/test-19916f7d.ext'], 'hello world');
assert.equal(output['input.js'].code, `var input = new URL('../assets/test-19916f7d.ext', import.meta.url).href;\n\nexport default input;\n`);
assert.equal(output[0].code, `var input = new URL('../assets/test-19916f7d.ext', import.meta.url).href;\n\nexport default input;\n`);
assert.equal(output[1].fileName, 'assets/test-19916f7d.ext');
assert.equal(output[1].source, 'hello world');

return rollup
.rollup({
Expand All @@ -293,8 +294,9 @@ describe('hooks', () => {
return bundle.generate({ format: 'es' });
})
.then(({ output }) => {
assert.equal(output['assets/test-19916f7d.ext'], 'hello world');
assert.equal(output['input.js'].code, `var input = new URL('../assets/test-19916f7d.ext', import.meta.url).href;\n\nexport default input;\n`);
assert.equal(output[0].code, `var input = new URL('../assets/test-19916f7d.ext', import.meta.url).href;\n\nexport default input;\n`);
assert.equal(output[1].fileName, 'assets/test-19916f7d.ext');
assert.equal(output[1].source, 'hello world');
});
});

Expand Down Expand Up @@ -322,8 +324,9 @@ describe('hooks', () => {
return bundle.generate({ format: 'es' });
})
.then(({ output }) => {
assert.equal(output['assets/test-19916f7d.ext'], 'hello world');
assert.equal(output['input.js'].code, `var input = new URL('../assets/test-19916f7d.ext', import.meta.url).href;\n\nexport default input;\n`);
assert.equal(output[0].code, `var input = new URL('../assets/test-19916f7d.ext', import.meta.url).href;\n\nexport default input;\n`);
assert.equal(output[1].fileName, 'assets/test-19916f7d.ext');
assert.equal(output[1].source, 'hello world');

return rollup
.rollup({
Expand All @@ -346,8 +349,8 @@ describe('hooks', () => {
})
.then(({ output }) => {
assert.equal(runs, 2);
assert.equal(output['assets/test-19916f7d.ext'], undefined);
assert.equal(output['input.js'].code.trim(), `alert('hello world');`);
assert.equal(output[0].code.trim(), `alert('hello world');`);
assert.equal(output.length, 1);
});
});

Expand Down Expand Up @@ -483,7 +486,7 @@ module.exports = input;
return bundle.generate({ format: 'es' });
})
.then(({ output: [,output] }) => {
assert.equal(output['assets/test-19916f7d.ext'], 'hello world');
assert.equal(output.source, 'hello world');
assert.equal(thrown, true);
});
});
Expand Down Expand Up @@ -964,8 +967,8 @@ module.exports = input;
format: 'es'
});
})
.then(bundle => {
assert.equal(bundle.code.trim(), `alert('hello');`);
.then(({ output }) => {
assert.equal(output[0].code.trim(), `alert('hello');`);
});
});
});
2 changes: 1 addition & 1 deletion test/misc/optionList.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion test/sourcemaps/index.js
Expand Up @@ -59,7 +59,7 @@ function generateAndTestBundle(bundle, outputOptions, config, format, warnings)
}
return bundle.generate(outputOptions);
})
.then(({ code, map }) => {
.then(({ output: [{ code, map }] }) => {
if (config.test) {
return config.test(code, map, { format });
}
Expand Down

0 comments on commit 1045ed9

Please sign in to comment.