dinou 1.3.1 → 1.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -18,7 +18,7 @@ Or you can create one by yourself with the following steps:
18
18
 
19
19
  - "eject": "dinou eject"
20
20
 
21
- - Create an `src` folder with a `page.jsx` (or `.tsx`, `.js`)
21
+ - Create an `src` folder with a `page.jsx` (or `.tsx`)
22
22
 
23
23
  ```typescript
24
24
  "use client";
@@ -52,6 +52,8 @@ dinou main features are:
52
52
 
53
53
  - Support for the use of images in your components (`.png`, `.jpeg`, `.jpg`, `.gif`, `.svg`, `.webp`)
54
54
 
55
+ - Support for the use of an import alias in `tsconfig.json` or `jsconfig.json` file.
56
+
55
57
  ## Table of contents
56
58
 
57
59
  - [Routing system, layouts, pages, not found pages, ...](#routing-system-layouts-pages-not-found-pages-)
@@ -104,6 +106,8 @@ dinou main features are:
104
106
 
105
107
  - [Images (`.png`, `.jpeg`, `.jpg`, `.gif`, `.svg`, and `.webp`)](#images-png-jpeg-jpg-gif-svg-and-webp)
106
108
 
109
+ - [Import alias (e.g. `"@/..."`)](#import-alias-eg-)
110
+
107
111
  - [How to run a dinou app](#how-to-run-a-dinou-app)
108
112
 
109
113
  - [Eject dinou](#eject-dinou)
@@ -112,13 +116,13 @@ dinou main features are:
112
116
 
113
117
  ## Routing system, layouts, pages, not found pages, ...
114
118
 
115
- - Routes are defined by defining a `page.tsx` file (or `.jsx`, `.js`) in a folder.
119
+ - Routes are defined by defining a `page.tsx` file (or `.jsx`) in a folder.
116
120
 
117
121
  - Route "/" corresponds to the `src` folder.
118
122
 
119
- - You can define layouts and nested layouts by defining a `layout.tsx` (or `.jsx`, `.js`) file in a folder. A layout file found in a folder wraps a layout file found in a more nested folder, and finally composition of all layouts found in a route hierarchy wraps the `page` component or `not_found` component.
123
+ - You can define layouts and nested layouts by defining a `layout.tsx` (or `.jsx`) file in a folder. A layout file found in a folder wraps a layout file found in a more nested folder, and finally composition of all layouts found in a route hierarchy wraps the `page` component or `not_found` component.
120
124
 
121
- - You can define not found pages by defining `not_found.tsx` (or `.jsx`, `.js`) file in a folder. If more than a `not_found.tsx` file is found in a route hierarchy, the more nested one will be used.
125
+ - You can define not found pages by defining `not_found.tsx` (or `.jsx`) file in a folder. If more than a `not_found.tsx` file is found in a route hierarchy, the more nested one will be used.
122
126
 
123
127
  - If you don't want a `page` to be applied layouts define a `no_layout` file (without extension) in the same folder. A `no_layout` file, if present, also applies to the `not_found` file if present in the same folder. There exists also a `no_layout_not_found` file if you don't want a `not_found` file to be applied layouts but you do in `page` component.
124
128
 
@@ -665,11 +669,11 @@ The routing system is file-based and supports static routes, dynamic routes, opt
665
669
 
666
670
  - All routes are resolved relative to the `src/` directory.
667
671
 
668
- - A route is defined by a `page.tsx` (or `.jsx`, `.js`) file in a directory.
672
+ - A route is defined by a `page.tsx` (or `.jsx`) file in a directory.
669
673
 
670
- - Layouts are defined by `layout.tsx` (or `.jsx`, `.js`) files, which wrap the content of pages or nested layouts.
674
+ - Layouts are defined by `layout.tsx` (or `.jsx`) files, which wrap the content of pages or nested layouts.
671
675
 
672
- - Not found pages are defined by `not_found.tsx` (or `.jsx`, `.js`) files.
676
+ - Not found pages are defined by `not_found.tsx` (or `.jsx`) files.
673
677
 
674
678
  - Slots are defined by folders starting with `@` (e.g., `@sidebar`), containing a `page.tsx` file.
675
679
 
@@ -905,7 +909,7 @@ MY_VAR=my_value
905
909
 
906
910
  ## Styles (Tailwind.css, .module.css, and .css)
907
911
 
908
- dinou is ready to use Tailwind.css, `.module.css`, and `.css` styles. All styles will be generated in a file in `public` folder named `styles.css`. So you must include this in your `page.tsx` or `layout.tsx` file, in the `head` tag:
912
+ dinou is ready to use Tailwind.css, `.module.css`, and `.css` styles. All styles will be generated in a file in `____public____` folder named `styles.css`. So you must include this in your `page.tsx` or `layout.tsx` file, in the `head` tag:
909
913
 
910
914
  ```typescript
