This project is read-only.
1
Vote

Error loading camljs package into spfx solution

description

Im trying to load camljs.js ina client webpart using the SharePoint Framework Experience.I am getting the following error

*ERROR MESSAGE:
***Failed to load component "df52bb7c-0165-4fa5-adfa-1e1c91740246" (Test2WebPart).
Original error: ***Failed to load path dependency "df52bb7c-0165-4fa5-adfa-1e1c91740246" from component "Test2WebPart" (Error loading https://component-id.invalid/df52bb7c-0165-4fa5-adfa-1e1c91740246_0.0.1/camljs
https://component-id.invalid/df52bb7c-0165-4fa5-adfa-1e1c91740246_0.0.1/camljs did not call System.register or AMD define. If loading a global module configure the global name via the meta exports property for script injection support.).
However, the network tab in Chrome developer tools shows that camljs.js is loading


The solution is using the React template. After scaffolding has been completed, I am installing camljs as follows

npm install --save camljs
npm install --save @types/camljs

I have also excluded camljs from being bundled in the config file (externals) and have set a globalname:

"camljs":{
  "path" : "node_modules/camljs/camljs.js",
  "globalName": "camljs"
}
}

in the solutions. tsx file I am importing camljs in the following way:

import camljs from 'camljs'

but the module cannot be found using intellisense in Visual Code

Any thoughts as to how to fix this?

comments

omlin wrote May 27 at 2:57 PM

Hi,

Sorry for a delay with response.

I think the "globalName": "camljs" piece is incorrect. Library name is indeed "camljs", but the global object is "CamlBuilder". Can you try changing it?

Best,
Andrei