@dbx-tools/projen 0.6.44 → 0.6.45
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/bun-app.ts +21 -0
- package/src/project.ts +3 -0
package/package.json
CHANGED
package/src/bun-app.ts
CHANGED
|
@@ -131,6 +131,7 @@ export class BunBuildFile extends TextFile {
|
|
|
131
131
|
readonly: true,
|
|
132
132
|
lines: String.raw`
|
|
133
133
|
import { existsSync } from "node:fs";
|
|
134
|
+
import { basename } from "node:path";
|
|
134
135
|
import tailwind from "bun-plugin-tailwind";
|
|
135
136
|
|
|
136
137
|
// Unmanaged override (${BUN_BUILD_OVERRIDE}): its default export is merged over
|
|
@@ -155,6 +156,26 @@ if (!result.success) {
|
|
|
155
156
|
for (const message of result.logs) console.error(message);
|
|
156
157
|
process.exit(1);
|
|
157
158
|
}
|
|
159
|
+
|
|
160
|
+
// Fix a Bun bug: with \`splitting: true\` and an HTML entrypoint, the emitted
|
|
161
|
+
// HTML's <script src> is wired to an arbitrary chunk instead of the JS
|
|
162
|
+
// entry-point, so the app never boots (a blank page). Rewrite the HTML script
|
|
163
|
+
// (and stylesheet) to the real entry-point outputs. No-op when they already
|
|
164
|
+
// match (e.g. splitting off), so it is always safe to run.
|
|
165
|
+
const htmlOut = result.outputs.find((o) => o.path.endsWith(".html"));
|
|
166
|
+
const entryJs = result.outputs.find((o) => o.kind === "entry-point" && o.path.endsWith(".js"));
|
|
167
|
+
const entryCss = result.outputs.find((o) => o.kind === "entry-point" && o.path.endsWith(".css"));
|
|
168
|
+
if (htmlOut && entryJs) {
|
|
169
|
+
let html = await Bun.file(htmlOut.path).text();
|
|
170
|
+
const jsName = basename(entryJs.path);
|
|
171
|
+
html = html.replace(/(<script[^>]*\bsrc=")([^"]*\/)?[^"/]+\.js(")/i, "$1$2" + jsName + "$3");
|
|
172
|
+
if (entryCss) {
|
|
173
|
+
const cssName = basename(entryCss.path);
|
|
174
|
+
html = html.replace(/(<link[^>]*\bhref=")([^"]*\/)?[^"/]+\.css(")/i, "$1$2" + cssName + "$3");
|
|
175
|
+
}
|
|
176
|
+
await Bun.write(htmlOut.path, html);
|
|
177
|
+
}
|
|
178
|
+
|
|
158
179
|
console.log("built " + result.outputs.length + " files to " + options.outdir);
|
|
159
180
|
`
|
|
160
181
|
.trimStart()
|
package/src/project.ts
CHANGED
|
@@ -913,6 +913,9 @@ function initProject(
|
|
|
913
913
|
// them to a project. ESLint still cannot parse them.
|
|
914
914
|
eslint.addIgnorePattern("**/dev.ts");
|
|
915
915
|
eslint.addIgnorePattern("**/build.ts");
|
|
916
|
+
// A deploy-staging helper that lives at a package root (outside any `src/**`
|
|
917
|
+
// tsconfig), same parse-resolution problem as the bun app scripts above.
|
|
918
|
+
eslint.addIgnorePattern("**/stage-deploy.ts");
|
|
916
919
|
for (const override of BUN_APP_OVERRIDES) {
|
|
917
920
|
eslint.addIgnorePattern(`**/${override}`);
|
|
918
921
|
}
|