Skip to content

Commit

Permalink
chore(repo): convert entire NX workspace to use ES modules
Browse files Browse the repository at this point in the history
  • Loading branch information
MFarabi619 authored and HasithDeAlwis committed Sep 3, 2024
1 parent 89ee8e9 commit 82b03db
Show file tree
Hide file tree
Showing 20 changed files with 175 additions and 144 deletions.
58 changes: 33 additions & 25 deletions apps/docs-e2e/eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,40 @@
const { FlatCompat } = require('@eslint/eslintrc')
const js = require('@eslint/js')
const baseConfigPromise = require('../../eslint.config.js')
// TODO: merge with antfu eslint config
// const { FlatCompat } = require('@eslint/eslintrc');
import baseConfigPromise from '../../eslint.config.js'

module.exports = (async () => {
export default (async () => {
const baseConfig = await baseConfigPromise
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
})

return [
...baseConfig,
...compat.extends('plugin:playwright/recommended'),
{
files: ['**/*.ts', '**/*.tsx', '**/*.js', '**/*.jsx'],
rules: {},
},
{
files: ['**/*.ts', '**/*.tsx'],
rules: {},
},
{
files: ['**/*.js', '**/*.jsx'],
rules: {},
},
{
files: ['src/**/*.{ts,js,tsx,jsx}'],
rules: {},
},
// ...compat.extends("plugin:playwright/recommended"),
// The following configurations are commented out
// ...compat.extends(
// 'plugin:@nx/react-typescript',
// 'next',
// 'next/core-web-vitals'
// ),
// {
// files: ['**/*.ts', '**/*.tsx', '**/*.js', '**/*.jsx'],
// rules: {
// '@next/next/no-html-link-for-pages': ['error', 'apps/portal/pages'],
// },
// },
// {
// files: ['**/*.ts', '**/*.tsx'],
// rules: {},
// },
// {
// files: ['**/*.js', '**/*.jsx'],
// rules: {},
// },
// ...compat.config({ env: { jest: true } }).map((config) => ({
// ...config,
// files: ['**/*.spec.ts', '**/*.spec.tsx', '**/*.spec.js', '**/*.spec.jsx'],
// rules: {
// ...config.rules,
// },
// })),
// { ignores: ['.next/**/*'] },
]
})()
3 changes: 3 additions & 0 deletions apps/docs-e2e/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
// TODO: Investigate node global process usage
/* eslint-disable node/prefer-global/process */
import { fileURLToPath } from 'node:url'
import { defineConfig, devices } from '@playwright/test'
import { nxE2EPreset } from '@nx/playwright/preset'

import { workspaceRoot } from '@nx/devkit'

const __filename = fileURLToPath(import.meta.url)

// For CI, you may want to set BASE_URL to the deployed application.
const baseURL = process.env.BASE_URL || 'http://127.0.0.1:3000'

