Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: setup stencil development environment with component preview #1196

Merged
merged 3 commits into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -120,3 +120,6 @@ packages/devreact/webpack.config.json

# Local Netlify folder
.netlify

# Turborepo
.turbo
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"postinstall": "patch-package",
"link-packages": "./scripts/link-packages.sh",
"prepare": "husky install",
"dev:core": "turbo run dev --parallel --filter=@metamask/sdk-communication-layer --filter=@metamask/sdk --filter=@metamask/sdk-react",
"lint": "yarn workspaces foreach --no-private run lint",
"lint:changelogs": "yarn workspaces foreach --no-private run lint:changelog",
"lint:eslint": "yarn workspaces foreach --no-private run lint:eslint",
Expand Down Expand Up @@ -86,6 +87,8 @@
"rimraf": "^3.0.2",
"serve": "^14.2.1",
"ts-jest": "^29.0.3",
"turbo": "^2.3.3",
"turborepo": "^0.0.1",
"typescript": "^4.3.5"
},
"engines": {
Expand Down
2 changes: 2 additions & 0 deletions packages/sdk-communication-layer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"build:clean": "yarn clean && yarn build",
"build": "yarn build:types && rollup -c --bundleConfigAsCjs",
"build:dev": "yarn build:types && NODE_ENV=dev rollup -c --bundleConfigAsCjs",
"dev": "concurrently \"tsc --watch\" \"rollup -c --bundleConfigAsCjs -w\"",
"build:post-tsc": "echo 'N/A'",
"build:pre-tsc": "echo 'N/A'",
"size": "size-limit",
Expand Down Expand Up @@ -69,6 +70,7 @@
"@types/uuid": "^9.0.0",
"@typescript-eslint/eslint-plugin": "^4.26.0",
"@typescript-eslint/parser": "^4.26.0",
"concurrently": "^9.1.2",
"cross-fetch": "^4.0.0",
"eciesjs": "^0.4.11",
"eslint": "^7.30.0",
Expand Down
1 change: 1 addition & 0 deletions packages/sdk-install-modal-web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"generate": "stencil generate",
"build:types": "tsc --project tsconfig.json --emitDeclarationOnly --outDir dist/types",
"build:clean": "yarn clean && yarn build",
"dev": "stencil build --dev --watch --serve",
"build": "stencil build --prod",
"build:dev": "NODE_ENV=development stencil build --debug --dev",
"build:tsc": "tsc --build tsconfig.json --verbose",
Expand Down
82 changes: 82 additions & 0 deletions packages/sdk-install-modal-web/src/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<!DOCTYPE html>
<html dir="ltr" lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=5.0" />
<title>SDK Install Modal Web</title>
<script type="module" src="/build/sdk-install-modal-web.esm.js"></script>
<script nomodule src="/build/sdk-install-modal-web.js"></script>
<style>
.nav {
padding: 20px;
background: #f5f5f5;
margin-bottom: 20px;
position: fixed;
top: 0;
left: 0;
right: 0;
z-index: 100000;
}
.nav a {
margin-right: 15px;
color: #333;
text-decoration: none;
}
.nav a:hover {
text-decoration: underline;
}
.component-container {
padding: 20px;
margin-top: 60px;
}
</style>
</head>
<body>
<div class="nav">
<a href="#install">Install Modal</a>
<a href="#pending">Pending Modal</a>
<a href="#select">Select Modal</a>
</div>

<div class="component-container">
<div id="install" style="display: none">
<h2>Install Modal</h2>
<mm-install-modal
link="https://example.com/install"
sdk-version="1.0.0"
prefer-desktop="true"
></mm-install-modal>
</div>

<div id="pending" style="display: none">
<h2>Pending Modal</h2>
<mm-pending-modal></mm-pending-modal>
</div>

<div id="select" style="display: none">
<h2>Select Modal</h2>
<mm-select-modal
link="https://example.com/select"
sdk-version="1.0.0"
prefer-desktop="true"
></mm-select-modal>
</div>
</div>

<script>
function showComponent() {
const hash = window.location.hash || '#install';
document.querySelectorAll('.component-container > div').forEach(div => {
div.style.display = 'none';
});
const componentDiv = document.querySelector(hash);
if (componentDiv) {
componentDiv.style.display = 'block';
}
}

window.addEventListener('hashchange', showComponent);
showComponent();
</script>
</body>
</html>
5 changes: 5 additions & 0 deletions packages/sdk-install-modal-web/stencil.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ export const config: Config = {
type: 'dist',
isPrimaryPackageOutputTarget: true,
},
{
type: 'www',
serviceWorker: null,
baseUrl: 'http://localhost:4444/'
}
],
enableCache: true,
buildEs5: false,
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"build:post-tsc": "echo 'N/A'",
"build:pre-tsc": "echo 'N/A'",
"clean": "rimraf dist",
"dev": "rollup -c -w",
"dev": "rollup -c -w --bundleConfigAsCjs",
"lint": "yarn lint:eslint && yarn lint:misc --check",
"lint:changelog": "../../scripts/validate-changelog.sh @metamask/sdk-react",
"lint:eslint": "eslint . --cache --ext js,ts",
Expand Down
6 changes: 4 additions & 2 deletions packages/sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
"build:types": "tsc --project tsconfig.build.json --emitDeclarationOnly --outDir dist/types",
"build": "yarn build:types && rollup -c --bundleConfigAsCjs",
"build:clean": "yarn clean && yarn build",
"build:dev": "yarn build:types && NODE_ENV=dev rollup -c --bundleConfigAsCjs",
"build:post-tsc": "echo 'N/A'",
"build:pre-tsc": "echo 'N/A'",
"typecheck": "tsc --noEmit",
Expand All @@ -44,7 +43,9 @@
"test:e2e": "jest --testPathPattern \"/e2e/\"",
"test:ci": "jest --coverage --passWithNoTests --setupFilesAfterEnv ./jest-preload.js --testPathIgnorePatterns \"/e2e/\"",
"test:dev": "jest -c ./jest.config.ts --detectOpenHandles --testPathIgnorePatterns \"/e2e/\"",
"watch": "rollup -c -w"
"watch": "rollup -c -w",
"dev": "concurrently \"tsc --watch\" \"rollup -c -w --bundleConfigAsCjs\"",
"build:dev": "yarn build:types && NODE_ENV=dev rollup -c --bundleConfigAsCjs"
},
"dependencies": {
"@babel/runtime": "^7.26.0",
Expand Down Expand Up @@ -91,6 +92,7 @@
"@typescript-eslint/parser": "^4.26.0",
"browserify-zlib": "^0.2.0",
"buffer": "^6.0.3",
"concurrently": "^9.1.2",
"crypto-browserify": "^3.12.0",
"eslint": "^7.30.0",
"eslint-config-prettier": "^8.3.0",
Expand Down
34 changes: 34 additions & 0 deletions turbo.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"$schema": "https://turbo.build/schema.json",
"globalDependencies": [
"**/.env.*local"
],
"globalEnv": [
"NODE_ENV",
"SITEED_NPM_TOKEN"
],
"tasks": {
"build": {
"dependsOn": [
"^build"
],
"outputs": [
"dist/**",
".next/**"
]
},
"check-types": {
"dependsOn": [
"^check-types"
]
},
"lint": {
"outputs": []
},
"dev": {
"cache": false,
"persistent": true,
"outputs": ["dist/**"]
}
}
}
Loading
Loading