systemjs / plugin-babel

SystemJS Babel Plugin
MIT License
82 stars 33 forks source link

0.0.10: Crash with custom babel-plugin #36

Closed benbender closed 8 years ago

benbender commented 8 years ago

I'm running a react/relay/graphql-app powered by jspm. Until 0.0.9 I could use a custom loader to load the graphql-schema into relay. After the update in the morning the app simply hangs without any error when I'm trying to load a custom babel-plugin.

It doesn't seem to be specific to my usecase. I've build a testcase where I was trying to load the code of "babel-plugin-transform-react-jsx" as a custom plugin with the same result. The same code runs flawless when it's loaded via package.

My config:

SystemJS.config({
  transpiler: 'plugin-babel',
  packages: {
    'app': {
      'main': 'main.js',
      'meta': {
        '*.js': {
          'loader': 'plugin-babel',
          'babelOptions': {
            'stage1': true,
            'passPerPreset': true,
            'plugins': [
              'babel-plugin-transform-react-jsx',
              'babel-plugin-transform-class-properties',
              'babel-relay-plugin-jspm',
            ],
          },
        },
      },
    },
  },
  map: {
    'babel-relay-plugin-jspm': 'src/utils/babelRelayPlugin.js',
  },
});

Content of babelRelayPlugin.js:

var getbabelRelayPlugin = require('babel-relay-plugin');

var schema = require('../src/data/schema.json!');

module.exports = getbabelRelayPlugin(schema.data);

For me it simply stops to load files in the browser. No error-message :(

Any ideas?

benbender commented 8 years ago

I have to correct mysqlf - it's not 0.0.10-specific. Even if I go back to 0.0.9, I have the same issue.

I digged a little bit and found out, that Promise.all(pluginAndPresetModuleLoads) never resolves in 0.0.9/0.0.10 when I try to load a custom babel-plugin (even if there is only a console.log()-statement in it). Yesterday it was working and I have no clou what else has changed. Any help is appreciated!

guybedford commented 8 years ago

Usually these types of stalling issues are due to inadvertant circular references - eg installing a plugin to use with Babel, that itself is being compiled with Babel. If your src folder is set to compile through Babel then that is exactly the problem.

benbender commented 8 years ago

Thank you - you are right! I didn't thought about the path which I changed yesterday. Maybe this kind of issue (using es6-features in custom-plugins/presets and/or the position of the file) would be worth a note in the readme.

Please close the issue!