Coder Social home page Coder Social logo

Switching from 3.0.4 to 4.0.0 results in TypeError: Cannot read property 'replace' of undefined while parsing file about uglifyify HOT 12 OPEN

hughsk avatar hughsk commented on June 19, 2024 2
Switching from 3.0.4 to 4.0.0 results in TypeError: Cannot read property 'replace' of undefined while parsing file

from uglifyify.

Comments (12)

tristanls avatar tristanls commented on June 19, 2024 1

I don't have a minimal reproduction yet, but using [email protected] my production use case results in:

`_flags` is not a supported option

from uglifyify.

lrlna avatar lrlna commented on June 19, 2024

Hey! I am looking into it for you.

Out of curiosity does something like this uglifyify -c dead_code still return an error for you?

from uglifyify.

tristanls avatar tristanls commented on June 19, 2024

Is this what you mean?

$ cat pr.js 
"use strict";

module.exports = "nope";
$ ./node_modules/.bin/browserify -g [ uglifyify -c ] pr.js 
TypeError: Cannot read property 'replace' of undefined while parsing file: pr.js
    at Stream.ready (node_modules/uglifyify/index.js:78:24)
    at Stream.<anonymous> (node_modules/uglifyify/index.js:100:12)
    at _end (node_modules/through/index.js:65:9)
    at Stream.stream.end (node_modules/through/index.js:74:5)
    at DestroyableTransform.onend (node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:499:10)
    at Object.onceWrapper (events.js:314:30)
    at emitNone (events.js:110:20)
    at DestroyableTransform.emit (events.js:207:7)
    at endReadableNT (node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:920:12)
    at _combinedTickCallback (internal/process/next_tick.js:102:11)

from uglifyify.

tristanls avatar tristanls commented on June 19, 2024

For completeness, it succeeds on 3.0.4:

$ npm install uglifyify --no-save
+ [email protected]
removed 1 package and updated 1 package in 3.265s
$ ./node_modules/.bin/browserify -g [ uglifyify -c ] pr.js 
(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);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.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){
"use strict";module.exports="nope";
},{}]},{},[1]);

from uglifyify.

lrlna avatar lrlna commented on June 19, 2024

No, not quite. I wanted to see if passing an option to--compress might help, since the new uglify comes with a bunch of them you could work with.

But let me try to just replicate it just as you have it in the latter two examples and see where I get on.

from uglifyify.

lrlna avatar lrlna commented on June 19, 2024

Okay, cool, I was able to replicate and it's having issues on extend; interestingly only with command-line options. I use it outside of the command-line context, so never noticed this issue with the original pr. Give me a bit, and I should have a fix for you.

from uglifyify.

Alxmerino avatar Alxmerino commented on June 19, 2024

I'm seeing the same issue but with 3.0.4 I am running it programmatically as opposed to the CLI

from uglifyify.

iamjochem avatar iamjochem commented on June 19, 2024

the TypeError is masking the real error the return value from ujs.minify() (see here), is always an object BUT it may contain an error property, in which case it is likely that it does not have a code property (which the code is blindly assuming it it).

The underlying error (at least those I have had) alwasy relate to invalid options (for uglify) - this is because the uglify-es modules is being used (which breaks API compatibility with uglify@v2).

I think this modules should do suitable checking of the return value of ujs.minify() (does min.code exist, does min.error exist, etc ... and then display, throw the returned error data), also alway pass a copy/clone of the opts object to ujs.minify() (really the given opts should be cloned and then the clone manipulated)

from uglifyify.

iamjochem avatar iamjochem commented on June 19, 2024

I hacked the following PR, which tackles the swallowed minify() errors & problems related to not-cloning options before manipulating and/or passing them on : PR-69

from uglifyify.

lrlna avatar lrlna commented on June 19, 2024

Ok, so uglify no longer supports shortened CLI in there JS api, but hopefully that is fixed for you in 📦 4.0.2.

I still want to address creating a new opts object, and that should be fixed by @iamjochem #69.

from uglifyify.

yoshuawuyts avatar yoshuawuyts commented on June 19, 2024

from uglifyify.

sassanh avatar sassanh commented on June 19, 2024

I'm also affected by `_flags` is not a supported option

from uglifyify.

Related Issues (20)

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.