Repro
- Generate a v2 plugin (fresh boilerplate or
php bones migrate:to-v2).
- Place a TypeScript declaration file in
resources/assets/apps/, for example global.d.ts with the usual:
declare module '*.png' {
const value: string;
export default value;
}
yarn build
Observed
public/apps/global.d.js and public/apps/global.d.asset.php are emitted as if global.d.ts were a real entry, polluting the output and (if they get enqueued by name) producing an empty/broken script.
The webpack compilation itself succeeds — the bug is purely in entry discovery.
Expected
.d.ts files are TypeScript-only declarations. They should be ignored by the auto-discovery glob.
Root cause
In the stub generated by migrate:to-v2 (and shipped in all boilerplates) we do:
// webpack.config.js (stub) — single-file apps branch
glob.sync('resources/assets/apps/*.{ts,tsx,js,jsx}').forEach((file) => {
const name = path.basename(file).replace(/\.(ts|tsx|js|jsx)$/, '');
entries[`apps/${name}`] = `./${file}`;
});
*.ts matches *.d.ts, and the .replace(...) trims only the outer .ts, leaving global.d as the entry name. A file named components.d.ts, types.d.ts, etc. all fall into the same trap.
Suggested fix
Filter .d.ts out of the glob result. One-line change:
glob.sync('resources/assets/apps/*.{ts,tsx,js,jsx}')
.filter((file) => !file.endsWith('.d.ts'))
.forEach((file) => {
const name = path.basename(file).replace(/\.(ts|tsx|js|jsx)$/, '');
entries[`apps/${name}`] = `./${file}`;
});
(Or the equivalent glob.sync(..., { ignore: '**/*.d.ts' }).)
This has to land in two places:
src/Console/stubs/webpack-config.stub — so fresh migrate:to-v2 runs pick it up.
- Documented as a manual patch for plugins that already migrated before the fix.
Workaround (for already-migrated plugins)
Move .d.ts files out of resources/assets/apps/ (e.g. to resources/assets/types/) and extend tsconfig.json include accordingly. That's what I did on Scotty during its v2 alignment.
Impact
Low. Purely cosmetic — spurious public/apps/<name>.d.js files and their asset PHP. Only hits projects that keep their declaration files inside the apps folder. But confusing when you stumble across it, and the fix is a one-liner.
Target
Good candidate for v2.0.4 alongside any other small follow-ups.
Repro
php bones migrate:to-v2).resources/assets/apps/, for exampleglobal.d.tswith the usual:yarn buildObserved
public/apps/global.d.jsandpublic/apps/global.d.asset.phpare emitted as ifglobal.d.tswere a real entry, polluting the output and (if they get enqueued by name) producing an empty/broken script.The webpack compilation itself succeeds — the bug is purely in entry discovery.
Expected
.d.tsfiles are TypeScript-only declarations. They should be ignored by the auto-discovery glob.Root cause
In the stub generated by
migrate:to-v2(and shipped in all boilerplates) we do:*.tsmatches*.d.ts, and the.replace(...)trims only the outer.ts, leavingglobal.das the entry name. A file namedcomponents.d.ts,types.d.ts, etc. all fall into the same trap.Suggested fix
Filter
.d.tsout of the glob result. One-line change:(Or the equivalent
glob.sync(..., { ignore: '**/*.d.ts' }).)This has to land in two places:
src/Console/stubs/webpack-config.stub— so freshmigrate:to-v2runs pick it up.Workaround (for already-migrated plugins)
Move
.d.tsfiles out ofresources/assets/apps/(e.g. toresources/assets/types/) and extendtsconfig.jsonincludeaccordingly. That's what I did on Scotty during its v2 alignment.Impact
Low. Purely cosmetic — spurious
public/apps/<name>.d.jsfiles and their asset PHP. Only hits projects that keep their declaration files inside the apps folder. But confusing when you stumble across it, and the fix is a one-liner.Target
Good candidate for v2.0.4 alongside any other small follow-ups.