Skip to content

Commit

Permalink
Bail out early in parcel-transformer if @compiled/react is not present (
Browse files Browse the repository at this point in the history
#1621)

* Bail out early in parcel-transformer if @compiled/reactis present but unused

* Update packages/parcel-transformer/src/index.ts

Co-authored-by: Grant Wong <[email protected]>

* Add changeset

---------

Co-authored-by: Grant Wong <[email protected]>
  • Loading branch information
eddie-atkinson and dddlr authored Feb 8, 2024
1 parent ece91fd commit 41bcb1e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/ten-candles-own.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@compiled/parcel-transformer': patch
---

Allow the transformer to bail early if compiled isn't present
5 changes: 4 additions & 1 deletion packages/parcel-transformer/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,10 @@ export default new Transformer<ParcelTransformerOpts>({
}

const code = await asset.getCode();
if (code.indexOf('@compiled/react') === -1) {
if (
code.indexOf('@compiled/react') === -1 &&
(config.importSources?.every((importSource) => !code.includes(importSource)) ?? true)
) {
// We only want to parse files that are actually using Compiled.
// For everything else we bail out.
return undefined;
Expand Down

0 comments on commit 41bcb1e

Please sign in to comment.