Using external ''d3-org-chart" module in your volto project and importing it in your views with import { OrgChart } from 'd3-org-chart' results in following error.
Am not sure if this is result of webpack error or something far simpler.
node_modules/d3-org-chart/src/d3-org-chart.js:1
import { selection, select } from "d3-selection";
^^^^^^
SyntaxError: Cannot use import statement outside a module
at wrapSafe (internal/modules/cjs/loader.js:915:16)
at Module._compile (internal/modules/cjs/loader.js:963:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
at Module.load (internal/modules/cjs/loader.js:863:32)
at Function.Module._load (internal/modules/cjs/loader.js:708:14)
at Module.require (internal/modules/cjs/loader.js:887:19)
at require (internal/modules/cjs/helpers.js:74:18)
at Object.d3-org-chart (/Code/frontend/external "d3-org-chart":1:1)
at __webpack_require__ (/Code/frontend/build/webpack:/webpack/bootstrap:754:1)
at fn (/Code/frontend/build/webpack:/webpack/bootstrap:59:1)
Thank you @tiberiuichim for following up. I noticed that the razzle.config.js in my current volto site is outdated. This might be due to the fact that it was generated quite a few volto versions ago.
/**
* Replace with custom razzle config when needed.
* @module razzle.config
*/
const fs = require('fs');
let voltoPath = './node_modules/@plone/volto';
let configFile;
if (fs.existsSync(`${this.projectRootPath}/tsconfig.json`))
configFile = `${this.projectRootPath}/tsconfig.json`;
else if (fs.existsSync(`${this.projectRootPath}/jsconfig.json`))
configFile = `${this.projectRootPath}/jsconfig.json`;
if (configFile) {
const jsConfig = require(configFile).compilerOptions;
const pathsConfig = jsConfig.paths;
if (pathsConfig['@plone/volto'])
voltoPath = `./${jsConfig.baseUrl}/${pathsConfig['@plone/volto'][0]}`;
}
module.exports = require(`${voltoPath}/razzle.config`);
I think I should finish update it to upstream version in volto site before making the changes you suggested?