feat: requires ts-node to start a project for any config that uses ts or jsx
This commit is contained in:
@@ -12,5 +12,5 @@
|
|||||||
"test/"
|
"test/"
|
||||||
],
|
],
|
||||||
"ext": "ts,js,json",
|
"ext": "ts,js,json",
|
||||||
"exec": "node ./test/dev.js"
|
"exec": "ts-node ./test/dev.ts"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -88,7 +88,6 @@
|
|||||||
"@faceless-ui/window-info": "^2.0.2",
|
"@faceless-ui/window-info": "^2.0.2",
|
||||||
"@monaco-editor/react": "^4.4.6",
|
"@monaco-editor/react": "^4.4.6",
|
||||||
"@swc/core": "^1.3.24",
|
"@swc/core": "^1.3.24",
|
||||||
"@swc/register": "^0.1.10",
|
|
||||||
"body-parser": "^1.19.0",
|
"body-parser": "^1.19.0",
|
||||||
"bson-objectid": "^2.0.1",
|
"bson-objectid": "^2.0.1",
|
||||||
"compression": "^1.7.4",
|
"compression": "^1.7.4",
|
||||||
@@ -181,6 +180,7 @@
|
|||||||
"swc-minify-webpack-plugin": "^1.0.1",
|
"swc-minify-webpack-plugin": "^1.0.1",
|
||||||
"terser-webpack-plugin": "^5.0.3",
|
"terser-webpack-plugin": "^5.0.3",
|
||||||
"ts-essentials": "^7.0.1",
|
"ts-essentials": "^7.0.1",
|
||||||
|
"ts-node": "^10.9.1",
|
||||||
"url-loader": "^4.1.1",
|
"url-loader": "^4.1.1",
|
||||||
"use-context-selector": "^1.4.1",
|
"use-context-selector": "^1.4.1",
|
||||||
"uuid": "^8.1.0",
|
"uuid": "^8.1.0",
|
||||||
@@ -284,7 +284,6 @@
|
|||||||
"shelljs": "^0.8.5",
|
"shelljs": "^0.8.5",
|
||||||
"slash": "^3.0.0",
|
"slash": "^3.0.0",
|
||||||
"start-server-and-test": "^1.14.0",
|
"start-server-and-test": "^1.14.0",
|
||||||
"ts-node": "^10.9.1",
|
|
||||||
"typescript": "^4.1.2"
|
"typescript": "^4.1.2"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
/* eslint-disable import/no-dynamic-require */
|
/* eslint-disable import/no-dynamic-require */
|
||||||
/* eslint-disable global-require */
|
/* eslint-disable global-require */
|
||||||
// eslint-disable-next-line import/no-extraneous-dependencies
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
||||||
import swcRegister from '@swc/register';
|
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import pino from 'pino';
|
import pino from 'pino';
|
||||||
import Logger from '../utilities/logger';
|
import Logger from '../utilities/logger';
|
||||||
@@ -15,24 +14,6 @@ const loadConfig = (logger?: pino.Logger): SanitizedConfig => {
|
|||||||
|
|
||||||
const configPath = findConfig();
|
const configPath = findConfig();
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
||||||
// @ts-ignore
|
|
||||||
swcRegister({
|
|
||||||
sourceMaps: 'inline',
|
|
||||||
jsc: {
|
|
||||||
parser: {
|
|
||||||
syntax: 'typescript',
|
|
||||||
tsx: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
ignore: [
|
|
||||||
/node_modules[\\/](?!.pnpm[\\/].*[\\/]node_modules[\\/])(?!payload[\\/]dist[\\/]admin|payload[\\/]components).*/,
|
|
||||||
],
|
|
||||||
module: {
|
|
||||||
type: 'commonjs',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
clientFiles.forEach((ext) => {
|
clientFiles.forEach((ext) => {
|
||||||
require.extensions[ext] = () => null;
|
require.extensions[ext] = () => null;
|
||||||
});
|
});
|
||||||
|
|||||||
36
test/dev.js
36
test/dev.js
@@ -1,36 +0,0 @@
|
|||||||
const fs = require('fs');
|
|
||||||
const path = require('path');
|
|
||||||
const swcRegister = require('@swc/register');
|
|
||||||
|
|
||||||
const [testSuiteDir] = process.argv.slice(2);
|
|
||||||
|
|
||||||
if (!testSuiteDir) {
|
|
||||||
console.error('ERROR: You must provide an argument for "testSuiteDir"');
|
|
||||||
process.exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
const configPath = path.resolve(__dirname, testSuiteDir, 'config.ts');
|
|
||||||
|
|
||||||
if (!fs.existsSync(configPath)) {
|
|
||||||
console.error('ERROR: You must pass a valid directory under test/ that contains a config.ts');
|
|
||||||
process.exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
process.env.PAYLOAD_CONFIG_PATH = configPath;
|
|
||||||
|
|
||||||
process.env.PAYLOAD_DROP_DATABASE = 'true';
|
|
||||||
|
|
||||||
swcRegister({
|
|
||||||
sourceMaps: 'inline',
|
|
||||||
jsc: {
|
|
||||||
parser: {
|
|
||||||
syntax: 'typescript',
|
|
||||||
tsx: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
module: {
|
|
||||||
type: 'commonjs',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
require('./devServer');
|
|
||||||
@@ -1,9 +1,29 @@
|
|||||||
|
import fs from 'fs';
|
||||||
|
import path from 'path';
|
||||||
import express from 'express';
|
import express from 'express';
|
||||||
import { v4 as uuid } from 'uuid';
|
import { v4 as uuid } from 'uuid';
|
||||||
import payload from '../src';
|
import payload from '../src';
|
||||||
|
|
||||||
|
const [testSuiteDir] = process.argv.slice(2);
|
||||||
|
|
||||||
|
if (!testSuiteDir) {
|
||||||
|
console.error('ERROR: You must provide an argument for "testSuiteDir"');
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
const configPath = path.resolve(__dirname, testSuiteDir, 'config.ts');
|
||||||
|
|
||||||
|
if (!fs.existsSync(configPath)) {
|
||||||
|
console.error('ERROR: You must pass a valid directory under test/ that contains a config.ts');
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
process.env.PAYLOAD_CONFIG_PATH = configPath;
|
||||||
|
|
||||||
|
process.env.PAYLOAD_DROP_DATABASE = 'true';
|
||||||
|
|
||||||
const expressApp = express();
|
const expressApp = express();
|
||||||
|
|
||||||
const init = async () => {
|
const init = async () => {
|
||||||
await payload.init({
|
await payload.init({
|
||||||
secret: uuid(),
|
secret: uuid(),
|
||||||
@@ -30,6 +30,9 @@
|
|||||||
"skipLibCheck": true, /* Skip type checking of declaration files. */
|
"skipLibCheck": true, /* Skip type checking of declaration files. */
|
||||||
"forceConsistentCasingInFileNames": true, /* Disallow inconsistently-cased references to the same file. */
|
"forceConsistentCasingInFileNames": true, /* Disallow inconsistently-cased references to the same file. */
|
||||||
},
|
},
|
||||||
|
"ts-node": {
|
||||||
|
"swc": true,
|
||||||
|
},
|
||||||
"include": [
|
"include": [
|
||||||
"src/"
|
"src/"
|
||||||
],
|
],
|
||||||
|
|||||||
20
yarn.lock
20
yarn.lock
@@ -1950,15 +1950,6 @@
|
|||||||
"@jest/create-cache-key-function" "^27.4.2"
|
"@jest/create-cache-key-function" "^27.4.2"
|
||||||
jsonc-parser "^3.2.0"
|
jsonc-parser "^3.2.0"
|
||||||
|
|
||||||
"@swc/register@^0.1.10":
|
|
||||||
version "0.1.10"
|
|
||||||
resolved "https://registry.yarnpkg.com/@swc/register/-/register-0.1.10.tgz#74a20b7559669e03479b05e9e5c6d1524d4d92a2"
|
|
||||||
integrity sha512-6STwH/q4dc3pitXLVkV7sP0Hiy+zBsU2wOF1aXpXR95pnH3RYHKIsDC+gvesfyB7jxNT9OOZgcqOp9RPxVTx9A==
|
|
||||||
dependencies:
|
|
||||||
lodash.clonedeep "^4.5.0"
|
|
||||||
pirates "^4.0.1"
|
|
||||||
source-map-support "^0.5.13"
|
|
||||||
|
|
||||||
"@szmarczak/http-timer@^5.0.1":
|
"@szmarczak/http-timer@^5.0.1":
|
||||||
version "5.0.1"
|
version "5.0.1"
|
||||||
resolved "https://registry.yarnpkg.com/@szmarczak/http-timer/-/http-timer-5.0.1.tgz#c7c1bf1141cdd4751b0399c8fc7b8b664cd5be3a"
|
resolved "https://registry.yarnpkg.com/@szmarczak/http-timer/-/http-timer-5.0.1.tgz#c7c1bf1141cdd4751b0399c8fc7b8b664cd5be3a"
|
||||||
@@ -8079,11 +8070,6 @@ locate-path@^5.0.0:
|
|||||||
dependencies:
|
dependencies:
|
||||||
p-locate "^4.1.0"
|
p-locate "^4.1.0"
|
||||||
|
|
||||||
lodash.clonedeep@^4.5.0:
|
|
||||||
version "4.5.0"
|
|
||||||
resolved "https://registry.yarnpkg.com/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz#e23f3f9c4f8fbdde872529c1071857a086e5ccef"
|
|
||||||
integrity sha512-H5ZhCF25riFd9uB5UCkVKo61m3S/xZk1x4wA6yp/L3RFP6Z/eHH1ymQcGLo7J3GMPfm0V/7m1tryHuGVxpqEBQ==
|
|
||||||
|
|
||||||
lodash.get@^4.4.2:
|
lodash.get@^4.4.2:
|
||||||
version "4.4.2"
|
version "4.4.2"
|
||||||
resolved "https://registry.yarnpkg.com/lodash.get/-/lodash.get-4.4.2.tgz#2d177f652fa31e939b4438d5341499dfa3825e99"
|
resolved "https://registry.yarnpkg.com/lodash.get/-/lodash.get-4.4.2.tgz#2d177f652fa31e939b4438d5341499dfa3825e99"
|
||||||
@@ -9353,7 +9339,7 @@ pino@^6.4.1:
|
|||||||
quick-format-unescaped "^4.0.3"
|
quick-format-unescaped "^4.0.3"
|
||||||
sonic-boom "^1.0.2"
|
sonic-boom "^1.0.2"
|
||||||
|
|
||||||
pirates@^4.0.1, pirates@^4.0.4:
|
pirates@^4.0.4:
|
||||||
version "4.0.5"
|
version "4.0.5"
|
||||||
resolved "https://registry.yarnpkg.com/pirates/-/pirates-4.0.5.tgz#feec352ea5c3268fb23a37c702ab1699f35a5f3b"
|
resolved "https://registry.yarnpkg.com/pirates/-/pirates-4.0.5.tgz#feec352ea5c3268fb23a37c702ab1699f35a5f3b"
|
||||||
integrity sha512-8V9+HQPupnaXMA23c5hvl69zXvTwTzyAYasnkb0Tts4XvO4CliqONMOnvlq26rkhLC3nWDFBJf73LU1e1VZLaQ==
|
integrity sha512-8V9+HQPupnaXMA23c5hvl69zXvTwTzyAYasnkb0Tts4XvO4CliqONMOnvlq26rkhLC3nWDFBJf73LU1e1VZLaQ==
|
||||||
@@ -11159,7 +11145,7 @@ source-map-support@0.5.13:
|
|||||||
buffer-from "^1.0.0"
|
buffer-from "^1.0.0"
|
||||||
source-map "^0.6.0"
|
source-map "^0.6.0"
|
||||||
|
|
||||||
source-map-support@^0.5.13, source-map-support@~0.5.20:
|
source-map-support@~0.5.20:
|
||||||
version "0.5.21"
|
version "0.5.21"
|
||||||
resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.21.tgz#04fe7c7f9e1ed2d662233c28cb2b35b9f63f6e4f"
|
resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.21.tgz#04fe7c7f9e1ed2d662233c28cb2b35b9f63f6e4f"
|
||||||
integrity sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==
|
integrity sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==
|
||||||
@@ -11773,7 +11759,7 @@ ts-essentials@^7.0.1:
|
|||||||
|
|
||||||
ts-node@^10.9.1:
|
ts-node@^10.9.1:
|
||||||
version "10.9.1"
|
version "10.9.1"
|
||||||
resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-10.9.1.tgz#e73de9102958af9e1f0b168a6ff320e25adcff4b"
|
resolved "https://registry.npmjs.org/ts-node/-/ts-node-10.9.1.tgz#e73de9102958af9e1f0b168a6ff320e25adcff4b"
|
||||||
integrity sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw==
|
integrity sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw==
|
||||||
dependencies:
|
dependencies:
|
||||||
"@cspotcode/source-map-support" "^0.8.0"
|
"@cspotcode/source-map-support" "^0.8.0"
|
||||||
|
|||||||
Reference in New Issue
Block a user