Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 🎸 expose esbuild loglevel & logOverride options #1499

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/curly-parents-vanish.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@vanilla-extract/integration': minor
---

Exposed esbuild's logLevel & logOverride options
4 changes: 3 additions & 1 deletion packages/integration/src/compile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export interface CompileOptions {
cwd?: string;
esbuildOptions?: Pick<
EsbuildOptions,
'plugins' | 'external' | 'define' | 'loader' | 'tsconfig' | 'conditions'
'plugins' | 'external' | 'define' | 'loader' | 'tsconfig' | 'conditions' | 'logLevel' | 'logOverride'
>;
}
export async function compile({
Expand All @@ -74,6 +74,8 @@ export async function compile({
define: esbuildOptions?.define,
tsconfig: esbuildOptions?.tsconfig,
conditions: esbuildOptions?.conditions,
logLevel: esbuildOptions?.logLevel,
logOverride: esbuildOptions?.logOverride,
});

const { outputFiles, metafile } = result;
Expand Down
56 changes: 29 additions & 27 deletions packages/vite-plugin/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import type {
ResolvedConfig,
ConfigEnv,
ViteDevServer,
Rollup,
PluginOption,
TransformResult,
UserConfig,
} from 'vite';
import {
Expand Down Expand Up @@ -40,7 +40,9 @@ const removeIncompatiblePlugins = (plugin: PluginOption) =>
// Additionally, some internal Remix plugins rely on a `ctx` object to be initialized by
// the main Remix plugin, and may not function correctly without it. To address this, we
// filter out all Remix-related plugins.
!plugin.name.startsWith('remix');
!plugin.name.startsWith('remix') &&
// As React-Router plugin works the same as Remix plugin, also ignore it.
!plugin.name.startsWith('react-router');

interface Options {
identifiers?: IdentifierOption;
Expand Down Expand Up @@ -96,23 +98,6 @@ export function vanillaExtractPlugin({
}
}

function addWatchFiles(
this: Rollup.PluginContext,
fromId: string,
files: Set<string>,
) {
// We don't need to watch files in build mode
if (config.command === 'build' && !config.build.watch) {
return;
}

for (const file of files) {
if (!file.includes('node_modules') && normalizePath(file) !== fromId) {
this.addWatchFile(file);
}
}
}

return {
name: 'vanilla-extract',
configureServer(_server) {
Expand Down Expand Up @@ -210,16 +195,33 @@ export function vanillaExtractPlugin({
absoluteId,
{ outputCss: true },
);

addWatchFiles.call(this, absoluteId, watchFiles);

// We have to invalidate the virtual module, not the real one we just transformed
invalidateModule(fileIdToVirtualId(absoluteId));

return {
const result: TransformResult = {
code: source,
map: { mappings: '' },
};

// We don't need to watch files in build mode
if (config.command === 'build' && !config.build.watch) {
return result;
}

for (const file of watchFiles) {
if (
!file.includes('node_modules') &&
normalizePath(file) !== absoluteId
) {
this.addWatchFile(file);
}

// We have to invalidate the virtual module & deps, not the real one we just transformed
// The deps have to be invalidated in case one of them changing was the trigger causing
// the current transformation
if (cssFileFilter.test(file)) {
invalidateModule(fileIdToVirtualId(file));
}
}

return result;
}
},
resolveId(source) {
Expand Down Expand Up @@ -251,4 +253,4 @@ export function vanillaExtractPlugin({
return css;
},
};
}
}
Loading