include mapping plugin with webpack

51 views
Skip to first unread message

Nate A

unread,
Jun 9, 2020, 4:25:47 PM6/9/20
to KnockoutJS
I'm currently extending the mumble-web code [1] and load some extra data from a JSON string. To do that I want to use the mapping plugin.
How do I "install" or "use" the plugin in in generell (I know that I have to call ko.mapping.fromJSON in the code).
How do I include the plugin specifically with webpack?

So far I have found some snipped on StackOverflow, but adding the entry and plugins part to my webpack.config.js ended up with

…/mumble-web/node_modules/webpack-cli/bin/cli.js:93
throw err;
^

ReferenceError: webpack is not defined

So I think that was not the correct path to follow.

I would be very happy if some one can help me with that.

Natanael

Nate A

unread,
Jun 9, 2020, 4:38:01 PM6/9/20
to KnockoutJS

Am Dienstag, 9. Juni 2020 22:25:47 UTC+2 schrieb Nate A:
I'm currently extending the mumble-web code [1] and load some extra data from a JSON string. To do that I want to use the mapping plugin.
How do I "install" or "use" the plugin in in generell (I know that I have to call ko.mapping.fromJSON in the code).
How do I include the plugin specifically with webpack?

So far I have found some snipped on StackOverflow, but adding the entry and plugins part to my webpack.config.js ended up with

…/mumble-web/node_modules/webpack-cli/bin/cli.js:93
throw err;
^

ReferenceError: webpack is not defined 

So I think that was not the correct path to follow.

Ok so that was obviously wrong, I missed requiring webpack in my webpackg.config.js. After I did that, webpack compiled correctly but I get an error on runtime:

ReferenceError: invalid assignment left-hand side in index.js:274, which is the following:

!(function webpackMissingModule() { var e = new Error("Cannot find module 'knockout'"); e.code = 'MODULE_NOT_FOUND'; throw e; }()).extenders.logChange = function (target, option) {

The code I'm working on is here: https://github.com/AKSW/mumble-web/tree/feature/tryLoadingJSON

Andrew Vickers

unread,
Jun 10, 2020, 3:47:48 PM6/10/20
to KnockoutJS
It looks like there is a maintained version of knockout mapping on npm that lists knockout as a peer dependency in its package.json


I would try using that and just requiring it normally.  Be sure to remove the explicit configuration that you added.

Nate A

unread,
Jun 12, 2020, 1:11:43 PM6/12/20
to KnockoutJS
Cool, thank you very much. This works great.
Reply all
Reply to author
Forward
0 new messages