mizchi / uniroll

Opinionated universal frontend bundler in browser
https://focused-raman-3ce115.netlify.com/
113 stars 5 forks source link

cannot bundle with webpack, When upgrading uniroll from 1.2.1 to 2.4.1 #18

Closed kazupon closed 3 years ago

kazupon commented 3 years ago

It happens when you try the following playground example: https://github.com/mizchi/uniroll-playground

output console:

``` $ yarn webpack-dev-server yarn run v1.22.4 $ /Users/kazuya.kawaguchi/Projects/my/uniroll-playground/node_modules/.bin/webpack-dev-server Project is running at http://localhost:8080/ webpack output is served from / Content not from webpack is served from /Users/kazuya.kawaguchi/Projects/my/uniroll-playground Hash: 7a3167e664bd71df116a Version: webpack 4.43.0 Time: 7670ms Built at: 2020/10/08 10:05:37 Asset Size Chunks Chunk Names 0.1af66ba0c7e2d1ef5e2b.worker.js 3.42 KiB [emitted] [immutable] 0.js 10.8 KiB 0 [emitted] 1.1af66ba0c7e2d1ef5e2b.worker.js 211 KiB [emitted] [immutable] 1.js 7.83 MiB 1 [emitted] 10.js 4.5 KiB 10 [emitted] 11.js 5.03 KiB 11 [emitted] 12.js 20.2 KiB 12 [emitted] 13.js 7.8 KiB 13 [emitted] 14.js 8.83 KiB 14 [emitted] 15.js 3.23 KiB 15 [emitted] 16.js 8.18 KiB 16 [emitted] 17.js 4.91 KiB 17 [emitted] 18.js 6.39 KiB 18 [emitted] 19.js 6.66 KiB 19 [emitted] 1af66ba0c7e2d1ef5e2b.worker.js 10.2 MiB [emitted] [immutable] 2.js 1.57 MiB 2 [emitted] 20.js 5.89 KiB 20 [emitted] 21.js 10.8 KiB 21 [emitted] 22.js 8.61 KiB 22 [emitted] 23.js 3.25 KiB 23 [emitted] 24.js 6.6 KiB 24 [emitted] 25.js 7.07 KiB 25 [emitted] 26.js 7.14 KiB 26 [emitted] 27.js 5.21 KiB 27 [emitted] 28.js 8.76 KiB 28 [emitted] 29.js 6.1 KiB 29 [emitted] 3.js 920 KiB 3 [emitted] 30.js 8.38 KiB 30 [emitted] 31.js 21.4 KiB 31 [emitted] 32.js 6 KiB 32 [emitted] 33.js 6.32 KiB 33 [emitted] 34.js 5 KiB 34 [emitted] 35.js 18.1 KiB 35 [emitted] 36.js 25.4 KiB 36 [emitted] 37.js 13.9 KiB 37 [emitted] 38.js 21 KiB 38 [emitted] 39.js 30.5 KiB 39 [emitted] 4.js 463 KiB 4 [emitted] 40.js 7.75 KiB 40 [emitted] 41.js 10.5 KiB 41 [emitted] 42.js 7.71 KiB 42 [emitted] 43.js 7.08 KiB 43 [emitted] 44.js 14.4 KiB 44 [emitted] 45.js 6.87 KiB 45 [emitted] 46.js 17.6 KiB 46 [emitted] 47.js 7.49 KiB 47 [emitted] 48.js 19.5 KiB 48 [emitted] 49.js 7.45 KiB 49 [emitted] 5.js 63.3 KiB 5 [emitted] 50.js 4.54 KiB 50 [emitted] 51.js 4.31 KiB 51 [emitted] 52.js 11.3 KiB 52 [emitted] 53.js 6.86 KiB 53 [emitted] 54.js 23.2 KiB 54 [emitted] 55.js 6.37 KiB 55 [emitted] 56.js 33.6 KiB 56 [emitted] 57.js 12.1 KiB 57 [emitted] 58.js 7.82 KiB 58 [emitted] 59.js 6.7 KiB 59 [emitted] 6.js 13.1 KiB 6 [emitted] 60.js 12.4 KiB 60 [emitted] 61.js 9.82 KiB 61 [emitted] 62.js 9.61 KiB 62 [emitted] 63.js 4.31 KiB 63 [emitted] 64.js 7.91 KiB 64 [emitted] 65.js 4.81 KiB 65 [emitted] 7.js 7.71 KiB 7 [emitted] 8.js 9.22 KiB 8 [emitted] 9.js 2.85 KiB 9 [emitted] 9242107df7da7c6ad3cadf3133abcd37.ttf 55.2 KiB [emitted] css.worker.js 2 MiB [emitted] editor.worker.js 466 KiB [emitted] html.worker.js 1.32 MiB [emitted] index.html 431 bytes [emitted] json.worker.js 891 KiB [emitted] main.js 1.33 MiB main [emitted] main ts.worker.js 9.17 MiB [emitted] Entrypoint main = main.js [0] multi (webpack)-dev-server/client?http://localhost:8080 ./src 40 bytes {main} [built] [./node_modules/ansi-html/index.js] 4.16 KiB {main} [built] [./node_modules/react-dom/index.js] 1.33 KiB {main} [built] [./node_modules/react/index.js] 190 bytes {main} [built] [./node_modules/webpack-dev-server/client/index.js?http://localhost:8080] (webpack)-dev-server/client?http://localhost:8080 4.29 KiB {main} [built] [./node_modules/webpack-dev-server/client/overlay.js] (webpack)-dev-server/client/overlay.js 3.51 KiB {main} [built] [./node_modules/webpack-dev-server/client/socket.js] (webpack)-dev-server/client/socket.js 1.53 KiB {main} [built] [./node_modules/webpack-dev-server/client/utils/createSocketUrl.js] (webpack)-dev-server/client/utils/createSocketUrl.js 2.91 KiB {main} [built] [./node_modules/webpack-dev-server/client/utils/log.js] (webpack)-dev-server/client/utils/log.js 964 bytes {main} [built] [./node_modules/webpack-dev-server/client/utils/reloadApp.js] (webpack)-dev-server/client/utils/reloadApp.js 1.59 KiB {main} [built] [./node_modules/webpack-dev-server/client/utils/sendMessage.js] (webpack)-dev-server/client/utils/sendMessage.js 402 bytes {main} [built] [./node_modules/webpack-dev-server/node_modules/strip-ansi/index.js] (webpack)-dev-server/node_modules/strip-ansi/index.js 161 bytes {main} [built] [./node_modules/webpack/hot sync ^\.\/log$] (webpack)/hot sync nonrecursive ^\.\/log$ 170 bytes {main} [built] [./src/components/App.tsx] 1.03 KiB {main} [built] [./src/index.tsx] 202 bytes {main} [built] + 889 hidden modules WARNING in new Worker() will only be bundled if passed a String. @ ./node_modules/monaco-editor/esm/vs/editor/common/services/editorWorkerServiceImpl.js 66:0-84 378:35-55 @ ./node_modules/monaco-editor/esm/vs/editor/common/services/webWorker.js @ ./node_modules/monaco-editor/esm/vs/editor/standalone/browser/standaloneEditor.js @ ./node_modules/monaco-editor/esm/vs/editor/editor.api.js @ include-loader!./node_modules/monaco-editor/esm/vs/editor/editor.api.js @ ./node_modules/monaco-editor/esm/vs/language/css/monaco.contribution.js @ include-loader!./node_modules/monaco-editor/esm/vs/editor/editor.main.js @ ./src/components/MonacoEditor.tsx @ ./src/components/App.tsx @ ./src/index.tsx WARNING in new Worker() will only be bundled if passed a String. @ ./src/worker/uniroll.worker.ts 2:41-363 @ ./src/components/Preview.tsx @ ./src/components/App.tsx @ ./src/index.tsx Child HtmlWebpackCompiler: 1 asset Entrypoint HtmlWebpackPlugin_0 = __child-HtmlWebpackPlugin_0 [./node_modules/html-webpack-plugin/lib/loader.js!./src/index.html] 681 bytes {HtmlWebpackPlugin_0} [built] Child vs/editor/editor: Asset Size Chunks Chunk Names editor.worker.js 466 KiB main [emitted] main Entrypoint main = editor.worker.js [./node_modules/monaco-editor/esm/vs/base/common/arrays.js] 7.5 KiB {main} [built] [./node_modules/monaco-editor/esm/vs/base/common/diff/diff.js] 46.7 KiB {main} [built] [./node_modules/monaco-editor/esm/vs/base/common/errors.js] 2.97 KiB {main} [built] [./node_modules/monaco-editor/esm/vs/base/common/iterator.js] 7.69 KiB {main} [built] [./node_modules/monaco-editor/esm/vs/base/common/lifecycle.js] 5.71 KiB {main} [built] [./node_modules/monaco-editor/esm/vs/base/common/platform.js] 3.97 KiB {main} [built] [./node_modules/monaco-editor/esm/vs/base/common/types.js] 5.53 KiB {main} [built] [./node_modules/monaco-editor/esm/vs/base/common/uri.js] 22 KiB {main} [built] [./node_modules/monaco-editor/esm/vs/base/common/worker/simpleWorker.js] 11.8 KiB {main} [built] [./node_modules/monaco-editor/esm/vs/editor/common/core/position.js] 4.53 KiB {main} [built] [./node_modules/monaco-editor/esm/vs/editor/common/core/range.js] 14 KiB {main} [built] [./node_modules/monaco-editor/esm/vs/editor/common/diff/diffComputer.js] 21 KiB {main} [built] [./node_modules/monaco-editor/esm/vs/editor/common/model/mirrorTextModel.js] 5.13 KiB {main} [built] [./node_modules/monaco-editor/esm/vs/editor/common/services/editorSimpleWorker.js] 25.8 KiB {main} [built] [./node_modules/monaco-editor/esm/vs/editor/editor.worker.js] 1.07 KiB {main} [built] + 23 hidden modules Child vs/language/css/cssWorker: Asset Size Chunks Chunk Names css.worker.js 2 MiB main [emitted] main Entrypoint main = css.worker.js [./node_modules/monaco-editor/esm/vs/base/common/arrays.js] 7.5 KiB {main} [built] [./node_modules/monaco-editor/esm/vs/base/common/diff/diff.js] 46.7 KiB {main} [built] [./node_modules/monaco-editor/esm/vs/base/common/errors.js] 2.97 KiB {main} [built] [./node_modules/monaco-editor/esm/vs/base/common/iterator.js] 7.69 KiB {main} [built] [./node_modules/monaco-editor/esm/vs/base/common/lifecycle.js] 5.71 KiB {main} [built] [./node_modules/monaco-editor/esm/vs/base/common/platform.js] 3.97 KiB {main} [built] [./node_modules/monaco-editor/esm/vs/base/common/types.js] 5.53 KiB {main} [built] [./node_modules/monaco-editor/esm/vs/base/common/uri.js] 22 KiB {main} [built] [./node_modules/monaco-editor/esm/vs/base/common/worker/simpleWorker.js] 11.8 KiB {main} [built] [./node_modules/monaco-editor/esm/vs/editor/common/core/position.js] 4.53 KiB {main} [built] [./node_modules/monaco-editor/esm/vs/editor/common/services/editorSimpleWorker.js] 25.8 KiB {main} [built] [./node_modules/monaco-editor/esm/vs/editor/editor.worker.js] 1.07 KiB {main} [built] [./node_modules/monaco-editor/esm/vs/language/css/_deps/vscode-css-languageservice/cssLanguageService.js] 3.84 KiB {main} [built] [./node_modules/monaco-editor/esm/vs/language/css/css.worker.js] 652 bytes {main} [built] [./node_modules/monaco-editor/esm/vs/language/css/cssWorker.js] 6.24 KiB {main} [built] + 65 hidden modules Child vs/language/html/htmlWorker: Asset Size Chunks Chunk Names html.worker.js 1.32 MiB main [emitted] main Entrypoint main = html.worker.js [./node_modules/monaco-editor/esm/vs/base/common/arrays.js] 7.5 KiB {main} [built] [./node_modules/monaco-editor/esm/vs/base/common/diff/diff.js] 46.7 KiB {main} [built] [./node_modules/monaco-editor/esm/vs/base/common/errors.js] 2.97 KiB {main} [built] [./node_modules/monaco-editor/esm/vs/base/common/iterator.js] 7.69 KiB {main} [built] [./node_modules/monaco-editor/esm/vs/base/common/lifecycle.js] 5.71 KiB {main} [built] [./node_modules/monaco-editor/esm/vs/base/common/platform.js] 3.97 KiB {main} [built] [./node_modules/monaco-editor/esm/vs/base/common/types.js] 5.53 KiB {main} [built] [./node_modules/monaco-editor/esm/vs/base/common/uri.js] 22 KiB {main} [built] [./node_modules/monaco-editor/esm/vs/base/common/worker/simpleWorker.js] 11.8 KiB {main} [built] [./node_modules/monaco-editor/esm/vs/editor/common/services/editorSimpleWorker.js] 25.8 KiB {main} [built] [./node_modules/monaco-editor/esm/vs/editor/editor.worker.js] 1.07 KiB {main} [built] [./node_modules/monaco-editor/esm/vs/language/html/_deps/vscode-html-languageservice/htmlLanguageService.js] 2.6 KiB {main} [built] [./node_modules/monaco-editor/esm/vs/language/html/fillers/polyfills.js] 1.29 KiB {main} [built] [./node_modules/monaco-editor/esm/vs/language/html/html.worker.js] 655 bytes {main} [built] [./node_modules/monaco-editor/esm/vs/language/html/htmlWorker.js] 4.26 KiB {main} [built] + 56 hidden modules Child vs/language/json/jsonWorker: Asset Size Chunks Chunk Names json.worker.js 891 KiB main [emitted] main Entrypoint main = json.worker.js [./node_modules/monaco-editor/esm/vs/base/common/arrays.js] 7.5 KiB {main} [built] [./node_modules/monaco-editor/esm/vs/base/common/diff/diff.js] 46.7 KiB {main} [built] [./node_modules/monaco-editor/esm/vs/base/common/errors.js] 2.97 KiB {main} [built] [./node_modules/monaco-editor/esm/vs/base/common/iterator.js] 7.69 KiB {main} [built] [./node_modules/monaco-editor/esm/vs/base/common/lifecycle.js] 5.71 KiB {main} [built] [./node_modules/monaco-editor/esm/vs/base/common/platform.js] 3.97 KiB {main} [built] [./node_modules/monaco-editor/esm/vs/base/common/types.js] 5.53 KiB {main} [built] [./node_modules/monaco-editor/esm/vs/base/common/uri.js] 22 KiB {main} [built] [./node_modules/monaco-editor/esm/vs/base/common/worker/simpleWorker.js] 11.8 KiB {main} [built] [./node_modules/monaco-editor/esm/vs/editor/common/core/position.js] 4.53 KiB {main} [built] [./node_modules/monaco-editor/esm/vs/editor/common/services/editorSimpleWorker.js] 25.8 KiB {main} [built] [./node_modules/monaco-editor/esm/vs/editor/editor.worker.js] 1.07 KiB {main} [built] [./node_modules/monaco-editor/esm/vs/language/json/_deps/vscode-json-languageservice/jsonLanguageService.js] 3.9 KiB {main} [built] [./node_modules/monaco-editor/esm/vs/language/json/json.worker.js] 655 bytes {main} [built] [./node_modules/monaco-editor/esm/vs/language/json/jsonWorker.js] 5.49 KiB {main} [built] + 49 hidden modules Child vs/language/typescript/tsWorker: Asset Size Chunks Chunk Names ts.worker.js 9.17 MiB main [emitted] main Entrypoint main = ts.worker.js [./node_modules/monaco-editor/esm/vs/base/common/arrays.js] 7.5 KiB {main} [built] [./node_modules/monaco-editor/esm/vs/base/common/diff/diff.js] 46.7 KiB {main} [built] [./node_modules/monaco-editor/esm/vs/base/common/errors.js] 2.97 KiB {main} [built] [./node_modules/monaco-editor/esm/vs/base/common/iterator.js] 7.69 KiB {main} [built] [./node_modules/monaco-editor/esm/vs/base/common/lifecycle.js] 5.71 KiB {main} [built] [./node_modules/monaco-editor/esm/vs/base/common/platform.js] 3.97 KiB {main} [built] [./node_modules/monaco-editor/esm/vs/base/common/types.js] 5.53 KiB {main} [built] [./node_modules/monaco-editor/esm/vs/base/common/uri.js] 22 KiB {main} [built] [./node_modules/monaco-editor/esm/vs/base/common/worker/simpleWorker.js] 11.8 KiB {main} [built] [./node_modules/monaco-editor/esm/vs/editor/common/services/editorSimpleWorker.js] 25.8 KiB {main} [built] [./node_modules/monaco-editor/esm/vs/editor/editor.worker.js] 1.07 KiB {main} [built] [./node_modules/monaco-editor/esm/vs/language/typescript/lib/lib.js] 1.11 MiB {main} [built] [./node_modules/monaco-editor/esm/vs/language/typescript/lib/typescriptServices.js] 7.41 MiB {main} [built] [./node_modules/monaco-editor/esm/vs/language/typescript/ts.worker.js] 665 bytes {main} [built] [./node_modules/monaco-editor/esm/vs/language/typescript/tsWorker.js] 8.98 KiB {main} [built] + 28 hidden modules Child worker: Asset Size Chunks Chunk Names 0.1af66ba0c7e2d1ef5e2b.worker.js 3.42 KiB 0 [emitted] [immutable] 1.1af66ba0c7e2d1ef5e2b.worker.js 211 KiB 1 [emitted] [immutable] 1af66ba0c7e2d1ef5e2b.worker.js 10.2 MiB main [emitted] [immutable] main Entrypoint main = 1af66ba0c7e2d1ef5e2b.worker.js [./node_modules/@rollup/plugin-replace/dist/rollup-plugin-replace.es.js] 2.71 KiB {main} [built] [./node_modules/comlink-loader/dist/comlink-worker-loader.js!./node_modules/ts-loader/index.js?!./src/worker/uniroll.worker.ts] ./node_modules/comlink-loader/dist/comlink-worker-loader.js!./node_modules/ts-loader??ref--5-1!./src/worker/uniroll.worker.ts 542 bytes {main} [built] [./node_modules/comlink/dist/esm/comlink.mjs] 10.6 KiB {main} [built] [./node_modules/crypto-browserify/index.js] 2.87 KiB {main} [built] [./node_modules/events/events.js] 13 KiB {main} [built] [./node_modules/fs-monkey/lib/util/lists.js] 1.2 KiB {main} [built] [./node_modules/memfs/lib/Dirent.js] 1.82 KiB {main} [built] [./node_modules/memfs/lib/index.js] 2.11 KiB {main} [built] [./node_modules/memfs/lib/promises.js] 6.09 KiB {main} [built] [./node_modules/rollup/dist/es/rollup.js] 321 bytes {main} [built] [./node_modules/uniroll/lib/config/base.js] 696 bytes {main} [built] [./node_modules/uniroll/lib/config/minimal.js] 1.27 KiB {main} [built] [./node_modules/uniroll/lib/helpers.js] 1.63 KiB {main} [built] [./node_modules/uniroll/lib/index.js] 891 bytes {main} [built] [./node_modules/uniroll/lib/transform/createScriptTransfomer.js] 1.49 KiB {main} [built] + 245 hidden modules WARNING in ./node_modules/typescript/lib/typescript.js 5706:41-60 Critical dependency: the request of a dependency is an expression @ ./node_modules/uniroll/lib/transform/createScriptTransfomer.js @ ./node_modules/uniroll/lib/config/base.js @ ./node_modules/uniroll/lib/index.js @ ./node_modules/comlink-loader/dist/comlink-worker-loader.js!./node_modules/ts-loader??ref--5-1!./src/worker/uniroll.worker.ts ERROR in ./node_modules/rollup/dist/es/rollup.js Module not found: Error: Can't resolve 'fs' in '/Users/kazuya.kawaguchi/Projects/my/uniroll-playground/node_modules/rollup/dist/es' @ ./node_modules/rollup/dist/es/rollup.js 14:0-12 @ ./node_modules/uniroll/lib/helpers.js @ ./node_modules/uniroll/lib/index.js @ ./node_modules/comlink-loader/dist/comlink-worker-loader.js!./node_modules/ts-loader??ref--5-1!./src/worker/uniroll.worker.ts ERROR in ./node_modules/rollup/dist/es/shared/rollup.js Module not found: Error: Can't resolve 'fs' in '/Users/kazuya.kawaguchi/Projects/my/uniroll-playground/node_modules/rollup/dist/es/shared' @ ./node_modules/rollup/dist/es/shared/rollup.js 13:0-119 17671:59-69 17675:8-19 17680:12-21 17692:8-19 17729:22-31 17731:28-40 17735:26-37 @ ./node_modules/rollup/dist/es/rollup.js @ ./node_modules/uniroll/lib/helpers.js @ ./node_modules/uniroll/lib/index.js @ ./node_modules/comlink-loader/dist/comlink-worker-loader.js!./node_modules/ts-loader??ref--5-1!./src/worker/uniroll.worker.ts ERROR in ./node_modules/rollup/dist/es/shared/watch.js Module not found: Error: Can't resolve 'fs' in '/Users/kazuya.kawaguchi/Projects/my/uniroll-playground/node_modules/rollup/dist/es/shared' @ ./node_modules/rollup/dist/es/shared/watch.js 14:0-20 4110:26-28 4111:23-25 4112:24-26 4113:27-29 4206:34-36 4978:25-27 4979:27-29 4980:28-30 4981:26-28 4982:31-33 5069:11-13 5188:4-6 5205:15-17 5226:6-8 5636:27-29 5637:28-30 5638:31-33 6160:27-29 6161:30-32 6812:4-6 @ ./node_modules/rollup/dist/es/shared/rollup.js @ ./node_modules/rollup/dist/es/rollup.js @ ./node_modules/uniroll/lib/helpers.js @ ./node_modules/uniroll/lib/index.js @ ./node_modules/comlink-loader/dist/comlink-worker-loader.js!./node_modules/ts-loader??ref--5-1!./src/worker/uniroll.worker.ts ERROR in ./node_modules/fsevents/fsevents.node 1:0 Module parse failed: Unexpected character '�' (1:0) You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders (Source code omitted for this binary file) @ ./node_modules/fsevents/fsevents.js 13:15-41 @ ./node_modules/rollup/dist/es/shared/rollup.js @ ./node_modules/rollup/dist/es/rollup.js @ ./node_modules/uniroll/lib/helpers.js @ ./node_modules/uniroll/lib/index.js @ ./node_modules/comlink-loader/dist/comlink-worker-loader.js!./node_modules/ts-loader??ref--5-1!./src/worker/uniroll.worker.ts Failed to compile. ```

Module not found: Error: Can't resolve 'fs' was avoided around with node: { fs: 'empty' }. For ERROR in ./node_modules/fsevents/fsevents.node 1:0, I tried to get around it by using externals, so I seem it uses chokidar in rollup, but I couldn't work around it.

How to work around this issue in webpack? 🙏

kazupon commented 3 years ago

I've added reproduction codes https://github.com/kazupon/uniroll-playground/commit/53ee4892288f68d3f15c30773318079fed60cfb4

kazupon commented 3 years ago

I've just avoided with using IgnorePlugin https://github.com/kazupon/uniroll-playground/commit/7b5015d810135afe4a8329bdb5f83965958e3f70#diff-11e9f7f953edc64ba14b0cc350ae7b9dR64

However, It’s occured another problem. the worker did not work properly... 🤔 image

kazupon commented 3 years ago

For some reason, the globalObject option of the worker-plugin doesn't seem to be passed on to webpack. We worked around it by adding a configuration to the output.globalObject of the webpack.

https://github.com/kazupon/uniroll-playground/commit/8c80d623464904895c6a11174c2f056068d7f2ed#diff-11e9f7f953edc64ba14b0cc350ae7b9dR9

kazupon commented 3 years ago

close due to self resolution