jhildenbiddle / css-vars-ponyfill

Client-side support for CSS custom properties (aka "CSS variables") in legacy and modern browsers
https://jhildenbiddle.github.io/css-vars-ponyfill
MIT License
1.46k stars 64 forks source link

v2.4.4 no longer transpiles to pure ECMAScript 5 #158

Closed vvanpo closed 3 years ago

vvanpo commented 3 years ago

In my project I use es-check to verify that my bundles are properly transpiled down to ES5, as I don't run all node_modules dependencies through Babel. After upgrading from 2.4.3 to 2.4.4, this check failed.

Example:

$ cd /tmp
$ npm i css-vars-ponyfill@2.4.3
$ npx es-check es5 node_modules/css-vars-ponyfill/dist/css-vars-ponyfill.min.js
ES-Check: there were no ES version matching errors!  🎉 
$ npm i css-vars-ponyfill@2.4.4
$ npx es-check es5 node_modules/css-vars-ponyfill/dist/css-vars-ponyfill.min.js
ES-Check: there were 1 ES version matching errors.

          ES-Check Error:
          ----
          · erroring file: node_modules/css-vars-ponyfill/dist/css-vars-ponyfill.min.js
          · error: SyntaxError: The keyword 'const' is reserved (8:5130)
          · see the printed err.stack below for context
          ----

          SyntaxError: The keyword 'const' is reserved (8:5130)

I assume that the dist/css-vars-ponyfill.min.js is intended to be referenced by a <script> tag within IE9, so I would expect the bundle to pass all ES5 checks.

jhildenbiddle commented 3 years ago

Thanks, @vvanpo. Fixed in 2.4.5.

FWIW, the issue was caused by upgrading balanced-match to v2.0.0. The new version does not contain a pre-built ES5 distributable, and my babel configuration is set to exclude files in /node_modules/. The end result was balanced-match v2.0.0 was being included as-is (i.e., no transpilation).

I have added es-check to the build process to prevent this from happening in the future.