Browse Source

Force ids specified in `external` to actually _be_ external.

Fixes #410
Builds on top of #417
gh-438-b
Oskar Segersvärd 9 years ago
parent
commit
0b92d518d1
  1. 7
      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

7
src/Bundle.js

@ -172,9 +172,14 @@ export default class Bundle {
const promises = module.dependencies.map( source => {
return Promise.resolve( this.resolveId( source, module.id ) )
.then( resolvedId => {
if ( !resolvedId ) {
// If the `resolvedId` is supposed to be exteral, make it so.
const forcedExternal = ~this.external.indexOf( resolvedId );
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