911
915
  <link href="/styles.css" rel="stylesheet"></link>
@@ -991,7 +995,7 @@ dinou is ready to use Tailwind.css, `.module.css`, and `.css` styles. All styles
991
995
 
992
996
  - The above will produce the text `hi world!` in red, underlined, and with a purple background color.
993
997
 
994
- - **Only styles imported under `"use client"` directive will be detected by Webpack and generated in a `styles.css` in `public` folder**. This means that if you want to use server components instead of client components, then you must create an additional file (e.g. `styles.ts`) where you use the `"use client"` directive and import all the `.css` files used in server components.
998
+ - **Only styles imported under `"use client"` directive will be detected by Webpack and generated in a `styles.css` in `____public____` folder**. This means that if you want to use server components instead of client components, then you must create an additional file (e.g. `styles.ts`) where you use the `"use client"` directive and import all the `.css` files used in server components.
995
999
 
996
1000
  - Example with server components:
997
1001
 
@@ -1088,7 +1092,7 @@ export default function Component() {
1088
1092
  }
1089
1093
  ```
1090
1094
 
1091
- **Only images imported under `"use client"` directive will be detected by Webpack and generated in `public` folder**. If you use server components, then you must create an additional file (e.g. `images.ts`) with the `"use client"` directive and import there the images too:
1095
+ **Only images imported under `"use client"` directive will be detected by Webpack and generated in `____public____` folder**. If you use server components, then you must create an additional file (e.g. `images.ts`) with the `"use client"` directive and import there the images too:
1092
1096
 
1093
1097
  ```typescript
1094
1098
  // src/images.ts
@@ -1106,6 +1110,38 @@ export default async function Component() {
1106
1110
  }
