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

Support for external deps #27

Open
xtuc opened this issue Aug 14, 2017 · 7 comments · May be fixed by #37
Open

Support for external deps #27

xtuc opened this issue Aug 14, 2017 · 7 comments · May be fixed by #37

Comments

@xtuc
Copy link
Collaborator

xtuc commented Aug 14, 2017

Following the discussion from babel/website#1302.

It would be great to allow externals for both Browserify and Rollup. What do you think @Rich-Harris?

PS: i'm working on it

@xtuc
Copy link
Collaborator Author

xtuc commented Aug 14, 2017

Imagine I want to dedupe babel-types (babel-plugin-ivi-jsx is requiring it):

<script type="text/javascript" src="http://localhost:9000/babel-types"></script>
<script type="text/javascript" src="http://localhost:9000/babel-plugin-ivi-jsx"></script>

When I declare babel-types as an external dependency, browserify fails at runtime with Cannot find module 'babel-types'. In the page babel-types is a available as window.babelTypes. I don't know how to tell browserify to use it.

Maybe we could generate a fake package called babel-types somehow which just contains a alias statement: module.exports = window.babelTypes but sounds hacky and fragile.

Do you have an idea?

@Daniel15
Copy link

Daniel15 commented Aug 14, 2017

What about allowing externals to be passed as querystring parameters? For example /babel-plugin-ivi-jsx?externals[babel-types]=babelTypes could do the equivalent of doing this in a Webpack config:

externals: {
  'babel-types': 'babelTypes',
}

@xtuc
Copy link
Collaborator Author

xtuc commented Aug 14, 2017

Yeah, configuration is only possible through query parameters (because of the CDN).

I planned something like this: /babel-plugin-ivi-jsx?externals=babel-types,babel-core.

I don't get how browserify is working with externals, they are not passed as arguments as with Rollup. Maybe @Rich-Harris could help us here.

@Rich-Harris
Copy link
Owner

This seems like a good. Afraid I have no idea how to make it work with Browserify! 😬

@ceremcem
Copy link

Our project is using browserify, you may want to take a look at the gulpfile. My two cents...

@xtuc
Copy link
Collaborator Author

xtuc commented Dec 25, 2017

We need this for the Babel REPL. Since Browserify is only used as a fallback, I think it's fine to support externals only when you bundle with Rollup (and your module supports it).

@xtuc xtuc linked a pull request Dec 26, 2017 that will close this issue
@xtuc
Copy link
Collaborator Author

xtuc commented Dec 26, 2017

Well now we have a PR #37 but I don't get it, it can't work. If someone has the time to look at it 🙏

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

Successfully merging a pull request may close this issue.

4 participants