Code Monkey home page Code Monkey logo

Comments (30)

es128 avatar es128 commented on July 18, 2024 1

I just released a new version of the plugin in case this is somehow related to 421f79c.

Run npm update from R:\project\ and try again.

from terser-brunch.

paulmillr avatar paulmillr commented on July 18, 2024

Make sure you have the latest brunch version, remove node_modules and do npm install

from terser-brunch.

thasmo avatar thasmo commented on July 18, 2024

@paulmillr Alright, I'll try, but I actually installed it today for the first time so I guess it was the latest version. I'll report back. Thanks!

from terser-brunch.

thasmo avatar thasmo commented on July 18, 2024

@paulmillr Done like you told me. brunch --version reports 1.7.8, but I get the same errors when using brunch watch.

This is my package.json:
https://gist.github.com/thasmo/3d3d4e3580b4831bf013

This is my config.coffee:
https://gist.github.com/thasmo/a23b1ed21da85c58a020

from terser-brunch.

thasmo avatar thasmo commented on July 18, 2024

Ah, did you mean the 'node_modules' directory in 'AppData\Roaming'? The error stack trace refers to files in 'node_modules' and in the project directory. How do they relate? Sorry, I'm new to this.

from terser-brunch.

es128 avatar es128 commented on July 18, 2024

Delete the entire R:\project\node_modules directory. Then run npm install from inside the R:\project\ directory.

You do not want to mess with the one in AppData/Roaming, which would impact your global brunch installation. If it somehow got corrupted, you'll want to npm uninstall -g brunch, then npm install -g brunch.

from terser-brunch.

thasmo avatar thasmo commented on July 18, 2024

I actually did delete R:\project\node_modules and ran npm install afterwards, but the problem persisted.

Now I ran npm uninstall -g brunch, deleted the project node_modules directory and then I did npm install -g brunch and npm install. Problem persist. :(

from terser-brunch.

paulmillr avatar paulmillr commented on July 18, 2024

R:\project\node_modules\uglify-js-brunch\package.json

what's the version field of this?

from terser-brunch.

es128 avatar es128 commented on July 18, 2024

It might also be useful to know node --version and npm --version.

from terser-brunch.

thasmo avatar thasmo commented on July 18, 2024

node --version v0.10.20
npm --version v1.3.11

/node_modules/uglify-js-brunch/package.json
https://gist.github.com/thasmo/085efd15f430af16f196

from terser-brunch.

thasmo avatar thasmo commented on July 18, 2024

Now I get another error:

R:\project\node_modules\uglify-js-brunch\lib\index.js:37
    options.outSourceMap = options.sourceMaps ? "" + path + ".map" : void 0;
                                  ^
TypeError: Cannot read property 'sourceMaps' of undefined
    at module.exports.UglifyMinifier.optimize (R:\project\node_modules\uglify-js-brunch\lib\index.js:37:35)
    at generate (C:\Users\myuser\AppData\Roaming\npm\node_modules\brunch\lib\fs_utils\generate.js:253:12)
    at gen (C:\Users\myuser\AppData\Roaming\npm\node_modules\brunch\lib\fs_utils\write.js:93:14)
    at C:\Users\myuser\AppData\Roaming\npm\node_modules\brunch\node_modules\async-each\index.js:16:7
    at Array.forEach (native)
    at each (C:\Users\myuser\AppData\Roaming\npm\node_modules\brunch\node_modules\async-each\index.js:15:11)
    at Object.module.exports.write (C:\Users\myuser\AppData\Roaming\npm\node_modules\brunch\lib\fs_utils\write.js:95:12)
    at C:\Users\myuser\AppData\Roaming\npm\node_modules\brunch\lib\watch.js:266:23
    at FileList.<anonymous> (C:\Users\myuser\AppData\Roaming\npm\node_modules\brunch\lib\watch.js:523:18)
    at FileList.EventEmitter.emit (events.js:92:17)
    at null._onTimeout (C:\Users\myuser\AppData\Roaming\npm\node_modules\brunch\lib\fs_utils\file_list.js:115:17)
    at Timer.listOnTimeout [as ontimeout] (timers.js:110:15)

from terser-brunch.

es128 avatar es128 commented on July 18, 2024

There may be a bug lurking in the combo of function call, existential operator, and or operator at https://github.com/brunch/uglify-js-brunch/blob/master/src/index.coffee#L15. Will investigate further.

That said, this could be solved immediately with options?.sourceMaps instead of options.sourceMaps in the two places where that's happening.

from terser-brunch.

thasmo avatar thasmo commented on July 18, 2024

Thanks, appreciate your work! :) Keep me updated!

