I had to be creative with TypeScript to prevent a common problem in our codebase, where we can't validate our *.d.ts files through skipLibCheck: false
and a type (Action
) sometimes become any
...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import type { Plugin } from 'vite' | |
import path from 'path' | |
const name = 'prevent-server-data-circular-imports' | |
const defaultOptions = { verbose: false } | |
// Detect if the module is in server-data | |
const serverDataFileRegexp = /(.*)?server-data\/src\// | |
// Extract the imported path |
This gist are for my Vite migration articles, here you can find the links to the articles
- Migrating a 150K LOC codebase to Vite and ESBuild: Why? (Part 1/3) (Medium - dev.to)
- Migrating a 150K LOC codebase to Vite and ESBuild: How? (Part 2/3) (Medium - dev.to)
- Migrating a 150K LOC codebase to Vite and ESBuild: Is it worthile? (Part 3/3) (Medium - [dev.to](https://dev.to/noriste/migrating-a-150k-loc-codebase-to-vite-and-esbuild-is-it-worthwhil
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// services | |
const fetchConfig = () => Promise.resolve({ hereId: 'foo', hereCode: 'bar' }) | |
const fetchOrder = () => Promise.resolve({ status: 'done', pods: [1, 2, 3] }) | |
const fetchOrder2 = () => { | |
if (Math.random() > 0.5) { | |
return Promise.resolve({ status: 'done', pods: [1, 2, 3] }) | |
} else { | |
return Promise.reject({ errorMessage: 'foo' }) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// services | |
const fetchConfig = () => Promise.resolve({ hereId: 'foo', hereCode: 'bar' }) | |
const fetchOrder = () => Promise.resolve({ status: 'done', pods: [1, 2, 3] }) | |
const fetchOrder2 = () => { | |
if (Math.random() > 0.5) { | |
return Promise.resolve({ status: 'done', pods: [1, 2, 3] }) | |
} else { | |
return Promise.reject({ errorMessage: 'foo' }) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# AUTOMATIC MIGRATION FROM WEBPACK TO VITE | |
# chmod +x migrate-to-vite.sh to make this file executable | |
# installing codemods | |
# https://docs.python-guide.org/starting/install3/osx/ | |
# https://dev.to/malwarebo/how-to-set-python3-as-a-default-python-version-on-mac-4jjf | |
# https://pip.pypa.io/en/stable/installing/#installing-with-get-pip-py | |
# NO NEED; ALREADY ON MASTER - (manual action) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// services | |
const fetchConfig = () => Promise.resolve({ hereId: 'foo', hereCode: 'bar' }) | |
const fetchOrder = () => Promise.resolve({ status: 'done', pods: [1, 2, 3] }) | |
const fetchIntl = () => Promise.resolve({ messages: { foo: 'bar' } }) | |
const fetchMachine = Machine( | |
{ | |
id: 'tracking-app', | |
initial: 'loading', | |
context: { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const setOnline = assign({ | |
offline: (context, event) => (context.offline = false), | |
}) | |
const setOffline = assign({ | |
offline: (context, event) => (context.offline = true), | |
}) | |
const setLastUpdate = assign({ | |
lastUpdate: (context, event) => (context.lastUpdate = Date.now()), | |
}) | |
const setStatusOk = assign({ |