-
Notifications
You must be signed in to change notification settings - Fork 98
Conversation
fca0396
to
ac12a4a
Compare
@@ -9,18 +12,29 @@ const EDITOR_MODULE = { | |||
worker: { | |||
id: 'vs/editor/editor', | |||
entry: 'vs/editor/editor.worker', | |||
output: 'editor.worker.js', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is no longer required as the [name]
attribute used to resolve the filename template is based on the entry filename. All generated files have the same names as before unless filename
is specified.
*/ | ||
function getWorkerFilename(filename, entry) { | ||
return loaderUtils.interpolateName({resourcePath: entry}, filename, { | ||
content: fs.readFileSync(resolveMonacoPath(entry)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using loader-utils
so that the full breadth of Webpack filename
options is supported. We read the entry file from the file system so that content-based hashes will update based on worker file contents.
Add support for custom filename template for worker scripts.
ac12a4a
to
5e3cec5
Compare
* custom output path for worker scripts, relative to the main webpack `output.path`. | ||
* Defaults to ''. | ||
*/ | ||
output?: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This new option subsumes the old output
option since filenames can include directories through use of a slash.
package.json
Outdated
@@ -35,6 +35,7 @@ | |||
"webpack-cli": "^3.1.2" | |||
}, | |||
"dependencies": { | |||
"@types/webpack": "^4.4.19" | |||
"@types/webpack": "^4.4.19", | |||
"loader-utils": "^1.2.3" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is already included in #74 but adding this here to pin the version so that [contenthash]
is available when testing.
Thank you! ❤️ |
Add support for a custom filename template for worker scripts through use of Webpack's
loader-utils
. This allows worker files to be served with long-lived caching headers through the use of content hashes. It also allows for files to be generated into particular directories through use of a template likejs/[name].worker.js
.Like #81, not sure what the automated testing strategy should be.
Fixes #29.