diff --git a/.changeset/strange-tools-smile.md b/.changeset/strange-tools-smile.md new file mode 100644 index 0000000..02d7d18 --- /dev/null +++ b/.changeset/strange-tools-smile.md @@ -0,0 +1,5 @@ +--- +"esbuild-plugin-preserve-directives": patch +--- + +Account for single-quote directives diff --git a/package.json b/package.json index a431055..b5cc3e1 100644 --- a/package.json +++ b/package.json @@ -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 ", "license": "MIT", diff --git a/src/index.ts b/src/index.ts index 106fcba..af9a296 100644 --- a/src/index.ts +++ b/src/index.ts @@ -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);