-
Notifications
You must be signed in to change notification settings - Fork 74
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
Support External Require #60
Comments
I think I've just tripped up on the same issue. I've got a project that uses Babel / Browserify at present. I'm trying to migrate a few pieces over to TypeScript in a piecemeal fashion. tsify seems to be doing just fine apart from when it comes to 3rd party typings. Talk is cheap, show me the code. Here's an excerpt from the browerify + tsify gulp build step: var src = './src/main.js';
var dependencies = ['react', 'react-router', 'flux','events','babel/polyfill'];
var appBundler = browserify({
entries: [src],
transform: [babelify.configure({ sourceMaps: false, stage: 3 })],
debug: options.isDevelopment,
cache: {}, packageCache: {}, fullPaths: options.isDevelopment
})
.external(dependencies)
.plugin('tsify'); This works great apart from when it comes to require-ing 3rd party typings. Consider the start of
The above code requires the protobufjs typing. When using atom-typescript for text editing this is resolved quite happily using the typing specified in
Is this an error in my usage of tsify? Have I failed to point it to the correct place to find the typings? I have a
In case it helps, I'm using tsd for pulling in typings from DefinitelyTyped and my
|
I think (I'm not sure) that this problem might be related to PR #32. The |
@giggio Thanks for the report, I'll take a look. @johnnyreilly Let me see if I get the dependency graph of your case:
If that's the case, then what you're missing here is to add |
So |
@giggio Reproduced... I think I'm going to have to delve into the guts of |
This appears to be a bug in |
Okay, this is definitely a Browserify bug. Exposing a file causes transforms not to run against it, unless the exposed name is different from the filename. This is described in browserify/browserify#1077, and further discussed in browserify/browserify#1131. A workaround would be to do something like:
If that won't work for you, then you can open an issue on Browserify and/or module-deps. |
Worked a dream once I updated to the latest version of tsify and the associated typings. Thanks! |
@johnnyreilly As far as I can tell I have an issue similar to the one you described at the top of the thread. I'm not so sure about what I'm doing though, and in particular am not sure what to do with smrq's workaround. Where did you put that in your project? I want mine to work like a dream too! |
If anyone is using browserify-shim and has this problem in the future, adding var browserify = require('browserify')
var files = ['./src/index.tsx', './src/other/index.ts']
browserify({
entries: files,
extension: ['js', 'ts', 'tsx'],
external: ['angular', 'jquery', 'lodash', 'moment', 'react', 'react-dom', 'rx'],
noParse: []
})
.plugin('tsify')
.transform('browserify-shim', {
global: true
})
.bundle()
.on('error', error => console.error(error.toString()))
.on('log', msg => console.info(msg))
.pipe(process.stdout) |
@frankkoenigstein What makes you think it's related to this particular issue? Yours is the only comment that mentions Karma. Is it the error message?
You'll see that whenever Browserify encounters ES6 content. Could you please open a separate issue and include complete version information for the packages (Angular, Browserify, Tsify, etc.) that you are using? |
As defined in:
https://github.com/substack/node-browserify#external-requires
Using
.require(
as defined in https://github.com/substack/node-browserify#brequirefile-opts throws, it seems that the file is not being compiled before passed to browserify.The text was updated successfully, but these errors were encountered: