Skip to content

Commit

Permalink
feat: umd support mako bundler (#750)
Browse files Browse the repository at this point in the history
* feat: use mako

* feat: umd support mako bundler

* fix: 不需要启动 dev 服务

* chore: use the same opts for bundler

* fix: delete code

* chore: 调整external与platform传入方式, 与bundle-webpack对齐

* chore: add entry assert

* chore: mako test case

* chore: 补充 mako 测试用例

---------

Co-authored-by: Jinbao1001 <[email protected]>
  • Loading branch information
xiaohuoni and Jinbao1001 authored Jun 4, 2024
1 parent a119151 commit b3697aa
Show file tree
Hide file tree
Showing 23 changed files with 3,639 additions and 3,961 deletions.
14 changes: 14 additions & 0 deletions examples/mako/.fatherrc.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { defineConfig } from '../../dist';
const path = require('path');

export default defineConfig({
umd: {
bundler: 'mako',
},
alias: {
'@': path.resolve(__dirname, './src'),
'hello-a': path.resolve(__dirname, './src/a.tsx'),
'hello-foo': path.resolve(__dirname, './src/foo.ts'),
},
platform: 'browser',
});
3 changes: 3 additions & 0 deletions examples/mako/mako.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"hmr": false
}
15 changes: 15 additions & 0 deletions examples/mako/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"scripts": {
"build": "father build",
"build:no-clean": "father build --no-clean",
"dev": "father dev",
"dev:no-clean": "father dev --no-clean",
"doctor": "father doctor",
"version": "father version"
},
"dependencies": {
"father": "workspace:*",
"react": "^18.2.0",
"react-dom": "^18.2.0"
}
}
15 changes: 15 additions & 0 deletions examples/mako/src/a.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
console.log('hello here');

// @ts-ignore
import React from 'react';
// @ts-ignore
import ReactDOM from 'react-dom';

function App({content}:{content:string}) {
// @ts-ignore
return <div>{content}</div>;
}

// @ts-ignore
const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(<App content={'hello'}/>);
7 changes: 7 additions & 0 deletions examples/mako/src/content.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class Content {
say() {
return 'Hello father';
}
}

export default new Content().say();
1 change: 1 addition & 0 deletions examples/mako/src/foo.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
console.log('foo here');
27 changes: 27 additions & 0 deletions examples/mako/src/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import content from '@/content';
import 'hello-a'
import 'hello-foo'










/*
import React from 'react';
import ReactDOM from 'react-dom';
// const content = 'Hello'
function App() {
return <div>{content}</div>;
}
// @ts-ignore
const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(<App />);
*/
console.log(content);
19 changes: 19 additions & 0 deletions examples/mako/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"compilerOptions": {
"declaration": true,
"declarationMap": true,
"esModuleInterop": true,
"module": "commonjs",
"moduleResolution": "node",
"noUnusedLocals": true,
"noUnusedParameters": true,
"strict": true,
"skipLibCheck": true,
"target": "es2015",
"jsx": "react",
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"]
}
}
}
43 changes: 24 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,12 @@
"format": "prettier --write .",
"prepare": "husky install",
"release": "esno scripts/release.ts",
"test": "jest",
"test:cov": "jest --collectCoverage"
"test": "jest --runInBand --forceExit",
"test:build": "jest tests/build.test.ts",
"test:cov": "jest --collectCoverage --runInBand --forceExit",
"test:dev": "jest tests/dev.test.ts",
"test:mako-build": "jest tests/mako.build.test.ts",
"test:mako-dev": "jest tests/mako.dev.test.ts"
},
"commitlint": {
"extends": [
Expand All @@ -43,12 +47,13 @@
},
"dependencies": {
"@microsoft/api-extractor": "7.39.1",
"@umijs/babel-preset-umi": "^4.2.8",
"@umijs/bundler-utils": "^4.2.8",
"@umijs/bundler-webpack": "^4.2.8",
"@umijs/babel-preset-umi": "^4.2.9",
"@umijs/bundler-mako": "0.5.3",
"@umijs/bundler-utils": "^4.2.9",
"@umijs/bundler-webpack": "^4.2.9",
"@umijs/case-sensitive-paths-webpack-plugin": "^1.0.1",
"@umijs/core": "^4.2.8",
"@umijs/utils": "^4.2.8",
"@umijs/core": "^4.2.9",
"@umijs/utils": "^4.2.9",
"@vercel/ncc": "0.33.3",
"babel-plugin-dynamic-import-node": "2.3.3",
"babel-plugin-module-resolver": "4.1.0",
Expand All @@ -66,25 +71,25 @@
"v8-compile-cache": "2.3.0"
},
"devDependencies": {
"@commitlint/cli": "^17.6.1",
"@commitlint/config-conventional": "^17.6.1",
"@swc/core": "^1.3.53",
"@types/jest": "^27",
"@commitlint/cli": "^17.8.1",
"@commitlint/config-conventional": "^17.8.1",
"@swc/core": "^1.5.24",
"@types/jest": "^27.5.2",
"@types/loader-runner": "2.2.4",
"@types/minimatch": "3.0.5",
"@types/node": "^18.15.13",
"@umijs/test": "^4.0.68",
"@types/node": "^18.19.34",
"@umijs/test": "^4.2.9",
"esno": "^0.16.3",
"git-repo-info": "^2.1.1",
"husky": "^8.0.3",
"jest": "^27",
"jest": "^27.5.1",
"jest-mock-process": "^1.5.1",
"lint-staged": "^13.2.1",
"prettier": "^2.8.7",
"prettier-plugin-organize-imports": "^3.2.2",
"prettier-plugin-packagejson": "^2.4.3",
"lint-staged": "^13.3.0",
"prettier": "^2.8.8",
"prettier-plugin-organize-imports": "^3.2.4",
"prettier-plugin-packagejson": "^2.5.0",
"rimraf": "^3.0.2",
"ts-node": "^10.9.1",
"ts-node": "^10.9.2",
"zx": "^4.3.0"
},
"packageManager": "[email protected]",
Expand Down
Loading

0 comments on commit b3697aa

Please sign in to comment.