1107
1111
  ```
1108
1112
 
1113
+ ## Import alias (e.g. `"@/..."`)
1114
+
1115
+ dinou is ready to support import alias, as `import some from "@/..."`. If you want to use them just define the options in `tsconfig.json` or `jsconfig.json`:
1116
+
1117
+ ```json
1118
+ // tsconfig.json
1119
+ {
1120
+ "compilerOptions": {
1121
+ // other options
1122
+ "baseUrl": ".",
1123
+ "paths": {
1124
+ "@/*": ["src/*"]
1125
+ }
1126
+ },
1127
+ "include": ["src/**/*"]
1128
+ // other configuration fields
1129
+ }
1130
+ ```
1131
+
1132
+ ```json
1133
+ // jsconfig.json
1134
+ {
1135
+ "compilerOptions": {
1136
+ "baseUrl": ".",
1137
+ "paths": {
1138
+ "@/*": ["src/*"]
1139
+ }
1140
+ },
1141
+ "include": ["src"]
1142
+ }
1143
+ ```
1144
+
1109
1145
  ## How to run a dinou app
1110
1146
 
1111
1147
  Run `npm run dev` (or `npx dinou dev`) to start the dinou app in development mode. Wait for the logs of Webpack and `Listening on port <port>` to load the page on your browser.
@@ -4,6 +4,7 @@ register({
4
4
  target: "esnext",
5
5
  format: "cjs",
6
6
  extensions: [".js", ".jsx", ".ts", ".tsx"],
7
+ jsx: "automatic",
7
8
  });
8
9
  const createScopedName = require("./createScopedName");
9
10
  require("css-modules-require-hook")({
package/dinou/server.js CHANGED
@@ -17,6 +17,7 @@ register({
17
17
  target: "esnext",
18
18
  format: "cjs",
19
19
  extensions: [".js", ".jsx", ".ts", ".tsx"],
20
+ jsx: "automatic",
20
21
  });
21
22
  const createScopedName = require("./createScopedName");
22
23
  require("css-modules-require-hook")({
@@ -45,7 +46,7 @@ if (isDevelopment) {
45
46
  app.use(webpackHotMiddleware(compiler));
46
47
  }
47
48
 
48
- app.use(express.static(path.resolve(process.cwd(), "public")));
49
+ app.use(express.static(path.resolve(process.cwd(), "____public____")));
49
50
 
50
51
  app.get(/^\/____rsc_payload____\/.*\/?$/, async (req, res) => {
51
52
  try {
@@ -55,7 +56,7 @@ app.get(/^\/____rsc_payload____\/.*\/?$/, async (req, res) => {
55
56
 
56
57
  jsx = await getSSGJSXOrJSX(reqPath, { ...req.query });
57
58
  const manifest = readFileSync(
58
- path.resolve(process.cwd(), "public/react-client-manifest.json"),
59
+ path.resolve(process.cwd(), "____public____/react-client-manifest.json"),
59
60
  "utf8"
60
61
  );
61
62
  const moduleMap = JSON.parse(manifest);
package/dinou/ssg.js CHANGED
@@ -5,6 +5,7 @@ register({
5
5
  target: "esnext",
6
6
  format: "cjs",
7
7
  extensions: [".js", ".jsx", ".ts", ".tsx"],
8
+ jsx: "automatic",
8
9
  });
9
10
  const createScopedName = require("./createScopedName");
10
11
  require("css-modules-require-hook")({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dinou",
3
- "version": "1.3.1",
3
+ "version": "1.4.1",
4
4
  "description": "Minimal React 19 Framework",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -20,11 +20,6 @@
20
20
  "url": "https://github.com/roggc/dinou.git"
21
21
  },
22
22
  "dependencies": {
23
- "@babel/core": "^7.27.1",
24
- "@babel/plugin-syntax-import-meta": "^7.10.4",
25
- "@babel/plugin-transform-modules-commonjs": "^7.27.1",
26
- "@babel/preset-react": "^7.27.1",
27
- "@babel/preset-typescript": "^7.27.1",
28
23
  "@tailwindcss/postcss": "^4.1.10",
29
24
  "autoprefixer": "^10.4.21",
30
25
  "babel-loader": "^10.0.0",
@@ -34,6 +29,7 @@
34
29
  "css-loader": "^7.1.2",
35
30
  "css-modules-require-hook": "^4.2.3",
36
31
  "dotenv": "^16.5.0",
32
+ "esbuild-loader": "^4.3.0",
37
33
  "esbuild-register": "^3.6.0",
38
34
  "express": "^5.1.0",
39
35
  "generic-names": "^4.0.0",
@@ -43,6 +39,7 @@
43
39
  "postcss-loader": "^8.1.1",
44
40
  "react-server-dom-webpack": "^19.1.0",
45
41
  "tailwindcss": "^4.1.10",
42
+ "tsconfig-paths-webpack-plugin": "^4.2.0",
46
43
  "webpack": "^5.99.8",
47
44
  "webpack-cli": "^6.0.1",
48
45
  "webpack-dev-middleware": "^7.4.2",
package/webpack.config.js CHANGED
@@ -1,13 +1,28 @@
1
1
  require("dotenv/config");
2
2
  const path = require("path");
3
+ const fs = require("fs");
3
4
  const ReactServerWebpackPlugin = require("react-server-dom-webpack/plugin");
4
5
  const webpack = require("webpack");
5
6
  const CopyWebpackPlugin = require("copy-webpack-plugin");
6
7
  const MiniCssExtractPlugin = require("mini-css-extract-plugin");
7
8
  const createScopedName = require("./dinou/createScopedName");
9
+ const TsconfigPathsPlugin = require("tsconfig-paths-webpack-plugin");
10
+ const { EsbuildPlugin } = require("esbuild-loader");
8
11
 
9
12
  const isDevelopment = process.env.NODE_ENV !== "production";
10
13
 
14
+ function getConfigFileIfExists() {
15
+ const tsconfigPath = path.resolve(process.cwd(), "tsconfig.json");
16
+ const jsconfigPath = path.resolve(process.cwd(), "jsconfig.json");
17
+
18
+ if (fs.existsSync(tsconfigPath)) return tsconfigPath;
19
+ if (fs.existsSync(jsconfigPath)) return jsconfigPath;
20
+
21
+ return null;
22
+ }
23
+
24
+ const configFile = getConfigFileIfExists();
25
+
11
26
  module.exports = {
12
27
  mode: isDevelopment ? "development" : "production",
13
28
  entry: {
@@ -17,7 +32,7 @@ module.exports = {
17
32
  ].filter(Boolean),
18
33
  },
19
34
  output: {
20
- path: path.resolve(process.cwd(), "./public"),
35
+ path: path.resolve(process.cwd(), "./____public____"),
21
36
  filename: "main.js",
22
37
  publicPath: "/",
23
38
  clean: true,
@@ -25,26 +40,25 @@ module.exports = {
25
40
  module: {
26
41
  rules: [
27
42
  {
28
- test: /\.(js|jsx|ts|tsx)$/,
29
- use: {
30
- loader: "babel-loader",
31
- options: {
32
- presets: [
33
- ["@babel/preset-react", { runtime: "automatic" }],
34
- "@babel/preset-typescript",
35
- ],
36
- plugins: [
37
- "@babel/plugin-transform-modules-commonjs",
38
- "@babel/plugin-syntax-import-meta",
39
- ],
40
- },
43
+ // Match `.js`, `.jsx`, `.ts` or `.tsx` files
44
+ test: /\.[jt]sx?$/,
45
+ loader: "esbuild-loader",
46
+ options: {
47
+ // JavaScript version to compile to
48
+ target: "esnext",
49
+ jsx: "automatic", // Use React's automatic JSX runtime
41
50
  },
42
- exclude: [/node_modules\/(?!dinou)/, /dist/],
51
+ exclude: [/node_modules\/(?!dinou)/],
43
52
  },
44
53
  {
45
54
  test: /\.module\.css$/,
46
55
  use: [
47
- MiniCssExtractPlugin.loader,
56
+ {
57
+ loader: MiniCssExtractPlugin.loader,
58
+ options: {
59
+ defaultExport: true,
60
+ },
61
+ },
48
62
  {
49
63
  loader: "css-loader",
50
64
  options: {
@@ -115,6 +129,14 @@ module.exports = {
115
129
  ].filter(Boolean),
116
130
  resolve: {
117
131
  extensions: [".js", ".jsx", ".ts", ".tsx"],
132
+ plugins: configFile
133
+ ? [
134
+ new TsconfigPathsPlugin({
135
+ configFile,
136
+ extensions: [".js", ".jsx", ".ts", ".tsx"],
137
+ }),
138
+ ]
139
+ : [],
118
140
  },
119
141
  optimization: {
120
142
  splitChunks: {
@@ -127,5 +149,12 @@ module.exports = {
127
149
  },
128
150
  },
129
151
  },
152
+ minimize: !isDevelopment,
153
+ minimizer: !isDevelopment
154
+ ? [new EsbuildPlugin({ target: "esnext", css: true })]
155
+ : [],
156
+ },
157
+ watchOptions: {
158
+ ignored: /____public____/,
130
159
  },
131
160
  };