Skip to content
This repository has been archived by the owner on Feb 9, 2023. It is now read-only.

Fail to compress js builded from typescript #27

Closed
baptistedonaux opened this issue Aug 14, 2015 · 10 comments
Closed

Fail to compress js builded from typescript #27

baptistedonaux opened this issue Aug 14, 2015 · 10 comments

Comments

@baptistedonaux
Copy link

I made a little plugin to build typescript with brunch (https://www.npmjs.com/package/brunch-typescript). For a personal project, I want build and uglify but I have an error with compression. So strange, because when I execute manually uglify-js, I don't have fail.

'use strict';

exports.config = {
    paths: {
        'public': 'dist',
        'watched': [
            'src'
        ]
    },
    files: {
        javascripts: {
            joinTo: {
                'dest.js': 'my/source.ts'
            }
        },
    },
    plugins: {
        uglify: {
            mangle: true
        }
    }
};

My package.json :

{
    "dependencies": {
        "brunch": "1.8.*",
        "brunch-typescript": "1.5.*",
        "uglify-js-brunch": "1.7.*"
    }
}
@baptistedonaux baptistedonaux changed the title Execution order with brunch-typescript Fail to compress js builded from typescript Aug 14, 2015
@baptistedonaux
Copy link
Author

Sorry, the log given is :

14 Aug 12:05:12 - error: JS minification failed on dist/dest.js: Unexpected token: name (Params) (line: 123, col: 10, pos: 3308)

Error
    at new JS_Parse_Error (/data/node_modules/uglify-js-brunch/node_modules/uglify-js/lib/parse.js:196:18)
    at js_error (/data/node_modules/uglify-js-brunch/node_modules/uglify-js/lib/parse.js:204:11)
    at croak (/data/node_modules/uglify-js-brunch/node_modules/uglify-js/lib/parse.js:684:41)
    at token_error (/data/node_modules/uglify-js-brunch/node_modules/uglify-js/lib/parse.js:688:9)
    at unexpected (/data/node_modules/uglify-js-brunch/node_modules/uglify-js/lib/parse.js:694:9)
    at semicolon (/data/node_modules/uglify-js-brunch/node_modules/uglify-js/lib/parse.js:714:43)
    at simple_statement (/data/node_modules/uglify-js-brunch/node_modules/uglify-js/lib/parse.js:894:73)
    at /data/node_modules/uglify-js-brunch/node_modules/uglify-js/lib/parse.js:767:19
    at /data/node_modules/uglify-js-brunch/node_modules/uglify-js/lib/parse.js:727:24
    at block_ (/data/node_modules/uglify-js-brunch/node_modules/uglify-js/lib/parse.js:1007:20)

… and other warning logs display by brunch-typescript

@paulmillr
Copy link
Contributor

We can't really help here unless we see the result source code i'm afraid.

Try looking into your non-minified (disable it) dest.js — maybe there's something wrong with it

@baptistedonaux
Copy link
Author

Yes of course !

I try build my project https://github.com/autocompletejs/autocomplete.js/tree/2.0. I have versionned the brunch-config.js.

The fail appears when I execute brunch b -P.

@baptistedonaux
Copy link
Author

Up ! Do you have a little time to show my autocomplete build :-/

Thank you for less time devoted at my problem.

@kripod
Copy link

kripod commented Sep 28, 2015

I am experiencing the same issue when trying to minify TypeScript files.

By the way, minification works well when I paste the compiled TypeScript code to http://lisperator.net/uglifyjs

@baptistedonaux
Copy link
Author

@kripod Do you have a solution ? I have re-search a solution in brunch-typescript (I searched a possible workflow error) but unfortunately no…

It's really damage, brunch it's a great solution to build simple project but this little is disappointing… :-/

@es128
Copy link
Member

es128 commented Nov 19, 2015

@baptistedonaux how does your plugin work? Just took a very quick look at https://github.com/baptistedonaux/brunch-typescript/blob/master/index.js, and it doesn't seem like you're passing the compiled result back to brunch in the compile method. Seems like you're just passing the source data back and somehow bypassing the brunch compilation pipeline to get your typescript compiled, which would easily explain why uglify chokes on it.

@es128
Copy link
Member

es128 commented Nov 19, 2015

This issue really belongs in your plugin's issue tracker, as it doesn't function the way a brunch compiler plugin is supposed to. Or just shift attention over to the typescript plugin that already existed and does seem to follow the regular plugin conventions https://github.com/joshheyse/typescript-brunch, although it seems it could use some updating.

@es128 es128 closed this as completed Nov 19, 2015
@kripod
Copy link

kripod commented Nov 19, 2015

@baptistedonaux I have no solution, and also suspended my projects written in TypeScript, sorry.

@baptistedonaux
Copy link
Author

@kripod The last release of brunch-typescript@1.7.0 (dev by @colinbate ) supports production flag.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

4 participants