Skip to content
This repository was archived by the owner on Jul 2, 2021. It is now read-only.

Conversation

@nodkz
Copy link

@nodkz nodkz commented May 29, 2017

Describe classes via flow-typed is too lazy and it may stale with time.
The moreover types are already in the code. So let export them, like it done in graphql-js.
Related: graphql/graphql-js#412

…annotations

Describe classes via `flow-typed` is too lazy and it may stale with time. 
The moreover types are already in the code. So let export them, like it done in `graphql-js`.
Related: graphql/graphql-js#412
@zpao
Copy link
Contributor

zpao commented May 31, 2017

It's unfortunately not as simple as that here. Because these files are using @providesModule the type references will end pointing at non-existent modules when compiled (eg https://github.com/facebook/emitter/blob/master/src/BaseEventEmitter.js#L20). We have tooling around all of this in fbjs-scripts to get around that problem - you can see some of that in use in https://github.com/facebook/draft-js/blob/master/gulpfile.js or fbjs itself https://github.com/facebook/fbjs/blob/master/packages/fbjs/gulpfile.js.

Want to give that a shot? It's definitely more involved but perhaps worth it.

FWIW, this library has changed very little in the last couple years so I think there's little risk of it going too stale on flow-typed :)

@nodkz
Copy link
Author

nodkz commented Jun 1, 2017

@zpao I tried to do it like in draft-js. But got following error:

ReferenceError: [BABEL] /Users/nod/www/_sandbox/emitter/src/BaseEventEmitter.js: Unknown option: direct.presets
    at Logger.error (/Users/nod/www/_sandbox/emitter/node_modules/babel-core/lib/transformation/file/logger.js:58:11)
    at OptionManager.mergeOptions (/Users/nod/www/_sandbox/emitter/node_modules/babel-core/lib/transformation/file/options/option-manager.js:126:29)
    at OptionManager.init (/Users/nod/www/_sandbox/emitter/node_modules/babel-core/lib/transformation/file/options/option-manager.js:216:10)
var rename = require('gulp-rename');
var moduleMapFile = require('fbjs/module-map');
var fbjsConfigurePreset = require('babel-preset-fbjs/configure');

gulp.task('flow', function() {
  return gulp
    .src(paths.src)
    .pipe(babel({
      presets: [
        fbjsConfigurePreset({
          // autoImport: false,
          target: 'flow',
          rewriteModules: {map: moduleMapFile},
        }),
      ],
    }))
    .pipe(flatten())
    .pipe(rename({extname: '.js.flow'}))
    .pipe(gulp.dest(paths.lib));
});

It requires too much time for this trivial task from me. Too much unknowns 🤗 Even I'm not sure npm install correct packages or not without yarn.lock.
Anyway, without better knowledge of your build process, I'll waste my time.
Can you do it yourself? It will be a good lesson for me.

@zpao
Copy link
Contributor

zpao commented Jun 1, 2017 via email

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants