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

[legacy-framework] Switch from tsdx to preconstruct for DX/perf improvements (meta) #2013

Merged
merged 18 commits into from Feb 28, 2021
Merged
2 changes: 1 addition & 1 deletion .eslintrc.js
Expand Up @@ -6,7 +6,7 @@ module.exports = {
ecmaFeatures: {
jsx: true,
},
project: `./tsconfig.json`,
project: `./tsconfig.eslint.json`,
},
plugins: ["@typescript-eslint", "import", "unicorn", "simple-import-sort"],
extends: ["react-app"],
Expand Down
24 changes: 24 additions & 0 deletions babel.config.js
@@ -0,0 +1,24 @@
module.exports = {
presets: [
"@babel/preset-typescript",
"@babel/preset-react",
[
"@babel/preset-env",
{
modules: false,
loose: true,
exclude: [
"@babel/plugin-transform-async-to-generator",
"@babel/plugin-transform-regenerator",
],
},
],
],
plugins: [
"babel-plugin-annotate-pure-calls",
"babel-plugin-dev-expression",
["@babel/plugin-proposal-class-properties", {loose: true}],
"babel-plugin-macros",
// ["babel-plugin-polyfill-regenerator", {method: "usage-pure"}],
],
}
13 changes: 0 additions & 13 deletions examples/auth/app/mutations/makeCoffee.ts

This file was deleted.

1 change: 1 addition & 0 deletions examples/auth/blitz.config.js
Expand Up @@ -3,6 +3,7 @@ const withBundleAnalyzer = require("@next/bundle-analyzer")({
enabled: process.env.ANALYZE === "true",
})

