GitHub iconTwitter icon

Recent

git commit --amend --author="Author Name <email@address.com>" --no-edit

after that, change entire project commit.

git rebase -r --root --exec "git commit --amend --no-edit --reset-author"

`Author Name <email@address.com>` is newer author info.

refs: https://stackoverflow.com/questions/750172/how-do-i-change-the-author-and-committer-name-email-for-multiple-commits

`RUST_LOG=trace cargo test -- --nocapture`

use swc_core::ecma::{ast::Ident, visit::VisitMut};
use tracing::debug;

pub struct Whatplatform;

impl VisitMut for Whatplatform {
    // Implement necessary visit_mut_* methods for actual custom transform.
    // A comprehensive list of possible visitor methods can be found here:
    // https://rustdoc.swc.rs/swc_ecma_visit/trait.VisitMut.html
    fn visit_mut_ident(&mut self, n: &mut Ident) {
        debug!("Values: {:#?}", n);
    }
}
import "package"

declare module "package" {
  interface types {}
}

`permissions` is required Check https://github.com/{repo}/settings/actions Workflow permissions with `Allow github actions create and approve pull request` & `Read & Write permissons`.

name: Release
on:
  push:
    branches:
      - main
      - master
      - 'releases/*'
env:
  CI: true
jobs:
  version:
    timeout-minutes: 15
    runs-on: ubuntu-latest
    permissions:
      id-token: write
      contents: write
      packages: write
      pull-requests: write
      issues: read
    steps:
      - name: checkout code repository
        uses: actions/checkout@v2
        with:
          fetch-depth: 0
      - name: setup node.js
        uses: actions/setup-node@v2
        with:
          node-version: 14
      - name: install pnpm
        run: npm i pnpm@7.23.0 -g
      - name: install dependencies
        run: pnpm install --frozen-lockfile=false
      - name: create and publish versions
        uses: changesets/action@master
        with:
          version: pnpm ci:version
          commit: "chore: update versions"
          title: "chore: update versions"
          publish: pnpm ci:publish
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

`ln -s ./packages/core/CHANGELOG.md CHANGELOG.md`

docs: https://nodejs.org/api/corepack.html

important

{
  "packageManager": "pnpm@version"
}
  1. `corepack enable` will auto switch to `pnpm@7`(from `package.json`) if `pnpm@7` available.
  2. use pnpm@7 - `corepack prepare pnpm@latest-7 --activate`
  3. use pnpm@8 - `corepack prepare pnpm@latest-8 --activate`

Somethings, corepack will not working as expect, please uninstall pnpm older pnpm version with `pnpm uninstall pnpm@version -g`.

refs:

  • https://github.com/pnpm/pnpm/issues/1383
class DeleteEmptyAssetsPlugin {
  trash: string[];
  apply(compiler: Compiler) {
    compiler.hooks.thisCompilation.tap('DeleteEmptyAssetsPlugin', compilation => {
      compilation.hooks.afterOptimizeAssets.tap('DeleteEmptyAssetsPlugin', assets => {
        const emptyAssets = Object.keys(assets).filter(filename => {
          const asset = assets[filename];
          return asset.size() === 0;
        });
        if (emptyAssets.length !== 0) {
          console.log('Found empty chunks, try to delete it!');
        }
        emptyAssets.forEach(asset => delete compilation.assets[asset]);
      });
    });
  }
}

Only ignore `.css`, `*.module.css` will still process by `bundler` to generate `.json` file.

webpack

{
  test: CSS_RE,
  exclude: CSS_MODULES_RE,
  sideEffects: true,
  use: [
    {
      loader: require.resolve('@ies/pace-kit/ignore-loader.cjs'),
    },
  ],
}

Based on `react-router@v6`

function generatePaths(route: RouteObject, parentPath = '') {
  const { path, children } = route
  const fullPath = cleanDoubleSlashes(withoutTrailingSlash(`${parentPath}/${path ?? ''}`))

  let paths = new Set([fullPath])

  if (children) {
    for (const childRoute of children) {
      const childPaths = generatePaths(childRoute, fullPath)
      paths = new Set([...paths, ...childPaths])
    }
  }

  return paths
}

// Paths should be uniq
const paths = routes.flatMap(route => Array.from(generatePaths(route)))
replace({
  delimiters: ['', ''],
  preventAssignment: true,
  values: {
    'import \'source-map-support/register.js\';': '',
  },
})