Skip to content

@@directive should be emitted on the first line, above header comment #6170

Closed
@aspeddro

Description

@aspeddro

ReScript: 10.1.4 and 11.0.0-alpha.3

One use case: emit shebang on first line. Node throws a syntax error. Apparently shebang should be on the first line.

@@directive("#!/usr/bin/env node;");

Js.log("Hello")

Compiled:

// Generated by ReScript, PLEASE EDIT WITH CARE
#!/usr/bin/env node;


console.log("Hello");

export {
  
}
/*  Not a pure module */
node src/directive.bs.mjs
file:///home/pedro/Desktop/learning-rescript/src/directive.b
s.mjs:2
#!/usr/bin/env node;
^

SyntaxError: Invalid or unexpected token
    at ESMLoader.moduleStrategy (node:internal/modules/esm/t
ranslators:119:18)
    at ESMLoader.moduleProvider (node:internal/modules/esm/l
oader:468:14)
    at async link (node:internal/modules/esm/module_job:67:2
1)

Thank you for filing! Check list:

  • Is it a bug? Usage questions should often be asked in the forum instead.
  • Concise, focused, friendly issue title & description.
  • A minimal, reproducible example.
  • OS and browser versions, if relevant.
  • Is it already fixed in master? Instructions

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions