@@ -4,7 +4,7 @@ import { dirname, join } from 'path';
44import { babelTransform , compile } from '@macaron-css/integration' ;
55
66/*
7- -> load /(t|j)sx?/
7+ -> load /(t|j)sx?/
88 -> extract css and inject imports (extracted_HASH.css.ts)
99 -> resolve all imports
1010 -> load imports, bundle code again
@@ -14,7 +14,14 @@ import { babelTransform, compile } from '@macaron-css/integration';
1414 -> process the file with vanilla-extract
1515 -> resolve with js loader
1616*/
17- export function macaronEsbuildPlugin ( ) : EsbuildPlugin {
17+
18+ interface MacaronEsbuildPluginOptions {
19+ includeNodeModulesPattern ?: RegExp ;
20+ }
21+
22+ export function macaronEsbuildPlugin ( {
23+ includeNodeModulesPattern,
24+ } : MacaronEsbuildPluginOptions = { } ) : EsbuildPlugin {
1825 return {
1926 name : 'macaron-css-esbuild' ,
2027 setup ( build ) {
@@ -90,7 +97,10 @@ export function macaronEsbuildPlugin(): EsbuildPlugin {
9097 ) ;
9198
9299 build . onLoad ( { filter : / \. ( j | t ) s x ? $ / } , async args => {
93- if ( args . path . includes ( 'node_modules' ) ) return ;
100+ if ( args . path . includes ( 'node_modules' ) ) {
101+ if ( ! includeNodeModulesPattern ) return ;
102+ if ( ! includeNodeModulesPattern . test ( args . path ) ) return ;
103+ } ;
94104
95105 // gets handled by @vanilla -extract/esbuild-plugin
96106 if ( args . path . endsWith ( '.css.ts' ) ) return ;
0 commit comments