vuejs / component-compiler-utils

Lower level utilities for compiling Vue single file components
321 stars 75 forks source link

use JSON.stringify in caching parse results #35

Closed Tidyzq closed 5 years ago

Tidyzq commented 5 years ago

In order to fix issue: https://github.com/vuejs/rollup-plugin-vue/issues/239 The reason is that rollup will manipulate the styles.map.mapping object, which is in https://github.com/rollup/rollup/blob/ea82d134400ecee72e274a02b0e623959e1b36a8/src/utils/transform.ts#L30

if (originalSourcemap && typeof originalSourcemap.mappings === 'string')
    originalSourcemap.mappings = decode(originalSourcemap.mappings);

So we should return a fresh copy by JSON.stringify and JSON.parse when the cache is hit.

znck commented 5 years ago

The output SFC descriptor should be treated immutable. Rollup plugin should create a copy of descriptor rather than manipulating it directly.