-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Enable Local Testing of Webpack Federation Module (get-starknet…
… remoteEntry.js) (#249) * feat: add webpack.config.dev.js for local serving of remoteEntry.js * chore: lint and optional env variable for SNAP_ID * fix: update get-starknet/webpack-dev-server dep to address security vulnerability * fix: remoteEntry.js serving done on static file from dist/webpack folder * chore: added .env.sample example file * feat: optional PUBLIC_PATH env variable to produce local remoteEntry.js * chore: updated README.md * fix: env variable for local environment resolved at build time
- Loading branch information
Showing
10 changed files
with
676 additions
and
112 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
SNAPI_ID=local:http://localhost:8081 |
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// eslint-disable-next-line @typescript-eslint/no-var-requires | ||
const path = require('path'); | ||
const Dotenv = require('dotenv-webpack'); | ||
const webpack = require('webpack'); | ||
|
||
module.exports = { | ||
entry: './src/index.ts', | ||
output: { | ||
path: path.resolve(__dirname, './dist/webpack'), | ||
filename: 'index.js', | ||
library: { | ||
type: 'commonjs2', | ||
}, | ||
}, | ||
resolve: { | ||
extensions: ['.ts', '.tsx', '.js'], | ||
}, | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.tsx?$/, | ||
use: 'ts-loader', | ||
exclude: /node_modules/, | ||
}, | ||
], | ||
}, | ||
plugins: [ | ||
new Dotenv(), | ||
new webpack.DefinePlugin({ | ||
'process.env.SNAP_ID': JSON.stringify(process.env.SNAP_ID || 'npm:@consensys/starknet-snap') | ||
}) | ||
] | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// eslint-disable-next-line @typescript-eslint/no-var-requires | ||
const { merge } = require('webpack-merge'); | ||
// eslint-disable-next-line @typescript-eslint/no-var-requires | ||
const common = require('./webpack.common.js'); | ||
// eslint-disable-next-line @typescript-eslint/no-var-requires | ||
const path = require('path'); | ||
module.exports = merge(common, { | ||
mode: 'development', | ||
output: { | ||
publicPath: 'http://localhost:8082/', // Adjust the development publicPath as needed | ||
}, | ||
devServer: { | ||
static: path.join(__dirname, 'dist/webpack'), | ||
compress: true, | ||
port: 8082, | ||
}, | ||
}); |
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// eslint-disable-next-line @typescript-eslint/no-var-requires | ||
const { merge } = require('webpack-merge'); | ||
// eslint-disable-next-line @typescript-eslint/no-var-requires | ||
const common = require('./webpack.common.js'); | ||
// eslint-disable-next-line @typescript-eslint/no-var-requires | ||
const { ModuleFederationPlugin } = require('webpack').container; | ||
|
||
module.exports = (env) => merge(common, { | ||
mode: 'production', | ||
output: { | ||
publicPath: env.PUBLIC_PATH || 'https://snaps.consensys.io/starknet/get-starknet/v1/', | ||
}, | ||
plugins: [ | ||
new ModuleFederationPlugin({ | ||
name: 'MetaMaskStarknetSnapWallet', | ||
filename: 'remoteEntry.js', | ||
exposes: { | ||
'./index': './src/index.ts', | ||
}, | ||
}), | ||
], | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
REACT_APP_SNAP_ID=local:http://localhost:8081/ | ||
REACT_APP_SNAP_ID=local:http://localhost:8081 | ||
REACT_APP_SNAP_VERSION=* | ||
REACT_APP_MIN_SNAP_VERSION=2.2.0 | ||
REACT_APP_DEBUG_LEVEL=all | ||
REACT_APP_DEBUG_LEVEL=all |
Oops, something went wrong.