Title: [path] replacer token passed to workerize-loader has stopped working in Webpack 5 · Issue #130 · developit/workerize-loader · GitHub
Open Graph Title: [path] replacer token passed to workerize-loader has stopped working in Webpack 5 · Issue #130 · developit/workerize-loader
X Title: [path] replacer token passed to workerize-loader has stopped working in Webpack 5 · Issue #130 · developit/workerize-loader
Description: Used to be the case with Webpack 4 that we could pass [path][name].[contenthash] as the name template for workerize-loader to use; and we'd get workers output into a folder structure mirroring their original source location. This was nic...
Open Graph Description: Used to be the case with Webpack 4 that we could pass [path][name].[contenthash] as the name template for workerize-loader to use; and we'd get workers output into a folder structure mirroring thei...
X Description: Used to be the case with Webpack 4 that we could pass [path][name].[contenthash] as the name template for workerize-loader to use; and we'd get workers output into a folder structure mirroring ...
Opengraph URL: https://github.com/developit/workerize-loader/issues/130
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[path] replacer token passed to workerize-loader has stopped working in Webpack 5","articleBody":"Used to be the case with Webpack 4 that we could pass `[path][name].[contenthash]` as the name template for workerize-loader to use; and we'd get workers output into a folder structure mirroring their original source location.\r\n\r\nThis was nice for debugging purposes to easily identify workers, because the entry point file for esp. larger workers is usually some kind of `index.js` file. `[path]` means you don't need to inspect every separate worker named `index.[hash].worker.js` - and it prevented name collisions when you would generate names in development builds without hash fingerprints in them.\r\n\r\nAs of Webpack 5, that functionality appears to be broken. It resolves `[name]` and `[contenthash]` just fine, but doesn't know how to deal with `[path]`.\r\n\r\n\r\nI'm using a plugin to dynamically inject options into loaders to configure bare loader URLs such as\r\n```js\r\nimport worker from \"workerize-loader!./path-to/worker\"\r\n```\r\n\r\ncentrally, and luckily I was able to extend the logic there to use the current compilation context and module context to compute a relative path, but yeah... _this_ is not very ergonomic, easily understood or maintainable:\r\n\r\n```js\r\nnew InjectOptionsPlugin({\r\n loaders : {\r\n \"workerize-loader\" : ( module, compilation ) =\u003e {\r\n const context = path\r\n .relative( compilation.options.context, module.context );\r\n .replace( /\\\\/g, \"/\" );\r\n \r\n return {\r\n name : dev ? `${context}[name]` : \"${context}[name].[contenthash]`\r\n };\r\n }\r\n }\r\n})\r\n```\r\n\r\ncompared to what it _used_ to be:\r\n\r\n```js\r\nnew InjectOptionsPlugin({\r\n loaders : {\r\n \"workerize-loader\" : {\r\n name : dev ? \"[path][name]\" : \"[path][name].[contenthash]\"\r\n }\r\n }\r\n})\r\n```","author":{"url":"https://github.com/rjgotten","@type":"Person","name":"rjgotten"},"datePublished":"2022-09-12T10:21:26.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/130/workerize-loader/issues/130"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:bdcabaf1-5c23-cac8-ec99-90f6b1fdf830 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9958:36F659:5D568E:7FB0C8:6A5545A9 |
| html-safe-nonce | 87e4f59a6df30403170f41fef4e48cfa64c0415764c4577affd5a79b952c5e85 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5OTU4OjM2RjY1OTo1RDU2OEU6N0ZCMEM4OjZBNTU0NUE5IiwidmlzaXRvcl9pZCI6IjgwMzMzMjAwMjYzNjE5MDY2MDIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 844cecb5d8f311faa5fd2a200a4e64557eb759fe270560f65daf3c932516bbed |
| hovercard-subject-tag | issue:1369636061 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/developit/workerize-loader/130/issue_layout |
| twitter:image | https://opengraph.githubassets.com/f191e204ef8eb3aa6ee970edc6958a8d569742bbec1427a6915d6d3b27f1fba7/developit/workerize-loader/issues/130 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/f191e204ef8eb3aa6ee970edc6958a8d569742bbec1427a6915d6d3b27f1fba7/developit/workerize-loader/issues/130 |
| og:image:alt | Used to be the case with Webpack 4 that we could pass [path][name].[contenthash] as the name template for workerize-loader to use; and we'd get workers output into a folder structure mirroring thei... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | rjgotten |
| hostname | github.com |
| expected-hostname | github.com |
| None | cd9eea424140838b22e9eabd53d92b5702617ddd6d76efcd3a37f08d44309ca5 |
| turbo-cache-control | no-preview |
| go-import | github.com/developit/workerize-loader git https://github.com/developit/workerize-loader.git |
| octolytics-dimension-user_id | 105127 |
| octolytics-dimension-user_login | developit |
| octolytics-dimension-repository_id | 116874897 |
| octolytics-dimension-repository_nwo | developit/workerize-loader |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 116874897 |
| octolytics-dimension-repository_network_root_nwo | developit/workerize-loader |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 3084b9f587e8f1e19803bbe0c77ac77ce3c99c5c |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width