support esm modules
This commit is contained in:
parent
765cc0c7cf
commit
dcbdb0ccb7
11 changed files with 43 additions and 38 deletions
|
|
@ -1,7 +1,6 @@
|
|||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
const fs = require("fs")
|
||||
|
||||
module.exports = {
|
||||
const config = {
|
||||
extends: [
|
||||
"next",
|
||||
"prettier",
|
||||
|
|
@ -77,3 +76,5 @@ function getDirectories(path) {
|
|||
return fs.statSync(path + "/" + file).isDirectory()
|
||||
})
|
||||
}
|
||||
|
||||
module.exports = config
|
||||
|
|
@ -1,11 +1,10 @@
|
|||
<img align="right" width="360px" height="410px" src="./.github/assets/project-logo-vertical.png">
|
||||
|
||||
# Next.js Enterprise Boilerplate </br> [![GitHub Actions Workflow Status][check-workflow-badge]][check-workflow-badge-link] [![GitHub License][github-license-badge]][github-license-badge-link] [![GitHub contributors][github-contributors-badge]][github-contributors-badge-link] [![Discord][discord-badge]][discord-badge-link] [![Blazity][made-by-blazity-badge]][made-by-blazity-badge-link]
|
||||
# Next.js Enterprise Boilerplate </br> [![GitHub Actions Workflow Status][check-workflow-badge]][check-workflow-badge-link] [![GitHub License][github-license-badge]][github-license-badge-link] [![GitHub contributors][github-contributors-badge]][github-contributors-badge-link] [![Discord][discord-badge]][discord-badge-link] [![Blazity][made-by-blazity-badge]][made-by-blazity-badge-link]
|
||||
|
||||
Welcome to the _Next.js Enterprise Boilerplate_, an open-source template for enterprise projects! It's loaded with features that'll help you build a high-performance, maintainable, and enjoyable app. We've done all the heavy lifting for you, so sit back, relax, and get ready to conquer the world with your incredible app! 🌍
|
||||
|
||||
> [!NOTE]
|
||||
> **Blazity** is a group of Next.js/Headless experts. Contact us at [contact@blazity.com](https://blazity.com) if you’d like to talk about your project or just to have a chat with us
|
||||
> [!NOTE] > **Blazity** is a group of Next.js/Headless experts. Contact us at [contact@blazity.com](https://blazity.com) if you’d like to talk about your project or just to have a chat with us
|
||||
|
||||
## Features
|
||||
|
||||
|
|
@ -227,7 +226,7 @@ To use ChatGPT Code Review, add an `OPENAI_API_KEY` environment variable with an
|
|||
|
||||
[T3 Env](https://env.t3.gg/) is a library that provides environmental variables checking at build time, type validation and transforming. It ensures that your application is using the correct environment variables and their values are of the expected type. You’ll never again struggle with runtime errors caused by incorrect environment variable usage.
|
||||
|
||||
Config file is located at `env.mjs`. Simply set your client and server variables and import `env` from any file in your project.
|
||||
Config file is located at `env.js`. Simply set your client and server variables and import `env` from any file in your project.
|
||||
|
||||
```ts
|
||||
export const env = createEnv({
|
||||
|
|
@ -273,7 +272,6 @@ If you're looking for help or simply want to share your thoughts about the proje
|
|||
</a>
|
||||
<br />
|
||||
|
||||
|
||||
## 📜 License
|
||||
|
||||
This project is licensed under the MIT License. For more information, see the [LICENSE](./LICENSE) file.
|
||||
|
|
@ -314,7 +312,6 @@ This project is licensed under the MIT License. For more information, see the [L
|
|||
[github-contributors-badge]: https://img.shields.io/github/contributors/blazity/next-enterprise?link=https%3A%2F%2Fgithub.com%2FBlazity%2Fnext-enterprise%2Fgraphs%2Fcontributors
|
||||
[discord-badge]: https://img.shields.io/discord/1111676875782234175?color=7b8dcd&link=https%3A%2F%2Fblazity.com%2Fdiscord
|
||||
[made-by-blazity-badge]: https://img.shields.io/badge/made_by-Blazity-blue?color=FF782B&link=https://blazity.com/
|
||||
|
||||
[check-workflow-badge-link]: https://github.com/Blazity/next-enterprise/actions/workflows/check.yml
|
||||
[github-license-badge-link]: https://github.com/Blazity/next-enterprise/blob/main/LICENSE
|
||||
[github-contributors-badge-link]: https://github.com/Blazity/next-enterprise/graphs/contributors
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import withBundleAnalyzer from "@next/bundle-analyzer"
|
||||
import withPlugins from "next-compose-plugins"
|
||||
import { env } from "./env.mjs"
|
||||
import { env } from "./env.js"
|
||||
|
||||
/**
|
||||
* @type {import('next').NextConfig}
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
{
|
||||
"name": "next-enterprise",
|
||||
"version": "0.0.0",
|
||||
"type": "module",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "cross-env FORCE_COLOR=1 next dev",
|
||||
|
|
@ -20,7 +21,7 @@
|
|||
"format": "prettier --write \"**/*.{ts,tsx,md}\"",
|
||||
"preinstall": "npx npm-only-allow@latest --PM yarn",
|
||||
"postinstall": "npx patch-package -y",
|
||||
"coupling-graph": "npx madge --extensions js,jsx,ts,tsx,css,md,mdx ./ --exclude '.next|tailwind.config.js|reset.d.ts|prettier.config.js|postcss.config.js|playwright.config.ts|next.config.js|next-env.d.ts|instrumentation.ts|e2e/|README.md|.storybook/|.eslintrc.js' --image graph.svg"
|
||||
"coupling-graph": "npx madge --extensions js,jsx,ts,tsx,css,md,mdx ./ --exclude '.next|tailwind.config.js|reset.d.ts|prettier.config.js|postcss.config.cjs|playwright.config.ts|next.config.js|next-env.d.ts|instrumentation.ts|e2e/|README.md|.storybook/|.eslintrc.cjs' --image graph.svg"
|
||||
},
|
||||
"dependencies": {
|
||||
"@next/bundle-analyzer": "^14.0.3",
|
||||
|
|
|
|||
|
|
@ -1,7 +1,10 @@
|
|||
module.exports = {
|
||||
/** @type {import("prettier").Config} */
|
||||
const config = {
|
||||
plugins: ["prettier-plugin-tailwindcss"],
|
||||
trailingComma: "es5",
|
||||
tabWidth: 2,
|
||||
printWidth: 120,
|
||||
semi: false,
|
||||
}
|
||||
|
||||
export default config
|
||||
|
|
|
|||
|
|
@ -7,13 +7,13 @@
|
|||
|
||||
// edited to work with the appdir by @raphaelbadia
|
||||
|
||||
const gzSize = require("gzip-size")
|
||||
const mkdirp = require("mkdirp")
|
||||
const fs = require("fs")
|
||||
const path = require("path")
|
||||
import gzSize from "gzip-size"
|
||||
import { mkdirp } from "mkdirp"
|
||||
import fs from "fs"
|
||||
import path from "path"
|
||||
|
||||
// Pull options from `package.json`
|
||||
const options = getOptions()
|
||||
const options = await getOptions()
|
||||
const BUILD_OUTPUT_DIRECTORY = getBuildOutputDirectory(options)
|
||||
|
||||
// first we check to make sure that the build output directory exists
|
||||
|
|
@ -28,8 +28,12 @@ try {
|
|||
}
|
||||
|
||||
// if so, we can import the build manifest
|
||||
const buildMeta = require(path.join(nextMetaRoot, "build-manifest.json"))
|
||||
const appDirMeta = require(path.join(nextMetaRoot, "app-build-manifest.json"))
|
||||
const { default: buildMeta } = await import(path.join(nextMetaRoot, "build-manifest.json"), {
|
||||
assert: { type: "json" },
|
||||
})
|
||||
const { default: appDirMeta } = await import(path.join(nextMetaRoot, "app-build-manifest.json"), {
|
||||
assert: { type: "json" },
|
||||
})
|
||||
|
||||
// this memory cache ensures we dont read any script file more than once
|
||||
// bundles are often shared between pages
|
||||
|
|
@ -116,8 +120,8 @@ function getScriptSize(scriptPath) {
|
|||
/**
|
||||
* Reads options from `package.json`
|
||||
*/
|
||||
function getOptions(pathPrefix = process.cwd()) {
|
||||
const pkg = require(path.join(pathPrefix, "package.json"))
|
||||
async function getOptions(pathPrefix = process.cwd()) {
|
||||
const pkg = await import(path.join(pathPrefix, "package.json"), { assert: { type: "json" } })
|
||||
|
||||
return { ...pkg.nextBundleAnalysis, name: pkg.name }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,7 @@
|
|||
/* eslint-disable @typescript-eslint/no-var-requires */
|
||||
const { pick, omit } = require("lodash")
|
||||
const colors = require("tailwindcss/colors")
|
||||
const defaultTheme = require("tailwindcss/defaultTheme")
|
||||
import defaultTheme from "tailwindcss/defaultTheme"
|
||||
|
||||
/** @type {import('tailwindcss').Config} */
|
||||
module.exports = {
|
||||
const config = {
|
||||
darkMode: "class",
|
||||
content: [
|
||||
"./index.html",
|
||||
|
|
@ -88,3 +85,5 @@ module.exports = {
|
|||
hoverOnlyWhenSupported: true,
|
||||
},
|
||||
}
|
||||
|
||||
export default config
|
||||
|
|
|
|||
26
yarn.lock
26
yarn.lock
|
|
@ -1441,9 +1441,9 @@
|
|||
integrity sha512-Y27x+MBLjXa+0JWDhykM3+JE+il3kHKAEqabfEWq3SDhZjLYb6/BHL/JKFnH3fe207JaXkyDo685Oc2Glt6ifA==
|
||||
|
||||
"@eslint/eslintrc@^2.1.3":
|
||||
version "2.1.3"
|
||||
resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-2.1.3.tgz#797470a75fe0fbd5a53350ee715e85e87baff22d"
|
||||
integrity sha512-yZzuIG+jnVu6hNSzFEN07e8BxF3uAzYtQb6uDkaYZLo6oYZDCq454c5kB8zxnzfCYyP4MIuyBn10L0DqwujTmA==
|
||||
version "2.1.4"
|
||||
resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-2.1.4.tgz#388a269f0f25c1b6adc317b5a2c55714894c70ad"
|
||||
integrity sha512-269Z39MS6wVJtsoUl10L60WdkhJVdPG24Q4eZTH3nnF6lpvSShEK3wQjDX9JRWAUPvPh7COouPpU9IrqaZFvtQ==
|
||||
dependencies:
|
||||
ajv "^6.12.4"
|
||||
debug "^4.3.2"
|
||||
|
|
@ -1523,12 +1523,12 @@
|
|||
"@hapi/hoek" "^9.0.0"
|
||||
|
||||
"@humanwhocodes/config-array@^0.11.13":
|
||||
version "0.11.13"
|
||||
resolved "https://registry.yarnpkg.com/@humanwhocodes/config-array/-/config-array-0.11.13.tgz#075dc9684f40a531d9b26b0822153c1e832ee297"
|
||||
integrity sha512-JSBDMiDKSzQVngfRjOdFXgFfklaXI4K9nLF49Auh21lmBWRLIK3+xTErTWD4KU54pb6coM6ESE7Awz/FNU3zgQ==
|
||||
version "0.11.14"
|
||||
resolved "https://registry.yarnpkg.com/@humanwhocodes/config-array/-/config-array-0.11.14.tgz#d78e481a039f7566ecc9660b4ea7fe6b1fec442b"
|
||||
integrity sha512-3T8LkOmg45BV5FICb15QQMsyUSWrQ8AygVfC7ZG32zOalnqrilm018ZVCw0eapXux8FtA33q8PSRSstjee3jSg==
|
||||
dependencies:
|
||||
"@humanwhocodes/object-schema" "^2.0.1"
|
||||
debug "^4.1.1"
|
||||
"@humanwhocodes/object-schema" "^2.0.2"
|
||||
debug "^4.3.1"
|
||||
minimatch "^3.0.5"
|
||||
|
||||
"@humanwhocodes/module-importer@^1.0.1":
|
||||
|
|
@ -1536,10 +1536,10 @@
|
|||
resolved "https://registry.yarnpkg.com/@humanwhocodes/module-importer/-/module-importer-1.0.1.tgz#af5b2691a22b44be847b0ca81641c5fb6ad0172c"
|
||||
integrity sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA==
|
||||
|
||||
"@humanwhocodes/object-schema@^2.0.1":
|
||||
version "2.0.1"
|
||||
resolved "https://registry.yarnpkg.com/@humanwhocodes/object-schema/-/object-schema-2.0.1.tgz#e5211452df060fa8522b55c7b3c0c4d1981cb044"
|
||||
integrity sha512-dvuCeX5fC9dXgJn9t+X5atfmgQAzUOWqS1254Gh0m6i8wKd10ebXkfNKiRK+1GWi/yTvvLDHpoxLr0xxxeslWw==
|
||||
"@humanwhocodes/object-schema@^2.0.2":
|
||||
version "2.0.2"
|
||||
resolved "https://registry.yarnpkg.com/@humanwhocodes/object-schema/-/object-schema-2.0.2.tgz#d9fae00a2d5cb40f92cfe64b47ad749fbc38f917"
|
||||
integrity sha512-6EwiSjwWYP7pTckG6I5eyFANjPhmPjUX9JRLUSfNPC7FX7zK9gyZAfUEaECL6ALTpGX5AjnBq3C9XmVWPitNpw==
|
||||
|
||||
"@isaacs/cliui@^8.0.2":
|
||||
version "8.0.2"
|
||||
|
|
@ -7438,7 +7438,7 @@ debug@2.6.9, debug@^2.6.9:
|
|||
dependencies:
|
||||
ms "2.0.0"
|
||||
|
||||
debug@4, debug@^4.0.0, debug@^4.1.0, debug@^4.1.1, debug@^4.3.2, debug@^4.3.3, debug@^4.3.4:
|
||||
debug@4, debug@^4.0.0, debug@^4.1.0, debug@^4.1.1, debug@^4.3.1, debug@^4.3.2, debug@^4.3.3, debug@^4.3.4:
|
||||
version "4.3.4"
|
||||
resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.4.tgz#1319f6579357f2338d3337d2cdd4914bb5dcc865"
|
||||
integrity sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue