linaria icon indicating copy to clipboard operation
linaria copied to clipboard

esbuild plugin transformation issues

Open silviogutierrez opened this issue 2 years ago • 2 comments

Environment

        "@linaria/babel-preset": "^4.4.5",
        "@linaria/core": "^4.2.10",
        "@linaria/esbuild": "^4.2.11",
        "@linaria/react": "^4.3.8",
        "@linaria/shaker": "^4.2.11",
        "esbuild": "^0.17.19",
  • Linaria version:
  • Bundler (+ version):
  • Node.js version: Node 16
  • OS: Mac OS and Linux

Description

As of esbuild 0.16 and higher, kind is supposed to be required for build.resolve. The typings don't enforce this, but instead of defaulting to entry-point, it now resolved to none. This doesn't cause problems for very basic linaria usage. But if you have utility functions that you import then pipe into linaria, such as:


import {myUtilityfunction} from "./anotherFile";

css`${myUtilityFunction()}`

Babel ends up throwing a ton of issues as it gets an untransformed file.

Reproducible Demo

I can provide but the fix is trivial and well documented. Let me know if it's necessary. All that is needed is this line here:

https://github.com/silviogutierrez/reactivated/blob/ccafe0ab08ed9f710bf7abc2d5f0cfc4e36193fb/packages/reactivated/src/linaria.tsx#L45

This may mean bumping up esbuild requirements. Here's the announcement https://github.com/evanw/esbuild/releases/tag/v0.16.0

and the specific code change: https://github.com/evanw/esbuild/blame/6c8d15d404874fd939d7f4062cc6a660dffdabcb/cmd/esbuild/service.go#L693

silviogutierrez avatar May 21 '23 18:05 silviogutierrez

looks related to the problem I had #1256, right?

sebasjm avatar May 31 '23 11:05 sebasjm

@sebasjm : could very much be related!

silviogutierrez avatar May 31 '23 16:05 silviogutierrez