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

Webpack no longer includes Vue as external module #200

Closed
hborchardt opened this issue May 24, 2022 · 2 comments
Closed

Webpack no longer includes Vue as external module #200

hborchardt opened this issue May 24, 2022 · 2 comments

Comments

@hborchardt
Copy link
Contributor

hborchardt commented May 24, 2022

Hi, thanks for the latest release!

In my app I was using the import { createBaklava } from "baklavajs"; syntax.
Unfortunately since the latest build 1.10.0 this throws an error:

Uncaught exception - Error: Uncaught (in promise): Error: Cannot find module 'undefined'
Error: Cannot find module 'undefined'
    at webpackEmptyContext (http://localhost/src_app_pages_vendor-tooling_vendor-tooling_module_ts.js:14767:21)
    at Object.553 (http://localhost/src_app_pages_vendor-tooling_vendor-tooling_module_ts.js:21112:71)
    at __nested_webpack_require_107280__ (http://localhost/src_app_pages_vendor-tooling_vendor-tooling_module_ts.js:21171:45)
    at Object.2659 (http://localhost/src_app_pages_vendor-tooling_vendor-tooling_module_ts.js:19985:56)
    at __nested_webpack_require_107280__ (http://localhost/src_app_pages_vendor-tooling_vendor-tooling_module_ts.js:21171:45)
    at Object.6716 (http://localhost/src_app_pages_vendor-tooling_vendor-tooling_module_ts.js:20094:75)
    at __nested_webpack_require_107280__ (http://localhost/src_app_pages_vendor-tooling_vendor-tooling_module_ts.js:21171:45)
    at Object.8681 (http://localhost/src_app_pages_vendor-tooling_vendor-tooling_module_ts.js:18696:209)
    at __nested_webpack_require_107280__ (http://localhost/src_app_pages_vendor-tooling_vendor-tooling_module_ts.js:21171:45)
    at Object.5721 (http://localhost/src_app_pages_vendor-tooling_vendor-tooling_module_ts.js:18030:95) Error: Uncaught (in promise): Error: Cannot find module 'undefined'
Error: Cannot find module 'undefined'
    at webpackEmptyContext (index.js:18:10)
    at Object.553 (index.js:2799:18)
    at __nested_webpack_require_107280__ (index.js:2823:42)
    at Object.2659 (index.js:2104:61)
    at __nested_webpack_require_107280__ (index.js:2823:42)
    at Object.6716 (index.js:2168:80)
    at __nested_webpack_require_107280__ (index.js:2823:42)
    at Object.8681 (index.js:1121:214)
    at __nested_webpack_require_107280__ (index.js:2823:42)
    at Object.5721 (index.js:713:100)
...

The relevant lines from the baklavajs/dist/index.js file is:

var vue__WEBPACK_IMPORTED_MODULE_0__ = __nested_webpack_require_78050__(553);
/***/ 553:
/***/ ((module) => {

"use strict";
module.exports = __webpack_require__(708)(undefined);

/***/ })
/***/ 708:
/***/ ((module) => {

function webpackEmptyContext(req) {
	var e = new Error("Cannot find module '" + req + "'");
	e.code = 'MODULE_NOT_FOUND';
	throw e;
}
webpackEmptyContext.keys = () => ([]);
webpackEmptyContext.resolve = webpackEmptyContext;
webpackEmptyContext.id = 708;
module.exports = webpackEmptyContext;

/***/ }),

So the error happens while referencing the vue module, which should be defined as an external module. This still works in the js version of the baklavajs submodules, for example in the @baklavajs/plugin-options-vue/dist/index.js:

/* harmony import */ var vue__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(8976);

and later

/***/ 8976:
/***/ ((module) => {

"use strict";
module.exports = __WEBPACK_EXTERNAL_MODULE__8976__;

/***/ })

Interestingly, in the cjs version (@baklavajs/plugin-options-vue/dist/index.cjs) it is broken:

/* harmony import */ var vue__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(553);
/***/ 553:
/***/ ((module) => {

"use strict";
module.exports = require(undefined);

/***/ })

I was able to workaround this by only using the @baklavajs/... packages and recreating the createBaklava function in my codebase, and patching the subpackage package.json files to use the js version when using import: "exports": { "import": "index.js", ...}. Of course that is quite hacky...

@newcat
Copy link
Owner

newcat commented May 24, 2022

Thanks, should be fixed with 1.10.1

Apparently, it is not allowed to write the externals in the object format when doing the CommonJS build

@hborchardt
Copy link
Contributor Author

With 1.10.1 it works, awesome!

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

2 participants