plugins icon indicating copy to clipboard operation
plugins copied to clipboard

[ [email protected]] use dataToEsm from pluginutils

Open shaoahs opened this issue 3 years ago • 3 comments

  • Rollup Plugin Name: plugin-yaml
  • Rollup Plugin Version: 4.0.1

Expected Behavior / Situation

yaml

---
'1': a
'01': b
'001': c
'0001': d


convert to javascript

{ 
  '1': 'a',
  '01': 'b',
  '001': 'c',
  '0001': 'd'
}

example: http://nodeca.github.io/js-yaml/#yaml=LS0tCicxJzogYQonMDEnOiBiCicwMDEnOiBjCicwMDAxJzogZAo=

Actual Behavior / Situation

yaml

---
'1': a
'01': b
'001': c
'0001': d


convert to javascript

[!] RollupError: Invalid number (Note that you need plugins to import files that are not JavaScript)

Modification Proposal

use dataToEsm

import YAML from 'js-yaml';
// remove toSource
// import toSource from 'tosource';

// use dataToEsm
import { createFilter, makeLegalIdentifier, dataToEsm } from '@rollup/pluginutils';

   let code = dataToEsm(data, {
       preferConst: false,
       compact: false,
       namedExports: true,
       indent: '  '
     });

shaoahs avatar Jan 30 '23 07:01 shaoahs

Why should we do this?

shellscape avatar Jan 30 '23 12:01 shellscape

I rewrite question. map key is string . tosource and dataToEsm has different result. yaml example http://nodeca.github.io/js-yaml/#yaml=LS0tCicxJzogYQonMDEnOiBiCicwMDEnOiBjCicwMDAxJzogZAo=

shaoahs avatar Jan 31 '23 02:01 shaoahs

Hey folks. This issue hasn't received any traction for 60 days, so we're going to close this for housekeeping. If this is still an ongoing issue, please do consider contributing a Pull Request to resolve it. Further discussion is always welcome even with the issue closed. If anything actionable is posted in the comments, we'll consider reopening it. ⓘ

stale[bot] avatar Apr 26 '23 00:04 stale[bot]