Skip to content

feat: warn when both code and postBanner contain shebang#8039

Merged
graphite-app[bot] merged 1 commit intomainfrom
copilot/implement-dynamic-scroll-feature
Jan 26, 2026
Merged

feat: warn when both code and postBanner contain shebang#8039
graphite-app[bot] merged 1 commit intomainfrom
copilot/implement-dynamic-scroll-feature

Conversation

Copy link
Contributor

Copilot AI commented Jan 24, 2026

Summary

Implements the feature requested in #7583 (comment)

This PR adds a warning when both the source code and postBanner contain shebang lines.

Changes

  • Add DuplicateShebang event kind to EventKind enum
  • Create new duplicate_shebang.rs event module
  • Update mod.rs to export the new event
  • Update constructors.rs to add constructor for DuplicateShebang
  • Modify post_banner_footer.rs to detect duplicate shebangs and emit warning
  • Add test case for duplicate shebang scenario
  • Run tests to verify the implementation - ✅ All tests pass
  • Run code review and address feedback
  • Address PR review feedback
  • Run format and generator
  • Fix lint and update CLI snapshot
  • Update JS snapshots
  • Fix test to run sequentially

Behavior

When both source code and postBanner contain shebang:

Example

Input file:

#!/usr/bin/env node
console.log('hello');

postBanner:

#!/usr/bin/env bun
/* Version 1.0.0 */

Output:

#!/usr/bin/env node
#!/usr/bin/env bun
/* Version 1.0.0 */
console.log('hello');

Warning:

[DUPLICATE_SHEBANG] Warning: Both the code and postBanner contain shebang in "main.js". This will cause a syntax error.

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

@netlify
Copy link

netlify bot commented Jan 24, 2026

Deploy Preview for rolldown-rs canceled.

Name Link
🔨 Latest commit 66c2f5a
🔍 Latest deploy log https://app.netlify.com/projects/rolldown-rs/deploys/6977269d44f7e700084f7ba1

Copilot AI changed the title [WIP] Add dynamic scrolling feature to improve user experience feat: warn when both code and postBanner contain shebang Jan 24, 2026
Copilot AI requested a review from sapphi-red January 24, 2026 10:26
Copy link
Member

@sapphi-red sapphi-red left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sapphi-red sapphi-red marked this pull request as ready for review January 24, 2026 11:11
Copilot AI review requested due to automatic review settings January 24, 2026 11:11
@sapphi-red
Copy link
Member

@copilot run format

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new warning to help users avoid generating invalid output when both the original source and output.postBanner contain a shebang (multiple shebangs in one file cause a syntax error).

Changes:

  • Introduces a new DUPLICATE_SHEBANG warning event kind and diagnostic.
  • Updates post_banner_footer to detect duplicate shebangs and return warnings to the generate pipeline.
  • Adds an integration fixture covering the duplicate-shebang scenario.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
packages/rolldown/tests/fixtures/function/post-banner/duplicate-shebang/main.js Adds a shebang-containing input to reproduce the duplicate-shebang output case.
packages/rolldown/tests/fixtures/function/post-banner/duplicate-shebang/_config.ts Adds a fixture test that expects a DUPLICATE_SHEBANG warning and validates output ordering.
crates/rolldown_error/src/types/event_kind.rs Adds EventKind::DuplicateShebang and maps it to DUPLICATE_SHEBANG.
crates/rolldown_error/src/build_diagnostic/events/mod.rs Registers the new duplicate_shebang event module.
crates/rolldown_error/src/build_diagnostic/events/duplicate_shebang.rs Implements the warning event message including the filename.
crates/rolldown_error/src/build_diagnostic/constructors.rs Adds BuildDiagnostic::duplicate_shebang(...) constructor.
crates/rolldown/src/stages/generate_stage/render_chunk_to_assets.rs Collects warnings returned by post_banner_footer and merges them into the warnings list.
crates/rolldown/src/stages/generate_stage/post_banner_footer.rs Detects duplicate shebangs between source and post_banner and emits a warning.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor Author

Copilot AI commented Jan 24, 2026

@copilot run format

Ran format and generator in f3fe753

@sapphi-red
Copy link
Member

@copilot fix lint and update snapshot in cli/cli-e2e.test.ts

Copy link
Contributor Author

Copilot AI commented Jan 24, 2026

@copilot fix lint and update snapshot in cli/cli-e2e.test.ts

Fixed lint error (changed map_or to is_some_and) and updated CLI snapshot in 8a2d7d0

@github-actions
Copy link
Contributor

github-actions bot commented Jan 24, 2026

Benchmarks Rust

  • target: main(1d26877)
  • pr: copilot/implement-dynamic-scroll-feature(799f08f)
