chore: converts dev script from cjs to esm
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
const withPayload = require('./packages/next/src/withPayload')
|
||||
const withBundleAnalyzer = require('@next/bundle-analyzer')({
|
||||
import withPayload from './packages/next/src/withPayload.js'
|
||||
import bundleAnalyzer from '@next/bundle-analyzer'
|
||||
|
||||
const withBundleAnalyzer = bundleAnalyzer({
|
||||
enabled: process.env.ANALYZE === 'true',
|
||||
})
|
||||
|
||||
module.exports = withBundleAnalyzer(
|
||||
export default withBundleAnalyzer(
|
||||
withPayload({
|
||||
reactStrictMode: false,
|
||||
async redirects() {
|
||||
@@ -2,6 +2,7 @@
|
||||
"name": "payload-monorepo",
|
||||
"version": "3.0.0-alpha.19",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"workspaces:": [
|
||||
"packages/*"
|
||||
],
|
||||
|
||||
@@ -70,4 +70,4 @@ const withPayload = (nextConfig = {}) => {
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = withPayload
|
||||
export default withPayload
|
||||
|
||||
39
test/dev.js
39
test/dev.js
@@ -1,12 +1,19 @@
|
||||
/* eslint-disable @typescript-eslint/no-var-requires */
|
||||
const minimist = require('minimist')
|
||||
const path = require('path')
|
||||
const { nextDev } = require(path.resolve(__dirname, '..', 'node_modules/next/dist/cli/next-dev'))
|
||||
const fs = require('fs')
|
||||
const { readFile } = require('fs').promises
|
||||
const { writeFile } = require('fs').promises
|
||||
const { rm } = require('fs').promises
|
||||
const JSON5 = require('json5')
|
||||
import { existsSync } from 'fs'
|
||||
import { promises } from 'fs'
|
||||
import minimist from 'minimist'
|
||||
import { nextDev } from 'next/dist/cli/next-dev.js'
|
||||
import { dirname } from 'path'
|
||||
import { resolve } from 'path'
|
||||
import { fileURLToPath } from 'url'
|
||||
const { readFile } = promises
|
||||
import { promises as _promises } from 'fs'
|
||||
const { writeFile } = _promises
|
||||
import { promises as __promises } from 'fs'
|
||||
const { rm } = __promises
|
||||
import json5 from 'json5'
|
||||
|
||||
const { parse } = json5
|
||||
|
||||
main()
|
||||
|
||||
@@ -20,24 +27,28 @@ async function main() {
|
||||
process.env.TURBOPACK = '1'
|
||||
}
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url)
|
||||
const __dirname = dirname(__filename)
|
||||
|
||||
const testSuite = testSuiteArg || '_community'
|
||||
|
||||
console.log('\nUsing config:', testSuite, '\n')
|
||||
|
||||
// Delete next webpack cache
|
||||
const nextWebpackCache = path.resolve(__dirname, '..', '.next/cache/webpack')
|
||||
if (fs.existsSync(nextWebpackCache)) {
|
||||
const nextWebpackCache = resolve(__dirname, '..', '.next/cache/webpack')
|
||||
if (existsSync(nextWebpackCache)) {
|
||||
await rm(nextWebpackCache, { recursive: true })
|
||||
}
|
||||
|
||||
// Set path.'payload-config' in tsconfig.json
|
||||
const tsConfigPath = path.resolve(__dirname, '..', 'tsconfig.json')
|
||||
const tsConfig = await JSON5.parse(await readFile(tsConfigPath, 'utf8'))
|
||||
const tsConfigPath = resolve(__dirname, '..', 'tsconfig.json')
|
||||
const tsConfig = await parse(await readFile(tsConfigPath, 'utf8'))
|
||||
tsConfig.compilerOptions.paths['@payload-config'] = [`./test/${testSuite}/config.ts`]
|
||||
|
||||
await writeFile(tsConfigPath, JSON.stringify(tsConfig, null, 2))
|
||||
|
||||
const PAYLOAD_CONFIG_PATH = path.resolve(testSuite, 'config')
|
||||
const PAYLOAD_CONFIG_PATH = resolve(testSuite, 'config')
|
||||
process.env.PAYLOAD_CONFIG_PATH = PAYLOAD_CONFIG_PATH
|
||||
|
||||
nextDev({ _: [path.resolve(__dirname, '..')], port: process.env.PORT || 3000 })
|
||||
nextDev({ _: [resolve(__dirname, '..')], port: process.env.PORT || 3000 })
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user