Skip to content

Commit

Permalink
Merge branch 'main' into remote-path-base-dts
Browse files Browse the repository at this point in the history
  • Loading branch information
sbvice authored Oct 4, 2024
2 parents 4d44ce2 + 8ebfa92 commit 673f969
Show file tree
Hide file tree
Showing 410 changed files with 16,190 additions and 20,941 deletions.
3 changes: 2 additions & 1 deletion .changeset/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
"@module-federation/bridge-shared",
"@module-federation/bridge-react-webpack-plugin",
"@module-federation/modern-js",
"@module-federation/retry-plugin"
"@module-federation/retry-plugin",
"@module-federation/data-prefetch"
]
],
"ignorePatterns": ["^alpha|^beta"],
Expand Down
8 changes: 6 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,18 @@
"rules": {
"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-unused-vars": "off"
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/no-extra-semi": "error",
"no-extra-semi": "off"
}
},
{
"files": ["*.js", "*.jsx"],
"extends": ["plugin:@nx/javascript"],
"rules": {
"@typescript-eslint/no-useless-constructor": "off"
"@typescript-eslint/no-useless-constructor": "off",
"@typescript-eslint/no-extra-semi": "error",
"no-extra-semi": "off"
}
},
{
Expand Down
7 changes: 5 additions & 2 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,17 @@ jobs:
- name: Check Code Format
run: npx nx format:check

- name: Warm Nx Cache
run: npx nx run-many --targets=build --projects=tag:type:pkg

- name: Run Build for All
run: npx nx run-many --targets=build --projects=tag:type:pkg --skip-nx-cache

- name: Run Affected Test
run: npx nx affected -t test --parallel=2 --exclude='*,!tag:type:pkg' --skip-nx-cache

- name: Warm Nx Cache
run: npx nx run-many --targets=build --projects=tag:type:pkg
- name: Run Affected Experimental Tests
run: npx nx affected -t test:experiments --parallel=2 --exclude='*,!tag:type:pkg' --skip-nx-cache

e2e-modern:
needs: checkout-install
Expand Down
36 changes: 31 additions & 5 deletions .github/workflows/devtools.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
branches: [main]

env:
PLAYWRIGHT_BROWSERS_PATH: 0 # Places binaries to node_modules/@playwright/test
PLAYWRIGHT_BROWSERS_PATH: 0

jobs:
main:
Expand All @@ -35,14 +35,40 @@ jobs:
run: pnpm install

- name: Run Affected Build
run: npx nx run-many --targets=build --projects=tag:type:pkg --skip-nx-cache
run: npx nx run-many --targets=build --projects=tag:type:pkg

- name: Configuration xvfb
shell: bash
run: sudo apt-get update && sudo apt-get install xvfb

- name: E2E Chrome Devtools
run: pnpm run app:manifest:dev & echo "done" && npx wait-on tcp:3009 tcp:3010 tcp:3011 tcp:3012 && sleep 10 && npx nx e2e:devtools chrome-devtools
- name: E2E Chrome Devtools Dev
uses: nick-fields/retry@v3
with:
timeout_minutes: 15
max_attempts: 3
command: |
npx kill-port 3009 3010 3011 3012 3013 4001 &&
pnpm run app:manifest:dev & echo "done" && \
npx wait-on tcp:3009 tcp:3010 tcp:3011 tcp:3012 tcp:3013 && \
sleep 10 &&
npx nx e2e:devtools chrome-devtools
- name: E2E Chrome Devtools Prod
uses: nick-fields/retry@v3
with:
timeout_minutes: 15
max_attempts: 3
command: |
npx kill-port 3009 3010 3011 3012 3013 4001 &&
npx kill-port 3009 3010 3011 3012 3013 4001 &&
pnpm run app:manifest:prod & echo "done" && \
npx kill-port 4001
npx wait-on tcp:3009 tcp:3010 tcp:3011 tcp:3012 tcp:3013 && \
sleep 10 &&
npx nx e2e:devtools chrome-devtools
- name: kill port
run: lsof -ti tcp:3008,3009,3010,3011,3012 | xargs kill
run: npx kill-port 3013 3009 3010 3011 3012 4001; exit 0

- name: Kill All Node Processes
run: pkill -f node || true
8 changes: 6 additions & 2 deletions .github/workflows/e2e-manifest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ jobs:
id: check-ci
run: node tools/scripts/ci-is-affected.mjs --appName=manifest-webpack-host

- name: E2E Test for Manifest Demo
- name: E2E Test for Manifest Demo Development
if: steps.check-ci.outcome == 'success'
run: pnpm run app:manifest:dev & echo "done" && npx wait-on tcp:3009 && npx wait-on tcp:3012 && npx nx run-many --target=e2e --projects=manifest-webpack-host --parallel=1 && npx kill-port 3013 3009 3010 3011 3012
run: pnpm run app:manifest:dev & echo "done" && npx wait-on tcp:3009 && npx wait-on tcp:3012 && npx wait-on http://127.0.0.1:4001/ && npx nx run-many --target=e2e --projects=manifest-webpack-host --parallel=1 && npx kill-port 3013 3009 3010 3011 3012 4001

- name: E2E Test for Manifest Demo Production
if: steps.check-ci.outcome == 'success'
run: pnpm run app:manifest:prod & echo "done" && npx wait-on tcp:3009 && npx wait-on tcp:3012 && npx wait-on http://127.0.0.1:4001/ && npx nx run-many --target=e2e --projects=manifest-webpack-host --parallel=1 && npx kill-port 3013 3009 3010 3011 3012 4001
3 changes: 3 additions & 0 deletions .github/workflows/e2e-modern.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,6 @@ jobs:
- name: E2E Test for ModernJS
if: steps.check-ci.outcome == 'success'
run: npx kill-port --port 4001 && npx nx run-many --target=test:e2e --projects=modernjs --parallel=1 && npx kill-port --port 4001

- name: Kill ports
run: npx kill-port --port 4001
4 changes: 2 additions & 2 deletions .github/workflows/e2e-next-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ jobs:
- name: E2E Test for Next.js Dev
if: steps.check-ci.outcome == 'success'
run: |
pnpm run app:next:dev > /dev/null 2>&1 &
pnpm run app:next:dev &
sleep 1 &&
npx wait-on tcp:3001 &&
npx wait-on tcp:3002 &&
npx wait-on tcp:3000 &&
npx nx run-many --target=test:e2e --projects=3000-home,3001-shop,3002-checkout --parallel=1 &&
lsof -ti tcp:3000,3001,3002 | xargs kill
npx kill-port 3000,3001,3002
2 changes: 1 addition & 1 deletion .github/workflows/e2e-next-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@ jobs:
npx wait-on tcp:3002 &&
npx wait-on tcp:3000 &&
npx nx run-many --target=test:e2e --projects=3000-home,3001-shop,3002-checkout --parallel=1 &&
lsof -ti tcp:3000,3001,3002 | xargs kill
npx kill-port 3000,3001,3002
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
- name: Install deps
run: pnpm install

- name: Build and test Packages
- name: Build Packages
run: pnpm run build:pkg

- name: Release
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,8 @@ packages/enhanced/test/js

# dts test cases
**/dist-test
**/cache
**/cache/**
**/dist-test/**
**/cypress/downloads
/packages/data-prefetch/jest/cache/
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@
pnpm-lock.yaml
**/dist/**
apps/website-new/docs

/.nx/workspace-data
/.nx/cache
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ You can consider the module federation capabilities provided by this repository

## ✨ What new features does Module Federation provide?

* 🎨 Module Federation Runtime
* 🧩 Runtime Plugins System
* 📝 Manifest
* 🚀 Dynamic type prompt
* 🛠️ Chrome Devtool
- 🎨 Module Federation Runtime
- 🧩 Runtime Plugins System
- 📝 Manifest
- 🚀 Dynamic type prompt
- 🛠️ Chrome Devtool

## 📚 Getting Started

Expand Down
123 changes: 123 additions & 0 deletions ai-lint-fix.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
#!/usr/bin/env node

const { execSync, execFileSync } = require('child_process');
const fs = require('fs');
const path = require('path');
const { OpenAI } = require('openai');
const yargs = require('yargs/yargs');
const { hideBin } = require('yargs/helpers');
const glob = require('glob');
// Initialize OpenAI client
const openai = new OpenAI({
apiKey: process.env.OPENAI_API_KEY,
});

// Parse command line arguments
const argv = yargs(hideBin(process.argv))
.option('pattern', {
alias: 'p',
type: 'string',
description: 'Glob pattern to match files',
})
.option('path', {
alias: 'f',
type: 'string',
description: 'Path to a specific file',
})
.check((argv) => {
if (!argv.pattern && !argv.path) {
throw new Error('You must provide either a --pattern or --path argument');
}
return true;
})
.help()
.alias('help', 'h').argv;

async function lintFileContent(fileContent) {
const prompt = `Perform safe cleanup and linting on the following file content.
RULES:
-Should preserve uses of normalizeWebpackPath
-Should preserve uses of ts-ignore
-Should improve the source code while ensuing its logic is preserved and functionality is not altered
-Update existing comments for accuracy
-Return only the updated file content with no other response text:
${fileContent}`;

const response = await openai.chat.completions.create({
model: 'gpt-4o',
messages: [{ role: 'user', content: prompt }],
max_completion_tokens: 4096,
});

let res = response.choices[0].message.content.trim().split('\n');
if (res[0].startsWith('`')) {
res[0] = undefined;
}

if (res[res.length - 1].startsWith('`')) {
res[res.length - 1] = undefined;
}

return res.filter((r) => r).join('\n');
}

async function processFile(filePath) {
const fileContent = fs.readFileSync(filePath, 'utf8');
try {
const lintedContent = await lintFileContent(fileContent);
fs.writeFileSync(filePath, lintedContent, 'utf8');
console.log(`File has been linted and updated successfully: ${filePath}`);
const tsConfigPath = findTsConfig(filePath);
try {
const tscOutput = execFileSync(
'tsc',
['--noEmit', '--project', tsConfigPath],
{
stdio: 'pipe',
},
).toString();
console.log(`TypeScript check passed for ${filePath}:\n${tscOutput}`);
} catch (error) {
console.error(
`TypeScript check failed for ${filePath}:\n${error.stdout.toString()}`,
);
}
} catch (error) {
console.error(`Error performing linting on ${filePath}:`, error.message);
process.exit(1);
}
}

function findTsConfig(filePath) {
let dir = path.dirname(filePath);
while (dir !== path.resolve(dir, '..')) {
const tsConfigPath = path.join(dir, 'tsconfig.json');
if (fs.existsSync(tsConfigPath)) {
return tsConfigPath;
}
dir = path.resolve(dir, '..');
}
throw new Error('tsconfig.json not found');
}

async function main() {
if (argv.path) {
await processFile(argv.path);
} else if (argv.pattern) {
console.log('pattern', argv.pattern);
try {
const files = await glob.glob(argv.pattern);

for (const filePath of files) {
await processFile(filePath);
}
} catch (err) {
console.error('Error finding files:', err.message);
process.exit(1);
}
}
execSync('nx format:write');
}

main();
1 change: 0 additions & 1 deletion apps/3000-home/components/SharedNav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ const SharedNav = () => {
</>
),
key: '/',
onMouseEnter: () => {},
},
{
className: 'shop-menu-link',
Expand Down
17 changes: 2 additions & 15 deletions apps/3000-home/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,9 @@
"dependencies": {
"antd": "5.19.1",
"@ant-design/cssinjs": "^1.21.0",
"buffer": "5.7.1",
"encoding": "0.1.13",
"eslint-scope": "7.2.2",
"events": "3.3.0",
"js-cookie": "3.0.5",
"lodash": "4.17.21",
"next": "14.1.2",
"node-fetch": "2.7.0",
"react": "18.2.0",
"react-dom": "18.2.0",
"schema-utils": "3.3.0",
"terser-webpack-plugin": "5.3.10",
"typescript": "5.3.3",
"upath": "2.0.1",
"url": "0.11.3",
"util": "0.12.5"
"next": "14.2.14",
"react": "18.3.1"
},
"devDependencies": {
"@module-federation/nextjs-mf": "workspace:*",
Expand Down
4 changes: 2 additions & 2 deletions apps/3000-home/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "apps/3000-home",
"projectType": "application",
"tags": [],
"targets": {
"build": {
"executor": "@nx/next:build",
Expand Down Expand Up @@ -93,6 +94,5 @@
]
}
}
},
"tags": []
}
}
24 changes: 2 additions & 22 deletions apps/3001-shop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,11 @@
"version": "1.0.0",
"private": true,
"dependencies": {
"acorn": "8.12.1",
"antd": "5.19.1",
"@ant-design/cssinjs": "^1.21.0",
"buffer": "5.7.1",
"chrome-trace-event": "1.0.4",
"encoding": "0.1.13",
"enhanced-resolve": "5.15.0",
"eslint-scope": "7.2.2",
"eventemitter3": "5.0.1",
"events": "3.3.0",
"fast-glob": "3.3.2",
"lodash": "4.17.21",
"next": "14.1.2",
"node-fetch": "2.7.0",
"react": "18.2.0",
"react-dom": "18.2.0",
"schema-utils": "3.3.0",
"semver": "6.3.1",
"tapable": "2.2.1",
"terser-webpack-plugin": "5.3.10",
"typescript": "5.3.3",
"upath": "2.0.1",
"url": "0.11.3",
"util": "0.12.5",
"webpack-sources": "3.2.3"
"next": "14.2.14",
"react": "18.3.1"
},
"devDependencies": {
"@module-federation/nextjs-mf": "workspace:*",
Expand Down
Loading

0 comments on commit 673f969

Please sign in to comment.