vikejs / bati

Next-gen scaffolder. Get started with fully-functional apps, and choose any tool you want.
https://batijs.dev
MIT License
228 stars 13 forks source link

BATI include-if-imported does not include file on import when used with /*# #346

Closed aheissenberger closed 3 weeks ago

aheissenberger commented 3 weeks ago

Describe the bug If BATI include-if-imported is commented with /*# BATI include-if-imported #*/ it fails. Does work with //# BATI include-if-imported

To Reproduce Steps to reproduce the behavior:

boilerplates/sentry/files/sentry.config.client.ts:

/*# BATI include-if-imported #*/

//import { useEffect } from "react";
import * as Sentry from "@sentry/react";

boilerplates/react/files/layouts/LayoutDefault.tsx:

import "./style.css";
//# BATI.has("sentry")
import "@batijs/sentry/sentry.config.client";
//# BATI.has("tailwindcss")
import "./tailwind.css";
import React from "react";
import logoUrl from "../assets/logo.svg";
import { Link } from "../components/Link.js";

export default function LayoutDefault({ children }: { children: React.ReactNode }) {
  return (<></>)
}

$ pnpm cli --react --sentry

sentry.config.client.ts: is missing

layouts/LayoutDefault.tsx:

import "./style.css";
import "../sentry/sentry.config.client";
import React from "react";
import logoUrl from "../assets/logo.svg";
import { Link } from "../components/Link.js";

export default function LayoutDefault({ children }: { children: React.ReactNode }) {
  return (<></>)
}

Expected behavior should work with both comment styles

Additional context

There was no difference when used with a local import import "../../sentry.config.client" or an import using import "@batijs/sentry/sentry.config.client"

I found /*# BATI include-if-imported #*/ in a lot of other boilerblates (e.g. boilerplates/lucia-auth/files/database/schema/auth.ts but only the other comment style worked in my code.

magne4000 commented 3 weeks ago

Have you tried before or after #345?

magne4000 commented 3 weeks ago

Should be fixed by https://github.com/vikejs/bati/commit/51b598404d681b7ac7a9e339fe4d5edf9057cf04