-
Notifications
You must be signed in to change notification settings - Fork 8
Open
Description
Hi, I'm trying to use this library in a Module Federation application, but I'm getting the error: grapesjs is not defined.
The error seems to occur here: https://github.com/Developer-Plexscape/ngx-grapesjs/blob/master/projects/ngx-grapesjs/src/lib/editor.component.ts
The declared var is not exported by webpack, and the code assumes the script will be loaded from angular.json, which the MF module doesn't loads. So when the Editor Component tries to load grapesjs, it fails since grapesjs was never defined...
I'm failing to make webpack export the script... Any tips on how to make this work?
My webpack.config.js:
const {
shareAll,
withModuleFederationPlugin,
share,
} = require('@angular-architects/module-federation/webpack');
const LiveReloadPlugin = require('webpack-livereload-plugin');
module.exports = withModuleFederationPlugin({
name: 'APP',
exposes: {
'./Module': './src/app/exposed/exposed.module.ts',
'grapesjs': 'grapesjs',
},
shared: {
...share({
//...
}),
},
});
module.exports.plugins.push(new LiveReloadPlugin());My angular.json:
//...
"build": {
"builder": "ngx-build-plus:browser",
"options": {
"outputPath": "dist/remote",
"index": "src/index.html",
"polyfills": ["zone.js"],
"tsConfig": "tsconfig.app.json",
"inlineStyleLanguage": "scss",
"assets": ["src/favicon.ico", "src/assets"],
"styles": [
"src/styles.scss",
"node_modules/grapesjs/dist/css/grapes.min.css"
],
"scripts": [
"node_modules/grapesjs/dist/grapes.min.js",
"node_modules/grapesjs-preset-webpage/dist/index.js",
"node_modules/grapesjs-blocks-basic/dist/index.js"
],
//...My package.json:
//...
"dependencies": {
"@angular/animations": "~17.2.0",
"@angular/common": "~17.2.0",
"@angular/compiler": "~17.2.0",
"@angular/core": "~17.2.0",
"@angular/forms": "~17.2.0",
"@angular/material-moment-adapter": "^16.0.0",
"@angular/platform-browser": "~17.2.0",
"@angular/platform-browser-dynamic": "~17.2.0",
"@angular/router": "~17.2.0",
"grapesjs": "^0.21.12",
"grapesjs-blocks-basic": "^1.0.2",
"grapesjs-preset-webpage": "^1.0.3",
"ngx-grapesjs": "^17.0.0",
//...I'm forced to use angular 17 so i picked ngx-grapesjs version that used Angular 17.
Metadata
Metadata
Assignees
Labels
No labels