1egoman / debundle

:card_file_box: A javascript debundler. Takes a Browserify or Webpack bundle and recreates the initial, pre-bundled source.
https://www.npmjs.com/package/debundle
704 stars 145 forks source link

The root level IIFE didn't have an array for it's first parameter, aborting... #7

Open lenin-anzen opened 7 years ago

lenin-anzen commented 7 years ago

@1egoman

In order to troubleshoot, I need:

A bundle that doesn't work, preferably as minimal as possible. Upload it to pastebin.com:

Link: https://pastebin.com/eg22rLqE

Any commands you ran prior to debundling:

mkdir debundle-test1 && cd debundle-test1
npm init -y
npm i --save-dev debundle

Your configuration that you passed with the -c argument when debundling.

{
  "type": "webpack",
  "entryPoint": 1,
  "knownPaths": {}
}

The EXACT command you ran to debundle.

node ./node_modules/debundle/src/index.js -i ext-bundle.js -o ext-dist/ -c debundle.config.json

Tell me what the issue is:

Error: The root level IIFE didn't have an array for it's first parameter, aborting...
    at webpackDecoder (~\debundle-test1\node_modules\debundle\src\decoders\webpack.js
:19:11)
    at Object.<anonymous> (~\debundle-test1\node_modules\debundle\src\index.js:104:13
)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.runMain (module.js:604:10)
    at run (bootstrap_node.js:389:7)
    at startup (bootstrap_node.js:149:9)

If you omit any of these parts, I can't help you!

1egoman commented 7 years ago

@lenin-anzen Looks like the bundle you're trying to debundle stores it's modules in an unfamiliar place. Using a tool like http://astexplorer.net/, you should be able to figure out where they are located, and specify the path in the configuration file with the property moduleAst.

In addition, I suspect that your entryPoint is wrong, the bundle contains this code which makes me thing that your entrypoint is actually module 0:

/******/    // Load entry module and return exports
/******/    return __webpack_require__(0);
lenin-anzen commented 7 years ago

I found that the one that makes the package is the following project:

With the next notes:

The model.xml file is:

<?xml version="1.0" encoding="UTF-8"?>
<catalog>
    <feature>
        <name>ext-bb-login-ng</name>
        <contextItemName>[BBHOST]</contextItemName>
        <properties>
            <property name="version" label="Version" readonly="true" viewHint="text-input,admin,designModeOnly">
                <value type="string">1.0.30</value>
            </property>
            <property name="title" label="Title" readonly="true" viewHint="admin,designModeOnly">
                <value type="string">ext-bb-login-ng</value>
            </property>
            <property name="path" label="Path" readonly="true" viewHint="designModeOnly">
                <value type="string">$(itemRoot)/scripts/ext-bb-login-ng.js</value>
            </property>
            <property name="feature.ui-bb-i18n-ng" label="Feature Ui Bb I 18 N Ng" readonly="true" viewHint="">
                <value type="string">ui-bb-i18n-ng</value>
            </property>
            <property name="feature.vendor-bb-angular-ng-aria" label="Feature Vendor Bb Angular Ng Aria" readonly="true" viewHint="">
                <value type="string">vendor-bb-angular-ng-aria</value>
            </property>
        </properties>
    </feature>
</catalog>
willvlad commented 6 years ago

I am having the same issue. Could you please explain where in the astexplorer one finds the AST of a bundle.js file? Not very familiar with the whole AST thing...

willvlad commented 6 years ago

Also, wondered if someone knows how to find the correct entrypoint for a webpack bundle??

nikogu commented 5 years ago

@willvlad make sure your bundle file only have webpack code, the amdumd mode config need remove. exp: https://github.com/1egoman/debundle/blob/master/test_bundles/webpack/bundle.js

webpack entrypoint is 0