mirror of
https://github.com/outline/outline.git
synced 2026-06-13 03:14:59 +03:00
e32b3772b2
* chore(deps-dev): bump vite-plugin-babel from 1.6.0 to 1.7.3 Bumps [vite-plugin-babel](https://github.com/owlsdepartment/vite-plugin-babel) from 1.6.0 to 1.7.3. - [Commits](https://github.com/owlsdepartment/vite-plugin-babel/commits) --- updated-dependencies: - dependency-name: vite-plugin-babel dependency-version: 1.7.3 dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> * fix: Use include option for vite-plugin-babel TS transform vite-plugin-babel 1.7.0 added an `include` option defaulting to `/\.jsx?$/` (JS only) that is applied before `filter`, so .ts/.tsx files were no longer transformed by Babel and reached the parser with types intact. Switch to the `include` option to match TS files. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Tom Moor <tom@getoutline.com> Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
112 lines
3.0 KiB
TypeScript
112 lines
3.0 KiB
TypeScript
import path from "node:path";
|
|
import babel from "vite-plugin-babel";
|
|
import { defineConfig } from "vitest/config";
|
|
|
|
const aliases = {
|
|
"@server": path.resolve(__dirname, "./server"),
|
|
"@shared": path.resolve(__dirname, "./shared"),
|
|
"~": path.resolve(__dirname, "./app"),
|
|
plugins: path.resolve(__dirname, "./plugins"),
|
|
};
|
|
|
|
const fileMock = path.resolve(__dirname, "./__mocks__/fileMock.js");
|
|
|
|
const babelPlugin = () =>
|
|
babel({
|
|
include: /\.(t|j)sx?$/,
|
|
babelConfig: {
|
|
babelrc: false,
|
|
configFile: false,
|
|
sourceMaps: "inline",
|
|
presets: [
|
|
["@babel/preset-react", { runtime: "automatic" }],
|
|
["@babel/preset-typescript", { allowDeclareFields: true }],
|
|
],
|
|
plugins: [
|
|
"babel-plugin-transform-typescript-metadata",
|
|
["@babel/plugin-proposal-decorators", { legacy: true }],
|
|
"@babel/plugin-transform-class-properties",
|
|
],
|
|
},
|
|
});
|
|
|
|
const sharedConfig = {
|
|
resolve: { alias: aliases },
|
|
plugins: [babelPlugin()],
|
|
esbuild: false as const,
|
|
oxc: false as const,
|
|
};
|
|
|
|
const aliasesAsArray = Object.entries(aliases).map(([find, replacement]) => ({
|
|
find,
|
|
replacement,
|
|
}));
|
|
|
|
const fileMockAlias = { find: /\.(gif|ttf|eot|svg)$/, replacement: fileMock };
|
|
|
|
export default defineConfig({
|
|
...sharedConfig,
|
|
test: {
|
|
globals: true,
|
|
pool: "threads",
|
|
// Unhandled promise rejections are logged but don't fail tests on their own.
|
|
dangerouslyIgnoreUnhandledErrors: true,
|
|
projects: [
|
|
{
|
|
...sharedConfig,
|
|
test: {
|
|
name: "server",
|
|
globals: true,
|
|
environment: "node",
|
|
include: ["server/**/*.test.{ts,tsx}", "plugins/**/*.test.{ts,tsx}"],
|
|
setupFiles: [
|
|
"./__mocks__/console.js",
|
|
"./server/test/setupMocks.ts",
|
|
"./server/test/setup.ts",
|
|
],
|
|
globalSetup: ["./server/test/globalTeardown.ts"],
|
|
fileParallelism: true,
|
|
},
|
|
},
|
|
{
|
|
...sharedConfig,
|
|
resolve: { alias: [fileMockAlias, ...aliasesAsArray] },
|
|
test: {
|
|
name: "app",
|
|
globals: true,
|
|
environment: "jsdom",
|
|
environmentOptions: {
|
|
jsdom: { url: "http://localhost" },
|
|
},
|
|
include: ["app/**/*.test.{ts,tsx}"],
|
|
setupFiles: ["./__mocks__/window.js", "./app/test/setup.ts"],
|
|
},
|
|
},
|
|
{
|
|
...sharedConfig,
|
|
test: {
|
|
name: "shared-node",
|
|
globals: true,
|
|
environment: "node",
|
|
include: ["shared/**/*.test.{ts,tsx}"],
|
|
setupFiles: ["./__mocks__/console.js", "./shared/test/setup.ts"],
|
|
},
|
|
},
|
|
{
|
|
...sharedConfig,
|
|
resolve: { alias: [fileMockAlias, ...aliasesAsArray] },
|
|
test: {
|
|
name: "shared-jsdom",
|
|
globals: true,
|
|
environment: "jsdom",
|
|
environmentOptions: {
|
|
jsdom: { url: "http://localhost" },
|
|
},
|
|
include: ["shared/**/*.test.{ts,tsx}"],
|
|
setupFiles: ["./__mocks__/window.js"],
|
|
},
|
|
},
|
|
],
|
|
},
|
|
});
|