the-goats / Goat

MIT License
6 stars 1 forks source link

ES6 Babel imports break build if it generates a Babel import #8

Open tmhrtwg opened 4 years ago

tmhrtwg commented 4 years ago

My source file (main.es6.js):

const possibleDirections = {
  top: true,
  right: false,
  bottom: true,
  left: true
}
const directions = Object.entries(possibleDirections)
for (const [direction, isPossible] of directions) {
  console.log(`${direction}, ${[isPossible]}`)
}

The rendered JS file (main.js):

import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
var possibleOptions = {
  top: true,
  right: false,
  bottom: true,
  left: true
};
var options = Object.entries(possibleOptions);

for (var _i = 0, _options = options; _i < _options.length; _i++) {
  var _options$_i = _slicedToArray(_options[_i], 2),
      direction = _options$_i[0],
      truefalse = _options$_i[1];
}

The for..of causes Babel to need an import. This cannot be found and Goat gives an error:


Module not found: Error: Can't resolve '@babel/runtime/helpers/slicedToArray' in '<my path>/src/js'
 @ ./src/js/main.es6.js 1:0-66 12:20-34```
stefspakman commented 3 years ago

This will be fixed in the next release, Rollup is used to resolve imports.