glromeo / esbuild-sass-plugin

esbuild plugin for sass
MIT License
155 stars 40 forks source link

[ERROR] [BUG] "Unreachable" on Production #188

Closed jorgedanisc closed 1 month ago

jorgedanisc commented 1 month ago

Repo: https://github.com/ducflair/duc/blob/main/packages/core/scripts/buildPackage.js

On this project, when I build locally, there is no problems, it runs without any error, however when I deploy to Vercel or run a Github Action for example I get this:

rm -rf dist && bun run ../scripts/buildPackage.js && bun run gen:types

✘ [ERROR] [BUG] Unreachable [plugin sass-plugin]

 components/footer/FooterCenter.tsx:3:7:
   3 │ import "./FooterCenter.scss";
     ╵        ~~~~~~~~~~~~~~~~~~~~~

✘ [ERROR] [BUG] Unreachable [plugin sass-plugin]

 components/Tooltip.tsx:1:7:
   1 │ import "./Tooltip.scss";
     ╵        ~~~~~~~~~~~~~~~~

✘ [ERROR] [BUG] Unreachable [plugin sass-plugin]

 components/main-menu/DefaultItems.tsx:31:7:§
   31 │ import "./DefaultItems.scss";
      ╵        ~~~~~~~~~~~~~~~~~~~~~

✘ [ERROR] [BUG] Unreachable [plugin sass-plugin]

 components/UserList.tsx:1:7:
   1 │ import "./UserList.scss";
     ╵        ~~~~~~~~~~~~~~~~~

✘ [ERROR] [BUG] Unreachable [plugin sass-plugin]

 components/Sidebar/Sidebar.tsx:32:7:
   32 │ import "./Sidebar.scss";
      ╵        ~~~~~~~~~~~~~~~~

and it goes on and on, this error is raised on every .scss import inside packages/core/canvas

More logs:

1645 | let { file, line, column } = e.location; 1646 | let pluginText = e.pluginName ? [plugin: ${e.pluginName}] : ""; 1647 | return 1648 | ${file}:${line}:${column}: ERROR: ${pluginText}${e.text}; 1649 | }).join(""); 1650 | let error = new Error(text); ^ error: Build failed with 45 errors: actions/actionExport.tsx:21:7: ERROR: [plugin: sass-plugin] [BUG] Unreachable components/Button.tsx:4:7: ERROR: [plugin: sass-plugin] [BUG] Unreachable components/CheckboxItem.tsx:5:7: ERROR: [plugin: sass-plugin] [BUG] Unreachable components/ColorPicker/ColorPicker.tsx:22:7: ERROR: [plugin: sass-plugin] [BUG] Unreachable components/ConfirmDialog.tsx:4:7: ERROR: [plugin: sass-plugin] [BUG] Unreachable ... errors: [ { "id": "", "location": { "column": 7, "file": "actions/actionExport.tsx", "length": 29, "line": 21, "lineText": "import \"../components/ToolIcon.scss\";", "namespace": "", "suggestion": "" }, "notes": [], "pluginName": "sass-plugin", "text": "[BUG] Unreachable" }, { "id": "", "location": { "column": 7, "file": "components/Button.tsx", "length": 15, "line": 4, "lineText": "import \"./Button.scss\";", "namespace": "", "suggestion": "" }, "notes": [], "pluginName": "sass-plugin", "text": "[BUG] Unreachable" }, { "id": "", "location": { "column": 7, "file": "components/CheckboxItem.tsx", "length": 21, "line": 5, "lineText": "import \"./CheckboxItem.scss\";", "namespace": "", "suggestion": "" }, "notes": [], "pluginName": "sass-plugin", "text": "[BUG] Unreachable" }, { "id": "", "location": { "column": 7, "file": "components/ColorPicker/ColorPicker.tsx", "length": 20, "line": 22, "lineText": "import \"./ColorPicker.scss\";", "namespace": "", "suggestion": "" }, "notes": [], "pluginName": "sass-plugin", "text": "[BUG] Unreachable" },

  at failureErrorWithLog (/home/runner/work/duc/duc/node_modules/esbuild/lib/main.js:1650:15)
  at /home/runner/work/duc/duc/node_modules/esbuild/lib/main.js:1058:25
  at buildResponseToResult (/home/runner/work/duc/duc/node_modules/esbuild/lib/main.js:1056:7)
  at /home/runner/work/duc/duc/node_modules/esbuild/lib/main.js:703:9
  at handleIncomingPacket (/home/runner/work/duc/duc/node_modules/esbuild/lib/main.js:763:9)
  at readFromStdout (/home/runner/work/duc/duc/node_modules/esbuild/lib/main.js:679:7)
  at emit (node:events:183:48)
  at addChunk (node:stream:1914:22)
  at readableAddChunk (node:stream:1868:30)
  at node:stream:32:51

Bun v1.1.30 (Linux x64 baseline) error: script "build:esm" exited with code 1 error: script "build" exited with code 1 Error: command finished with error: command (/home/runner/work/duc/duc/packages/core/canvas) /home/runner/.bun/bin/bun run build exited (1)

dungjk commented 1 month ago

Hello @jorgedanisc I've check you repo. I guess, we may miss option loadPaths. If you not explicitly specify this option, it will take default from process.cwd() and it is may not the source root as we expected on github action or Vercel build tasks. My suggestion:

  1. Update file buildPackage.js.

    plugins: [sassPlugin({
    type: 'css',
    loadPaths: ['.']
    })],

    If this not work. You may move file buildPackage.js into folder packages/core/canvas.

  2. Update import source of css, scss files.

    - @import "open-color/open-color";
    + @import "~open-color/open-color"; // `esbuild-sass-plugin` resolve package from `node_modules` with prefix `~`

Hope this help.

jorgedanisc commented 1 month ago

Thank you for the help! I had already solved this issue yesterday by doing some backward compatibility with a working build I had in the past and got it to work.

However I wanted to keep this issue open so that this error would be addressed as I haven't seen anybody with this error message in particular. I will be closing it now, and if I face this problem again will attempt to make these changes so thank you.