observablehq / feedback

Customer submitted bugs and feature requests
42 stars 3 forks source link

Compiled code drops leading/following comments #359

Open mootari opened 2 years ago

mootari commented 2 years ago

Describe the bug

If a cell contains comments before the first statement or after the last, then these comments are not included in the exported module. This poses a problem, as it means that inlined attribution might get dropped. This behavior is not intuitive and may cause authors to involuntarily violate licenses of copied code.

Expected behavior

Given a cell:

// Comment before
foo = "bar"
// Comment after

the compiled code should read:

  main.variable(observer("foo")).define("foo", function(){return(
// Comment before
"bar"
// Comment after
)});
mootari commented 2 years ago

It also becomes impossible to properly use JSDoc style inline documentation, as leading docblocks are dropped. In order to access them, one would have to fetch the raw cell contents from Observable's internal API.