Code Monkey home page Code Monkey logo

coffeeify's Introduction

Hello World

coffeeify's People

Contributors

bobthecow avatar geoffreybooth avatar hongymagic avatar hurrymaplelad avatar jnordberg avatar jtmalinowski avatar juanxo avatar max-degterev avatar thlorenz avatar tomyam1-personal avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

coffeeify's Issues

7.0.0 Breaks rebundles with coffeescript using watchify

As mentioned by @startswithaj in browserify issues, v7.0.0 breaks coffeeify when used with watchify. @startswithaj has well explain the problem: browserify/browserify#1012

Copy of the original issue:

The transform changes introduced in 7.0.0 cause coffee-script compiles to be called on already compiled data when bundle() is called after the initial bundle.

b = browserify
  extensions: ".coffee"
  debug: true
  cache: {}

bundler = watchify b
bundler.transform coffeeify
bundler.add paths.entry
bundler.on 'update', =>
  bundler.source = null
  bundler.bundle (err, src) =>
      bundler.source = src
      reloadJS(clients)

bundler.on 'log', (msg) => 
  console.log msg

# Start browserifying script resources
bundleStream = bundler.bundle (err, src) ->
  if err then console.error "initial browserify bundling error: \n  %s \n  %s %s:%s", err.toString(), err.file, err.location?.first_line, err.location?.first_column, terminalAlertBadge
  bundler.source = src

https://cloud.githubusercontent.com/assets/3658522/5334062/86cd8d20-7ed5-11e4-9767-086e99c9cb1c.png

See data property in scope variables

Source maps broken when using with coffee-script 1.11.*

When using with coffee-script 1.11.0 or 1.11.1 (latest at the time of reporting) this command:

browserify --debug --transform coffeeify --extension .coffee --outfile build/application.js src/index.coffee

produces a bundle with source maps that make Chrome Dev Tools display files with .coffee extensions, but compiled JS content, whit source maps string at the bottom:

screen shot 2016-11-03 at 14 01 34

It might be related to change in lexer and parser announced in the changelog for v. 1.11.0:

Improved the internal representation of a CoffeeScript program. This is only noticeable to tools that use CoffeeScript.tokens or CoffeeScript.nodes. Such tools need to update to take account for changed or added tokens and nodes.

I don't think it's a bug in CS, as the source maps are generated correctly if I do it like that:

coffee -cMo build/js/ src/
browserify --debug --outfile build/application.js build/js/index.js

Upgrade to coffeescript 1.10.0

As a side node, why do we force a coffeescript version in this package ?
We could let it to the developer discretion, shouldn't we ?

Coffeeify sourcemaps have absolute paths to original source

The sourcemaps generated by coffeeify have an absolute path to the original .coffee file, which breaks source loading.

I've made a sample app demonstrating the problem. After checking out:

npm install
npm run bundle

... open index.html in a browser, and look at the javascript sources. Chrome actually will follow the absolute path to bar.coffee, but Firefox will fail to load the source.

The (base64 decoded) sources portion of the sourcemap looks like:

"sources":[
  "../../../../usr/local/lib/node_modules/browserify/node_modules/browser-pack/_prelude.js",
  "app.js",
  "/Users/kingp/Projects/coffeeify_bug_submission/bar.coffee",
  "foo.js"
],

Manually changing the absolute path to just bar.coffee fixes the problem.

'global' is not parsed correctly

Problem: coffeeify causes browserify to generate a SyntaxError when the input file contains global keyword.

To recreate:

$ npm install -g browserify # installs 3.24.11
$ npm install coffeeify # installs 0.6.0
$ echo "console.log(global)" > test.coffee
$ browserify -t coffeeify test.coffee > test.js
SyntaxError: Line 3: Unexpected end of input while parsing /Users/jamesgary/huh/test.coffee

The fact that it detect SyntaxError on line 3 of a one-line file leads me to believe coffeeify/browserify is expanding global prematurely.

global works fine when browserifying .js files, but not .coffee files, which leads me to believe it is an error in coffeeify. Let me know if this issue belongs in node-browserify instead.

Possibly related: browserify/browserify#616

