Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

babel-plugin-transform-flow-strip-types includes imported flow types #152

Closed
mhagmajer opened this issue Nov 16, 2015 · 3 comments
Closed

Comments

@mhagmajer
Copy link

Flow allows referencing types from other file with a syntax similar to ES6 imports: http://flowtype.org/blog/2015/02/18/Import-Types.html. These types (just like any other flow declarations) have no effect on runtime.

However, it seems like babelify doesn't prevent browserify from fetching and including modules referenced in this way. Expected behaviour would be to ignore import type statements.

$ echo "import type {Type1} from 'my-lib'" | ./node_modules/.bin/browserify -t [ babelify --plugins [ transform-flow-strip-types ] ] -
Error: Cannot find module 'my-lib' from '/my-project'
    at /my-project/node_modules/browserify/node_modules/resolve/lib/async.js:46:17
    at process (/my-project/node_modules/browserify/node_modules/resolve/lib/async.js:173:43)
    at ondir (/my-project/node_modules/browserify/node_modules/resolve/lib/async.js:188:17)
    at load (/my-project/node_modules/browserify/node_modules/resolve/lib/async.js:69:43)
    at onex (/my-project/node_modules/browserify/node_modules/resolve/lib/async.js:92:31)
    at /my-project/node_modules/browserify/node_modules/resolve/lib/async.js:22:47
    at FSReqWrap.oncomplete (fs.js:82:15)

Tested with latest versions:

  "devDependencies": {
    "babel-plugin-transform-flow-strip-types": "^6.1.18",
    "babelify": "^7.2.0",
    "browserify": "^12.0.1",
@zertosh
Copy link
Member

zertosh commented Nov 16, 2015

Works for me https://gist.github.com/zertosh/5a08b2eedb46c602550c. I think something is broken in browserify 12.0 with reading from stdin - but that's independent of babelify.

@mhagmajer
Copy link
Author

@zertosh, thanks for your response!

I omitted the bug when minifying my example. Please try

./node_modules/.bin/browserify -t [ babelify --presets [ es2015 react ] ] entry.js

with latest versions as well

    "babel-preset-es2015": "^6.1.18",
    "babel-preset-react": "^6.1.18",

@zertosh
Copy link
Member

zertosh commented Nov 16, 2015

This is a babel issue. babel/babel#3084 (comment)

@zertosh zertosh closed this as completed Nov 16, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants