Title: webpack: emitFile is not supported inside buildEnd · Issue #473 · unjs/unplugin · GitHub
Open Graph Title: webpack: emitFile is not supported inside buildEnd · Issue #473 · unjs/unplugin
X Title: webpack: emitFile is not supported inside buildEnd · Issue #473 · unjs/unplugin
Description: Environment Node: v22.13.1 unplugin: 2.1.2 Reproduction import { createWebpackPlugin } from 'unplugin'; export default createWebpackPlugin((rawOptions = {}) => { return { buildEnd() { this.emitFile({ fileName: 'test.json', source: '{}', ...
Open Graph Description: Environment Node: v22.13.1 unplugin: 2.1.2 Reproduction import { createWebpackPlugin } from 'unplugin'; export default createWebpackPlugin((rawOptions = {}) => { return { buildEnd() { this.emitFile...
X Description: Environment Node: v22.13.1 unplugin: 2.1.2 Reproduction import { createWebpackPlugin } from 'unplugin'; export default createWebpackPlugin((rawOptions = {}) => { return { buildEnd() { th...
Opengraph URL: https://github.com/unjs/unplugin/issues/473
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"webpack: emitFile is not supported inside buildEnd","articleBody":"### Environment\n\nNode: v22.13.1\nunplugin: 2.1.2\n\n### Reproduction\n\n```js\nimport { createWebpackPlugin } from 'unplugin';\n\nexport default createWebpackPlugin((rawOptions = {}) => {\n return {\n buildEnd() {\n this.emitFile({\n fileName: 'test.json',\n source: '{}',\n type: 'asset',\n });\n }\n };\n});\n```\n\n### Describe the bug\n\nNot sure if this is a bug or oversight but\nhttps://github.com/unjs/unplugin/blob/c71bf5530ce345e554ca56f7c266999b146b968f/src/webpack/context.ts#L43\nbuildEnd is not a supported hook for emitFile, as far as webpack is concerned. The reason is because compilation is sealed before emit which is what buildEnd hooks.\nhttps://github.com/webpack/webpack/blob/f123ce5090e56ce1216debce487e8be25275b896/lib/Compiler.js#L1341\nThus you get `TypeError: Cannot add property test.json, object is not extensible`\nSo either emitFile isn't supported or buildEnd is using the wrong hook.\n\n### Additional context\n\nhttps://github.com/webpack/webpack/pull/10876","author":{"url":"https://github.com/austinw-fineart","@type":"Person","name":"austinw-fineart"},"datePublished":"2025-02-08T06:51:42Z","url":"https://github.com/unjs/unplugin/issues/473"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| 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:7b09b01e-f2fd-cb62-268a-b821da892190 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A70C:164C7:208349:2D4DBC:6B0067FB |
| html-safe-nonce | a9b5b49fc72cb29e9ab08bd015a49c18612d127c410cb084619b55bf63c5659d |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNzBDOjE2NEM3OjIwODM0OToyRDREQkM6NkIwMDY3RkIiLCJ2aXNpdG9yX2lkIjoiNzUxNDcxODQ0MDY2NjQ1ODEwNyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 7d48cbb26cb1734bad06e76012330ed724d992bf94467953c82c66ce0e62e576 |
| hovercard-subject-tag | issue:2839653065 |
| 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/unjs/unplugin/473/issue_layout |
| twitter:image | https://opengraph.githubassets.com/5a7392bd81e7db158d083f2b27bf5528418499763e204bd47f725967e1f41814/unjs/unplugin/issues/473 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/5a7392bd81e7db158d083f2b27bf5528418499763e204bd47f725967e1f41814/unjs/unplugin/issues/473 |
| og:image:alt | Environment Node: v22.13.1 unplugin: 2.1.2 Reproduction import { createWebpackPlugin } from 'unplugin'; export default createWebpackPlugin((rawOptions = {}) => { return { buildEnd() { this.emitFile... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | austinw-fineart |
| hostname | github.com |
| expected-hostname | github.com |
| None | 25854482a1773a7c1ebb8be3d2bc1c6e61d82d78126be63b5044474a86d44d9e |
| turbo-cache-control | no-preview |
| go-import | github.com/unjs/unplugin git https://github.com/unjs/unplugin.git |
| octolytics-dimension-user_id | 80154025 |
| octolytics-dimension-user_login | unjs |
| octolytics-dimension-repository_id | 385261169 |
| octolytics-dimension-repository_nwo | unjs/unplugin |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 385261169 |
| octolytics-dimension-repository_network_root_nwo | unjs/unplugin |
| 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 | e4f5c239e31f1f680e6bbc419ff92d774da616ec |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width