group                                                        pr                                     target
-----                                                        --                                     ------
bundle/bundle@multi-duplicated-top-level-symbol              1.00     66.2±2.09ms        ? ?/sec    1.01     67.1±3.36ms        ? ?/sec
bundle/bundle@multi-duplicated-top-level-symbol-sourcemap    1.00     67.8±1.70ms        ? ?/sec    1.07     72.3±4.90ms        ? ?/sec
bundle/bundle@rome_ts                                        1.00     95.6±1.67ms        ? ?/sec    1.01     96.4±2.95ms        ? ?/sec
bundle/bundle@rome_ts-sourcemap                              1.00    106.7±2.25ms        ? ?/sec    1.03    109.9±2.97ms        ? ?/sec
bundle/bundle@threejs                                        1.00     34.8±1.20ms        ? ?/sec    1.00     34.8±1.97ms        ? ?/sec
bundle/bundle@threejs-sourcemap                              1.00     39.5±0.68ms        ? ?/sec    1.01     40.0±0.76ms        ? ?/sec
bundle/bundle@threejs10x                                     1.00    343.9±2.44ms        ? ?/sec    1.02    350.2±5.46ms        ? ?/sec
bundle/bundle@threejs10x-sourcemap                           1.00    409.8±3.90ms        ? ?/sec    1.01    412.5±3.28ms        ? ?/sec
scan/scan@rome_ts                                            1.00     73.9±1.23ms        ? ?/sec    1.00     74.1±1.04ms        ? ?/sec
scan/scan@threejs                                            1.00     26.3±1.73ms        ? ?/sec    1.01     26.5±0.45ms        ? ?/sec
scan/scan@threejs10x                                         1.00    264.1±2.98ms        ? ?/sec    1.01    265.7±2.74ms        ? ?/sec

@sapphi-red
Copy link
Member

@copilot update snapshot in js files

Copy link
Contributor Author

Copilot AI commented Jan 26, 2026

@copilot update snapshot in js files

Updated CLI snapshot with the new duplicate-shebang check option in a514bce

@sapphi-red
Copy link
Member

@copilot the test is not passing

Copy link
Contributor Author

Copilot AI commented Jan 26, 2026

@copilot the test is not passing

The test is passing now. I verified:

  • duplicate-shebang test passes
  • ✅ All 6 post-banner tests pass
  • ✅ CLI tests pass (39 passed)
  • ✅ Rust linting passes
  • ✅ Generated output is correct (original shebang first, then postBanner with its shebang)

The warning is being emitted correctly when both code and postBanner contain shebangs.

@sapphi-red
Copy link
Member

@copilot just test-node is failing

Copy link
Contributor Author

Copilot AI commented Jan 26, 2026

@copilot just test-node is failing

Fixed in 799f08f. The issue was that the test used vi.fn() at module level but didn't have sequential: true, causing race conditions when running with other concurrent tests. Added sequential: true to ensure the test runs sequentially like other tests that use module-level mocks.

@sapphi-red sapphi-red requested review from hyf0 and removed request for sapphi-red January 26, 2026 05:03
Copy link
Member

hyf0 commented Jan 26, 2026

Merge activity

graphite-app bot pushed a commit that referenced this pull request Jan 26, 2026
## Summary

Implements the feature requested in #7583 (comment)

This PR adds a warning when both the source code and `postBanner` contain shebang lines.

## Changes

- [x] Add `DuplicateShebang` event kind to `EventKind` enum
- [x] Create new `duplicate_shebang.rs` event module
- [x] Update `mod.rs` to export the new event
- [x] Update `constructors.rs` to add constructor for DuplicateShebang
- [x] Modify `post_banner_footer.rs` to detect duplicate shebangs and emit warning
- [x] Add test case for duplicate shebang scenario
- [x] Run tests to verify the implementation - ✅ All tests pass
- [x] Run code review and address feedback
- [x] Address PR review feedback
- [x] Run format and generator
- [x] Fix lint and update CLI snapshot
- [x] Update JS snapshots
- [x] Fix test to run sequentially

## Behavior

