Git Product home page Git Product logo

Comments (10)

ScriptedAlchemy avatar ScriptedAlchemy commented on July 16, 2024

Ill add try catch for users who has CSP it will fall back to possibly dangerous global access

from core.

72gm avatar 72gm commented on July 16, 2024

Sorry, not sure I understand what that means?... I was hoping there would be a way to use a webpack nonce as this is becoming the recommended way for CSPs!

from core.

ScriptedAlchemy avatar ScriptedAlchemy commented on July 16, 2024

I can fix unsafe-eval issues.
Is there something else you want as well?

If this is about nonce you can try using the createScript hook via runtime plugin

from core.

ScriptedAlchemy avatar ScriptedAlchemy commented on July 16, 2024

where is the unsafe eval getting triggered?

from core.

ScriptedAlchemy avatar ScriptedAlchemy commented on July 16, 2024

I just tried setting this in the meta

<meta http-equiv="Content-Security-Policy" content="script-src 'self' http://localhost:3008 http://localhost:3009 http://localhost:3010 http://localhost:3011 http://localhost:3012;">

and no eval error was triggered, please provide a repo where its failing and i can take a look

from core.

72gm avatar 72gm commented on July 16, 2024

Hi,

It is when the lazy load actually loads. Each of our remotes exposes its own routes which are pieced together in the host. When the host tries to load a module then the issue occurs

In this example a collection of routes are loaded into the host, similar to below. When the host tries to route to the module then the error occurs. No eval error is triggered until you actually try to invoke the module

image

I'll add a repo, shortly

from core.

72gm avatar 72gm commented on July 16, 2024

@ScriptedAlchemy you can see this issue here https://github.com/72gm/gm-mfe-csp

bootstrap file in the Host generates the csp policy.. which needs unsafe-eval added to make it work

(isn't a monorepo so need open top level folder in vs code and run each via it's own terminal)

from core.

ScriptedAlchemy avatar ScriptedAlchemy commented on July 16, 2024

This is not federation v2 its just normal webpack, there is no unsafe eval here.
Webpack in development mode wraps modules in eval, dont use CSP on development machines or change your devtool config.

from core.

72gm avatar 72gm commented on July 16, 2024

Apologies, just moved to webpack. Easy when you know how!

@ScriptedAlchemy much appreciate your help on this, saved me a load of grief

For anyone having this issue there are some pointers here webpack/webpack#5627 on what you might need to do

from core.

joe-coady avatar joe-coady commented on July 16, 2024

@ScriptedAlchemy ~ I am having a similar issue in loadEsmEntry when it tries to execute

new Function(
          'callbacks',
          `import("${entry}").then(callbacks[0]).catch(callbacks[1])`,
        )([resolve, reject]);

the module federation config I am using is:

{
  "name": "shell-service-views",
  "library": {
    "type": "module"
  },
  "filename": "remoteEntry.js",
  "remotes": {
    "admin-service-views": "https://.../admin/remoteEntry.js",
    "shop-service-views": "https://.../shop/remoteEntry.js"
  },
  "shared": {
    "react": {
      "singleton": true,
      "requiredVersion": "18.3.1"
    },
    "react-dom": {
      "singleton": true,
      "requiredVersion": "18.3.1"
    }
  }
}

I am using NX's implementation of the ModuleFederationPlugin from @module-federation/enhanced/webpack.

from core.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.