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

Browserify the code? #13

Closed
orels1 opened this issue May 11, 2017 · 11 comments
Closed

Browserify the code? #13

orels1 opened this issue May 11, 2017 · 11 comments
Milestone

Comments

@orels1
Copy link

orels1 commented May 11, 2017

First of all - thanks for a great tool, which will come in handy many times for smaller projects (like landing pages and so on.

But I really wish that you would browserify the code, so I could import React from 'react' for example.

If I'm doing something wrong - it'll be cool to know

@davej
Copy link
Member

davej commented May 11, 2017

I want to keep it super simple for the moment. As bugs are ironed out and 1.0 is released, I'll start exploring if there's a simple way to support modules. Thanks for your feedback! :)

@mtimofiiv
Copy link

+1 on this feature request - would be fantastic.

Currently, I really love this project, but I can't use it anywhere except the simplest landing pages.

@davej davej added this to the post-v1.0 milestone Jun 22, 2017
@davej
Copy link
Member

davej commented Jun 22, 2017

Noted.

I've given this a post-v1.0 milestone tag. I'll reopen and re-investigate once 1.0 is released. For now, I'm keeping any issue that is post 1.0 closed.

@Daidalos117
Copy link

And what is the easiest ways to make it work? Thank you.

@mtimofiiv
Copy link

@Daidalos117 I suppose integrating browserify into the module would be easiest.

@lunelson
Copy link

lunelson commented Oct 27, 2017

Another option for those who are just using Pingy as a quick prototyping tool, would be to offer a Javascript option that leverages native ES Modules support in bleeding-edge browsers, by using type="module" on the script tag. It requires enabling a special flag on the browser; but otherwise would 'just work'. You might call it Javascript ESM for example, to differentiate from the straight Javascript option. Implicitly, a lot of ESx features come with it too, without the need for Babel. Or, there may be a configuration of Babel that would transpile ES7+ plus things without transpiling import statements to require calls...

<script type="module" src="module.js"></script>

REF: https://medium.com/dev-channel/es6-modules-in-chrome-canary-m60-ba588dfb8ab7

@lunelson
Copy link

lunelson commented Oct 27, 2017

It seems you can add a modules: false option to the .babelrc file options for babel-preset-env, to disable changing of the module format

EDIT: just tested this, can confirm it works fine in Chrome 61+. The catch is that you cannot leave off the .js extension in import statements, like you can with module bundlers and in Node

@davej
Copy link
Member

davej commented Oct 27, 2017

Thanks @lunelson, that's very helpful.

@lunelson
Copy link

Glad to help. The only snag seems to be that changes to .js files other than the main one don't trigger a livereload event. If you choose to implement these suggestions that would need some kind of patch too.

@davej
Copy link
Member

davej commented Oct 27, 2017

The only snag seems to be that changes to .js files other than the main one don't trigger a livereload event.

Ah, I'll consider that a bug and create an issue for it. Thanks!

@davej
Copy link
Member

davej commented Oct 29, 2017

@lunelson: As of v0.9.5, Live reload should now work with type="module" scripts and it's descendant modules.

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

5 participants