From fd3ae38c18f0d8a092d3604f3efd9e3caaff51bc Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Tue, 6 Oct 2015 11:52:26 -0400 Subject: [PATCH] make external modules configurable --- src/Statement.js | 2 +- test/function/configure-external-module-b/_config.js | 11 +++++++++++ test/function/configure-external-module-b/main.js | 3 +++ test/function/configure-external-module/_config.js | 11 +++++++++++ test/function/configure-external-module/main.js | 3 +++ 5 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 test/function/configure-external-module-b/_config.js create mode 100644 test/function/configure-external-module-b/main.js create mode 100644 test/function/configure-external-module/_config.js create mode 100644 test/function/configure-external-module/main.js diff --git a/src/Statement.js b/src/Statement.js index 8a5ff4e..18f9460 100644 --- a/src/Statement.js +++ b/src/Statement.js @@ -195,7 +195,7 @@ export default class Statement { const declaration = statement.module.trace( subject.name ); - if ( !declaration || declaration.statement.isIncluded ) { + if ( !declaration || declaration.isExternal || declaration.statement.isIncluded ) { hasSideEffect = true; } } diff --git a/test/function/configure-external-module-b/_config.js b/test/function/configure-external-module-b/_config.js new file mode 100644 index 0000000..63ff041 --- /dev/null +++ b/test/function/configure-external-module-b/_config.js @@ -0,0 +1,11 @@ +var assert = require( 'assert' ); + +module.exports = { + description: 'allows external module to be configured (b)', + options: { + external: [ 'path' ] + }, + exports: function () { + assert.equal( require( 'path' ).resolve.configured, 'yes' ); + } +}; diff --git a/test/function/configure-external-module-b/main.js b/test/function/configure-external-module-b/main.js new file mode 100644 index 0000000..4fff995 --- /dev/null +++ b/test/function/configure-external-module-b/main.js @@ -0,0 +1,3 @@ +import { resolve } from 'path'; + +resolve.configured = 'yes'; diff --git a/test/function/configure-external-module/_config.js b/test/function/configure-external-module/_config.js new file mode 100644 index 0000000..9142996 --- /dev/null +++ b/test/function/configure-external-module/_config.js @@ -0,0 +1,11 @@ +var assert = require( 'assert' ); + +module.exports = { + description: 'allows external module to be configured', + options: { + external: [ 'path' ] + }, + exports: function () { + assert.equal( require( 'path' ).resolve.configured, 'yes' ); + } +}; diff --git a/test/function/configure-external-module/main.js b/test/function/configure-external-module/main.js new file mode 100644 index 0000000..dc84e72 --- /dev/null +++ b/test/function/configure-external-module/main.js @@ -0,0 +1,3 @@ +import * as path from 'path'; + +path.resolve.configured = 'yes';