// withPreconstruct only needed for our internal monorepo
module.exports = withBundleAnalyzer({
middleware: [
sessionMiddleware({
Expand Down
2 changes: 1 addition & 1 deletion examples/auth/package.json
Expand Up @@ -11,7 +11,7 @@
"cy:open": "cypress open",
"cy:run": "cypress run || cypress run",
"test": "prisma generate && yarn test:jest && yarn test:e2e",
"test:jest": "jest",
"test:jest": "jest --color",
"test:server": "cross-env NODE_ENV=test blitz prisma migrate deploy --preview-feature && blitz build && cross-env NODE_ENV=test blitz start -p 3099",
"test:e2e": "cross-env NODE_ENV=test start-server-and-test test:server http://localhost:3099 cy:run"
},
Expand Down
2 changes: 1 addition & 1 deletion examples/auth/tsconfig.json
Expand Up @@ -17,5 +17,5 @@
"jsx": "preserve"
},
"exclude": ["node_modules", "cypress"],
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"]
"include": ["**/*.ts", "**/*.tsx"]
}
1 change: 1 addition & 0 deletions examples/auth/types
1 change: 1 addition & 0 deletions examples/custom-server/types
1 change: 1 addition & 0 deletions examples/fauna/types
1 change: 1 addition & 0 deletions examples/no-prisma/types
1 change: 1 addition & 0 deletions examples/store/types
26 changes: 20 additions & 6 deletions jest.config.js
@@ -1,16 +1,24 @@
const {resolveAliases} = require("@blitzjs/config")

module.exports = {
preset: "ts-jest",
testEnvironment: "node",
moduleFileExtensions: ["ts", "tsx", "js", "json"],
moduleFileExtensions: ["ts", "tsx", "js", "jsx", "json", "node"],
modulePathIgnorePatterns: ["<rootDir>/tmp", "<rootDir>/dist", "<rootDir>/templates"],
moduleNameMapper: {
...resolveAliases.node,
moduleNameMapper: {},
setupFilesAfterEnv: ["<rootDir>/jest.setup.js"],
transform: {
".(ts|tsx)$": require.resolve("ts-jest/dist"),
".(js|jsx)$": require.resolve("babel-jest"), // jest's default
},
transformIgnorePatterns: ["[/\\\\]node_modules[/\\\\].+\\.(js|jsx)$"],
testMatch: ["<rootDir>/**/*.(spec|test).{ts,tsx,js,jsx}"],
testURL: "http://localhost",
watchPlugins: [
require.resolve("jest-watch-typeahead/filename"),
require.resolve("jest-watch-typeahead/testname"),
],
coverageReporters: ["json", "lcov", "text", "clover"],
// collectCoverage: !!`Boolean(process.env.CI)`,
collectCoverageFrom: ["src/**/*.ts"],
collectCoverageFrom: ["src/**/*.{ts,tsx,js,jsx}"],
coveragePathIgnorePatterns: ["/templates/"],
// coverageThreshold: {
// global: {
Expand All @@ -20,4 +28,10 @@ module.exports = {
// statements: 100,
// },
// },
globals: {
"ts-jest": {
tsconfig: __dirname + "/tsconfig.test.json",
isolatedModules: true,
},
},
}
63 changes: 40 additions & 23 deletions package.json
Expand Up @@ -12,40 +12,55 @@
"**/@prisma/**"
]
},
"preconstruct": {
"packages": [
"packages/*",
"!packages/cli",
"!packages/eslint-config"
]
},
"engines": {
"node": ">=12"
},
"scripts": {
"postinstall": "npm rebuild husky && patch-package",
"predev": "lerna run clean --no-private --stream --parallel",
"dev": "lerna run dev --no-private --stream --parallel",
"postinstall": "npm rebuild husky",
"waitfortypes": "wait-on packages/core/dist/blitzjs-core.esm.js && wait-on packages/server/dist/blitzjs-server.esm.js",
"dev:preconstruct": "preconstruct watch",
"dev:tsc": "yarn waitfortypes && tsc --watch --pretty --preserveWatchOutput",
"dev:cli": "yarn waitfortypes && yarn workspace @blitzjs/cli dev",
"dev:templates": "yarn waitfortypes && yarn workspace @blitzjs/generator dev",
"dev": "concurrently --names \"BUILD,TYPES,CLI,TEMPLATES\" -c \"blue,magenta,yellow,green\" \"npm:dev:preconstruct\" \"npm:dev:tsc\" \"npm:dev:cli\" \"npm:dev:templates\"",
"build": "preconstruct build && lerna run build --scope @blitzjs/* && tsc",
"lint": "eslint --ignore-path .gitignore --ignore-pattern types --ext \".js,.ts,.tsx\" .",
"link-cli": "yarn workspace blitz link",
"unlink-cli": "yarn workspace blitz unlink",
"build": "lerna run build --no-private --stream",
"lint": "eslint --ignore-path .gitignore --ext \".js,.ts,.tsx\" .",
"test": "yarn run lint && yarn run build && lerna run test --stream",
"test:packages": "yarn run build && yarn testonly:packages",
"test:examples": "yarn run build && yarn testonly:examples",
"testonly": "yarn test:packages && yarn test:examples",
"testonly:packages": "lerna run test --scope blitz && lerna run test --stream --scope @blitzjs/*",
"testonly:packages": "lerna run test --scope blitz && lerna run test --stream --parallel --scope @blitzjs/*",
"testonly:examples": "lerna run test --stream --scope @examples/* --concurrency 1",
"reset": "rimraf node_modules && git clean -xfd packages && yarn",
"publish-prep": "lerna run clean && yarn && yarn build",
"prepack": "cpy README.md packages/blitz/",
"publish-prep": "yarn && yarn build",
"prepack": "cpx README.md packages/blitz/",
"postpack": "rimraf packages/blitz/README.md",
"publish-local": "yarn workspaces run yalc publish",
"publish-canary": "yarn run publish-prep && lerna publish --force-publish --preid canary --pre-dist-tag canary",
"publish-latest": "yarn run publish-prep && lerna publish --force-publish",
"publish-danger": "lerna publish --canary --pre-dist-tag danger --preid danger.$(git rev-parse --short HEAD) --allow-branch * --force-publish",
"danger:push-all": "git push --no-verify && git push --no-verify --tags"
},
"resolutions-NOTE1": "typescript and ts-jest pinned to here overside tsdx included versions",
"resolutions": {
"typescript": "4.1.3",
"ts-jest": "26.5.0"
"prerelease": "patch-package",
"release": "release"
},
"devDependencies": {
"dependencies": {
"@babel/core": "7.13.1",
"@babel/plugin-proposal-class-properties": "7.13.0",
"@babel/preset-env": "7.13.5",
"@babel/preset-react": "7.12.13",
"@babel/preset-typescript": "7.13.0",
"@manypkg/cli": "0.17.0",
"@preconstruct/cli": "2.0.5",
"@rollup/pluginutils": "4.1.0",
"@size-limit/preset-small-lib": "4.9.2",
"@testing-library/jest-dom": "5.11.9",
"@testing-library/react": "11.2.3",
"@testing-library/react-hooks": "4.0.1",
Expand All @@ -64,19 +79,20 @@
"@types/gulp-if": "0.0.33",
"@types/ink-spinner": "3.0.0",
"@types/jest": "26.0.20",
"@types/module-alias": "2.0.0",
"@types/jsonwebtoken": "8.5.0",
"@types/lodash": "4.14.168",
"@types/mem-fs": "1.1.2",
"@types/mem-fs-editor": "7.0.0",
"@types/merge-stream": "1.1.2",
"@types/mock-fs": "4.13.0",
"@types/module-alias": "2.0.0",
"@types/node": "14.14.22",
"@types/node-fetch": "2.5.8",
"@types/parallel-transform": "1.1.0",
"@types/passport": "1.0.5",
"@types/pluralize": "0.0.29",
"@types/prettier": "2.1.6",
"@types/progress": "^2.0.3",
"@types/pump": "1.1.0",
"@types/pumpify": "1.4.1",
"@types/react": "17.0.0",
Expand All @@ -94,8 +110,11 @@
"@wessberg/rollup-plugin-ts": "1.3.8",
"babel-eslint": "10.x",
"babel-jest": "26.6.3",
"concurrently": "5.3.0",
"cpy-cli": "3.1.1",
"babel-plugin-annotate-pure-calls": "0.4.0",
"babel-plugin-dev-expression": "0.2.2",
"babel-plugin-macros": "3.0.1",
"concurrently": "6.0.0",
"cpx": "1.5.0",
"cross-env": "7.0.3",
"cypress": "6.2.1",
"debug": "4.3.1",
Expand All @@ -113,9 +132,8 @@
"eslint-plugin-react-hooks": "4.2.0",
"eslint-plugin-simple-import-sort": "7.0.0",
"eslint-plugin-unicorn": "26.0.1",
"eslint_d": "10.0.0",
"husky": "4.3.8",
"@size-limit/preset-small-lib": "4.9.2",
"size-limit": "4.9.2",
"jest": "26.6.3",
"jest-environment-jsdom-sixteen": "1.0.3",
"lerna": "3.22.1",
Expand All @@ -139,15 +157,14 @@
"rollup-plugin-node-resolve": "5.2.0",
"rollup-plugin-peer-deps-external": "2.2.4",
"semver": "7.3.4",
"size-limit": "4.9.2",
"stdout-stderr": "0.1.13",
"test-listen": "1.1.0",
"ts-jest": "26.5.0",
"tsdx": "0.14.1",
"tslib": "2.1.0",
"typescript": "4.1.3",
"wait-on": "5.2.1",
"yalc": "1.0.0-pre.49",
"eslint_d": "10.0.0"
"yalc": "1.0.0-pre.49"
},
"husky": {
"hooks": {
Expand Down
27 changes: 13 additions & 14 deletions packages/babel-preset/package.json
Expand Up @@ -2,29 +2,24 @@
"name": "@blitzjs/babel-preset",
"version": "0.30.6",
"license": "MIT",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"scripts": {
"test": "jest --passWithNoTests --color",
"test:watch": "jest --watch"
},
"module": "dist/blitzjs-babel-preset.esm.js",
"main": "dist/blitzjs-babel-preset.cjs.js",
"typings": "dist/blitzjs-babel-preset.cjs.d.ts",
"author": "Brandon Bayer",
"files": [
"dist",
"src"
],
"scripts": {
"clean": "rimraf dist",
"dev": "tsdx watch --verbose",
"build": "tsdx build",
"test": "tsdx test --passWithNoTests",
"test:watch": "tsdx test --watch --passWithNoTests",
"size": "size-limit",
"analyze": "size-limit --why"
},
"prettier": {
"printWidth": 80,
"semi": true,
"singleQuote": true,
"trailingComma": "es5"
},
"author": "Brandon Bayer",
"module": "dist/babel-preset.esm.js",
"size-limit": [
{
"path": "dist/babel-preset.cjs.production.min.js",
Expand All @@ -36,6 +31,10 @@
}
],
"dependencies": {
"babel-plugin-superjson-next": "0.2.2"
"babel-plugin-superjson-next": "0.2.2",
"@babel/helper-module-imports": "^7.0.0"
},
"peerDependencies": {
"@babel/core": "*"
}
}
9 changes: 0 additions & 9 deletions packages/babel-preset/tsconfig.json

This file was deleted.

2 changes: 1 addition & 1 deletion packages/blitz/bin/blitz
Expand Up @@ -8,7 +8,7 @@ if (process.env.INSPECT_BRK === 'true') {
}

try {
const cliBin = require.resolve('../dist/cli')
const cliBin = require.resolve('../cli/dist/blitz-cli.cjs')
const binArgs = process.argv.slice(2)
const result = spawn.sync('node', [...nodeOpts, cliBin, ...binArgs], { stdio: 'inherit' })
process.exit(result.status)
Expand Down
4 changes: 4 additions & 0 deletions packages/blitz/cli/package.json
@@ -0,0 +1,4 @@
{
"main": "dist/blitz-cli.cjs.js",
"module": "dist/blitz-cli.esm.js"
}
3 changes: 1 addition & 2 deletions packages/blitz/jest-preset.js
@@ -1,6 +1,6 @@
const path = require("path")
const {pathsToModuleNameMapper} = require("ts-jest/utils")
const {getProjectRoot, resolveAliases} = require("@blitzjs/config")
const {getProjectRoot} = require("@blitzjs/config")
const projectRoot = getProjectRoot()
const {compilerOptions} = require(path.join(projectRoot, "tsconfig"))

Expand All @@ -27,7 +27,6 @@ const common = {
// Ignore the build directories
modulePathIgnorePatterns: ["<rootDir>/.blitz", "<rootDir>/.next"],
moduleNameMapper: {
...resolveAliases.node,
// This ensures any path aliases in tsconfig also work in jest
...pathsToModuleNameMapper(compilerOptions.paths || {}),
"\\.(css|less|sass|scss)$": path.resolve(__dirname, "./jest-preset/identity-obj-proxy.js"),
Expand Down
3 changes: 3 additions & 0 deletions packages/blitz/jest.config.js
@@ -0,0 +1,3 @@
module.exports = {
preset: "../../jest.config.js",
}