Skip to content

The value of a --custom-header is not placed in the begining of the file [BUG] #1441

@modlfo

Description

@modlfo

Describe the bug

The value passed using the --custom-header is not placed in the beginning of the file. For example:

js_of_ocaml --custom-header="#!/usr/bin/env node" main.bc

This produces the following code where the header is in the third line

// Generated by js_of_ocaml
//# buildInfo:effects=false, kind=exe, use-js-string=true, version=5.1.1
#!/usr/bin/env node
(function(a){typeof .......

Expected behavior
That the first line of the file is the header and any other text comes after.

#!/usr/bin/env node
// Generated by js_of_ocaml
//# buildInfo:effects=false, kind=exe, use-js-string=true, version=5.1.1

This produces the following error when running the code:

SyntaxError: Invalid or unexpected token
    at wrapSafe (internal/modules/cjs/loader.js:915:16)
    at Module._compile (internal/modules/cjs/loader.js:963:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
    at Module.load (internal/modules/cjs/loader.js:863:32)
    at Function.Module._load (internal/modules/cjs/loader.js:708:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)
    at internal/main/run_main_module.js:17:47
F/home/leonardo/main.js:3
#!/usr/bin/env node
^

Versions
Version of packages used to reproduce the bug
Ocaml 4.14.0
js_of_ocaml version=5.1.1

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions