rollup-plugin-cleanup icon indicating copy to clipboard operation
rollup-plugin-cleanup copied to clipboard

rollup hang up when running with this plugin in node.js

Open Aqours opened this issue 7 years ago • 10 comments

(async function build() {
    let b = await rollup.rollup({
        input: 'absolute_path_entry.js',
        plugins: [rollupCleanup()],
    }); // hang up here

    let out = {
        format: 'esm',
        sourcemap: true,
        file: path.resolve(__dirname, "dist/test.js"),
    };

    await b.generate(out);
    await b.write(out);
})();

Aqours avatar Mar 15 '19 06:03 Aqours

@Aqours I will check it asap. Thanks.

aMarCruz avatar Mar 16 '19 01:03 aMarCruz

@aMarCruz were you able to look into this? I bumped into this issue today as well.

gevalo1 avatar May 02 '19 18:05 gevalo1

I'll look at this issue until this week-end.

aMarCruz avatar May 03 '19 20:05 aMarCruz

Same issue here! I was able to narrow it down to this line in skip-regex.js. For context the stacktrace is included.

image

R_JS_REGEX: "^/(?=[^/])[^[/\](?:(?:\.|[(?:\.|[^]\])])[^[\/])?/[gimuys]*" match[0] "/element.height;var pathData=pathMap.getScaledPath('DATA_OBJECT_COLLECTION_PATH',{xScaleFactor:1,yScaleFactor:1,containerWidth:element.width,containerHeight:element.height,position:{mx:0.451,my:yPosition}});drawPath(parentGfx,pathData,{strokeWidth:2});}this._drawPath=drawPath;}inherits(BpmnRenderer,BaseRenderer);BpmnRenderer.$inject=['config.bpmnRenderer','eventBus','styles','pathMap','canvas','textRenderer'];BpmnRenderer.prototype.canRender=function(element){return is(element,'bpmn:BaseElement');};BpmnRenderer.prototype.drawShape=function(parentGfx,element){var type=element.type;var h=this.handlers[type];return h(parentGfx,element);};BpmnRenderer.prototype.drawConnection=function(parentGfx,element){var type=element.type;var h=this.handlers[type];return h(parentGfx,element);};BpmnRenderer.prototype.getShapePath=function(element){if(is(element,'bpmn:Event')){return getCirclePath(element);}if(is(element,'bpmn:Activity')){return getRoundRectPath(element,TASK_BORDER_RADIUS);}if(is(element,'bpmn:Gateway')){return getDiamondPath(element);}return getRectPath(element);};"

xania avatar Nov 29 '19 23:11 xania

I think I am encountering the same issue, rollup hangs forever with this plugin enabled on this particular statement. Removing the statement, or this plugin from my rollup config makes rollup not hang anymore. Let me know if I can provide any further details.

I tried reproducing the problem by passing the same code through js-cleanup but wasn't able to reproduce that way.

bwindels avatar Sep 17 '20 07:09 bwindels

@Aqours, @gevalo1, @xania, @bwindels , please try cleanup v3.2.1, it is already in npm.

aMarCruz avatar Sep 23 '20 00:09 aMarCruz

@Aqours, @gevalo1, @xania, @bwindels , please try cleanup v3.2.1, it is already in npm.

Still hangs for me with cat node_modules/rollup-plugin-cleanup/package.json | jq ".version": "3.2.1"

bwindels avatar Sep 25 '20 09:09 bwindels

@bwindels thanks, I will check it asap.

aMarCruz avatar Sep 27 '20 21:09 aMarCruz

Same issue here! I was able to narrow it down to this line in skip-regex.js. For context the stacktrace is included.

image

