-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[bug] compile @fluentui/react fail after using esbuild-plugin-postcss2 #1834
Comments
This is by design. When plugins take control of module resolution, they are in control. If they are doing the wrong thing then that's a problem with the plugin, not with esbuild, and the plugin should be changed to avoid the issue. Arguably that package could also be changed to not use such problematic file names. |
hi @evanw , thanks for your reply. I agree with you that if If we let the plugins do this check, every plugin needs to implement the check ideally, that doesn't make sense very much. And I believe the esbuild does this check (in this case it means resolve the Not sure whether I explain it clearly. |
Currently it's not possible to compile @fluentui/react package with any style plugin. From the esbuild thread evanw/esbuild#1834 it is mentioned the plugins should take care of properly selecting the files to compile. Thus I added 3 simple lines of code which will prevent inclusion of those precompiled files. In the example of fluentui there is for instance the import for BasePicker.less which indeed exists but it will instead picked the pre-compiled BasePicker.less.js. Every esbuild style plugin tries to compile these JS files with less or what ever. So the condition just makes sure the resolved file is really a style.
Just wanted to line out that with the above merged pr the esbuild-style-plugin works like a charm with fluentui. It also supports css modules and sass/less/stylus etc and is working for me as I would like to have it.
|
After the original comment for this issue was posted, esbuild exposed a |
Reproduce steps
Initial a react project by
npx esbuild-create-react-app my-app
, chooseTypeScript
template. esbuild-create-react-appInstall
@fluentui/react
by runningyarn add @fluentui/react
Test
@fluentui/react
components:Running
yarn build
oryarn start
, works fine.Demo code: miscs-test/esbuild-demo@d6eb07c
Install esbuild-plugin-postcss2 to help comiple
.less
CSS, but it tasks over.css/.scss/.styl
as well. Runningyarn add -D esbuild-plugin-postcss2
.Config esbuild options:
Running
yarn build
oryarn start
, report the following errors:After investigating, it is true that
'node_modules/@fluentui/react/lib/components/ExtendedPicker/PeoplePicker/ExtendedPeoplePicker.scss'
doesn't exist, but existExtendedPeoplePicker.scss.js
.So, although this error is thrown by
esbuild-plugin-postcss2
, I think the root reason comes from esbuild self. It doesn't check whether exist the.js
file before passing it to theesbuild-plguin-postcss2
plugin.Demo code: miscs-test/esbuild-demo@1a057d9
Workaround
I work around this issue by hacking the
esbuild-plugin-postcss2
code in the node_modules, I add the logic to check if it exists the corresponding.js
file, just return it back to esbuild self to handle it.The text was updated successfully, but these errors were encountered: