nativew / esbuild-plugin-babel

Babel plugin for esbuild.
ISC License
72 stars 14 forks source link

Return `contents` if `babelOptions` do not exist #3

Closed schloerke closed 3 years ago

schloerke commented 3 years ago

When setting ignore field in babel.config.json, ex:

  "ignore":[
    "node_modules/core-js"
  ]

, the babelOptions for the ignored files is null. This causes a failure when trying to retrieve babelOptions.sourceMaps. Ex:

 > src/index.ts: error: [babel] Cannot read property 'sourceMaps' of null
    6 │ import "core-js/modules/es.array.join.js";

Since the options are null, I interpreted that as no transformations should be performed. So I preemptively return the contents before setting up the processing Promise.


Other packages installed that might be related to my original error.

    "@babel/core": "^7.12.17",
    "@babel/preset-env": "^7.12.17",
    "@babel/preset-typescript": "^7.12.17",
    "@babel/runtime": "^7.12.18",
hum-n commented 3 years ago

Good point. Thanks.