When both source code and `postBanner` contain shebang:
- ✅ Original shebang preserved as first line
- ✅ postBanner placed after shebang (per PR #7583)
- ✅ Warning emitted: `[DUPLICATE_SHEBANG] Warning: Both the code and postBanner contain shebang in "main.js". This will cause a syntax error.`

## Example

**Input file:**
```javascript
#!/usr/bin/env node
console.log('hello');
```

**postBanner:**
```javascript
#!/usr/bin/env bun
/* Version 1.0.0 */
```

**Output:**
```javascript
#!/usr/bin/env node
#!/usr/bin/env bun
/* Version 1.0.0 */
console.log('hello');
```

**Warning:**
```
[DUPLICATE_SHEBANG] Warning: Both the code and postBanner contain shebang in "main.js". This will cause a syntax error.
```

<!-- START COPILOT CODING AGENT TIPS -->
---

💬 We'd love your input! Share your thoughts on Copilot coding agent in our [2 minute survey](https://gh.io/copilot-coding-agent-survey).
@graphite-app graphite-app bot force-pushed the copilot/implement-dynamic-scroll-feature branch from 799f08f to d3da657 Compare January 26, 2026 08:24
## Summary

Implements the feature requested in #7583 (comment)

This PR adds a warning when both the source code and `postBanner` contain shebang lines.

## Changes

- [x] Add `DuplicateShebang` event kind to `EventKind` enum
- [x] Create new `duplicate_shebang.rs` event module
- [x] Update `mod.rs` to export the new event
- [x] Update `constructors.rs` to add constructor for DuplicateShebang
- [x] Modify `post_banner_footer.rs` to detect duplicate shebangs and emit warning
- [x] Add test case for duplicate shebang scenario
- [x] Run tests to verify the implementation - ✅ All tests pass
- [x] Run code review and address feedback
- [x] Address PR review feedback
- [x] Run format and generator
- [x] Fix lint and update CLI snapshot
- [x] Update JS snapshots
- [x] Fix test to run sequentially

## Behavior

When both source code and `postBanner` contain shebang:
- ✅ Original shebang preserved as first line
- ✅ postBanner placed after shebang (per PR #7583)
- ✅ Warning emitted: `[DUPLICATE_SHEBANG] Warning: Both the code and postBanner contain shebang in "main.js". This will cause a syntax error.`

## Example

**Input file:**
```javascript
#!/usr/bin/env node
console.log('hello');
```

**postBanner:**
```javascript
#!/usr/bin/env bun
/* Version 1.0.0 */
```

**Output:**
```javascript
#!/usr/bin/env node
#!/usr/bin/env bun
/* Version 1.0.0 */
console.log('hello');
```

**Warning:**
```
[DUPLICATE_SHEBANG] Warning: Both the code and postBanner contain shebang in "main.js". This will cause a syntax error.
```

<!-- START COPILOT CODING AGENT TIPS -->
---

💬 We'd love your input! Share your thoughts on Copilot coding agent in our [2 minute survey](https://gh.io/copilot-coding-agent-survey).
@graphite-app graphite-app bot force-pushed the copilot/implement-dynamic-scroll-feature branch from d3da657 to 66c2f5a Compare January 26, 2026 08:32
@graphite-app graphite-app bot merged commit 66c2f5a into main Jan 26, 2026
34 checks passed
@graphite-app graphite-app bot deleted the copilot/implement-dynamic-scroll-feature branch January 26, 2026 08:45
This was referenced Jan 28, 2026
shulaoda added a commit that referenced this pull request Jan 28, 2026
## [1.0.0-rc.2] - 2026-01-28

⚡ Lazy Barrel Optimization

- Skips compilation of unused re-export modules in side-effect-free barrel modules
- Particularly beneficial for projects importing from large component libraries

For large component libraries like Ant Design, when you import just one component:

```js
import { Button } from 'antd';
Button;
```

| Metric                    | Without lazy barrel | With lazy barrel |
| -------------------- | --------------------- | ---------------- |
| Modules compiled | 2986                       | 250              |
| Build time               | ~210ms                  | ~50ms            |

By enabling lazy barrel, Rolldown reduces the number of compiled modules by 90% and speeds up the build by 2-4x. 

Enable it in your config:

```js
export default {
  experimental: {
    lazyBarrel: true,
  },
};
```

For more details, see the https://rolldown.rs/in-depth/lazy-barrel-optimization

### 💥 BREAKING CHANGES

- expose `\0rolldown/runtime` in transform hook (#8068) by @hyf0
- rename `rolldown:runtime` to `\0rolldown/runtime.js` (#8067) by @hyf0

### 🚀 Features

- remove inlined constants in smart mode (#8085) by @sapphi-red
- allow more options for `this.emitFile` with `type: 'prebuilt-chunk'` (#8062) by @sapphi-red
- warn when both code and postBanner contain shebang (#8039) by @Copilot

### 🐛 Bug Fixes

- update the links to Rolldown docs in the error messages (#8103) by @sapphi-red
- handle tsconfig.json load errors (#8105) by @sapphi-red
- include inlined constants in namespace object (#8099) by @sapphi-red
- vite test ci (#8084) by @IWANABETHATGUY
- renamer: nested binding shadowing external module namespace in UMD/IIFE formats (#8083) by @Dunqing
- deduplicate ESM chunk imports by canonical symbol (#8059) by @IWANABETHATGUY
- refine side-effect detection for BigInt and RegExp (#8060) by @IWANABETHATGUY
- rust: use string literal span for `new URL` error diagnostic (#8043) by @valadaptive
- rust: use ModuleType::Asset for `new URL` imports (#8035) by @valadaptive
- CJS-ESM interop - property assignment on CJS module exports (#8006) by @IWANABETHATGUY
- eliminate the facade chunk if the dynamic entry module has been merged into common chunk (#8046) by @IWANABETHATGUY
- Inlining dynamic imports broken with multiple entry points (#8037) by @IWANABETHATGUY
- devtools: revert `Chunk#id` to `Chunk#chunk_id` (#8040) by @hyf0
- invert `__exportAll` parameter logic to reduce default output size (#8036) by @Copilot
- `</script` tag search should be case insensitive (#8033) by @IWANABETHATGUY
- use directory name as-is for the variable name even if the name contained `.` (#8029) by @Copilot
- dev/lazy: remove unnecessary rewrite from top level `this` to `undefined` (#8020) by @hyf0
- dev/lazy: should keep lazy entries imports for patch file (#8019) by @hyf0
- `output.generatedCode.preset: 'es2015'` was not set by default (#8026) by @sapphi-red
- node: align option validator to types (#8023) by @sapphi-red
- node: allow `output.strictExecutionOrder` by the option validator (#8022) by @sapphi-red
- types: return `this` from on / off methods of `RolldownWatcher` (#8015) by @sapphi-red

### 🚜 Refactor

- rolldown_plugin_vite_dynamic_import_vars: remove v1 implementation (#8096) by @shulaoda
- rolldown_plugin_vite_import_glob: remove v1 implementation (#8095) by @shulaoda
- lazy-barrel: restructure lazy barrel implementation (#8070) by @shulaoda
- remove `use_built_ins` and `use_spread` from internal JSX options (#8079) by @sapphi-red
- remove `experimental.transformHiresSourcemap` (#8055) by @Copilot
- rust: use `is_data_url` more consistently (#8042) by @valadaptive
- use `FxIndexMap` to store EntryPoint (#8032) by @IWANABETHATGUY
- node: add type checks that ensures validator schema is up to date with types (#8024) by @sapphi-red

### 📚 Documentation

- link to vite plugin registry (#8086) by @sapphi-red
- lazy-barrel: improve documentation and enable in sidebar (#8072) by @shulaoda
- add more examples and details (#8054) by @sapphi-red
- in-depth: add dead code elimination page (#8007) by @sapphi-red
- update status from beta to release candidate (#8012) by @shulaoda

### ⚡ Performance

- run inline-const pass for modules that are affected by inlining (#8064) by @sapphi-red

### 🧪 Testing

- lazy-barrel: use package.json sideEffects instead of plugin hook (#8077) by @shulaoda
- lazy-barrel: enable tests and add treeshake-behavior cases (#8071) by @shulaoda

### ⚙️ Miscellaneous Tasks

- deps: update crate-ci/typos action to v1.42.3 (#8087) by @renovate[bot]
- deps: update rollup submodule for tests to v4.56.0 (#8073) by @sapphi-red
- deps: update oxc to v0.111.0 (#8063) by @renovate[bot]
- deps: update dependency rolldown-plugin-dts to v0.21.6 (#8076) by @renovate[bot]
- deps: update test262 submodule for tests (#8074) by @sapphi-red
- deps: update crate-ci/typos action to v1.42.2 (#8069) by @renovate[bot]
- deps: update oxc apps (#8066) by @renovate[bot]
- remove `{@include ./foo.md}` from d.ts files (#8056) by @sapphi-red
- deps: update dependency oxlint-tsgolint to v0.11.2 (#8057) by @renovate[bot]
- deps: update github-actions (#8050) by @renovate[bot]
- deps: update npm packages (#8051) by @renovate[bot]
- deps: update rust crates (#8049) by @renovate[bot]
- debug: add IdxExt debug trait for human-readable index debugging (#8045) by @IWANABETHATGUY
- deps: update dependency rolldown-plugin-dts to v0.21.5 (#8034) by @renovate[bot]
- deps: update oxc resolver to v11.16.4 (#8031) by @renovate[bot]
- deps: update dependency rolldown-plugin-dts to v0.21.4 (#8030) by @renovate[bot]
- deps: update dependency rust to v1.93.0 (#8018) by @renovate[bot]
- archive 2025 beta changelog (#8014) by @shulaoda
- update release workflow version pattern from beta to rc (#8013) by @shulaoda

### ❤️ New Contributors

* @valadaptive made their first contribution in [#8043](#8043)

Co-authored-by: shulaoda <165626830+shulaoda@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants