-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[INTERNAL] Bundler: Ignore non-JS resources when creating module name…
… mapping This lead to issues where non-JS resources tagged as "IsDebugVariant" (like source map resources) where processed since ModuleName#getNonDebugName can only handle .js and .css extensions.
- Loading branch information
1 parent
f1c57ac
commit 4f54a62
Showing
4 changed files
with
57 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import test from "ava"; | ||
import sinonGlobal from "sinon"; | ||
import createModuleNameMapping from "../../../../../lib/tasks/bundlers/utils/createModuleNameMapping.js"; | ||
|
||
test.beforeEach((t) => { | ||
const sinon = t.context.sinon = sinonGlobal.createSandbox(); | ||
t.context.taskUtil = { | ||
getTag: sinon.stub(), | ||
STANDARD_TAGS: { | ||
IsDebugVariant: "🦄", | ||
}, | ||
}; | ||
}); | ||
test.afterEach.always((t) => { | ||
t.context.sinon.restore(); | ||
}); | ||
|
||
test("createModuleNameMapping", (t) => { | ||
const {taskUtil} = t.context; | ||
taskUtil.getTag.callsFake((resource) => { | ||
if (resource.getPath() === "/resources/Module.js") { | ||
return false; | ||
} | ||
// All but the first shall be assumed debug variants | ||
return true; | ||
}); | ||
const resources = [{ | ||
getPath: () => "/resources/Module.js" | ||
}, { | ||
getPath: () => "/resources/Module-dbg.js" | ||
}, { | ||
getPath: () => "/resources/Module-dbg.js.map" | ||
}, { | ||
getPath: () => "/resources/Module-dbg-dbg.js" | ||
}, { | ||
getPath: () => "/resources/Module-dbg-dbg.js.map" | ||
}, { | ||
getPath: () => "/resources/Module.xml" | ||
}, { | ||
getPath: () => "/resources/Module.css" | ||
}]; | ||
const res = createModuleNameMapping({ | ||
resources, | ||
taskUtil | ||
}); | ||
|
||
t.deepEqual(res, { | ||
"/resources/Module-dbg-dbg.js": "Module-dbg.js", | ||
"/resources/Module-dbg.js": "Module.js" | ||
}, "Expected module name mapping"); | ||
}); |