single-spa / create-single-spa

https://single-spa.js.org/docs/create-single-spa
Other
128 stars 60 forks source link

Unable to resolve bare specifier '@ambevtech/wms-push-notification-react-client' #365

Closed AlexandreAkao closed 1 year ago

AlexandreAkao commented 1 year ago

Hello guys I'm facing this error: image

But @ambevtech/wms-push-notification-react-client is only used in one micro frontend, I don't wanna share it with other micro frontends.

I know that probably will solve if I add this @ambevtech/wms-push-notification-react-client on import-map, but it is a private dependency that requires authentication.

This is my import-map: image

Does anyone know how to solve this?

Thanks for the help :)

filoxo commented 1 year ago

Our webpack configs use the orgName as a scope to define webpack externals. Per the create-single-spa documentation,

This changes whether package names that start with @your-org-name are treated as webpack externals or not. Defaults to true.

Set orgPackagesAsExternal: false in the singleSpaDefaults config and then either

AlexandreAkao commented 1 year ago

When I set orgPackagesAsExternal: false shows a new error: image

This is my webpack: image

filoxo commented 1 year ago

process.env is only compatible with Node but your code is making use of it somewhere. You need to compile it away, see webpack's EnvironmentPlugin or DefinePlugin.

These configs are intended to be a starting point. Not a one-size-fits-all solution like CRA or similar so keep that in mind.

filoxo commented 1 year ago

Seems like this could have also been caused by your use of streamBrowserify https://stackoverflow.com/questions/68542553/webpack-5process-is-not-defined-triggered-by-stream-browserify but the solution is the same.

AlexandreAkao commented 1 year ago

Setting the ProvidePlugin on Webpack.config the process.env shows, but with no values

plugins: [
  new webpack.ProvidePlugin({
    process: 'process/browser',
  }),
]

I'm migrating from a CRA project, so will be perfect if the envs be similar in the CRA, with all presets envs that CRA provides

filoxo commented 1 year ago

We intentionally don't provide a full replacement for CRA. It may also be a good idea to compare CRA's webpack config with our basic webpack config so that you can enable the missing features yourself. See our FAQ here for some basic info and potential alternatives: https://single-spa.js.org/docs/faq/#create-react-app We unfortunately don't have the resources to do this on behalf of every user who wants to migrate.

AlexandreAkao commented 1 year ago

Okay fine, thanks a lot for the support 😊

AlexandreAkao commented 1 year ago

Only for information I found this plugin and work perfectly for environment variables https://github.com/mrsteele/dotenv-webpack