init
This commit is contained in:
6
packages/host/.babelrc
Normal file
6
packages/host/.babelrc
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"presets": ["@babel/preset-typescript", "@babel/preset-react", "@babel/preset-env"],
|
||||
"plugins": [
|
||||
["@babel/transform-runtime"]
|
||||
]
|
||||
}
|
||||
116
packages/host/.gitignore
vendored
Normal file
116
packages/host/.gitignore
vendored
Normal file
@@ -0,0 +1,116 @@
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
lerna-debug.log*
|
||||
|
||||
# Diagnostic reports (https://nodejs.org/api/report.html)
|
||||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
||||
|
||||
# Runtime data
|
||||
pids
|
||||
*.pid
|
||||
*.seed
|
||||
*.pid.lock
|
||||
|
||||
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||
lib-cov
|
||||
|
||||
# Coverage directory used by tools like istanbul
|
||||
coverage
|
||||
*.lcov
|
||||
|
||||
# nyc test coverage
|
||||
.nyc_output
|
||||
|
||||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
||||
.grunt
|
||||
|
||||
# Bower dependency directory (https://bower.io/)
|
||||
bower_components
|
||||
|
||||
# node-waf configuration
|
||||
.lock-wscript
|
||||
|
||||
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
||||
build/Release
|
||||
|
||||
# Dependency directories
|
||||
node_modules/
|
||||
jspm_packages/
|
||||
|
||||
# Snowpack dependency directory (https://snowpack.dev/)
|
||||
web_modules/
|
||||
|
||||
# TypeScript cache
|
||||
*.tsbuildinfo
|
||||
|
||||
# Optional npm cache directory
|
||||
.npm
|
||||
|
||||
# Optional eslint cache
|
||||
.eslintcache
|
||||
|
||||
# Microbundle cache
|
||||
.rpt2_cache/
|
||||
.rts2_cache_cjs/
|
||||
.rts2_cache_es/
|
||||
.rts2_cache_umd/
|
||||
|
||||
# Optional REPL history
|
||||
.node_repl_history
|
||||
|
||||
# Output of 'npm pack'
|
||||
*.tgz
|
||||
|
||||
# Yarn Integrity file
|
||||
.yarn-integrity
|
||||
|
||||
# dotenv environment variables file
|
||||
.env
|
||||
.env.test
|
||||
|
||||
# parcel-bundler cache (https://parceljs.org/)
|
||||
.cache
|
||||
.parcel-cache
|
||||
|
||||
# Next.js build output
|
||||
.next
|
||||
out
|
||||
|
||||
# Nuxt.js build / generate output
|
||||
.nuxt
|
||||
dist
|
||||
|
||||
# Gatsby files
|
||||
.cache/
|
||||
# Comment in the public line in if your project uses Gatsby and not Next.js
|
||||
# https://nextjs.org/blog/next-9-1#public-directory-support
|
||||
# public
|
||||
|
||||
# vuepress build output
|
||||
.vuepress/dist
|
||||
|
||||
# Serverless directories
|
||||
.serverless/
|
||||
|
||||
# FuseBox cache
|
||||
.fusebox/
|
||||
|
||||
# DynamoDB Local files
|
||||
.dynamodb/
|
||||
|
||||
# TernJS port file
|
||||
.tern-port
|
||||
|
||||
# Stores VSCode versions used for testing VSCode extensions
|
||||
.vscode-test
|
||||
|
||||
# yarn v2
|
||||
.yarn/cache
|
||||
.yarn/unplugged
|
||||
.yarn/build-state.yml
|
||||
.yarn/install-state.gz
|
||||
.pnp.*
|
||||
43
packages/host/package.json
Normal file
43
packages/host/package.json
Normal file
@@ -0,0 +1,43 @@
|
||||
{
|
||||
"name": "host",
|
||||
"version": "1.0.0",
|
||||
"scripts": {
|
||||
"build": "webpack --mode production",
|
||||
"build:dev": "webpack --mode development",
|
||||
"build:start": "cd dist && PORT=8080 npx serve",
|
||||
"start": "webpack serve --open --mode development",
|
||||
"start:live": "webpack serve --open --mode development --live-reload --hot"
|
||||
},
|
||||
"license": "MIT",
|
||||
"author": {
|
||||
"name": "Jack Herrington",
|
||||
"email": "jherr@pobox.com"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.15.8",
|
||||
"@babel/plugin-transform-runtime": "^7.15.8",
|
||||
"@babel/preset-env": "^7.15.8",
|
||||
"@babel/preset-react": "^7.14.5",
|
||||
"@babel/preset-typescript": "^7.10.4",
|
||||
"@types/react": "^17.0.2",
|
||||
"@types/react-dom": "^17.0.2",
|
||||
"autoprefixer": "^10.1.0",
|
||||
"babel-loader": "^8.2.2",
|
||||
"css-loader": "^6.3.0",
|
||||
"html-webpack-plugin": "^5.3.2",
|
||||
"postcss": "^8.2.1",
|
||||
"postcss-loader": "^4.1.0",
|
||||
"shared-types": "1.0.0",
|
||||
"style-loader": "^3.3.0",
|
||||
"typescript": "^4.5.2",
|
||||
"webpack": "^5.57.1",
|
||||
"webpack-cli": "^4.9.0",
|
||||
"webpack-dev-server": "^4.3.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"@reduxjs/toolkit": "^1.8.5",
|
||||
"react": "^17.0.2",
|
||||
"react-dom": "^17.0.2",
|
||||
"react-redux": "^8.0.4"
|
||||
}
|
||||
}
|
||||
32
packages/host/src/App.tsx
Normal file
32
packages/host/src/App.tsx
Normal file
@@ -0,0 +1,32 @@
|
||||
import React, { useEffect } from 'react'
|
||||
import ReactDOM from 'react-dom'
|
||||
import Counter from 'remote/Counter'
|
||||
import './index.css'
|
||||
import { Counter as CounterComponentType } from 'shared-types'
|
||||
import SvelteCounter from 'remoteSvelte/Counter'
|
||||
import { StoreProvider } from 'store/store'
|
||||
|
||||
const CounterComp = Counter as CounterComponentType
|
||||
|
||||
const App = () => {
|
||||
useEffect(() => {
|
||||
new SvelteCounter({
|
||||
target: document.getElementById('svelteApp'),
|
||||
})
|
||||
}, [])
|
||||
|
||||
return (
|
||||
<div className="container">
|
||||
<CounterComp initialValue={2} />
|
||||
|
||||
<div id={'svelteApp'}></div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
ReactDOM.render(
|
||||
<StoreProvider>
|
||||
<App />
|
||||
</StoreProvider>,
|
||||
document.getElementById('app'),
|
||||
)
|
||||
10
packages/host/src/index.css
Normal file
10
packages/host/src/index.css
Normal file
@@ -0,0 +1,10 @@
|
||||
body {
|
||||
font-family: Arial, Helvetica, sans-serif;
|
||||
}
|
||||
|
||||
.container {
|
||||
font-size: 3rem;
|
||||
margin: auto;
|
||||
max-width: 800px;
|
||||
margin-top: 20px;
|
||||
}
|
||||
15
packages/host/src/index.html
Normal file
15
packages/host/src/index.html
Normal file
@@ -0,0 +1,15 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>host</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
3
packages/host/src/index.ts
Normal file
3
packages/host/src/index.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
import("./App");
|
||||
|
||||
export {};
|
||||
2
packages/host/src/remote.d.ts
vendored
Normal file
2
packages/host/src/remote.d.ts
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
declare module "remote/Counter";
|
||||
declare module "remoteSvelte/Counter";
|
||||
35
packages/host/tsconfig.json
Normal file
35
packages/host/tsconfig.json
Normal file
@@ -0,0 +1,35 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es5",
|
||||
"lib": [
|
||||
"dom",
|
||||
"dom.iterable",
|
||||
"esnext"
|
||||
],
|
||||
"allowJs": true,
|
||||
"skipLibCheck": true,
|
||||
"esModuleInterop": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"strict": false,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"module": "esnext",
|
||||
"moduleResolution": "node",
|
||||
"resolveJsonModule": true,
|
||||
"isolatedModules": true,
|
||||
"noEmit": true,
|
||||
"jsx": "react",
|
||||
"baseUrl": "./src",
|
||||
"rootDir": ".",
|
||||
"suppressImplicitAnyIndexErrors": true,
|
||||
"strictNullChecks": false,
|
||||
"noImplicitAny": false,
|
||||
"noFallthroughCasesInSwitch": true
|
||||
},
|
||||
"include": [
|
||||
"src"
|
||||
],
|
||||
"exclude": [
|
||||
"src/test/**",
|
||||
"node_modules"
|
||||
]
|
||||
}
|
||||
67
packages/host/webpack.config.js
Normal file
67
packages/host/webpack.config.js
Normal file
@@ -0,0 +1,67 @@
|
||||
const HtmlWebPackPlugin = require("html-webpack-plugin");
|
||||
const ModuleFederationPlugin = require("webpack/lib/container/ModuleFederationPlugin");
|
||||
|
||||
const deps = require("./package.json").dependencies;
|
||||
module.exports = {
|
||||
output: {
|
||||
publicPath: "http://localhost:8080/",
|
||||
},
|
||||
|
||||
resolve: {
|
||||
extensions: [".tsx", ".ts", ".jsx", ".js", ".json"],
|
||||
},
|
||||
|
||||
devServer: {
|
||||
port: 8080,
|
||||
historyApiFallback: true,
|
||||
},
|
||||
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.m?js/,
|
||||
type: "javascript/auto",
|
||||
resolve: {
|
||||
fullySpecified: false,
|
||||
},
|
||||
},
|
||||
{
|
||||
test: /\.(css|s[ac]ss)$/i,
|
||||
use: ["style-loader", "css-loader", "postcss-loader"],
|
||||
},
|
||||
{
|
||||
test: /\.(ts|tsx|js|jsx)$/,
|
||||
exclude: /node_modules/,
|
||||
use: {
|
||||
loader: "babel-loader",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
plugins: [
|
||||
new ModuleFederationPlugin({
|
||||
name: "host",
|
||||
filename: "remoteEntry.js",
|
||||
remotes: {
|
||||
remote: "remote@http://localhost:3000/remoteEntry.js",
|
||||
remoteSvelte: "remoteSvelte@http://localhost:3001/remoteEntry.js",
|
||||
store: "store@http://localhost:7070/remoteEntry.js",
|
||||
},
|
||||
shared: {
|
||||
...deps,
|
||||
react: {
|
||||
singleton: true,
|
||||
requiredVersion: deps.react,
|
||||
},
|
||||
"react-dom": {
|
||||
singleton: true,
|
||||
requiredVersion: deps["react-dom"],
|
||||
},
|
||||
},
|
||||
}),
|
||||
new HtmlWebPackPlugin({
|
||||
template: "./src/index.html",
|
||||
}),
|
||||
],
|
||||
};
|
||||
3867
packages/host/yarn.lock
Normal file
3867
packages/host/yarn.lock
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user