Uglify during production mode breaks web worker

349 views
Skip to first unread message

Benjamin Newland

unread,
Aug 22, 2013, 11:51:12 AM8/22/13
to meteo...@googlegroups.com

I'm using Recorder.js with Meteor for client-side audio recording, and it works wonderfully in development. However, when I run in production, the web worker associated with Recorder throws a syntax error:

unexpected token '<'.

I think it has something to do with concatenation of Javascript files in production mode, because the file has already been minified (works in development after minifying). Is there a way to exclude some files from Uglify? A look at the development console shows,

Resource interpreted as Script but transferred with MIME type text/html: "http://myapp:3000/client/compatibility/recorderWorker.min.js".  

When inspecting the recorderWorker.js file from either Chrome or Safari's consoles, it shows up as an html document. This is not the case in development. Any ideas?

David Glasser

unread,
Aug 22, 2013, 12:00:05 PM8/22/13
to meteo...@googlegroups.com

You should put web workers in the public directory so they are considered as static assets and not as Meteor JS code.

--
You received this message because you are subscribed to the Google Groups "meteor-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to meteor-talk...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Benjamin Newland

unread,
Aug 22, 2013, 12:02:54 PM8/22/13
to meteo...@googlegroups.com
Do they go into a specific sub-directory, or just the main public folder?
> You received this message because you are subscribed to a topic in the
> Google Groups "meteor-talk" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/meteor-talk/uX28P8AblQg/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to

Benjamin Newland

unread,
Aug 22, 2013, 12:04:03 PM8/22/13
to meteo...@googlegroups.com
Just tried it, and it works brilliantly. Thank you.

nini

unread,
Jan 22, 2014, 6:46:56 AM1/22/14
to meteo...@googlegroups.com
Benjamin, 

Can you share your server side code .. Where are you storing the recorded audio.. I am having issues in transferring the blob
Message has been deleted

Benjamin Newland

unread,
Jan 22, 2014, 12:21:53 PM1/22/14
to meteo...@googlegroups.com

Meteor.saveFile = function(blob, name, path, type, callback) {
    var fileReader = new FileReader(),
        method, encoding = 'binary', type = type || 'binary';
    switch (type) {
        case 'text':
            method = 'readAsText';
            encoding = 'utf8';
            break;
        case 'binary':
            method = 'readAsBinaryString';
            encoding = 'binary';
            break;
        default:
            method = 'readAsBinaryString';
            encoding = 'binary';
            break;
    }
    fileReader.onload = function(file) {
        
        var form = new FormData();
        form.append("blob", blob, name);
        var request = new XMLHttpRequest();
        request.open(
            "POST",
            "http://ourDomain.com:9000",
            true
        );
        request.send(form);
        console.log('this be my '+name);
        Meteor.call('mo_upload', name);

        downloadname = name;
        this.downloadname= downloadname;
        console.log(downloadname);

    }
    fileReader[method](blob);
}
We're using a modified version of instant fileserver for node.js, which uses the formable module for file ingestion as web forms. So, I'm not sure if this solves your problem, but it works well for us.

Benjamin Newland

unread,
Jan 22, 2014, 1:28:26 PM1/22/14
to meteo...@googlegroups.com
Also, disregard the last three last lines of the onload function.
You're not going to actually need those.
Reply all
Reply to author
Forward
0 new messages