Respect coffee ` (backtick) escaping

When I have a coffee file with escaped JSX code in it

###
  @jsx React.DOM
###

Dropdown = React.createClass
  render: ->
    @transferPropsTo `
      <div class="btn-group">
        <button tabIndex='-1' type='button' class="btn dropdown-toggle"
            data-toggle="dropdown">
          <span class="caret"></span>
        </button>
        <ul class="dropdown-menu">
          {this.props.children}
        </ul>
      </div>`

And I use this grunt task:

    browserify:
      'build/app.js': ['clientapp/dropdown.coffee']
      options:
        transform: ['coffeeify']

I get:

$ grunt browserify
Running "browserify:build/app.js" (browserify) task
Warning: Unexpected token < Use --force to continue.

Aborted due to warnings.

It seems like the backtick escape isn't being acknowledged in the coffeeify transform.

where do I see syntax errors, etc.?

When I have a syntax error I just see undefined in my browser window. The terminal that the beefy server is running in shows nothing. Where do I see syntax errors, etc.? I'm sorry if this is a stupid question.

My command (as the terminal shows it when a request is served) ...

./node_modules/browserify client/app.coffee -d -o bundle.js -t coffeeify --extension .coffee

Source map error

This works fine:
browserify -t coffeeify/no-debug blah.coffee > bundle.js

This does not:
browserify -t coffeeify blah.coffee > bundle.js

blah.coffee:3
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiL2hvbWUvbWF0dC9zcmMvbGZtL3B1YmxpYy92aWV3cy9ibGFoLmNvZmZlZSIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi9ob21lL21hdHQvc3JjL2xmbS9wdWJsaWMvdmlld3MvYmxhaC5jb2ZmZWUiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxDQUFDLEdBQVIsQ0FBWSxvQkFBWixDQUFBLENBQUEiLCJzb3VyY2VzQ29udGVudCI6WyJjb25zb2xlLmxvZyBcInRoaXMgaXMgYSB0ZXN0IDEyM1wiIl19
^^
ParseError: unexpected //

Problem passing transform options with grunt-browserify

After upgrading from version 1.2.0 to any version 2.0.0-2.0.1, in an otherwise unchanged environment, I can no longer see the CoffeeScript source in Chrome's debugger.

This is with [email protected], loaded as a dependency of [email protected] (which is the latest at the time of writing).

Transforms are configured in package.json:

  ...
  "browserify": {
    "transform": [
      "coffeeify",
      "hbsfy",
      "browserify-shim"
    ]
  },
  ...

Options passed into browserify from grunt-browserify:

  "detectGlobals": true,
  "extensions": [
    ".coffee",
    ".hbs"
  ],
  "noParse": [
    "jquery"
  ],
  "debug": true

Note that the debug flag is enabled.

However, best as I can tell, the options argument to coffeeify( ... ){ ... } is always an empty object. Excerpt from: index.js:

...
function coffeeify(filename, options) {
    if (!isCoffee(filename)) return through();

    if (typeof options === 'undefined' || options === null) options = {};

    var compileOptions = {
        sourceMap: (options._flags && options._flags.debug),
        bare: true,
        header: false
    };
    ...

Keep generated .js files

Is is possible to save the transformed coffee sources as js files so they can be required in node?
I'm using coffeeify with grunt and it works perfect for generating my client bundle and it would be great if I didn't have to use something else for generating the js files again.

Read Configs from package.json

Hey man,

since I am using coffeeify and browserify in the command line, I simply cant pass any options to coffeeify.

Is it possible for us to add a feature to read configurations to disable sourceMaps in the package.json file? This feature exists here https://github.com/domenic/jadeify

What do you think about it?

I actually need to disable sourceMaps since I am not being able to use it properly, I believe I created some issues around it, but I just gave up trying.

not working for node_modules in Coffee

Hi,

I have this Javascript library that I'm authoring: https://github.com/wilkerlucio/composed-validations

I have a browser compilation script there for browser versions, that works just fine: https://github.com/wilkerlucio/composed-validations/blob/master/scripts/build

So, browserify + coffeeify is able to compile that. But when I try to do the same externally it does a parsing error...

How to reproduce the problem:

mkdir example-app
cd example-app
npm init
npm install -S composed-validations
npm install -D browserify coffeeify
echo "require('composed-validations')" > browser.js
./node_modules/.bin/browserify -t coffeeify browser.js

And you will get something like:

Error: Parsing file /Users/wilkerlucio/Development/coffeeify-bug/node_modules/composed-validations/lib/index.coffee: Line 2: Unexpected token :

I tried to debug it, and it seems that for some reason the coffeify transformer is not even being called on the module files... I'm not sure if this is a Browserify bug or Coffeeify bug...

Do you guys have any ideas about what's going on?

Document the API

Right now only the CLI is documented. This means anyone who is unfortunate enough to have to use the API will need to reverse engineer it.

Issues with sourceMaps and browserify-shim

Hey guys,

here, I am using browserify with coffeeify and browserify-shim as the transforms. I am guessing that the usage of browserify-shim is affecting the sourceMaps.

What can I do about it? What do u guys are doing regarding this issue, since I cant believe that everybody bundles jquery and other libraries into their bundle.

Thanks!

Middleware usage?

Hey guys,

I have a main.coffee which has "require('helpers')" in it, and I thought it would be easy for enchilada with coffeeify to automatically find helpers.coffee .

I'm doing:

enchilada_ify = enchilada
  src: rootPath
  extensions: ['.coffee']
  routes:
    '/js/main.js': rootPath + '/js/main.coffee'
  transforms: [ coffeeify ]
app.use enchilada_ify

And rendering /js/main.js gives:

Error: module "helpers" not found from "/vagrant/public/js/main.coffee" at notFound ...

Any advice?

Merge coffeify and caching-coffeify

... or figure out how to best share code between the modules.

Moving this out from the discussion in #1.

Personally i'm in favor of merging the 2 modules since the overhead from the caching is very small (md5(source) for each file) and i think most users would benefit from it. Perhaps adding a setting to allow you to disable it in applications where first-run performance really matters.

@mjpizz had an interesting solution to the problem by only enabling caching on the second run but i'm wary of adding functionality that tries to be too "smart". I can easily see a developer pulling his hair out trying to understand why stuff only goes wrong after the second or third request

Now that i think more on this, wouldn't the best solution be to have a generic cache module? something the through module but with caching support that replays a stream if the input stream is the same.

...anyways, what i'm looking for is a way to keep the 2 modules in sync :) Right now they behave differently

coffeeify doesn't work with stream input into browserify

I was debugging an issue using coffeeify internally deepak1556/gulp-browserify#7.

I slimmed the problem down into the following principle code that doesn't work:

var file_stream = fs.createReadStream('./coffee/subdir/a.coffee')

var opts = {}
opts.basedir = __dirname + '/coffee/subdir'

browserify(file_stream,  opts)
    .transform('coffeeify')
    .bundle()
        .on('error', console.log)
    .pipe(process.stdout);

What happens is that since the stream input has lost its file information, a tmp file is created via browserify in these following lines: https://github.com/substack/module-deps/blob/master/index.js#L23

module-deps is what browserify uses for processing. The tmp file created happens to be in .js extension -- and fails the isCoffee test within coffeeify, thereby making coffeeify act like a passthrough stream (stream contents passively passing to the next stream).

I propose a change in isCoffee and isLiterate methods to somehow lint the contents of file (the path) passed to coffeeify.

Required .coffee files inside node_modules treated as javascript

$ npm init && npm install coffeeify browserify
...

$ echo 'console.log "Hello"' > node_modules/b.coffee

# Not working when require()d from node_modules:
$ echo 'require "./node_modules/b.coffee"' > a.coffee
$ browserify -t coffeeify a.coffee

/tmp/browserify-test/node_modules/b.coffee:1
console.log "Hello"
            ^
ParseError: Unexpected string

# Works with other directories:
$ ln -s node_modules not_node_modules
$ echo 'require "./not_node_modules/b.coffee"' > a.coffee
$ browserify -t coffeeify a.coffee

;(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
require("./not_node_modules/b.coffee");


},{"./not_node_modules/b.coffee":2}],2:[function(require,module,exports){
console.log("Hello");


},{}]},{},[1])

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.