Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7581 from TimHambourger/master
Implement all path variables for webworker dynamic imports
- Loading branch information
Showing
5 changed files
with
109 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
it("should compile without error", function() { | ||
return import(/* webpackChunkName: "one" */ "./one"); | ||
}); |
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 @@ | ||
module.exports = 1; |
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,22 @@ | ||
var fs = require('fs'); | ||
|
||
module.exports = { | ||
noTests: true, | ||
findBundle: function(i, options) { | ||
var regex = new RegExp("^bundle\." + options.name, "i"); | ||
var files = fs.readdirSync(options.output.path); | ||
var bundle = files.find(function (file) { | ||
return regex.test(file); | ||
}); | ||
|
||
if (!bundle) { | ||
throw new Error( | ||
`No file found with correct name (regex: ${ | ||
regex.source | ||
}, files: ${files.join(", ")})` | ||
); | ||
} | ||
|
||
return "./" + bundle; | ||
} | ||
}; |
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,65 @@ | ||
"use strict"; | ||
|
||
// Have to test [hash] and [chunkhash] separately to avoid | ||
// "Cannot use [chunkhash] or [contenthash] for chunk in 'bundle1.[hash].[hash:16].[chunkhash].[chunkhash:16].[name].[id].[query].js' (use [hash] instead)" | ||
var testAllButHash = "[chunkhash].[chunkhash:16].[name].[id].[query]"; | ||
var testHash = "[hash].[hash:16]"; | ||
|
||
module.exports = [ | ||
{ | ||
name: "webworker-all", | ||
target: "webworker", | ||
output: { | ||
filename: "bundle.webworker-all." + testAllButHash + ".js" | ||
} | ||
}, | ||
{ | ||
name: "webworker-hash", | ||
target: "webworker", | ||
output: { | ||
filename: "bundle.webworker-hash." + testHash + ".js" | ||
} | ||
}, | ||
{ | ||
name: "node-all", | ||
target: "node", | ||
output: { | ||
filename: "bundle.node-all." + testAllButHash + ".js" | ||
} | ||
}, | ||
{ | ||
name: "node", | ||
target: "node", | ||
output: { | ||
filename: "bundle.node-hash." + testHash + ".js" | ||
} | ||
}, | ||
{ | ||
name: "async-node-all", | ||
target: "async-node", | ||
output: { | ||
filename: "bundle.async-node-all." + testAllButHash + ".js" | ||
} | ||
}, | ||
{ | ||
name: "async-node-hash", | ||
target: "async-node", | ||
output: { | ||
filename: "bundle.async-node-hash." + testHash + ".js" | ||
} | ||
}, | ||
{ | ||
name: "web-all", | ||
target: "web", | ||
output: { | ||
filename: "bundle.web-all." + testAllButHash + ".js" | ||
} | ||
}, | ||
{ | ||
name: "web-hash", | ||
target: "web", | ||
output: { | ||
filename: "bundle.web-hash." + testHash + ".js" | ||
} | ||
} | ||
]; |