Expand Down
5 changes: 1 addition & 4 deletions apps/docs-e2e/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"module": "commonjs",
"allowJs": true,
"outDir": "../../dist/out-tsc",
"sourceMap": false
"outDir": "../../dist/out-tsc"
},
"include": [
"**/*.ts",
Expand Down
5 changes: 3 additions & 2 deletions apps/docs/eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
// TODO: merge with antfu eslint config
// const { FlatCompat } = require('@eslint/eslintrc');
const baseConfigPromise = require('../../eslint.config.js')
// const baseConfigPromise = require('../../eslint.config.js')
import baseConfigPromise from '../../eslint.config.js'
// const js = require('@eslint/js');

module.exports = (async () => {
export default (async () => {
const baseConfig = await baseConfigPromise

return [
Expand Down
File renamed without changes.
58 changes: 28 additions & 30 deletions apps/docs/tailwind.config.js
Original file line number Diff line number Diff line change
@@ -1,39 +1,37 @@
// import type { Config } from 'tailwindcss'
// const { fontFamily } = require('tailwindcss/defaultTheme')
const { join } = require('node:path')
import { join } from 'node:path'

const { createPreset } = require('fumadocs-ui/tailwind-plugin')
import { createPreset } from 'fumadocs-ui/tailwind-plugin'

const { createGlobPatternsForDependencies } = require('@nx/react/tailwind')
import { createGlobPatternsForDependencies } from '@nx/react/tailwind'

/** @type {import('tailwindcss').Config} */
module.exports = {
darkMode: ['class'],
content: [
join(
__dirname,
'{src,pages,components,app}/**/*!(*.stories|*.spec).{ts,tsx,html}',
),
...createGlobPatternsForDependencies(__dirname),
'./mdx-components.tsx',
'../../node_modules/fumadocs-ui/dist/**/*.js',
],
theme: {
extend: {
fontFamily: {
// sans: ['var(--font-geist-sans)', ...fontFamily.sans],
},
export const darkMode = ['class']
export const content = [
join(
__dirname,
'{src,pages,components,app}/**/*!(*.stories|*.spec).{ts,tsx,html}',
),
...createGlobPatternsForDependencies(__dirname),
'./mdx-components.tsx',
'../../node_modules/fumadocs-ui/dist/**/*.js',
]
export const theme = {
extend: {
fontFamily: {
// sans: ['var(--font-geist-sans)', ...fontFamily.sans],
},
},
presets: [
createPreset({
// preset: 'default',
// preset: 'neutral',
// preset: 'dusk',
// preset: 'purple',
// preset: 'ocean',
preset: 'catppuccin',
}),
],
plugins: [],
}
export const presets = [
createPreset({
// preset: 'default',
// preset: 'neutral',
// preset: 'dusk',
// preset: 'purple',
// preset: 'ocean',
preset: 'catppuccin',
}),
]
export const plugins = []
14 changes: 10 additions & 4 deletions apps/docs/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
"incremental": true,
"jsx": "preserve",
"resolveJsonModule": true,
"types": ["node"],
"types": [
"node"
],
"allowJs": true,
"strict": true,
"noEmit": true,
Expand All @@ -28,8 +30,12 @@
"next-env.d.ts",
".next/types/**/*.ts",
"next.config.mjs",
"postcss.config.js",
"tailwind.config.js"
"postcss.config.cjs",
"tailwind.config.cjs"
],
"exclude": ["node_modules", "**/*.spec.ts", "**/*.test.ts"]
"exclude": [
"node_modules",
"**/*.spec.ts",
"**/*.test.ts"
]
}
58 changes: 33 additions & 25 deletions apps/portal-e2e/eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,40 @@
const { FlatCompat } = require('@eslint/eslintrc')
const js = require('@eslint/js')
const baseConfigPromise = require('../../eslint.config.js')
// TODO: merge with antfu eslint config
// const { FlatCompat } = require('@eslint/eslintrc');
import baseConfigPromise from '../../eslint.config.js'

module.exports = (async () => {
export default (async () => {
const baseConfig = await baseConfigPromise
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
})

return [
...baseConfig,
...compat.extends('plugin:playwright/recommended'),
{
files: ['**/*.ts', '**/*.tsx', '**/*.js', '**/*.jsx'],
rules: {},
},
{
files: ['**/*.ts', '**/*.tsx'],
rules: {},
},
{
files: ['**/*.js', '**/*.jsx'],
rules: {},
},
{
files: ['src/**/*.{ts,js,tsx,jsx}'],
rules: {},
},
// ...compat.extends("plugin:playwright/recommended"),
// The following configurations are commented out
// ...compat.extends(
// 'plugin:@nx/react-typescript',
// 'next',
// 'next/core-web-vitals'
// ),
// {
// files: ['**/*.ts', '**/*.tsx', '**/*.js', '**/*.jsx'],
// rules: {
// '@next/next/no-html-link-for-pages': ['error', 'apps/portal/pages'],
// },
// },
// {
// files: ['**/*.ts', '**/*.tsx'],
// rules: {},
// },
// {
// files: ['**/*.js', '**/*.jsx'],
// rules: {},
// },
// ...compat.config({ env: { jest: true } }).map((config) => ({
// ...config,
// files: ['**/*.spec.ts', '**/*.spec.tsx', '**/*.spec.js', '**/*.spec.jsx'],
// rules: {
// ...config.rules,
// },
// })),
// { ignores: ['.next/**/*'] },
]
})()
3 changes: 3 additions & 0 deletions apps/portal-e2e/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
/* eslint-disable node/prefer-global/process */
import { fileURLToPath } from 'node:url'
import { defineConfig, devices } from '@playwright/test'
import { nxE2EPreset } from '@nx/playwright/preset'

import { workspaceRoot } from '@nx/devkit'

const __filename = fileURLToPath(import.meta.url)

// For CI, you may want to set BASE_URL to the deployed application.
const baseURL = process.env.BASE_URL || 'http://127.0.0.1:3000'

Expand Down
5 changes: 1 addition & 4 deletions apps/portal-e2e/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"module": "commonjs",
"allowJs": true,
"outDir": "../../dist/out-tsc",
"sourceMap": false
"outDir": "../../dist/out-tsc"
},
"include": [
"**/*.ts",
Expand Down
5 changes: 3 additions & 2 deletions apps/portal/eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
// TODO: merge with antfu eslint config
// const { FlatCompat } = require('@eslint/eslintrc');
const baseConfigPromise = require('../../eslint.config.js')
// const baseConfigPromise = require('../../eslint.config.js')
import baseConfigPromise from '../../eslint.config.js'
// const js = require('@eslint/js');

module.exports = (async () => {
export default (async () => {
const baseConfig = await baseConfigPromise

return [
Expand Down
4 changes: 2 additions & 2 deletions apps/portal/next.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { composePlugins, withNx } = require('@nx/next')
import { composePlugins, withNx } from '@nx/next'

/**
* @type {import('@nx/next/plugins/with-nx').WithNxOptions}
Expand All @@ -16,4 +16,4 @@ const plugins = [
withNx,
]

module.exports = composePlugins(...plugins)(nextConfig)
export default composePlugins(...plugins)(nextConfig)
File renamed without changes.
26 changes: 12 additions & 14 deletions apps/portal/tailwind.config.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
const { join } = require('node:path')
const { createGlobPatternsForDependencies } = require('@nx/react/tailwind')
import { join } from 'node:path'
import { createGlobPatternsForDependencies } from '@nx/react/tailwind'

/** @type {import('tailwindcss').Config} */
module.exports = {
content: [
join(
__dirname,
'{src,pages,components,app}/**/*!(*.stories|*.spec).{ts,tsx,html}',
),
...createGlobPatternsForDependencies(__dirname),
],
theme: {
extend: {},
},
plugins: [],
export const content = [
join(
__dirname,
'{src,pages,components,app}/**/*!(*.stories|*.spec).{ts,tsx,html}',
),
...createGlobPatternsForDependencies(__dirname),
]
export const theme = {
extend: {},
}
export const plugins = []
4 changes: 3 additions & 1 deletion apps/portal/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@
"../../apps/portal/.next/types/**/*.ts",
"../../dist/apps/portal/.next/types/**/*.ts",
"next-env.d.ts",
".next/types/**/*.ts"
".next/types/**/*.ts",
"postcss.config.cjs",
"next.config.cjs"
],
"exclude": [
"node_modules",
Expand Down
Loading

0 comments on commit 82b03db

Please sign in to comment.