Created
July 20, 2023 19:51
-
-
Save Willmo36/ae5665cdd520774c24870250651dd410 to your computer and use it in GitHub Desktop.
ImportMap module federation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<body> | |
<script type="importmap"> | |
{ | |
"imports": { | |
"moduleA": "/moduleA.js", | |
"moduleB": "/moduleB.js", | |
"react": "https://esm.sh/react@17" | |
}, | |
"scopes": { | |
"http://localhost:3334": { | |
"moduleA": "http://localhost:3334/moduleA.js", | |
"moduleB": "http://localhost:3334/moduleB.js", | |
"react": "https://esm.sh/react@17" | |
} | |
} | |
} | |
</script> | |
<script type="module" src="moduleB.js"></script> | |
<script type="module" src="http://localhost:3334/moduleB.js"></script> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function foo() { | |
console.log(`Hello from ${import.meta.url}`); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {foo} from "moduleA" | |
import * as React from "react"; | |
foo(); | |
console.info(`${import.meta.url} imported React ->`, React); | |
console.info('-----') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
temp1 === temp2
)