R_JS_REGEX: "^/(?=[^/])[^[/](?:(?:.|[(?:.|[^]])])[^[/])?/[gimuys]*" match[0] "/element.height;var pathData=pathMap.getScaledPath('DATA_OBJECT_COLLECTION_PATH',{xScaleFactor:1,yScaleFactor:1,containerWidth:element.width,containerHeight:element.height,position:{mx:0.451,my:yPosition}});drawPath(parentGfx,pathData,{strokeWidth:2});}this._drawPath=drawPath;}inherits(BpmnRenderer,BaseRenderer);BpmnRenderer.$inject=['config.bpmnRenderer','eventBus','styles','pathMap','canvas','textRenderer'];BpmnRenderer.prototype.canRender=function(element){return is(element,'bpmn:BaseElement');};BpmnRenderer.prototype.drawShape=function(parentGfx,element){var type=element.type;var h=this.handlers[type];return h(parentGfx,element);};BpmnRenderer.prototype.drawConnection=function(parentGfx,element){var type=element.type;var h=this.handlers[type];return h(parentGfx,element);};BpmnRenderer.prototype.getShapePath=function(element){if(is(element,'bpmn:Event')){return getCirclePath(element);}if(is(element,'bpmn:Activity')){return getRoundRectPath(element,TASK_BORDER_RADIUS);}if(is(element,'bpmn:Gateway')){return getDiamondPath(element);}return getRectPath(element);};"

Confirmed, i'm running into the same issue! This might be a problem for a lot of people because this fails to cleanup Google Web Vitals distribution (node_modules/web-vitals/dist/web-vitals.es5.min.js)

Regex used by skip-regex

/^\/(?=[^*/])[^[/\\]*(?:(?:\\.|\[(?:\\.|[^\]\\]*)*\])[^[\\/]*)*?\/[gimuys]*/

String that kills it

/0,c((function(n){var e=n.timeStamp;return t=e}),!0)),{get timeStamp(){return t}}},v=function(t){var n,e=i("FCP"),r=d(),o=a("paint",(function(t){"first-contentful-paint"===t.name&&t.startTime<r.timeStamp&&(e.value=t.startTime,e.isFinal=!0,e.entries.push(t),n())}));o&&(n=l(t,e,o))},f=function(t){var n=i("FID"),e=d(),r=function(t){t.startTime<e.timeStamp&&(n.value=t.processingStart-t.startTime,n.entries.push(t),n.isFinal=!0,s())},o=a("first-input",r),s=l(t,n,o);o?c((function(){o.takeRecords().map(r),o.disconnect()}),!0):window.perfMetrics&&window.perfMetrics.onFirstInputDelay&&window.perfMetrics.onFirstInputDelay((function(t,i){i.timeStamp<e.timeStamp&&(n.value=t,n.isFinal=!0,n.entries=[{entryType:"first-input",name:i.type,target:i.target,cancelable:i.cancelable,startTime:i.timeStamp,processingStart:i.timeStamp+t}],s())}))},m=function(){return n||(n=new Promise((function(t){return["scroll","keydown","pointerdown"].map((function(n){addEventListener(n,t,{once:!0,passive:!0,capture:!0})}))}))),n},g=function(t){var n,e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=i("LCP"),o=d(),s=function(t){var e=t.startTime;e<o.timeStamp?(r.value=e,r.entries.push(t)):r.isFinal=!0,n()},u=a("largest-contentful-paint",s);if(u){n=l(t,r,u,e);var p=function(){r.isFinal||(u.takeRecords().map(s),r.isFinal=!0,n())};m().then(p),c(p,!0)}},h=function(t){var n,e=i("TTFB");n=function(){try{var n=performance.getEntriesByType("navigation")[0]||function(){var t=performance.timing,n={entryType:"navigation",startTime:0};for(var e in t)"navigationStart"!==e&&"toJSON"!==e&&(n[e]=Math.max(t[e]-t.navigationStart,0));return n}();e.value=e.delta=n.responseStart,e.entries=[n],e.isFinal=!0,t(e)}catch(t){}},"complete"===document.readyState?setTimeout(n,0):addEventListener("pageshow",n)};export{p as getCLS,v as getFCP,f as getFID,g as getLCP,h as getTTFB};

@aMarCruz I tried using a different regex found on stackoverflow - it solves the performance problem and works fine for my code, however it fails 6 of your test cases. Do you think this performance issue could be resolved any time soon?

ssivov avatar Nov 20 '20 00:11 ssivov

I can also confirm that the issue is with using this with web-vitals package

smashah avatar Nov 26 '20 02:11 smashah