from terser-brunch.

es128 avatar es128 commented on July 18, 2024

I haven't been able to reproduce it yet. I'll try later when I have access to a windows box and time to set up a test project with the same plugin list as yours. I have a suspicion that the lack of coffeescript-brunch (or any javascript compiler that generates source maps) may be relevant.

Is brunch build still working for you? In the case of both build and watch, I assume you've been using the --production CLI switch or equivalent when encountering the problem - is that correct?

from terser-brunch.

thasmo avatar thasmo commented on July 18, 2024

I have no access to the machine I was working on today now, can tell you tomorrow - but yes, I set 'optimize' to true in my config (https://gist.github.com/thasmo/a23b1ed21da85c58a020) which should be equal running --optimize or -P. It also only happens when the minification/uglyfying is used. Without it (concatenation only) it runs fine. If brunch build runs with minification/uglyfying disabled I can't tell you now, but as far as I remember only brunch watch threw the error, brunch build ran well.

from terser-brunch.

es128 avatar es128 commented on July 18, 2024

I was able to reproduce and debug the problem. Fixed with brunch/brunch@b84dcaa.

@thasmo please confirm by installing the brunch master branch with npm install -g brunch/brunch and then trying your use case again.

(I'm assuming npm properly handles the github / notation on windows, but if it doesn't then npm install -g https://github.com/brunch/brunch/tarball/master should definitely work.)

from terser-brunch.

thasmo avatar thasmo commented on July 18, 2024

@es128 It doesn't minify JS anymore now?! CSS gets minified but JS not.

from terser-brunch.

es128 avatar es128 commented on July 18, 2024

It certainly should with optimize turned on, and it did in my test case. What were your steps to get to that result? Any changes to the stuff you've shown us in the gists?

from terser-brunch.

thasmo avatar thasmo commented on July 18, 2024

Actually I didn't change anything. I uninstalled brunch, removed the node_modules folder, reinstalled brunch, ran npm install and then tried it again. I toggled the optimize flag within the configuration and on the command line and CSS works (gets minified on optimize = true) but JS never gets minified. I will try again in some minutes and report back.

from terser-brunch.

thasmo avatar thasmo commented on July 18, 2024

Change 'in some minutes' to 'later'. :>
Going to test it in some hours, sorry - hang on!

from terser-brunch.

thasmo avatar thasmo commented on July 18, 2024

@es128 Works for me at home. Not sure what I did at work. I will check again tomorrow, but for now I'll close the issue. If I don't get it to run I'll come back. Thank you all for your work! :)

from terser-brunch.

thasmo avatar thasmo commented on July 18, 2024

Eh, sorry - I was too fast. It still doesn't work. Investigating.

from terser-brunch.

thasmo avatar thasmo commented on July 18, 2024

Haha, sorry I'm just a bit confused. It works. @es128 is there a difference between npm install -g brunch/brunch and npm install -g brunch? The first helped me to get it running. Thanks!

from terser-brunch.

es128 avatar es128 commented on July 18, 2024

Yes there's a big difference. npm install -g brunch/brunch is a shortcut built into npm to install from the repo's master branch on github. npm install -g brunch installs the latest release from the npm registry.

The bug fix has been committed to the repo, but not yet published as a new version because I wanted to make sure it worked for you first.

I think we're all set now, but just to be safe, please try it out tomorrow in your work environment for confirmation that the issues you observed are fully resolved.

from terser-brunch.

thasmo avatar thasmo commented on July 18, 2024

Thanks for the explanation. I will check it tomorrow in the office.

from terser-brunch.

thasmo avatar thasmo commented on July 18, 2024

@es128 Actually it seems to work, basically. The problem probably is an already minified jQuery file which completely throws off the compiler. The file get created, JS code is in it, but at some point it stops minification and the JS also throws an error in the browser. Can't uglify.js handle already minified files?

from terser-brunch.

thasmo avatar thasmo commented on July 18, 2024

It's not jQuery, must be something else. No time for it now but the problem seems to be some JS which is not minified/uglified properly and gives the compiler troubles.

from terser-brunch.

thasmo avatar thasmo commented on July 18, 2024

And brunch watch doesn't crash anymore.

from terser-brunch.

es128 avatar es128 commented on July 18, 2024

The original issue seems solved. We should leave this closed and you should probably open a new one about the minification problem once you've examined it more closely.

Uglify should not have any problems with pre-minified source files.

from terser-brunch.

thasmo avatar thasmo commented on July 18, 2024

Alright, thanks!

from terser-brunch.

Related Issues (19)

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.