-
Notifications
You must be signed in to change notification settings - Fork 313
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
feat: add esbuild
plugin
#113
feat: add esbuild
plugin
#113
Conversation
packages/esbuild-plugin/src/index.js
Outdated
|
||
return { | ||
contents: code, | ||
loader: currFileName.endsWith('.js') ? 'js' : 'tsx', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tsx
loader can handle ts
, tsx
and jsx
files
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
update: turns out this wasn't entirely correct. encountered some import resolution problems when using tsx
loader for JSX
files, even though the esbuild
documentation said that either loader is fine. for the sake of simplicity, I just match extension to loader. we can rely on extensions because of the filter guarantees.
I could also create a dictionary and map extension to loader in case esbuild
changes the loader names or we want to use different loader for a given extension. lmk what you think.
Looks promising so far! |
@@ -196,6 +196,48 @@ provides plugins for Webpack, Rollup, and Next.js. | |||
|
|||
</details> | |||
|
|||
<details> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added esbuild plugin example to the installations page in docs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please be patient as it may take me a few days to review this properly.
Lots of failing tests, so please work on that as I make my way through the PR. |
@nmn yup, looking into it. probably related to package lock merge conflicts that I tried to resolve yesterday. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's almost there! I've left a few comments. Please address those and I'll test it merge it within a few days.
hey @nmn are you still considering adding this? |
@nedjulius Yes. Still planning to merge this for the next release. |
* Add eslint-plugin package * Add initial test suite * Improve CSS handling and tests * Address some of the comments * Add babel scripts for jsx, flow and ts * Add package diff * Add snapshots and fix nits * Fix rename bug * Add esbuild example app * Fix incorrect loaders * Update package-lock.json * Remove unnecessary file * Fix some nits in example * Add additional style to text fixture * Remove ext from import in example * Address some of the comments * Update package-lock.json * Add missing function call and snapshot * Remove comment * Pluralize function name * Add types * Fix build script * Add docs * Fix tabulation * Retake snapshots * Format prettier * Add more missing types * Run formatter * Fix formatting * Lock dependency and fix import * Disable unused key * Add docs * Update package-lock.json * Update package-lock.json * Add snapshots * Address comments
* Add eslint-plugin package * Add initial test suite * Improve CSS handling and tests * Address some of the comments * Add babel scripts for jsx, flow and ts * Add package diff * Add snapshots and fix nits * Fix rename bug * Add esbuild example app * Fix incorrect loaders * Update package-lock.json * Remove unnecessary file * Fix some nits in example * Add additional style to text fixture * Remove ext from import in example * Address some of the comments * Update package-lock.json * Add missing function call and snapshot * Remove comment * Pluralize function name * Add types * Fix build script * Add docs * Fix tabulation * Retake snapshots * Format prettier * Add more missing types * Run formatter * Fix formatting * Lock dependency and fix import * Disable unused key * Add docs * Update package-lock.json * Update package-lock.json * Add snapshots * Address comments
* Add eslint-plugin package * Add initial test suite * Improve CSS handling and tests * Address some of the comments * Add babel scripts for jsx, flow and ts * Add package diff * Add snapshots and fix nits * Fix rename bug * Add esbuild example app * Fix incorrect loaders * Update package-lock.json * Remove unnecessary file * Fix some nits in example * Add additional style to text fixture * Remove ext from import in example * Address some of the comments * Update package-lock.json * Add missing function call and snapshot * Remove comment * Pluralize function name * Add types * Fix build script * Add docs * Fix tabulation * Retake snapshots * Format prettier * Add more missing types * Run formatter * Fix formatting * Lock dependency and fix import * Disable unused key * Add docs * Update package-lock.json * Update package-lock.json * Add snapshots * Address comments
Addresses issue #83
Adds a StyleX plugin for esbuild bundler. There are some caveats with how the esbuild plugin API works, and it seems that the consumer will have to provide a full path to the build directory directly to the plugin, because there's no other way to access the
build
path in theonEnd
callback. I am using theonEnd
callback in this case (which runs at the end of the build, implied by the name), as we first have to transform eachts[x]/js[x]
before we can process theStyleX
rules. Let me know if you have simpler ideas on how to solve the bundling of CSS.An example of how consuming the plugin would look like:
Some remaining things to do: