fingerpan / vue-cli-plugin-dll

Vue CLI 3 plugin for Webpack DllPlugin/DllReferencePlugin
MIT License
76 stars 22 forks source link

test unit dll_library is not defined #18

Closed julesGoullee closed 4 years ago

julesGoullee commented 5 years ago

when i run serve task it's work, but when i use test:unit it's compiled, but before the first test i god this error ` ReferenceError: dll_library is not defined at Object.dll-reference dll_library (/Users/jules/WebstormProjects/shaders-midi/dist/webpack:/external "dll_library":1:1) at webpack_require__ (/Users/jules/WebstormProjects/shaders-midi/dist/webpack:/webpack/bootstrap:19:1) at Object../node_modules/vue/dist/vue.runtime.esm.js (/Users/jules/WebstormProjects/shaders-midi/dist/webpack:/delegated ./node_modules/vue/dist/vue.runtime.esm.js from dll-reference dll_library:1:1) at webpack_require (/Users/jules/WebstormProjects/shaders-midi/dist/webpack:/webpack/bootstrap:19:1) at Object../node_modules/@vue/test-utils/dist/vue-test-utils.js (/Users/jules/WebstormProjects/shaders-midi/dist/webpack:/node_modules/@vue/test-utils/dist/vue-test-utils.js:5:1) at webpack_require (/Users/jules/WebstormProjects/shaders-midi/dist/webpack:/webpack/bootstrap:19:1) at Module../tests/unit/components/MidiLoader.spec.js (/Users/jules/WebstormProjects/shaders-midi/dist/webpack:/tests/unit/components/MidiLoader.spec.js:1:1) at webpack_require (/Users/jules/WebstormProjects/shaders-midi/dist/webpack:/webpack/bootstrap:19:1) at run (/Users/jules/WebstormProjects/shaders-midi/dist/webpack:/node_modules/mocha-webpack/lib/entry.js:3:1) at Array.forEach () at Object../node_modules/mocha-webpack/lib/entry.js (/Users/jules/WebstormProjects/shaders-midi/dist/webpack:/node_modules/mocha-webpack/lib/entry.js:10:1) at __webpack_require (/Users/jules/WebstormProjects/shaders-midi/dist/webpack:/webpack/bootstrap:19:1) at /Users/jules/WebstormProjects/shaders-midi/dist/webpack:/webpack/bootstrap:83:1 at Object. (/Users/jules/WebstormProjects/shaders-midi/dist/main.js:87:10) at Module._compile (internal/modules/cjs/loader.js:689:30) at Object._module2.default._extensions.(anonymous function) [as .js] (/Users/jules/WebstormProjects/shaders-midi/node_modules/mocha-webpack/lib/util/registerRequireHook.js:148:12) at Module.load (internal/modules/cjs/loader.js:599:32) at tryModuleLoad (internal/modules/cjs/loader.js:538:12) at Function.Module._load (internal/modules/cjs/loader.js:530:3) at Module.require (internal/modules/cjs/loader.js:637:17) at require (internal/modules/cjs/helpers.js:22:18) at /Users/jules/WebstormProjects/shaders-midi/node_modules/mocha/lib/mocha.js:250:27 at Array.forEach () at Mocha.loadFiles (/Users/jules/WebstormProjects/shaders-midi/node_modules/mocha/lib/mocha.js:247:14) at Mocha.run (/Users/jules/WebstormProjects/shaders-midi/node_modules/mocha/lib/mocha.js:576:10) at /Users/jules/WebstormProjects/shaders-midi/node_modules/mocha-webpack/lib/runner/TestRunner.js:191:27 at /Users/jules/WebstormProjects/shaders-midi/node_modules/mocha-webpack/lib/webpack/compiler/registerReadyCallback.js:26:7 at AsyncSeriesHook.eval [as callAsync] (eval at create (/Users/jules/WebstormProjects/shaders-midi/node_modules/tapable/lib/HookCodeFactory.js:32:10), :45:1) at AsyncSeriesHook.lazyCompileHook (/Users/jules/WebstormProjects/shaders-midi/node_modules/tapable/lib/Hook.js:154:20) at emitRecords.err (/Users/jules/WebstormProjects/shaders-midi/node_modules/webpack/lib/Compiler.js:261:22) at Compiler.emitRecords (/Users/jules/WebstormProjects/shaders-midi/node_modules/webpack/lib/Compiler.js:375:39) at emitAssets.err (/Users/jules/WebstormProjects/shaders-midi/node_modules/webpack/lib/Compiler.js:255:10) at hooks.afterEmit.callAsync.err (/Users/jules/WebstormProjects/shaders-midi/node_modules/webpack/lib/Compiler.js:361:14) at _err0 (eval at create (/Users/jules/WebstormProjects/shaders-midi/node_modules/tapable/lib/HookCodeFactory.js:32:10), :16:1) at callback (/Users/jules/WebstormProjects/shaders-midi/node_modules/copy-webpack-plugin/dist/index.js:126:17) at afterEmit (/Users/jules/WebstormProjects/shaders-midi/node_modules/copy-webpack-plugin/dist/index.js:220:13) at AsyncSeriesHook.eval [as callAsync] (eval at create (/Users/jules/WebstormProjects/shaders-midi/node_modules/tapable/lib/HookCodeFactory.js:32:10), :12:1) at AsyncSeriesHook.lazyCompileHook (/Users/jules/WebstormProjects/shaders-midi/node_modules/tapable/lib/Hook.js:154:20) at asyncLib.forEach.err (/Users/jules/WebstormProjects/shaders-midi/node_modules/webpack/lib/Compiler.js:358:27) at /Users/jules/WebstormProjects/shaders-midi/node_modules/neo-async/async.js:2825:7 at done (/Users/jules/WebstormProjects/shaders-midi/node_modules/neo-async/async.js:2861:11) at /Users/jules/WebstormProjects/shaders-midi/node_modules/neo-async/async.js:2813:7 at MemoryFileSystem.writeFile (/Users/jules/WebstormProjects/shaders-midi/node_modules/memory-fs/lib/MemoryFileSystem.js:328:9) at writeOut (/Users/jules/WebstormProjects/shaders-midi/node_modules/webpack/lib/Compiler.js:342:29) at Immediate._onImmediate (/Users/jules/WebstormProjects/shaders-midi/node_modules/memory-fs/lib/MemoryFileSystem.js:288:4) at runCallback (timers.js:705:18) at tryOnImmediate (timers.js:676:5) at processImmediate (timers.js:658:5)

`

