Browse Source

Merge pull request #420 from rollup/force-external-windows

Force external (windows)
gh-438-b
Rich Harris 9 years ago
parent
commit
065990bb96
  1. 9
      src/Bundle.js
  2. 4
      test/cli/config-external/_config.js
  3. 6
      test/cli/config-external/_expected.js
  4. 4
      test/cli/config-external/main.js
  5. 19
      test/cli/config-external/rollup.config.js

9
src/Bundle.js

@ -59,7 +59,7 @@ export default class Bundle {
this.assumedGlobals = blank();
this.external = options.external || [];
this.external = ensureArray( options.external ).map( id => id.replace( /[\/\\]/g, '/' ) );
this.onwarn = options.onwarn || makeOnwarn();
// TODO strictly speaking, this only applies with non-ES6, non-default-only bundles
@ -172,9 +172,14 @@ export default class Bundle {
const promises = module.dependencies.map( source => {
return this.resolveId( source, module.id )
.then( resolvedId => {
if ( !resolvedId ) {
// If the `resolvedId` is supposed to be external, make it so.
const forcedExternal = resolvedId && ~this.external.indexOf( resolvedId.replace( /[\/\\]/g, '/' ) );
if ( !resolvedId || forcedExternal ) {
if ( !forcedExternal ) {
if ( isRelative( source ) ) throw new Error( `Could not resolve ${source} from ${module.id}` );
if ( !~this.external.indexOf( source ) ) this.onwarn( `Treating '${source}' as external dependency` );
}
module.resolvedIds[ source ] = source;
if ( !this.moduleById[ source ] ) {

4
test/cli/config-external/_config.js

@ -0,0 +1,4 @@
module.exports = {
description: 'external option gets passed from config',
command: 'rollup -c'
};

6
test/cli/config-external/_expected.js

@ -0,0 +1,6 @@
'use strict';
var ___config_js = require('./_config.js');
var assert = require('assert');
assert.ok( ___config_js.execute );

4
test/cli/config-external/main.js

@ -0,0 +1,4 @@
import { execute } from './_config.js';
import { ok } from 'assert';
ok( execute );

19
test/cli/config-external/rollup.config.js

@ -0,0 +1,19 @@
import assert from 'assert';
import { resolve } from 'path';
var config = resolve( './_config.js' );
export default {
entry: 'main.js',
format: 'cjs',
external: [ 'assert', config ],
plugins: [
{
load: function ( id ) {
assert.notEqual( id, config );
}
}
]
};
Loading…
Cancel
Save