diff --git a/.prettierignore b/.prettierignore index ab639d33..a4684ea7 100644 --- a/.prettierignore +++ b/.prettierignore @@ -5,4 +5,5 @@ .angular -/.nx/cache \ No newline at end of file +/.nx/cache +/.nx/workspace-data \ No newline at end of file diff --git a/api/index.js b/api/index.js deleted file mode 100644 index a424766e..00000000 --- a/api/index.js +++ /dev/null @@ -1,3 +0,0 @@ -const server = require('../dist/docs-static/server/main.js'); - -module.exports = server.app(); diff --git a/api/index.mjs b/api/index.mjs new file mode 100644 index 00000000..aa0a6aa9 --- /dev/null +++ b/api/index.mjs @@ -0,0 +1,3 @@ +import { app } from '../dist/docs-static/server/server.mjs'; + +export default app(); diff --git a/apps/docs/project.json b/apps/docs/project.json index 4530f643..c8dc7ddd 100644 --- a/apps/docs/project.json +++ b/apps/docs/project.json @@ -7,18 +7,25 @@ "tags": [], "targets": { "build": { - "executor": "@angular-devkit/build-angular:browser", - "outputs": ["{options.outputPath}"], + "executor": "@angular-devkit/build-angular:application", + "outputs": ["{options.outputPath.base}"], "options": { - "outputPath": "dist/docs-static/browser", + "outputPath": { + "base": "dist/docs-static" + }, "index": "apps/docs/src/index.html", - "main": "apps/docs/src/main.ts", - "polyfills": "zone.js", + "polyfills": ["zone.js"], "tsConfig": "apps/docs/tsconfig.app.json", "inlineStyleLanguage": "css", "assets": ["apps/docs/src/assets"], "styles": ["apps/docs/src/styles.css"], - "scripts": [] + "scripts": [], + "browser": "apps/docs/src/main.ts", + "server": "apps/docs/src/main.server.ts", + "prerender": true, + "ssr": { + "entry": "apps/docs/server.ts" + } }, "configurations": { "production": { @@ -43,9 +50,7 @@ "outputHashing": "all" }, "development": { - "buildOptimizer": false, "optimization": false, - "vendorChunk": true, "extractLicenses": false, "sourceMap": true, "namedChunks": true @@ -53,70 +58,18 @@ }, "defaultConfiguration": "production" }, - "server": { - "dependsOn": ["build"], - "executor": "@angular-devkit/build-angular:server", - "options": { - "outputPath": "dist/docs-static/server", - "main": "apps/docs/server.ts", - "tsConfig": "apps/docs/tsconfig.server.json", - "inlineStyleLanguage": "css" - }, + "serve": { + "executor": "@angular-devkit/build-angular:dev-server", "configurations": { "production": { - "outputHashing": "media", - "fileReplacements": [ - { - "replace": "apps/docs/src/environments/environment.ts", - "with": "apps/docs/src/environments/environment.prod.ts" - } - ] + "buildTarget": "docs:build:production" }, "development": { - "buildOptimizer": false, - "optimization": false, - "sourceMap": true, - "extractLicenses": false, - "vendorChunk": true + "buildTarget": "docs:build:development" } }, "defaultConfiguration": "production" }, - "prerender": { - "executor": "@angular-devkit/build-angular:prerender", - "options": { - "routes": ["/"] - }, - "configurations": { - "development": { - "browserTarget": "docs:build:development", - "serverTarget": "docs:server:development" - }, - "production": { - "browserTarget": "docs:build:production", - "serverTarget": "docs:server:production" - } - }, - "defaultConfiguration": "production" - }, - "start": { - "executor": "@angular-devkit/build-angular:ssr-dev-server", - "options": { - "browserTarget": "docs:build", - "serverTarget": "docs:server" - }, - "configurations": { - "production": { - "browserTarget": "docs:build:production", - "serverTarget": "docs:server:production" - }, - "development": { - "browserTarget": "docs:build:development", - "serverTarget": "docs:server:development" - } - }, - "defaultConfiguration": "development" - }, "test": { "executor": "@nx/jest:jest", "outputs": ["{workspaceRoot}/coverage/apps/docs"], diff --git a/apps/docs/server.ts b/apps/docs/server.ts index d7ba4345..aa74aaa3 100644 --- a/apps/docs/server.ts +++ b/apps/docs/server.ts @@ -1,39 +1,37 @@ -import 'zone.js/node'; - import bootstrap from './src/main.server'; import { APP_BASE_HREF } from '@angular/common'; import { CommonEngine } from '@angular/ssr'; -import * as express from 'express'; +import express from 'express'; -import { existsSync } from 'node:fs'; -import { join } from 'node:path'; +import { dirname, join, resolve } from 'node:path'; +import { fileURLToPath } from 'node:url'; // The Express app is exported so that it can be used by serverless Functions. export function app(): express.Express { const server = express(); - const distFolder = join(process.cwd(), 'dist/docs-static/browser'); - const indexHtml = existsSync(join(distFolder, 'index.original.html')) - ? join(distFolder, 'index.original.html') - : join(distFolder, 'index.html'); + const serverDistFolder = dirname(fileURLToPath(import.meta.url)); + const browserDistFolder = resolve(serverDistFolder, '../browser'); + const indexHtml = join(serverDistFolder, 'index.server.html'); const commonEngine = new CommonEngine(); server.set('view engine', 'html'); - server.set('views', distFolder); + server.set('views', browserDistFolder); // Example Express Rest API endpoints // server.get('/api/**', (req, res) => { }); // Serve static files from /browser server.get( - '*.*', - express.static(distFolder, { + '**', + express.static(browserDistFolder, { maxAge: '1y', + index: 'index.html', }), ); // All regular routes use the Angular engine - server.get('*', (req, res, next) => { + server.get('**', (req, res, next) => { const { protocol, originalUrl, baseUrl, headers } = req; commonEngine @@ -41,7 +39,7 @@ export function app(): express.Express { bootstrap, documentFilePath: indexHtml, url: `${protocol}://${headers.host}${originalUrl}`, - publicPath: distFolder, + publicPath: browserDistFolder, providers: [{ provide: APP_BASE_HREF, useValue: baseUrl }], }) .then((html) => res.send(html)) @@ -61,14 +59,4 @@ function run(): void { }); } -// Webpack will replace 'require' with '__webpack_require__' -// '__non_webpack_require__' is a proxy to Node 'require' -// The below code is to ensure that the server is run only when not requiring the bundle. -declare const __non_webpack_require__: NodeRequire; -const mainModule = __non_webpack_require__.main; -const moduleFilename = (mainModule && mainModule.filename) || ''; -if (moduleFilename === __filename || moduleFilename.includes('iisnode')) { - run(); -} - -export default bootstrap; +run(); diff --git a/apps/docs/tailwind.config.js b/apps/docs/tailwind.config.js index be90c4f6..3aebe420 100644 --- a/apps/docs/tailwind.config.js +++ b/apps/docs/tailwind.config.js @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/unbound-method */ /* eslint-disable @typescript-eslint/no-unsafe-argument */ /* eslint-disable @typescript-eslint/no-unsafe-assignment */ /* eslint-disable @typescript-eslint/no-unsafe-call */ diff --git a/apps/docs/tsconfig.app.json b/apps/docs/tsconfig.app.json index 14995e37..71757678 100644 --- a/apps/docs/tsconfig.app.json +++ b/apps/docs/tsconfig.app.json @@ -2,11 +2,11 @@ "extends": "./tsconfig.json", "compilerOptions": { "outDir": "../../dist/out-tsc", - "types": [], + "types": ["node"], "target": "ES2022", "useDefineForClassFields": false }, - "files": ["src/main.ts"], + "files": ["src/main.ts", "src/main.server.ts", "server.ts"], "include": ["src/**/*.d.ts", "tailwind.config.js"], "exclude": ["**/*.test.ts", "**/*.spec.ts", "jest.config.ts"] } diff --git a/apps/docs/tsconfig.json b/apps/docs/tsconfig.json index f4952b23..e140e589 100644 --- a/apps/docs/tsconfig.json +++ b/apps/docs/tsconfig.json @@ -24,7 +24,8 @@ "noPropertyAccessFromIndexSignature": true, "noImplicitReturns": true, "noFallthroughCasesInSwitch": true, - "target": "ES2022" + "target": "ES2022", + "esModuleInterop": true }, "angularCompilerOptions": { "strictInjectionParameters": true, diff --git a/apps/docs/tsconfig.server.json b/apps/docs/tsconfig.server.json deleted file mode 100644 index a1f97f4a..00000000 --- a/apps/docs/tsconfig.server.json +++ /dev/null @@ -1,10 +0,0 @@ -/* To learn more about this file see: https://angular.io/config/tsconfig. */ -{ - "extends": "./tsconfig.app.json", - "compilerOptions": { - "outDir": "../../out-tsc/server", - "target": "ES2022", - "types": ["node"] - }, - "files": ["src/main.server.ts", "server.ts"] -} diff --git a/libs/flowbite-angular/src/index.ts b/libs/flowbite-angular/src/index.ts index 51934e9f..e6053212 100644 --- a/libs/flowbite-angular/src/index.ts +++ b/libs/flowbite-angular/src/index.ts @@ -3,3 +3,4 @@ export * from './lib/components'; export * from './lib/pipes'; export * from './lib/services'; export * from './lib/utils'; +export * from './lib/directives'; diff --git a/libs/flowbite-angular/src/lib/directives/index.ts b/libs/flowbite-angular/src/lib/directives/index.ts new file mode 100644 index 00000000..694f5200 --- /dev/null +++ b/libs/flowbite-angular/src/lib/directives/index.ts @@ -0,0 +1,2 @@ +export { FlowbiteRouterLinkActiveDirective } from './flowbite-router-link-active.directive'; +export { FlowbiteRouterLinkDirective } from './flowbite-router-link.directive'; diff --git a/package.json b/package.json index add1c511..e81fd290 100644 --- a/package.json +++ b/package.json @@ -21,18 +21,18 @@ "test": "nx run-many --target test --all" }, "dependencies": { - "@angular-eslint/template-parser": "17.3.0", - "@angular/animations": "18.0.1", - "@angular/common": "18.0.1", - "@angular/compiler": "18.0.1", - "@angular/core": "18.0.1", - "@angular/platform-browser": "18.0.1", - "@angular/platform-browser-dynamic": "18.0.1", - "@angular/platform-server": "18.0.1", - "@angular/router": "18.0.1", - "@angular/ssr": "18.0.2", + "@angular-eslint/template-parser": "18.0.1", + "@angular/animations": "18.2.5", + "@angular/common": "18.2.5", + "@angular/compiler": "18.2.5", + "@angular/core": "18.2.5", + "@angular/platform-browser": "18.2.5", + "@angular/platform-browser-dynamic": "18.2.5", + "@angular/platform-server": "18.2.5", + "@angular/router": "18.2.5", + "@angular/ssr": "18.2.5", "@floating-ui/dom": "^1.2.6", - "@nx/angular": "19.1.1", + "@nx/angular": "19.8.0", "express": "~4.18.2", "rxjs": "7.8.1", "tailwind-merge": "^2.2.1", @@ -40,31 +40,32 @@ "zone.js": "0.14.6" }, "devDependencies": { - "@angular-devkit/build-angular": "18.0.2", - "@angular-devkit/core": "18.0.2", - "@angular-devkit/schematics": "18.0.2", - "@angular-eslint/eslint-plugin": "17.3.0", - "@angular-eslint/eslint-plugin-template": "17.3.0", - "@angular/cli": "~18.0.0", - "@angular/compiler-cli": "18.0.1", - "@angular/language-service": "18.0.1", + "@angular-devkit/build-angular": "18.2.5", + "@angular-devkit/core": "18.2.5", + "@angular-devkit/schematics": "18.2.5", + "@angular-eslint/eslint-plugin": "18.0.1", + "@angular-eslint/eslint-plugin-template": "18.0.1", + "@angular/cli": "~18.2.0", + "@angular/compiler-cli": "18.2.5", + "@angular/language-service": "18.2.5", "@commitlint/cli": "^18.4.4", "@commitlint/config-conventional": "^18.4.4", "@ianvs/prettier-plugin-sort-imports": "^4.3.0", - "@nx/cypress": "19.1.1", - "@nx/eslint": "19.1.1", - "@nx/eslint-plugin": "19.1.1", - "@nx/jest": "19.1.1", - "@nx/workspace": "19.1.1", - "@schematics/angular": "18.0.2", + "@nx/cypress": "19.8.0", + "@nx/eslint": "19.8.0", + "@nx/eslint-plugin": "19.8.0", + "@nx/jest": "19.8.0", + "@nx/workspace": "19.8.0", + "@schematics/angular": "18.2.5", "@types/express": "4.17.14", - "@types/jest": "29.5.11", + "@types/jest": "29.5.13", "@types/node": "18.16.9", "@typescript-eslint/eslint-plugin": "7.3.0", "@typescript-eslint/parser": "7.3.0", + "@typescript-eslint/utils": "^7.16.0", "autoprefixer": "^10.4.0", "browser-sync": "^3.0.0", - "cypress": "13.8.0", + "cypress": "13.13.0", "eslint": "8.57.0", "eslint-config-prettier": "^9.1.0", "eslint-plugin-cypress": "2.15.1", @@ -73,8 +74,8 @@ "jest-environment-jsdom": "29.7.0", "jest-preset-angular": "14.1.0", "lint-staged": "^15.2.0", - "ng-packagr": "18.0.0", - "nx": "19.1.1", + "ng-packagr": "18.2.1", + "nx": "19.8.0", "postcss": "^8.4.13", "postcss-import": "16.0.0", "postcss-preset-env": "9.3.0", diff --git a/vercel.json b/vercel.json index 7a02fa9d..9eb2db6f 100644 --- a/vercel.json +++ b/vercel.json @@ -2,7 +2,13 @@ "version": 2, "public": true, "name": "flowbite-angular", - "devCommand": "node dist/docs-static/server/main.js", + "framework": "angular", + "buildCommand": "yarn nx run docs:build", + "outputDirectory": "dist/docs-static", + "installCommand": "yarn install", + "env": { + "FORCE_RUNTIME_TAG": "canary" + }, "rewrites": [ { "source": "/(.*)", @@ -10,8 +16,8 @@ } ], "functions": { - "api/index.js": { - "includeFiles": "dist/docs-static/browser/**" + "api/index.mjs": { + "includeFiles": "dist/docs-static/**" } } }