Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaught ReferenceError: vendor is not defined when using dll #15

Open
ashokgelal opened this issue Sep 1, 2017 · 3 comments
Open

Uncaught ReferenceError: vendor is not defined when using dll #15

ashokgelal opened this issue Sep 1, 2017 · 3 comments

Comments

@ashokgelal
Copy link

ashokgelal commented Sep 1, 2017

As per your suggestion, I'm using dll to improve the build time but I get Uncaught ReferenceError: vendor is not defined error every time. With my experience with Laravel Mix I understand that I need to load the generated vendor.js file in dist/render-dll directoy but couldn't figure out how. I thought that this was automated and gets injected by electron-webpack.

I'm using electron-vue and my package.json looks something like this:

...
"files": [
      "dist/electron/**/*",
      "!node_modules/deep-diff/releases{,/**/*}",
      "!node_modules/bluebird/js/browser{,/**/*}",
      "!node_modules/source-map-support/**/*",
      "node_modules/source-map-support/source-map-support.js"
    ],
"electronWebpack": {
    "renderer": {
      "dll": [
        "vue",
        "vue-router",
        "vuex",
        "element-ui"
      ]
    }
  },
...

Thanks for your help.

@develar
Copy link
Member

develar commented Sep 8, 2017

Do you have "postinstall": "electron-webpack dll" ?

Maybe you use custom HTML?

@ashokgelal
Copy link
Author

Yes I do have "postintall": "electron-webpack dll"

Also, now I'm getting a different error when I run electron-webpack dll:

Error: DllPlugin: supply an Array as entry
Similar to this:
electron-react-boilerplate/electron-react-boilerplate#1199

@loopmode
Copy link
Collaborator

loopmode commented Sep 30, 2017

I have the same issue.
Debugging it, I found that in webpack/lib/DLLPlugin (webpack@3.6.0), there is this code:

		compiler.plugin("entry-option", (context, entry) => {
            		function itemToPlugin(item, name) {
				if(Array.isArray(item))
					return new DllEntryPlugin(context, item, name);
				else
					throw new Error("DllPlugin: supply an Array as entry");
			}
			if(typeof entry === "object" && !Array.isArray(entry)) {
				Object.keys(entry).forEach(name => {
					compiler.apply(itemToPlugin(entry[name], name));
				});
			} else {
				compiler.apply(itemToPlugin(entry, "main"));
			}
			return true;
		});

EDIT:
Logging via console.log('DllPlugin', {item}) inside function itemToPlugin(item, name) we can see this:

DllPlugin { item: [ 'classnames', 'autobind-decorator' ] }
DllPlugin { item: 'dll' }

The problem is that dll ends up in there as a string, which is not an array..

This is probably due to entry coming in as { vendor: [ 'classnames', 'autobind-decorator' ], main: 'dll' }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants