Skip to content
This repository was archived by the owner on Jan 13, 2022. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions src/AssetModule_DEPRECATED.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,14 @@ class AssetModule_DEPRECATED extends Module {
const {resolution, name} = getAssetDataFromName(this.path, platforms);
this.resolution = resolution;
this.name = name;
this.moduleName = 'image!' + name;
this.platforms = platforms;
}

isHaste() {
return Promise.resolve(false);
}

getName() {
return Promise.resolve(`image!${this.name}`);
}

getDependencies() {
return Promise.resolve([]);
}
Expand Down
16 changes: 15 additions & 1 deletion src/Module.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ class Module {
this._transformCode = transformCode;
this._depGraphHelpers = depGraphHelpers;
this._options = options;

if (!this.moduleName && !this.isPolyfill() && !this.isAsset_DEPRECATED()) {
this.getName().then(name => {
this.moduleName = name;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In other words, the moduleName property might or might not exists. I’m not really happy with this solution

});
}
}

isHaste() {
Expand All @@ -60,6 +66,9 @@ class Module {
}

getName() {
if (this.moduleName) {
return Promise.resolve(this.moduleName);
}
return this._cache.get(
this.path,
'name',
Expand Down Expand Up @@ -135,7 +144,8 @@ class Module {
return Promise.all([
fileContentPromise,
this._readDocBlock(fileContentPromise),
]).then(([source, {id, moduleDocBlock}]) => {
this.getName(),
]).then(([source, {id, moduleDocBlock}, moudleName]) => {
// Ignore requires in JSON files or generated code. An example of this
// is prebuilt files like the SourceMap library.
const extern = this.isJSON() || 'extern' in moduleDocBlock;
Expand All @@ -146,6 +156,10 @@ class Module {
const codePromise = transformCode
? transformCode(this, source, transformOptions)
: Promise.resolve({code: source});

if (!this.moduleName && moudleName) {
this.moduleName = moudleName
}
return codePromise.then(result => {
const {
code,
Expand Down