Related
I am currently modifying the configuration file a Vue app (acting here as a host app) to implement the plugin of webpack : ModuleFederationPlugin.
The goal for me is to set up a micro-frontend architecture by getting a component from a remote app called "foo".
Here is the code to reproduce the issue :
config file host app :
const path = require("path");
const helpers = require("./config/helpers");
const { ModuleFederationPlugin } = require("webpack").container;
const config = {
configureWebpack: {
entry: {
polyfill: "#babel/polyfill",
},
stats: {
cached: false,
cachedAssets: false,
chunks: false,
chunkModules: false,
chunkOrigins: false,
modules: false,
},
devServer: {
historyApiFallback: true,
port: 8765,
},
plugins: [
new ModuleFederationPlugin({
name: "vue",
remotes: {
foo: "foo#http://localhost:5173/remoteEntry.js",
},
}),
],
},
pluginOptions: {
"style-resources-loader": {
preProcessor: "scss",
patterns: [],
},
},
};
module.exports = config;
package.json host app :
{
"name": "Test",
"version": "1.0.0",
"description": "Test",
"author": "Test",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build"
},
"dependencies": {
"vue": "^2.6.10"
},
"devDependencies": {
"#babel/core": "7.7.2",
"#babel/plugin-transform-runtime": "7.6.2",
"#babel/preset-env": "7.7.1",
"#babel/register": "7.7.0",
"#vue/cli-plugin-babel": "^4.0.5",
"#vue/cli-plugin-eslint": "^4.0.5",
"#vue/cli-service": "^4.0.5",
"#vue/eslint-config-airbnb": "^5.0.0",
"babel-plugin-istanbul": "5.2.0",
"cache-loader": "^4.1.0",
"eventsource-polyfill": "0.9.6",
"image-webpack-loader": "^6.0.0",
"karma-webpack": "4.0.2",
"selenium-server": "3.141.59",
"url-loader": "^2.2.0",
"vue-cli-plugin-style-resources-loader": "^0.1.4",
"vue-loader": "15.7.2",
"vue-style-loader": "4.1.2",
"vue-template-compiler": "2.6.10",
"webpack": "^4.41.2",
"webpack-merge": "4.2.2"
},
"engines": {
"node": ">= 8.0.0",
"npm": ">= 5.0.0"
}
}
yarn version host app : 1.22.19
node version host app : v12.0.0
config file remote app :
import svgr from "vite-plugin-svgr"
import { defineConfig } from "vite"
import react from "#vitejs/plugin-react"
import * as path from "path"
import federation from "#originjs/vite-plugin-federation"
export default defineConfig({
plugins: [
svgr(),
react(),
federation({
name: "foo",
filename: "remoteEntry.js",
exposes: {
"./App": "./src/App.tsx",
},
}),
],
build: {
target: "esnext",
assetsDir: "assets",
},
server: {
host: "0.0.0.0",
port: 5173,
},
})
package.json file of the remote app :
{
"name": "test",
"version": "1.0.0",
"description": "test",
"author": "test",
"private": true,
"type": "module",
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"build:prod": "tsc && vite build",
"build:demo": "tsc && vite build --mode demo",
"preview": "vite preview",
"lint:check": "eslint \"./src/**/*.{ts,tsx}\"",
"lint:fix": "eslint --fix \"./src/**/*.{ts,tsx}\"",
"prettier:check": "prettier --check .",
"prettier:fix": "prettier --write ."
},
"dependencies": {
"#emotion/react": "^11.10.0",
"#emotion/styled": "^11.10.0",
"#mui/icons-material": "^5.10.9",
"#mui/material": "^5.10.0",
"#mui/x-date-pickers": "^5.0.0",
"#originjs/vite-plugin-federation": "^1.1.11",
"axios": "^0.27.2",
"classnames": "^2.3.1",
"dayjs": "^1.11.5",
"i18next": "^21.8.14",
"moment": "^2.29.4",
"npm": "^8.19.2",
"react": "^18.2.0",
"react-charts": "=3.0.0-beta.30",
"react-confetti": "^6.1.0",
"react-dom": "^18.2.0",
"react-hook-form": "^7.33.1",
"react-i18next": "^11.18.1",
"react-number-format": "^5.0.1",
"react-router-dom": "^6.3.0"
},
"devDependencies": {
"#types/node": "^18.7.18",
"#types/react": "^18.0.15",
"#types/react-dom": "^18.0.6",
"#typescript-eslint/eslint-plugin": "^5.30.7",
"#typescript-eslint/parser": "^5.30.7",
"#vitejs/plugin-react": "^2.0.0",
"eslint": "^8.20.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-react": "^7.30.1",
"prettier": "^2.7.1",
"sass": "^1.55.0",
"typescript": "^4.6.4",
"vite": "^3.0.0",
"vite-plugin-svgr": "^2.2.1"
}
}
yarn version of the remote app : 1.22.19
node version of the remote app : v12.0.0
Here is what I get when running the host app with "yarn serve" :
error logs when launching the app
My goal is then to be able to use the component App from the remote app in the host app by importing it like that :
Vue.component("App", () => import("foo/App"));
After running graphql-codegen-esm --config codegen.yml the following message is shown in the console
loadTs is not a function
I add files with my project configuration
package.json
{
"main": "src/index.js",
"type": "module",
"scripts": {
"dev": "concurrently \"nodemon\" \"npm run codegen --watch\"",
"codegen": "graphql-codegen-esm --config codegen.yml"
},
"dependencies": {
"#graphql-tools/load-files": "^6.6.0",
"apollo-server": "^3.10.0",
"graphql": "^16.5.0",
"graphql-modules": "^2.1.0",
"graphql-scalars": "^1.17.0"
},
"devDependencies": {
"#graphql-codegen/add": "^3.2.0",
"#graphql-codegen/cli": "2.11.3",
"#graphql-codegen/graphql-modules-preset": "^2.5.0",
"#graphql-codegen/typescript": "^2.7.2",
"#graphql-codegen/typescript-resolvers": "^2.7.2",
"#tsconfig/node18-strictest-esm": "^1.0.0",
"concurrently": "^7.3.0",
"nodemon": "^2.0.19",
"ts-node": "^10.9.1",
"typescript": "^4.7.4"
}
}
codegen.yml
schema: './src/**/*.graphql'
emitLegacyCommonJSImports: false
generates:
./src/graphql/:
preset: graphql-modules
presetConfig:
baseTypesPath: ../generated-types/graphql.ts # Where to create the complete schema types
filename: generated-types/module-types.ts # Where to create each module types
plugins:
- add:
content: '/* eslint-disable */'
- typescript
- typescript-resolvers
tsconfig.json
{
"extends": "#tsconfig/node18-strictest-esm/tsconfig.json",
"ts-node": {
"esm": true
},
"include": ["src/**/*"],
"exclude": ["node_modules", "**/*.spec.ts"]
}
Node
v18.7.0
I'm using nativescript with angular. After installing nativescript-ui-listview plugin I got this error
Error on worker #1: Error: getInternalNameOfClass() called on a non-ES5 class: expected RadListViewComponent to have an inner class declaration
while running the app.
With a Warning:
Warning: Invalid constructor parameter decorator in C:/Users/rashi/FNFtoursapp/node_modules/nativescript-ui-listview/angular/fesm2015/nativescript-ui-listview-angular.js:
() => [
{ type: ElementRef, decorators: [{ type: Inject, args: [ElementRef,] }] },
{ type: IterableDiffers, decorators: [{ type: Inject, args: [IterableDiffers,] }] },
{ type: NativeScriptRendererFactory, decorators: [{ type: Inject, args: [NativeScriptRendererFactory,] }] }
]
Need Help
Below is My Package Json File
{
"nativescript": {
"id": "org.nativescript.FNFtoursapp",
"tns-ios": {
"version": "6.5.0"
},
"tns-android": {
"version": "6.5.3"
}
},
"description": "NativeScript Application",
"license": "SEE LICENSE IN <your-license-filename>",
"repository": "<fill-your-repository-here>",
"scripts": {
"ngcc": "ngcc --properties es2015 module main --first-only",
"postinstall": "npm run ngcc"
},
"dependencies": {
"#angular/animations": "~9.1.0",
"#angular/common": "~9.1.0",
"#angular/compiler": "~9.1.0",
"#angular/core": "~9.1.0",
"#angular/forms": "~9.1.0",
"#angular/platform-browser": "~9.1.0",
"#angular/platform-browser-dynamic": "~9.1.0",
"#angular/router": "~9.1.0",
"#nativescript/angular": "~9.0.0",
"#nativescript/theme": "~2.3.0",
"#nstudio/nativescript-checkbox": "^1.0.0",
"nativescript-cardview": "^3.2.0",
"nativescript-plugin-firebase": "^10.5.2",
"nativescript-ui-listview": "^9.0.2",
"reflect-metadata": "~0.1.12",
"rxjs": "^6.5.0",
"tns-core-modules": "~6.5.0",
"zone.js": "~0.10.3"
},
"devDependencies": {
"#angular/compiler-cli": "~9.1.0",
"#ngtools/webpack": "~9.1.0",
"nativescript-dev-webpack": "~1.5.0",
"tns-platform-declarations": "~6.5.0",
"typescript": "~3.8.3"
},
"readme": "NativeScript Application"
}
changing compilerOptions of tsconfig.json from es5 to es2015 works fine with me, you can try
My application perfectly running and building on localhost. But when it's building on Heroku, I'm getting the following error:
./src/index.js
Error: Cannot find module '#babel/plugin-proposal-decorators' from '/app'
at Array.map (<anonymous>)
That's my package.json:
{
"name": "agroproject-ui",
"version": "0.1.0",
"private": true,
"dependencies": {
"#ckeditor/ckeditor5-build-classic": "^12.0.0",
"#ckeditor/ckeditor5-react": "^1.1.1",
"#fortawesome/fontawesome-svg-core": "^1.2.8",
"#fortawesome/free-solid-svg-icons": "^5.5.0",
"#fortawesome/react-fontawesome": "^0.1.3",
"#pluralsight/ps-design-system-actionmenu": "^3.1.10",
"#pluralsight/ps-design-system-badge": "^2.1.12",
"#pluralsight/ps-design-system-button": "^10.8.15",
"#pluralsight/ps-design-system-card": "^8.5.8",
"#pluralsight/ps-design-system-dropdown": "^0.5.3",
"#pluralsight/ps-design-system-layout": "^3.0.2",
"#pluralsight/ps-design-system-normalize": "^3.0.45",
"#pluralsight/ps-design-system-row": "^2.6.25",
"#pluralsight/ps-design-system-textinput": "^0.5.6",
"#svgr/webpack": "2.4.1",
"#tinymce/tinymce-react": "^3.0.1",
"axios": "^0.18.0",
"babel-eslint": "9.0.0",
"babel-jest": "23.6.0",
"babel-loader": "8.0.4",
"babel-plugin-named-asset-import": "^0.2.2",
"babel-preset-react-app": "^5.0.4",
"bfj": "6.1.1",
"case-sensitive-paths-webpack-plugin": "2.1.2",
"chalk": "2.4.1",
"css-loader": "1.0.0",
"dotenv": "6.0.0",
"dotenv-expand": "4.2.0",
"eslint": "5.6.0",
"eslint-config-react-app": "^3.0.4",
"eslint-loader": "2.1.1",
"eslint-plugin-flowtype": "2.50.1",
"eslint-plugin-import": "2.14.0",
"eslint-plugin-jsx-a11y": "6.1.2",
"eslint-plugin-react": "7.11.1",
"file-loader": "2.0.0",
"fs-extra": "7.0.0",
"glamor": "^2.20.40",
"google-maps-react": "^2.0.2",
"html-webpack-plugin": "4.0.0-alpha.2",
"identity-obj-proxy": "3.0.0",
"jest": "23.6.0",
"jest-pnp-resolver": "1.0.1",
"jest-resolve": "23.6.0",
"jsonwebtoken": "^8.4.0",
"mini-css-extract-plugin": "0.4.3",
"node-sass": "^4.9.4",
"optimize-css-assets-webpack-plugin": "5.0.1",
"pnp-webpack-plugin": "1.1.0",
"postcss-cssnext": "^3.1.0",
"postcss-flexbugs-fixes": "4.1.0",
"postcss-import": "^12.0.0",
"postcss-loader": "3.0.0",
"postcss-preset-env": "6.0.6",
"postcss-safe-parser": "4.0.1",
"prop-types": "^15.6.2",
"react": "^16.5.2",
"react-app-polyfill": "^0.1.3",
"react-aux": "^1.1.0",
"react-dev-utils": "^6.0.5",
"react-dom": "^16.5.2",
"react-redux": "^6.0.0",
"react-router": "^4.3.1",
"react-router-dom": "^4.3.1",
"react-table": "^6.8.6",
"redux": "^4.0.1",
"redux-thunk": "^2.3.0",
"resolve": "1.8.1",
"sass-loader": "7.1.0",
"style-loader": "0.23.0",
"terser-webpack-plugin": "1.1.0",
"url-loader": "1.1.1",
"webpack": "4.19.1",
"webpack-dev-server": "^3.2.1",
"webpack-manifest-plugin": "2.0.4",
"workbox-webpack-plugin": "3.6.2"
},
"scripts": {
"start": "node scripts/start.js",
"build": "node scripts/build.js",
"test": "node scripts/test.js"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": [
">0.2%",
"not dead",
"not ie <= 11",
"not op_mini all"
],
"jest": {
"collectCoverageFrom": [
"src/**/*.{js,jsx}"
],
"resolver": "jest-pnp-resolver",
"setupFiles": [
"react-app-polyfill/jsdom"
],
"testMatch": [
"<rootDir>/src/**/__tests__/**/*.{js,jsx}",
"<rootDir>/src/**/?(*.)(spec|test).{js,jsx}"
],
"testEnvironment": "jsdom",
"testURL": "http://localhost",
"transform": {
"^.+\\.(js|jsx)$": "<rootDir>/node_modules/babel-jest",
"^.+\\.css$": "<rootDir>/config/jest/cssTransform.js",
"^(?!.*\\.(js|jsx|css|json)$)": "<rootDir>/config/jest/fileTransform.js"
},
"transformIgnorePatterns": [
"[/\\\\]node_modules[/\\\\].+\\.(js|jsx)$",
"^.+\\.module\\.(css|sass|scss)$"
],
"moduleNameMapper": {
"^react-native$": "react-native-web",
"^.+\\.module\\.(css|sass|scss)$": "identity-obj-proxy"
},
"moduleFileExtensions": [
"web.js",
"js",
"json",
"web.jsx",
"jsx",
"node"
]
},
"babel": {
"presets": [
"react-app"
]
},
"devDependencies": {
"#babel/core": "^7.4.3",
"#babel/plugin-proposal-class-properties": "^7.4.0",
"#babel/plugin-proposal-decorators": "^7.4.0",
"#babel/preset-env": "^7.1.6",
"redux-devtools": "^3.4.2",
"redux-devtools-extension": "^2.13.7",
"stylelint-config-airbnb": "0.0.0"
}
Any idea what could possibly is wrong with package.json?
You have included #babel/plugin-proposal-decorators in your devDependencies.
By default, Heroku installs your dependencies and devDependencies, builds your slug, and then strips out your devDependencies. This makes sense: in most cases devDependencies shouldn't be on production; that's for things like testing frameworks, editor plugins, etc. that you need in development but not in production.
I recommend moving this module to your dependencies, though an alternative solution would be to tell Heroku not to prune your devDependencies by setting NPM_CONFIG_PRODUCTION=false or YARN_PRODUCTION=false, depending on the tool you're using.
Both approaches will require a redeploy to take effect, and unless you have a clear reason to use devDependencies on Heroku I urge you to use the former.
My build is working in Chrome, Safari, and Opera but breaking in Firefox.
I'm using React, Webpack, and Sass.
The console error I get is:
TypeError: wrappedCompareFn is not a function bundle.js:39813:24
and
TypeError: node is null bundle.js:7865:1
Below I've included my webpack file and the dependencies in my package.json. Any help we be greatly appreciated.
Webpack:
const path = require('path');
const webpack = require('webpack');
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
const autoprefixer = require('autoprefixer');
module.exports = {
context: __dirname,
debug: true,
devtool: 'cheap-module-source-map',
entry: './client/src/App.jsx',
output: {
path: path.join(__dirname, './client/public'),
filename: 'bundle.js',
},
resolve: {
extensions: ['', '.js', '.jsx', '.json'],
},
externals: {
},
stats: {
colors: true,
reasons: true,
chunks: false,
},
plugins: [
new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
// new BundleAnalyzerPlugin(),
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify('production'),
},
}),
],
module: {
preLoaders: [
{
test: /\.jsx$/,
loader: 'babel-loader',
exclude: /node-modules/,
},
],
noParse: [
/plotly\.js/,
],
loaders: [
{
test: /\.styl$/,
loader: 'style-loader!css-loader!stylus-loader',
},
{
test: /\.scss$/,
loader: 'style-loader!css-loader!postcss-loader!sass-loader',
},
{
test: /\.jsx?$/,
loader: 'babel-loader',
},
{
test: /\.json$/,
loader: 'json-loader',
},
{
test: /\.(jpe?g|png|gif|svg|ico|ttf)$/i,
loader: 'file-loader',
},
],
},
postcss: [autoprefixer({ browsers: ['last 2 versions'] })],
watch: false,
};
package.json dependencies:
"dependencies": {
"bluebird": "^3.4.6",
"classnames": "^2.2.5",
"connect-history-api-fallback": "^1.3.0",
"dotenv": "^2.0.0",
"express": "^4.14.0",
"http-status-codes": "^1.0.6",
"koa": "^1.2.4",
"koa-add-trailing-slashes": "^1.1.0",
"koa-basic-auth": "^1.1.2",
"koa-jwt": "^1.2.0",
"koa-mount": "^1.3.0",
"koa-route": "^2.4.2",
"koa-static": "^2.0.0",
"material-ui": "^0.16.2",
"materialize-css": "^0.97.8",
"moment": "^2.15.2",
"pm2": "^2.1.6",
"react": "^15.4.0",
"react-dom": "^15.4.0",
"react-materialize": "^0.17.0",
"react-redux": "^4.4.5",
"react-router": "^3.0.0",
"react-tap-event-plugin": "^2.0.0",
"react-tooltip": "^3.2.2",
"redux": "^3.6.0"
},
"devDependencies": {
"autofixture": "^0.1.2",
"autoprefixer": "^6.5.4",
"babel-core": "^6.18.0",
"babel-eslint": "^6.1.2",
"babel-jest": "^16.0.0",
"babel-loader": "^6.2.7",
"babel-plugin-transform-decorators-legacy": "^1.3.4",
"babel-preset-es2015": "^6.18.0",
"babel-preset-react": "^6.16.0",
"babel-preset-stage-0": "^6.16.0",
"babel-register": "^6.18.0",
"bluebird": "^3.4.6",
"chai": "^3.5.0",
"child_process": "^1.0.2",
"co-supertest": "0.0.10",
"concurrently": "^3.1.0",
"css-loader": "^0.25.0",
"enzyme": "^2.5.1",
"eslint": "^3.9.1",
"eslint-config-airbnb": "^12.0.0",
"eslint-plugin-import": "^2.0.1",
"eslint-plugin-jsx-a11y": "^2.2.3",
"eslint-plugin-react": "^6.4.1",
"file-loader": "^0.9.0",
"gulp": "^3.9.1",
"gulp-batch": "^1.0.5",
"gulp-debug": "^2.1.2",
"gulp-eslint": "^3.0.1",
"gulp-exit": "0.0.2",
"gulp-jest": "^0.6.0",
"gulp-mocha": "^3.0.1",
"gulp-notify": "^2.2.0",
"gulp-plumber": "^1.1.0",
"gulp-run": "^1.7.1",
"gulp-tap": "^0.1.3",
"gulp-testcafe": "^0.9.0",
"gulp-watch": "^4.3.11",
"gulp-webserver": "^0.9.1",
"jest": "^16.0.2",
"jquery": "^3.1.1",
"json-loader": "^0.5.4",
"live-server": "^1.1.0",
"lodash": "^4.16.6",
"materialize-css": "^0.97.8",
"mocha": "^3.1.2",
"node-materialize": "^1.1.1",
"node-sass": "^3.11.2",
"postcss-loader": "^1.2.1",
"react-addons-test-utils": "^15.4.0",
"react-test-renderer": "^15.4.0",
"request-promise": "^4.1.1",
"require-dir": "^0.3.1",
"sass": "^0.5.0",
"sass-loader": "^4.0.2",
"sass-rem": "^1.2.3",
"sinon": "^1.17.6",
"style-loader": "^0.13.1",
"stylus": "^0.54.5",
"stylus-loader": "^2.3.1",
"supertest": "^2.0.1",
"supertest-koa-agent": "^0.3.0",
"testcafe": "^0.9.0",
"webpack": "^1.13.3",
"webpack-bundle-analyzer": "^2.1.1",
"webpack-dev-server": "^1.16.2"
},
"jest": {
"moduleFileExtensions": [
"js",
"jsx"
],
"moduleNameMapper": {
"^.+\\.(css|styl|scss)$": "<rootDir>/test/mocks/styleMock.js",
"^.+\\.(gif|ttf|eot|svg)$": "<rootDir>/test/mocks/fileMock.js"
},
"moduleDirectories": [
"node_modules"
],
"scriptPreprocessor": "<rootDir>/node_modules/babel-jest",
"testPathDirs": [
"test/ui"
],
"testRegex": ".*-tests\\.(js|jsx)$"
}
}
Link to post possible duplicated from