Skip to content

Commit

Permalink
Merge pull request #2597 from opral/add-typecheck-to-build
Browse files Browse the repository at this point in the history
moves or adds tsc --noEmit from test to build phase
  • Loading branch information
LorisSigrist committed Apr 18, 2024
2 parents df93e84 + 43d8101 commit 94a6535
Show file tree
Hide file tree
Showing 20 changed files with 145 additions and 139 deletions.
4 changes: 2 additions & 2 deletions inlang/source-code/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
],
"scripts": {
"dev": "node ./build.js",
"build": "cross-env NODE_ENV=production node ./build.js",
"test": "tsc --noEmit && vitest run --passWithNoTests --coverage --test-timeout=10000",
"build": "cross-env NODE_ENV=production node ./build.js && tsc --noEmit",
"test": "vitest run --passWithNoTests --coverage --test-timeout=10000",
"lint": "eslint ./src --fix",
"format": "prettier ./src --write",
"clean": "rm -rf ./dist ./node_modules"
Expand Down
4 changes: 2 additions & 2 deletions inlang/source-code/editor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
"private": true,
"scripts": {
"dev": "vite",
"build": "paraglide-js compile --project ../../../project.inlang && vite build -- --max_old_space_size=1200000",
"build": "vite build -- --max_old_space_size=1200000 && tsc --noEmit",
"production": "NODE_ENV=production tsx ./src/server/main.ts",
"---- TEST ----------------------------------------------------------": "",
"test": "paraglide-js compile --project ../../../project.inlang && tsc --noEmit",
"test": "paraglide-js compile --project ../../../project.inlang",
"lint": "eslint ./src --fix",
"format": "prettier ./src --write",
"clean": "rm -rf ./dist ./node_modules"
Expand Down
4 changes: 2 additions & 2 deletions inlang/source-code/github-lint-action/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
},
"scripts": {
"dev": "node ./build.js",
"build": "pnpm run format && esbuild src/index.ts --bundle --platform=node --target=node20 --outfile=dist/index.cjs",
"test": "tsc --noEmit && vitest run --passWithNoTests --coverage --test-timeout=10000",
"build": "pnpm run format && tsc --noEmit && esbuild src/index.ts --bundle --platform=node --target=node20 --outfile=dist/index.cjs",
"test": "vitest run --passWithNoTests --coverage --test-timeout=10000",
"lint": "eslint ./src --fix",
"format": "prettier --write **/*.ts",
"clean": "rm -rf ./dist ./node_modules"
Expand Down
4 changes: 2 additions & 2 deletions inlang/source-code/ide-extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -143,14 +143,14 @@
},
"scripts": {
"check": "tsc --noEmit",
"build": "node ./build.js",
"build": "tsc --noEmit && node ./build.js",
"dev": "DEV=true node ./build.js",
"package": "pnpm vsce package --no-dependencies",
"publish": "pnpm vsce publish --no-dependencies",
"vscode:prepublish": "npm run build",
"---- TEST ----------------------------------------------------------": "",
"pretest": "node ./build.js",
"test": "tsc --noEmit && vitest run --passWithNoTests --coverage",
"test": "vitest run --passWithNoTests --coverage",
"test:e2e": "npm run pretest && wdio run ./test/wdio.conf.ts",
"---- LINT ----------------------------------------------------------": "",
"lint": "eslint ./src --fix",
Expand Down
150 changes: 64 additions & 86 deletions inlang/source-code/paraglide/paraglide-js-adapter-next/build.mjs
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
import { rollup } from "rollup"
import preserveDirectives from "rollup-preserve-directives"
import typescript from "@rollup/plugin-typescript"
import cjs from "@rollup/plugin-commonjs"
import json from "@rollup/plugin-json"
import resolve from "@rollup/plugin-node-resolve"
import replace from "@rollup/plugin-replace"
import { plugins } from "./plugins.mjs"
import fs from "node:fs/promises"

//remove the old dist folder
Expand All @@ -18,93 +13,76 @@ if (typeof version !== "string") {
const peerDependencies = Object.keys(packageJson.peerDependencies || {})
const dependencies = Object.keys(packageJson.dependencies || {})

export const plugins = [
typescript({ tsconfig: "./tsconfig.json" }),
cjs(),
resolve(),
preserveDirectives(),
json(),
replace({
values: {
MARKETPLACE_ID: JSON.stringify("library.inlang.paraglideJsAdapterNextJs"),
PARAGLIDE_NEXT_VERSION: JSON.stringify(version),
},
preventAssignment: true,
}),
]

// eslint-disable-next-line no-undef
if (process.env.SCRIPT === "build") {
// eslint-disable-next-line no-console
// eslint-disable-next-line no-undef
console.info(`Building ${packageJson.name} v${packageJson.version}...`)
// eslint-disable-next-line no-console
// eslint-disable-next-line no-undef
console.info(`Building ${packageJson.name} v${packageJson.version}...`)

const external = [
/node_modules/,
/^node:/,
"$paraglide/runtime.js",
...peerDependencies,
...dependencies,
]
const external = [
/node_modules/,
/^node:/,
"$paraglide/runtime.js",
...peerDependencies,
...dependencies,
]

const app_build = await rollup({
plugins,
input: {
"app/index.server": "src/app/index.server.tsx",
"app/index.client": "src/app/index.client.tsx",
},
external,
})
const app_build = await rollup({
plugins,
input: {
"app/index.server": "src/app/index.server.tsx",
"app/index.client": "src/app/index.client.tsx",
},
external,
})

const pages_build = await rollup({
plugins,
input: {
"pages/index": "src/pages/index.tsx",
},
external,
})
const pages_build = await rollup({
plugins,
input: {
"pages/index": "src/pages/index.tsx",
},
external,
})

const pluginBuild = await rollup({
plugins,
input: {
"plugin/index": "src/plugin/index.ts",
},
external,
})
const pluginBuild = await rollup({
plugins,
input: {
"plugin/index": "src/plugin/index.ts",
},
external,
})

const cliBuild = await rollup({
plugins,
input: {
"cli/index": "src/cli/index.ts",
},
external: [/^node:/, ...peerDependencies, ...dependencies],
})
const cliBuild = await rollup({
plugins,
input: {
"cli/index": "src/cli/index.ts",
},
external: [/^node:/, ...peerDependencies, ...dependencies],
})

await app_build.write({
preserveModules: true,
format: "es",
entryFileNames: "[name].js",
dir: "dist",
})
await app_build.write({
preserveModules: true,
format: "es",
entryFileNames: "[name].js",
dir: "dist",
})

await pages_build.write({
preserveModules: false,
format: "cjs",
entryFileNames: "[name].js",
dir: "dist",
})
await pages_build.write({
preserveModules: false,
format: "cjs",
entryFileNames: "[name].js",
dir: "dist",
})

await pluginBuild.write({
preserveModules: false,
format: "cjs",
entryFileNames: "[name].cjs",
dir: "dist",
})
await pluginBuild.write({
preserveModules: false,
format: "cjs",
entryFileNames: "[name].cjs",
dir: "dist",
})

await cliBuild.write({
preserveModules: true,
format: "esm",
entryFileNames: "[name].mjs",
dir: "dist",
})
}
await cliBuild.write({
preserveModules: true,
format: "esm",
entryFileNames: "[name].mjs",
dir: "dist",
})
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"url": "https://github.com/opral/inlang-paraglide-js"
},
"scripts": {
"build": "SCRIPT=build node ./build.mjs",
"build": "node ./build.mjs",
"clean": "rm -rf dist && rm -rf node_modules",
"test": "NODE_ENV=development vitest run && NODE_ENV=production vitest run",
"lint": "eslint ./src --fix"
Expand Down
29 changes: 29 additions & 0 deletions inlang/source-code/paraglide/paraglide-js-adapter-next/plugins.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { rollup } from "rollup"
import preserveDirectives from "rollup-preserve-directives"
import typescript from "@rollup/plugin-typescript"
import cjs from "@rollup/plugin-commonjs"
import json from "@rollup/plugin-json"
import resolve from "@rollup/plugin-node-resolve"
import replace from "@rollup/plugin-replace"
import fs from "node:fs/promises"

const packageJson = JSON.parse(await fs.readFile("./package.json", "utf-8"))
const version = packageJson.version
if (typeof version !== "string") {
throw new Error("the version in package.json is not a string")
}

export const plugins = [
typescript({ tsconfig: "./tsconfig.json" }),
cjs(),
resolve(),
preserveDirectives(),
json(),
replace({
values: {
MARKETPLACE_ID: JSON.stringify("library.inlang.paraglideJsAdapterNextJs"),
PARAGLIDE_NEXT_VERSION: JSON.stringify(version),
},
preventAssignment: true,
}),
]
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { dirname, resolve } from "node:path"
import { fileURLToPath } from "node:url"
import react from "@vitejs/plugin-react"
import { plugins } from "./build.mjs"
import { plugins } from "./plugins.mjs"

const __filename = resolve(fileURLToPath(import.meta.url))
const __dirname = dirname(__filename)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
{
"name": "@inlang/paraglide-js-adapter-rollup-example",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"build": "rollup src/main.js --config rollup.config.js",
"clean": "rm -rf ./dist ./node_modules ./src/paraglide"
},
"devDependencies": {
"@inlang/paraglide-js": "workspace:*",
"@inlang/paraglide-js-adapter-rollup": "workspace:*",
"rollup": "3.29.1",
"@rollup/plugin-alias": "^5.0.1",
"typescript": "^4.9.3"
}
"name": "@inlang/paraglide-js-adapter-rollup-example",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"build": "rollup src/main.js --config rollup.config.js && tsc --noEmit",
"clean": "rm -rf ./dist ./node_modules ./src/paraglide"
},
"devDependencies": {
"@inlang/paraglide-js": "workspace:*",
"@inlang/paraglide-js-adapter-rollup": "workspace:*",
"rollup": "3.29.1",
"@rollup/plugin-alias": "^5.0.1",
"typescript": "^4.9.3"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"scripts": {
"_dev": "vite dev",
"start": "vite dev",
"build": "vite build",
"build": "vite build && tsc --noEmit",
"test": "vite build",
"preview": "vite preview",
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"forceConsistentCasingInFileNames": true,
"resolveJsonModule": true,
"skipLibCheck": true,
"moduleResolution": "Bundler",
"sourceMap": true,
"strict": true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"test:with-base": "BASE_PATH=/base vitest run --test-timeout 30000 --dir src",
"test:without-base": "BASE_PATH=\"\" vitest run --test-timeout 30000 --dir src",
"test": "npm run test:with-base && npm run test:without-base",
"build": "svelte-package -i src -o dist",
"build": "tsc --noEmit && svelte-package -i src -o dist",
"dev": "svelte-package -w -i src -o dist",
"lint": "eslint ./src --fix",
"format": "prettier ./src --write",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"type": "module",
"scripts": {
"_dev": "vite dev",
"build": "vite build",
"build": "vite build && tsc --noEmit",
"clean": "rm -rf ./dist ./node_modules ./src/paraglide"
},
"devDependencies": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
{
"name": "@inlang/paraglide-js-adapter-webpack-example",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"build": "webpack --config webpack.config.js",
"clean": "rm -rf ./dist ./node_modules ./src/paraglide"
},
"devDependencies": {
"@inlang/paraglide-js": "workspace:*",
"@inlang/paraglide-js-adapter-webpack": "workspace:*",
"typescript": "^4.9.3",
"webpack": "^5.89.0",
"webpack-cli": "^5.1.4"
}
"name": "@inlang/paraglide-js-adapter-webpack-example",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"build": "webpack --config webpack.config.js && tsc --noEmit",
"clean": "rm -rf ./dist ./node_modules ./src/paraglide"
},
"devDependencies": {
"@inlang/paraglide-js": "workspace:*",
"@inlang/paraglide-js-adapter-webpack": "workspace:*",
"typescript": "^4.9.3",
"webpack": "^5.89.0",
"webpack-cli": "^5.1.4"
}
}
4 changes: 2 additions & 2 deletions inlang/source-code/paraglide/paraglide-js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
],
"scripts": {
"dev": "vite build --mode development --watch",
"build": "vite build --mode production",
"test": "tsc --noEmit --emitDeclarationOnly false && vitest run --coverage ./src/**/*",
"build": "tsc --noEmit --emitDeclarationOnly false && vite build --mode production",
"test": "vitest run --coverage ./src/**/*",
"lint": "eslint ./src --fix",
"format": "prettier ./src --write",
"clean": "rm -rf ./dist ./node_modules"
Expand Down
4 changes: 2 additions & 2 deletions inlang/source-code/paraglide/paraglide-js/src/cli/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Command } from "commander"
import { compileCommand } from "~/cli/commands/compile/command.js"
import { initCommand } from "~/cli/commands/init/command.js"
import { compileCommand } from "./commands/compile/command.js"
import { initCommand } from "./commands/init/command.js"

export const cli = new Command()
.name("paraglide-js")
Expand Down

0 comments on commit 94a6535

Please sign in to comment.