fingerpan commented 5 years ago

when i run serve task it's work, but when i use test:unit it's compiled, but before the first test i god this error ` ReferenceError: dll_library is not defined at Object.dll-reference dll_library (/Users/jules/WebstormProjects/shaders-midi/dist/webpack:/external "dll_library":1:1) at webpack_require (/Users/jules/WebstormProjects/shaders-midi/dist/webpack:/webpack/bootstrap:19:1) at Object../node_modules/vue/dist/vue.runtime.esm.js (/Users/jules/WebstormProjects/shaders-midi/dist/webpack:/delegated ./node_modules/vue/dist/vue.runtime.esm.js from dll-reference dll_library:1:1) at webpack_require (/Users/jules/WebstormProjects/shaders-midi/dist/webpack:/webpack/bootstrap:19:1) at Object../node_modules/@vue/test-utils/dist/vue-test-utils.js (/Users/jules/WebstormProjects/shaders-midi/dist/webpack:/node_modules/@vue/test-utils/dist/vue-test-utils.js:5:1) at webpack_require (/Users/jules/WebstormProjects/shaders-midi/dist/webpack:/webpack/bootstrap:19:1) at Module../tests/unit/components/MidiLoader.spec.js (/Users/jules/WebstormProjects/shaders-midi/dist/webpack:/tests/unit/components/MidiLoader.spec.js:1:1) at webpack_require (/Users/jules/WebstormProjects/shaders-midi/dist/webpack:/webpack/bootstrap:19:1) at run (/Users/jules/WebstormProjects/shaders-midi/dist/webpack:/node_modules/mocha-webpack/lib/entry.js:3:1) at Array.forEach () at Object../node_modules/mocha-webpack/lib/entry.js (/Users/jules/WebstormProjects/shaders-midi/dist/webpack:/node_modules/mocha-webpack/lib/entry.js:10:1) at webpack_require (/Users/jules/WebstormProjects/shaders-midi/dist/webpack:/webpack/bootstrap:19:1) at /Users/jules/WebstormProjects/shaders-midi/dist/webpack:/webpack/bootstrap:83:1 at Object. (/Users/jules/WebstormProjects/shaders-midi/dist/main.js:87:10) at Module._compile (internal/modules/cjs/loader.js:689:30) at Object._module2.default._extensions.(anonymous function) [as .js] (/Users/jules/WebstormProjects/shaders-midi/node_modules/mocha-webpack/lib/util/registerRequireHook.js:148:12) at Module.load (internal/modules/cjs/loader.js:599:32) at tryModuleLoad (internal/modules/cjs/loader.js:538:12) at Function.Module._load (internal/modules/cjs/loader.js:530:3) at Module.require (internal/modules/cjs/loader.js:637:17) at require (internal/modules/cjs/helpers.js:22:18) at /Users/jules/WebstormProjects/shaders-midi/node_modules/mocha/lib/mocha.js:250:27 at Array.forEach () at Mocha.loadFiles (/Users/jules/WebstormProjects/shaders-midi/node_modules/mocha/lib/mocha.js:247:14) at Mocha.run (/Users/jules/WebstormProjects/shaders-midi/node_modules/mocha/lib/mocha.js:576:10) at /Users/jules/WebstormProjects/shaders-midi/node_modules/mocha-webpack/lib/runner/TestRunner.js:191:27 at /Users/jules/WebstormProjects/shaders-midi/node_modules/mocha-webpack/lib/webpack/compiler/registerReadyCallback.js:26:7 at AsyncSeriesHook.eval [as callAsync] (eval at create (/Users/jules/WebstormProjects/shaders-midi/node_modules/tapable/lib/HookCodeFactory.js:32:10), :45:1) at AsyncSeriesHook.lazyCompileHook (/Users/jules/WebstormProjects/shaders-midi/node_modules/tapable/lib/Hook.js:154:20) at emitRecords.err (/Users/jules/WebstormProjects/shaders-midi/node_modules/webpack/lib/Compiler.js:261:22) at Compiler.emitRecords (/Users/jules/WebstormProjects/shaders-midi/node_modules/webpack/lib/Compiler.js:375:39) at emitAssets.err (/Users/jules/WebstormProjects/shaders-midi/node_modules/webpack/lib/Compiler.js:255:10) at hooks.afterEmit.callAsync.err (/Users/jules/WebstormProjects/shaders-midi/node_modules/webpack/lib/Compiler.js:361:14) at _err0 (eval at create (/Users/jules/WebstormProjects/shaders-midi/node_modules/tapable/lib/HookCodeFactory.js:32:10), :16:1) at callback (/Users/jules/WebstormProjects/shaders-midi/node_modules/copy-webpack-plugin/dist/index.js:126:17) at afterEmit (/Users/jules/WebstormProjects/shaders-midi/node_modules/copy-webpack-plugin/dist/index.js:220:13) at AsyncSeriesHook.eval [as callAsync] (eval at create (/Users/jules/WebstormProjects/shaders-midi/node_modules/tapable/lib/HookCodeFactory.js:32:10), :12:1) at AsyncSeriesHook.lazyCompileHook (/Users/jules/WebstormProjects/shaders-midi/node_modules/tapable/lib/Hook.js:154:20) at asyncLib.forEach.err (/Users/jules/WebstormProjects/shaders-midi/node_modules/webpack/lib/Compiler.js:358:27) at /Users/jules/WebstormProjects/shaders-midi/node_modules/neo-async/async.js:2825:7 at done (/Users/jules/WebstormProjects/shaders-midi/node_modules/neo-async/async.js:2861:11) at /Users/jules/WebstormProjects/shaders-midi/node_modules/neo-async/async.js:2813:7 at MemoryFileSystem.writeFile (/Users/jules/WebstormProjects/shaders-midi/node_modules/memory-fs/lib/MemoryFileSystem.js:328:9) at writeOut (/Users/jules/WebstormProjects/shaders-midi/node_modules/webpack/lib/Compiler.js:342:29) at Immediate._onImmediate (/Users/jules/WebstormProjects/shaders-midi/node_modules/memory-fs/lib/MemoryFileSystem.js:288:4) at runCallback (timers.js:705:18) at tryOnImmediate (timers.js:676:5) at processImmediate (timers.js:658:5)

` Thank you for your feedback. This error may be caused by the failure of loading the 'vendor..dll.js' file on your unit test environment. Because the dll_library variable is the global variable exposed after the loading of 'vendor. . dll. js'. Read more [libraryTarget ='var'](https://webpack.js.org/configuration/output/#output librarytarget) Please provide your test script, more information, more help i can offer

fingerpan commented 5 years ago

Thank you for your feedback. This error may be caused by the failure of loading the 'vendor..dll.js' file on your unit test environment. Because the dll_library variable is the global variable exposed after the loading of 'vendor. . dll. js'. Read more libraryTarget ='var' please provide your test script, more information, more help i can offer

julesGoullee commented 5 years ago

I got the same error with dev server: if the url location is / it's work fine, but when i use a different route of vue-router config the download of ddl.js file failed because the dev server return the index.html file. In production build it's work well. (It's awsome!)

fingerpan commented 5 years ago

@julesGoullee Can you give me a simple demo which allows me to better analyze the cause of the error?you can create a github repo.

lywzx commented 5 years ago

@fingerpan hello, i fixed the bug. when vue-router history mode, inject file should be used absolute path. bug fixed before. image

bug fixed. image

now, i resolve the program like this. change the package.json scripts dll like below. "dll": "node --eval \"var fs = require('fs');try {var path = 'node_modules/vue-cli-plugin-dll/src/helper.js';if(!fs.accessSync(path, fs.constants.R_OK | fs.constants.W_OK)) {fs.writeFileSync(path, fs.readFileSync(path, 'utf8').replace('publicPath: typeOfAsset,', 'publicPath: \\'/\\' + typeOfAsset,'), 'utf8');}} catch(e){}\" && vue-cli-service dll"