import YAML file, RollupError: 'Legacy octal escape is not permitted in strict mode'
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 48/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Quiet
- Tech stack
- javascript, yaml
- Domain
- build-system
Research direction
Start with the StackBlitz reproduction and inspect /tosource/src/tosource.ts, especially legalKey, to determine how the quoted YAML key becomes the generated object key. Confirm the generated JavaScript is accepted by Rollup in strict mode and that the imported key remains "01" without the legacy-octal error.
Written by the indexing model from the issue text.
Description
- Rollup Plugin Name: @rollup/plugin-yaml
- Rollup Plugin Version: 4.1.2
- Rollup Version: 4.60.1
- Operating System (or Browser): ubuntu 22.04
- Node Version: 24.14.0
- Link to reproduction: https://stackblitz.com/edit/rollup-repro-arqohgva
Expected Behavior
No errors occur.
Actual Behavior
[!] RollupError: src/data.yaml (1:13): Legacy octal escape is not permitted in strict mode (Note that you need plugins to import files that are not JavaScript)
src/data.yaml (1:13)
1: var data = { 01:"any value" };
^
2:
3: export default data;
Additional Information
I enclose key in quotes to indicate string.
On JS-YAML online demo, converted correctly.
input
# Enclose key in quotes to indicate string
'01': any value
output
{ '01': 'any value' }
Is this problem with tosource, not @rollup/plugin-yaml?
Is this problem in this code?
/tosource/src/tosource.ts
function legalKey(key: string) {
return (
- /^([a-z_$][0-9a-z_$]*|[0-9]+)$/gi.test(key) && !KEYWORD_REGEXP.test(key)
+ /^([a-z_$][0-9a-z_$]*|0|[1-9][0-9]*)$/gi.test(key) && !KEYWORD_REGEXP.test(key) // Like this?
);
}
- Dominant language
- JavaScript
- Stars
- 3.8k
- Forks
- 635
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from rollup/plugins
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 4/5 3-5 days Newbie friendliness 52/100
-
Difficulty 3/5 1-2 days Newbie friendliness 48/100
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
-
Support js-yaml v5 Open
Difficulty 4/5 3-5 days Newbie friendliness 45/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
HarperFast/skills#96 ·
-
[Block] Latest Posts [Type] Bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Automattic/studio#4908 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
sugarlabs/musicblocks#8847 ·