Skip to content

Commit

Permalink
Merge pull request #15 from adamsoderstrom/fix/single-quote-directives
Browse files Browse the repository at this point in the history
  • Loading branch information
Seojunhwan authored Sep 1, 2024
2 parents f3505d3 + ee02b38 commit 8f7be07
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/strange-tools-smile.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"esbuild-plugin-preserve-directives": patch
---

Account for single-quote directives
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "esbuild-plugin-preserve-directives",
"version": "0.0.8",
"version": "0.0.9",
"description": "An esbuild plugin to preserve important directives like 'use client' at the top of output files.",
"author": "seojunhwan <[email protected]>",
"license": "MIT",
Expand Down
8 changes: 7 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,13 @@ export function preserveDirectivesPlugin(options: DirectivePreservationOptions):

const foundDirectives = lines
.slice(0, 5)
.filter((line) => directives.some((directive) => line.trim().startsWith(`"${directive}"`)));
.filter((line) =>
directives.some(
(directive) =>
line.trim().startsWith(`"${directive}"`) ||
line.trim().startsWith(`'${directive}'`)
)
);

if (foundDirectives.length > 0) {
const relativePath = getRelativePath(args.path);
Expand Down

0 comments on commit 8f7be07

Please sign in to comment.