<commit_before>
export default class ExternalModule {
	constructor ( { id, bundle } ) {
		this.id = id;
		this.name = id;

		this.isExternal = true;
		this.importedByBundle = [];

		this.needsDefault = false;

		// Invariant: needsNamed and needsAll are never both true at once.
		// Because an import with both a namespace and named import is invalid:
		//
		// 		import * as ns, { a } from '...'
		//
		this.needsNamed = false;
		this.needsAll = false;

		bundle.scope.define( this.name, this );
		this.exports = bundle.scope.virtual();

		const ref = this.exports.reference;

		// Override reference.
		this.exports.reference = name => {
			if ( !this.exports.defines( name ) ) {
				let idName = name;

				if ( name === 'default' ) {
					idName = this.name;
					this.needsDefault = true;
				} else {
					this.needsNamed = true;
				}

				this.exports.define( name, {
					originalName: idName,
					name: idName,

					module: this
				});
			}

			return ref.call( this.exports, name );
		};
	}
}<commit_msg>Use ExternalModules as their own default value.<commit_after>
export default class ExternalModule {
	constructor ( { id, bundle } ) {
		this.id = id;

		// Implement `Identifier` interface.
		this.originalName = id;
		this.name = id;
		this.module = this;

		this.isExternal = true;
		this.importedByBundle = [];

		this.needsDefault = false;

		// Invariant: needsNamed and needsAll are never both true at once.
		// Because an import with both a namespace and named import is invalid:
		//
		// 		import * as ns, { a } from '...'
		//
		this.needsNamed = false;
		this.needsAll = false;

		bundle.scope.define( this.originalName, this );
		this.exports = bundle.scope.virtual();

		const { lookup, reference } = this.exports;

		// Override reference.
		this.exports.reference = name => {
			if ( name === 'default' ) {
				this.needsDefault = true;
				return bundle.scope.reference( this.originalName );
			}

			if ( !this.exports.defines( name ) ) {
				this.needsNamed = true;

				this.exports.define( name, {
					originalName: name,
					name,

					module: this
				});
			}

			return reference.call( this.exports, name );
		};

		// Override lookup.
		this.exports.lookup = name => {
			if ( name === 'default' ) {
				return this;
			}

			return lookup.call( this.exports, name );
		};
	}
}
{'fraction_non_alphanumeric': 0.1338209982788296, 'fraction_numerical': 0.0, 'mean_word_length': 2.544207317073171, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4081571', 'n_tokens_mistral': 906, 'n_tokens_neox': 732, 'n_words': 199}