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

refactor: use PNPM instead of Yarn & Vite instead of Webpack #1951

Draft
wants to merge 21 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions .github/workflows/pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ jobs:
registry-url: 'https://registry.npmjs.org'
- name: Build
run: |
yarn install
yarn workspace megalodon doc
corepack enable && pnpm install
pnpm --filter megalodon doc
- name: Setup Pages
uses: actions/configure-pages@v3
- name: Upload artifact
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ jobs:
cp LICENSE.txt ./megalodon/
- name: Install dependencies
run: |
yarn install
corepack enable && pnpm install
- name: Build
run: |
yarn workspace megalodon run build
pnpm --filter megalodon run build
- name: Publish
run: |
yarn workspace megalodon publish
pnpm --filter megalodon publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
8 changes: 4 additions & 4 deletions .github/workflows/reviewdog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,20 @@ jobs:
registry-url: 'https://registry.npmjs.org'
- name: Install dependencies
run: |
yarn install
corepack enable && pnpm install
- uses: reviewdog/action-setup@v1
- name: megalodon eslint
env:
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
yarn workspace megalodon lint | reviewdog -f=eslint -reporter=github-pr-review -fail-on-error=true
pnpm --filter megalodon lint | reviewdog -f=eslint -reporter=github-pr-review -fail-on-error=true
- name: example/typescript eslint
env:
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
yarn workspace example lint | reviewdog -f=eslint -reporter=github-pr-review -fail-on-error=true
pnpm --filter example lint | reviewdog -f=eslint -reporter=github-pr-review -fail-on-error=true
- name: example/browser eslint
env:
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
yarn workspace browser lint | reviewdog -f=eslint -reporter=github-pr-review -fail-on-error=true
pnpm --filter browser lint | reviewdog -f=eslint -reporter=github-pr-review -fail-on-error=true
19 changes: 9 additions & 10 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ jobs:
node-version: ${{ matrix.node-version }}
- name: Install dependencies
run: |
yarn install
corepack enable && pnpm install
- name: Build
run: |
yarn workspace megalodon run build
pnpm -r run build
- name: Testing
run: |
yarn workspace megalodon run test
pnpm --filter megalodon run test

example:
runs-on: ubuntu-latest
Expand All @@ -48,21 +48,20 @@ jobs:
node-version: ${{ matrix.node-version }}
- name: Install dependencies
run: |
yarn install
- name: Build
corepack enable && pnpm install
- name: Build library
run: |
yarn workspace megalodon run build
- name: Browser example
pnpm --filter megalodon run build
- name: Build examples
run: |
yarn workspace browser run build
pnpm --filter !megalodon run build
- name: Typescript example
env:
MASTODON_URL: https://fedibird.com
PLEROMA_URL: https://pleroma.io
FIREFISH_URL: https://cybre.club
FIREFISH_URL: https://fedi.software
FRIENDICA_URL: https://squeet.me
run: |
yarn workspace example run build
node example/typescript/dist/mastodon/instance.js
node example/typescript/dist/pleroma/instance.js
node example/typescript/dist/firefish/instance.js
Expand Down
2 changes: 1 addition & 1 deletion example/browser/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Megalodon</title>
<script src="./dist/main.js"></script>
<script type="module" src="./src/index.ts"></script>
</head>
<body>
</body>
Expand Down
14 changes: 9 additions & 5 deletions example/browser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,19 @@
"version": "4.0.0",
"private": true,
"scripts": {
"build": "webpack",
"build": "vite build",
"start": "http-server -p 8000 -s index.html",
"lint": "eslint --ext .js,.ts src"
"lint": "eslint --ext .js,.ts src",
"serve": "vite",
"preview": "vite preview"
},
"author": "Akira Fukushima <[email protected]> (https://github.com/h3poteto)",
"license": "MIT",
"dependencies": {
"megalodon": "*"
},
"devDependencies": {
"@originjs/vite-plugin-commonjs": "^1.0.1",
"assert": "^2.1.0",
"buffer": "^6.0.3",
"crypto-browserify": "^3.12.0",
Expand All @@ -27,7 +30,8 @@
"ts-loader": "^9.4.4",
"typescript": "5.2.2",
"url": "^0.11.3",
"webpack": "^5.88.2",
"webpack-cli": "^5.1.4"
"vite": "^2.7.2",
"vite-plugin-env-compatible": "^1.1.1",
"vite-plugin-html": "3.2.0"
}
}
}
4 changes: 3 additions & 1 deletion example/browser/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import generator, { Entity } from 'megalodon'
import { Entity } from 'megalodon'
// eslint-disable-next-line @typescript-eslint/no-var-requires
const generator = require('megalodon').default

const BASE_URL: string = process.env.MASTODON_URL!
const ACCESS_TOKEN: string = process.env.MASTODON_ACCESS_TOKEN!
Expand Down
38 changes: 38 additions & 0 deletions example/browser/vite.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { defineConfig } from 'vite'
import path from 'path'
import envCompatible from 'vite-plugin-env-compatible'
import { createHtmlPlugin } from 'vite-plugin-html'
import { viteCommonjs } from '@originjs/vite-plugin-commonjs'

// https://vitejs.dev/config/
export default defineConfig({
resolve: {
alias: [
{
find: /^~/,
replacement: ''
},
{
find: '@',
replacement: path.resolve(__dirname, 'src')
}
],
extensions: ['.mjs', '.js', '.ts']
},
plugins: [
viteCommonjs(),
envCompatible(),
createHtmlPlugin({
inject: {
data: {
title: 'browser'
}
}
})
],
optimizeDeps: {
// https-proxy-agent and socks-proxy-agent is node library, so can't compile for browser.
exclude: ['https-proxy-agent', 'socks-proxy-agent']
},
build: {}
})
58 changes: 0 additions & 58 deletions example/browser/webpack.config.js

This file was deleted.

6 changes: 1 addition & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
{
"private": true,
"workspaces": [
"megalodon",
"example/typescript",
"example/browser"
]
"packageManager": "[email protected]"
}
Loading
Loading