Skip to content

Commit

Permalink
fix: πŸ› add bare: true to coffee compiler
Browse files Browse the repository at this point in the history
βœ… Closes: Closes #134
  • Loading branch information
kaisermann committed Apr 21, 2020
1 parent 0c66a2b commit 7d38bfd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,12 @@ input(bind:value="{foo}")
input(on:input="{bar}")
```
### `coffeescript`
#### Safety wrapper
Since `coffeescript` transpiles variables to `var` definitions, it uses a safety mechanism to prevent variables from bleeding to outside contexts. This mechanism consists of wrapping your `coffeescript` code inside an IIFE which, unfortunately, prevents `svelte` from finding your variables. To bypass this behavior, `svelte-preprocess` sets the [`bare` coffeescript compiler option](https://coffeescript.org/#lexical-scope) to `true`.
## FAQ
### My VS Code is displaying a lot of errors on my templates when I try to use `x`...
Expand Down
1 change: 1 addition & 0 deletions src/transformers/coffeescript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const transformer: Transformer<Options.Coffeescript> = ({
const { js: code, sourceMap: map } = coffeescript.compile(content, {
filename,
sourceMap: true,
bare: false,
...options,
});

Expand Down

1 comment on commit 7d38bfd

@rhysallister
Copy link

Choose a reason for hiding this comment

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

bare is set to false, not true. But the text in README.md appears to indicate it should be set to true. Also the the fix says "add bare: true to coffee compiler".

Please sign in to comment.