Skip to content

Commit

Permalink
fix(vite): don't filter out qwik library files (#6760)
Browse files Browse the repository at this point in the history
  • Loading branch information
wmertens authored Aug 5, 2024
1 parent 59c2c43 commit b5fbd8f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/polite-feet-greet.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@builder.io/qwik': patch
---

The `fileFilter` option to `qwikVite()` now always allows `*.qwik.{m,c,}js` files so that QRLs in libraries can be processed.
8 changes: 7 additions & 1 deletion packages/qwik/src/optimizer/src/plugins/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -952,7 +952,13 @@ const RESOLVE_EXTS = {
'.cjs': true,
} as const;

const TRANSFORM_REGEX = /\.qwik\.[mc]?js$/;
/**
* Any file that matches this needs to be processed by Qwik to extract QRL segments etc. Used in
* libraries.
*
* @internal
*/
export const TRANSFORM_REGEX = /\.qwik\.[mc]?js$/;

export const QWIK_CORE_ID = '@builder.io/qwik';

Expand Down
5 changes: 4 additions & 1 deletion packages/qwik/src/optimizer/src/plugins/vite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
QWIK_JSX_RUNTIME_ID,
Q_MANIFEST_FILENAME,
SSR_OUT_DIR,
TRANSFORM_REGEX,
createPlugin,
parseId,
type NormalizedQwikPluginOptions,
Expand Down Expand Up @@ -68,7 +69,9 @@ export function qwikVite(qwikViteOpts: QwikVitePluginOptions = {}): any {
let rootDir: string | null = null;

let ssrOutDir: string | null = null;
const fileFilter = qwikViteOpts.fileFilter || (() => true);
const fileFilter: QwikVitePluginOptions['fileFilter'] = qwikViteOpts.fileFilter
? (id, type) => TRANSFORM_REGEX.test(id) || qwikViteOpts.fileFilter!(id, type)
: () => true;
const injections: GlobalInjections[] = [];
const qwikPlugin = createPlugin(qwikViteOpts.optimizerOptions);

Expand Down

0 comments on commit b5fbd8f

Please sign in to comment.