Skip to content

using CoffeeScript.compile in client with webpack #4277

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

Closed
Radivarig opened this issue Jul 1, 2016 · 6 comments
Closed

using CoffeeScript.compile in client with webpack #4277

Radivarig opened this issue Jul 1, 2016 · 6 comments
Labels

Comments

@Radivarig
Copy link

I am trying to use CoffeeScript.compile ("code") in browser but including the coffee-script library with webpack results in errors and warnings posted here #4276. The loader is not an option, because I don't have the code in advance.

There are two versions of coffee-script-min.js:

  • one is bigger size 160kb which I have locally (downloaded ~1year ago) and is not available on CDN. Including this file gives no errors and I'm currently using it, but would like to avoid adding it to source and to be able to update it above 1.9.3.
  • the other is the one hosted on CDN, and is 6kb. Including this one locally results in the same errors as using the coffee-script module with webpack.

That is why I am asking it here to get developers attention because I doubt that other users will have an idea on how the build was packaged.

I am kindly asking not to be referred to "google it" because it is insulting and serves no purpose. If you don't know how to solve this please do not comment or close, just pass it and let someone else take a look.

@vendethiel
Copy link
Collaborator

Please ask questions on StackOverflow or the google groups.

@akfish
Copy link
Contributor

akfish commented Apr 13, 2017

Running into the same issue here while trying to consume the compiler API in browser.
IMHO this should be a valid feature rather a google-it-yourself-and-hack-it-together thing.

@GeoffreyBooth
Copy link
Collaborator

Use the browser compiler:

<script src="http://coffeescript.org/v1/browser-compiler/coffee-script.js"></script>

@akfish
Copy link
Contributor

akfish commented Apr 13, 2017

@GeoffreyBooth Thanks for the information. I'm aware of the browser-compiler build.

However I believe the issue is about consuming CoffeeScript compiler with modern toolchain like webpack, which won't take more than a browser specific entry script and a "browser" field in package.json. Babel compiler, for example, supports webpack just fine.

Anyway, I'm using a custom fork for my project with compiler API exposed for webpack.

Just npm install --save github:akfish/coffeescript#webpack.

@GeoffreyBooth
Copy link
Collaborator

This has come up a few times before, so I’d rather solve it in the main repo than ask people to use forks that can get out of date. But I’m not sure exactly what the ask is, without an example that demonstrates what you’re trying to do.

@akfish
Copy link
Contributor

akfish commented Apr 14, 2017

@GeoffreyBooth From time to time, people will want to pack the CoffeeScript source directly into his bundle with webpack, rather than using the prebuilt one. The expectations is to simply require or import coffee-script and webpack will do the rest.

But the problem is that coffee-script didn't provide a browser field in package.json pointing to a browser-specific entry script. And the main script references node specific modules. Hence it won't work.

It would be ideal to solve this problem in main repo. My fork was too specific to send a PR. I'll send a proper one later.

@akfish akfish mentioned this issue Apr 14, 2017
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants