Skip to content

Commit

Permalink
v4.1.4 - Marked console unstable
Browse files Browse the repository at this point in the history
  • Loading branch information
AlemTuzlak committed Mar 26, 2024
1 parent 1965a09 commit f295207
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "remix-development-tools",
"description": "Remix development tools - a set of tools for developing/debugging Remix.run apps",
"author": "Alem Tuzlak",
"version": "4.1.2",
"version": "4.1.4",
"license": "MIT",
"keywords": [
"remix",
Expand Down
3 changes: 2 additions & 1 deletion src/test-apps/remix-vite/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ const config = defineRdtConfig({
requireUrlFlag: true
},server: {},
pluginDir: "./plugins",
includeInProd: true
includeInProd: true,
unstable_console: true
}, );

export default defineConfig({
Expand Down
2 changes: 1 addition & 1 deletion src/test-apps/remix-website/vite.config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ export default defineConfig({
server: {
open: true,
},
plugins: [remixDevTools(),tsconfigPaths(), splitVendorChunkPlugin(), arraybuffer(), remix()],
plugins: [remixDevTools({ unstable_console: true }),tsconfigPaths(), splitVendorChunkPlugin(), arraybuffer(), remix()],
});
14 changes: 8 additions & 6 deletions src/vite/plugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ type RemixViteConfig = {
client?: Partial<RdtClientConfig>;
server?: DevToolsServerConfig,
pluginDir?: string;
includeInProd?: boolean
includeInProd?: boolean;
unstable_console?: boolean;
};

export const defineRdtConfig = (config: RemixViteConfig) => config
Expand All @@ -31,6 +32,7 @@ export const remixDevTools: (args?:RemixViteConfig) => Plugin[] = (args) => {
const serverConfig = args?.server || {};
const clientConfig = args?.client || {};
const include = args?.includeInProd ?? false;
const unstable_console = args?.unstable_console ?? false;
const shouldInject = (mode: string | undefined) => mode === "development" || include;
let port = 5173;
return [
Expand Down Expand Up @@ -95,7 +97,7 @@ export const remixDevTools: (args?:RemixViteConfig) => Plugin[] = (args) => {
}
},
},
{
...(unstable_console ? [{
name: "better-console-logs",
enforce: "pre",
apply(config){
Expand All @@ -119,22 +121,22 @@ export const remixDevTools: (args?:RemixViteConfig) => Plugin[] = (args) => {
const column = line.indexOf("console.");
const logMessage = `"${chalk.magenta("LOG")} Logged in ${chalk.blueBright(`${id.replace(normalizePath(process.cwd()),"")}:${lineNumber+1}:${column+1}`)}"`;
if (line.includes("console.log(")) {
const newLine = `console.log(${logMessage});\nconsole.log`;
const newLine = `console.log(${logMessage});console.log`;
return line.replace("console.log", newLine);
}
else if (line.includes("console.error(")) {
const newLine = `console.error(${logMessage});\nconsole.error`;
const newLine = `console.error(${logMessage});console.error`;
return line.replace("console.error", newLine);
}
else if (line.includes("console.table(")) {
const newLine = `console.table(${logMessage});\nconsole.table`;
const newLine = `console.table(${logMessage});console.table`;
return line.replace("console.table",newLine);
}
return line;
}).join("\n");

}
}},
}} satisfies Plugin] : []),
{
name: "remix-development-tools",
apply(config) {
Expand Down

0 comments on commit f295207

Please sign in to comment.