Skip to content

When entry file has a shebang, output it in the first line of the bundle #2381

Description

@cprecioso

🙋 feature request

In UNIX systems, the first line of a script can be a shebang with the path to the interpreter. When the main entry file has this shebang (and optionally when target: node), this shebang line could be taken out of the bundled modules and outputted in the first line of the bundle.

🤔 Expected Behavior

hello-world.js:

#!/usr/bin/env node

console.log("Hello, world!");
$ parcel build -t node hello-world.js

dist/hello-world.js:

#!/usr/bin/env node

// parcel bundle prologue ...function(require,module,exports) {
console.log("Hello, world!");
// }... parcel bundle epilogue

😯 Current Behavior

dist/hello-world.js:

// parcel bundle prologue ...function(require,module,exports) {
#!/usr/bin/env node
console.log("Hello, world!");
// }... parcel bundle epilogue

(which is actually a SyntaxError)

🔦 Context

I run into this when trying to make executable scripts for node which have all their files already bundled.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions