Running a retidy test app: TypeError: not a webpackBootstrap function call AST
radiolondra opened this issue · 2 comments
Hello,
I'm trying to debundle a very short react file using retidy.
This is my test.js file:
test.js
import retidy from "retidy"
import fs from "fs"
const code = fs.readFileSync("vendor-bundle.js", "utf-8")
retidy.retidy(code, { type: "webpack-jsonp", outDir: "./out/", bundleAstReferenceKeys: ["body", 0, "expression"] })
This is the file to be unbundled:
vendor-bundle.js
!function(e){function n(t){if(r[t])return r[t].exports;var o=r[t]={exports:{},id:t,loaded:!1};return e[t].call(o.exports,o,o.exports,n),o.loaded=!0,o.exports}var t=window.webpackJsonp;window.webpackJsonp=function(a,l){for(var p,c,s=0,i=[];s<a.length;s++)c=a[s],o[c]&&i.push.apply(i,o[c]),o[c]=0;for(p in l)e[p]=l[p];for(t&&t(a,l);i.length;)i.shift().call(null,n);return l[0]?(r[0]=0,n(0)):void 0};var r={},o={4:0,6:0};n.e=function(e,t){if(0===o[e])return t.call(null,n);if(void 0!==o[e])o[e].push(t);else{o[e]=[t];var r=document.getElementsByTagName("head")[0],a=document.createElement("script");a.type="text/javascript",a.charset="utf-8",a.async=!0,a.src=n.p+""+e+"."+({5:"bundle",6:"common-bundle"}[e]||e)+".js",r.appendChild(a)}},n.m=e,n.c=r,n.p=""}([]);
This is my package.json:
package.json
{
"name": "testapp",
"version": "1.0.0",
"type": "module",
"description": "",
"main": "test.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"retidy": "^1.5.1"
}
}
And I have a common-bundle.js file:
common-bundle.js
webpackJsonp([6,4],[]);
This is the error i get running node --trace-warnings test.js
:
(node:9928) UnhandledPromiseRejectionWarning: TypeError: not a webpackBootstrap function call AST.
at Object.exports.notWebpackBootstrapAstErr (C:\Users\Roberto\Desktop\retidy\node_modules\retidy\dist\extractor\webpack\extract-modules.js:17:58)
at Object.exports.extractModules (C:\Users\Roberto\Desktop\retidy\node_modules\retidy\dist\extractor\webpack\extract-modules.js:41:23)
at exports.webpackExtractor (C:\Users\Roberto\Desktop\retidy\node_modules\retidy\dist\extractor\webpack\webpack-extractor.js:6:43)
at Object.exports.extractor (C:\Users\Roberto\Desktop\retidy\node_modules\retidy\dist\extractor\extractor.js:20:12)
at C:\Users\Roberto\Desktop\retidy\node_modules\retidy\dist\index.js:124:46
at step (C:\Users\Roberto\Desktop\retidy\node_modules\retidy\dist\index.js:33:23)
at Object.next (C:\Users\Roberto\Desktop\retidy\node_modules\retidy\dist\index.js:14:53)
at fulfilled (C:\Users\Roberto\Desktop\retidy\node_modules\retidy\dist\index.js:5:58)
at emitUnhandledRejectionWarning (internal/process/promises.js:168:15)
at processPromiseRejections (internal/process/promises.js:247:11)
at processTicksAndRejections (internal/process/task_queues.js:94:32)
(node:9928) TypeError: not a webpackBootstrap function call AST.
at Object.exports.notWebpackBootstrapAstErr (C:\Users\Roberto\Desktop\retidy\node_modules\retidy\dist\extractor\webpack\extract-modules.js:17:58)
at Object.exports.extractModules (C:\Users\Roberto\Desktop\retidy\node_modules\retidy\dist\extractor\webpack\extract-modules.js:41:23)
at exports.webpackExtractor (C:\Users\Roberto\Desktop\retidy\node_modules\retidy\dist\extractor\webpack\webpack-extractor.js:6:43)
at Object.exports.extractor (C:\Users\Roberto\Desktop\retidy\node_modules\retidy\dist\extractor\extractor.js:20:12)
at C:\Users\Roberto\Desktop\retidy\node_modules\retidy\dist\index.js:124:46
at step (C:\Users\Roberto\Desktop\retidy\node_modules\retidy\dist\index.js:33:23)
at Object.next (C:\Users\Roberto\Desktop\retidy\node_modules\retidy\dist\index.js:14:53)
at fulfilled (C:\Users\Roberto\Desktop\retidy\node_modules\retidy\dist\index.js:5:58)
(node:9928) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
at emitDeprecationWarning (internal/process/promises.js:180:11)
at processPromiseRejections (internal/process/promises.js:249:13)
at processTicksAndRejections (internal/process/task_queues.js:94:32)
I'm doing something wrong for sure, but I don't know what.
And I have no idea of what to write in the bundleAstReferenceKeys (and maybe in entryPoint option too)
Could someone help me?
Thanks
Could someone answer please please? 🙏🏻
Sorry I was busy.
The files you've given are not complete. There should be more things there.
!function(e){function n(t){if(r[t])return r[t].exports;var o=r[t]={exports:{},id:t,loaded:!1};return e[t].call(o.exports,o,o.exports,n),o.loaded=!0,o.exports}var t=window.webpackJsonp;window.webpackJsonp=function(a,l){for(var p,c,s=0,i=[];s<a.length;s++)c=a[s],o[c]&&i.push.apply(i,o[c]),o[c]=0;for(p in l)e[p]=l[p];for(t&&t(a,l);i.length;)i.shift().call(null,n);return l[0]?(r[0]=0,n(0)):void 0};var r={},o={4:0,6:0};n.e=function(e,t){if(0===o[e])return t.call(null,n);if(void 0!==o[e])o[e].push(t);else{o[e]=[t];var r=document.getElementsByTagName("head")[0],a=document.createElement("script");a.type="text/javascript",a.charset="utf-8",a.async=!0,a.src=n.p+""+e+"."+({5:"bundle",6:"common-bundle"}[e]||e)+".js",r.appendChild(a)}},n.m=e,n.c=r,n.p=""}([
/** more code should be here */
]);
webpackJsonp([6,4],[/** more code should be here */]);