create-plasmic-app 0.0.147 → 0.0.149

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.
Files changed (34) hide show
  1. package/cpa-out/.gitignore +1 -0
  2. package/cpa-out/nextjs-app-codegen-js/next.config.mjs +7 -0
  3. package/cpa-out/nextjs-app-codegen-js/package.json +6 -6
  4. package/cpa-out/nextjs-app-codegen-ts/next.config.ts +8 -0
  5. package/cpa-out/nextjs-app-codegen-ts/package.json +8 -8
  6. package/cpa-out/nextjs-app-codegen-ts/tsconfig.json +10 -2
  7. package/cpa-out/nextjs-app-loader-js/app/layout.js +8 -11
  8. package/cpa-out/nextjs-app-loader-js/next.config.mjs +6 -0
  9. package/cpa-out/nextjs-app-loader-js/package.json +6 -6
  10. package/cpa-out/nextjs-app-loader-ts/app/layout.tsx +8 -11
  11. package/cpa-out/nextjs-app-loader-ts/next.config.ts +7 -0
  12. package/cpa-out/nextjs-app-loader-ts/package.json +8 -8
  13. package/cpa-out/nextjs-app-loader-ts/tsconfig.json +10 -2
  14. package/cpa-out/nextjs-pages-codegen-js/next.config.mjs +7 -0
  15. package/cpa-out/nextjs-pages-codegen-js/package.json +6 -6
  16. package/cpa-out/nextjs-pages-codegen-ts/next.config.ts +8 -0
  17. package/cpa-out/nextjs-pages-codegen-ts/package.json +8 -8
  18. package/cpa-out/nextjs-pages-codegen-ts/tsconfig.json +10 -2
  19. package/cpa-out/nextjs-pages-loader-js/next.config.mjs +7 -0
  20. package/cpa-out/nextjs-pages-loader-js/package.json +6 -6
  21. package/cpa-out/nextjs-pages-loader-ts/next.config.ts +8 -0
  22. package/cpa-out/nextjs-pages-loader-ts/package.json +8 -8
  23. package/cpa-out/nextjs-pages-loader-ts/tsconfig.json +10 -2
  24. package/dist/nextjs/nextjs.js +59 -18
  25. package/dist/nextjs/templates/app-codegen/layout.d.ts +2 -2
  26. package/dist/nextjs/templates/app-codegen/layout.js +8 -2
  27. package/dist/nextjs/templates/pages-codegen/app.d.ts +2 -2
  28. package/dist/nextjs/templates/pages-codegen/app.js +8 -2
  29. package/dist/utils/types.d.ts +4 -0
  30. package/package.json +3 -3
  31. package/src/nextjs/nextjs.ts +87 -28
  32. package/src/nextjs/templates/app-codegen/layout.ts +16 -3
  33. package/src/nextjs/templates/pages-codegen/app.ts +16 -3
  34. package/src/utils/types.ts +5 -0
@@ -13,6 +13,7 @@
13
13
  !**/*.jsx
14
14
  !**/*.ts
15
15
  !**/*.tsx
16
+ !**/next.config.mjs
16
17
 
17
18
  # for tanstack start
18
19
  .tanstack/
@@ -0,0 +1,7 @@
1
+ /** @type {import('next').NextConfig} */
2
+ const nextConfig = {
3
+ trailingSlash: true,
4
+ reactStrictMode: true,
5
+ };
6
+
7
+ export default nextConfig;
@@ -6,17 +6,17 @@
6
6
  "dev": "next dev",
7
7
  "build": "next build",
8
8
  "start": "next start",
9
- "lint": "next lint"
9
+ "lint": "eslint"
10
10
  },
11
11
  "dependencies": {
12
12
  "@plasmicapp/cli": "^0.1.361",
13
13
  "@plasmicapp/react-web": "^1.0.8",
14
- "next": "14.2.35",
15
- "react": "^18",
16
- "react-dom": "^18"
14
+ "next": "16.2.6",
15
+ "react": "19.2.4",
16
+ "react-dom": "19.2.4"
17
17
  },
18
18
  "devDependencies": {
19
- "eslint": "^8",
20
- "eslint-config-next": "14.2.35"
19
+ "eslint": "^9",
20
+ "eslint-config-next": "16.2.6"
21
21
  }
22
22
  }
@@ -0,0 +1,8 @@
1
+ import type { NextConfig } from "next";
2
+
3
+ const nextConfig: NextConfig = {
4
+ trailingSlash: true,
5
+ reactStrictMode: true,
6
+ };
7
+
8
+ export default nextConfig;
@@ -6,21 +6,21 @@
6
6
  "dev": "next dev",
7
7
  "build": "next build",
8
8
  "start": "next start",
9
- "lint": "next lint"
9
+ "lint": "eslint"
10
10
  },
11
11
  "dependencies": {
12
12
  "@plasmicapp/cli": "^0.1.361",
13
13
  "@plasmicapp/react-web": "^1.0.8",
14
- "next": "14.2.35",
15
- "react": "^18",
16
- "react-dom": "^18"
14
+ "next": "16.2.6",
15
+ "react": "19.2.4",
16
+ "react-dom": "19.2.4"
17
17
  },
18
18
  "devDependencies": {
19
19
  "@types/node": "^20",
20
- "@types/react": "^18",
21
- "@types/react-dom": "^18",
22
- "eslint": "^8",
23
- "eslint-config-next": "14.2.35",
20
+ "@types/react": "^19",
21
+ "@types/react-dom": "^19",
22
+ "eslint": "^9",
23
+ "eslint-config-next": "16.2.6",
24
24
  "typescript": "^5"
25
25
  }
26
26
  }
@@ -1,5 +1,6 @@
1
1
  {
2
2
  "compilerOptions": {
3
+ "target": "ES2017",
3
4
  "lib": ["dom", "dom.iterable", "esnext"],
4
5
  "allowJs": true,
5
6
  "skipLibCheck": true,
@@ -10,7 +11,7 @@
10
11
  "moduleResolution": "bundler",
11
12
  "resolveJsonModule": true,
12
13
  "isolatedModules": true,
13
- "jsx": "preserve",
14
+ "jsx": "react-jsx",
14
15
  "incremental": true,
15
16
  "plugins": [
16
17
  {
@@ -21,6 +22,13 @@
21
22
  "@/*": ["./*"]
22
23
  }
23
24
  },
24
- "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
25
+ "include": [
26
+ "next-env.d.ts",
27
+ "**/*.ts",
28
+ "**/*.tsx",
29
+ ".next/types/**/*.ts",
30
+ ".next/dev/types/**/*.ts",
31
+ "**/*.mts"
32
+ ],
25
33
  "exclude": ["node_modules"]
26
34
  }
@@ -1,15 +1,14 @@
1
- import localFont from "next/font/local";
1
+ import { Geist, Geist_Mono } from "next/font/google";
2
2
  import "./globals.css";
3
3
 
4
- const geistSans = localFont({
5
- src: "./fonts/GeistVF.woff",
4
+ const geistSans = Geist({
6
5
  variable: "--font-geist-sans",
7
- weight: "100 900",
6
+ subsets: ["latin"],
8
7
  });
9
- const geistMono = localFont({
10
- src: "./fonts/GeistMonoVF.woff",
8
+
9
+ const geistMono = Geist_Mono({
11
10
  variable: "--font-geist-mono",
12
- weight: "100 900",
11
+ subsets: ["latin"],
13
12
  });
14
13
 
15
14
  export const metadata = {
@@ -19,10 +18,8 @@ export const metadata = {
19
18
 
20
19
  export default function RootLayout({ children }) {
21
20
  return (
22
- <html lang="en">
23
- <body className={`${geistSans.variable} ${geistMono.variable}`}>
24
- {children}
25
- </body>
21
+ <html lang="en" className={`${geistSans.variable} ${geistMono.variable}`}>
22
+ <body>{children}</body>
26
23
  </html>
27
24
  );
28
25
  }
@@ -0,0 +1,6 @@
1
+ /** @type {import('next').NextConfig} */
2
+ const nextConfig = {
3
+ /* config options here */
4
+ };
5
+
6
+ export default nextConfig;
@@ -6,16 +6,16 @@
6
6
  "dev": "next dev",
7
7
  "build": "next build",
8
8
  "start": "next start",
9
- "lint": "next lint"
9
+ "lint": "eslint"
10
10
  },
11
11
  "dependencies": {
12
12
  "@plasmicapp/loader-nextjs": "^2.0.4",
13
- "next": "14.2.35",
14
- "react": "^18",
15
- "react-dom": "^18"
13
+ "next": "16.2.6",
14
+ "react": "19.2.4",
15
+ "react-dom": "19.2.4"
16
16
  },
17
17
  "devDependencies": {
18
- "eslint": "^8",
19
- "eslint-config-next": "14.2.35"
18
+ "eslint": "^9",
19
+ "eslint-config-next": "16.2.6"
20
20
  }
21
21
  }
@@ -1,16 +1,15 @@
1
1
  import type { Metadata } from "next";
2
- import localFont from "next/font/local";
2
+ import { Geist, Geist_Mono } from "next/font/google";
3
3
  import "./globals.css";
4
4
 
5
- const geistSans = localFont({
6
- src: "./fonts/GeistVF.woff",
5
+ const geistSans = Geist({
7
6
  variable: "--font-geist-sans",
8
- weight: "100 900",
7
+ subsets: ["latin"],
9
8
  });
10
- const geistMono = localFont({
11
- src: "./fonts/GeistMonoVF.woff",
9
+
10
+ const geistMono = Geist_Mono({
12
11
  variable: "--font-geist-mono",
13
- weight: "100 900",
12
+ subsets: ["latin"],
14
13
  });
15
14
 
16
15
  export const metadata: Metadata = {
@@ -24,10 +23,8 @@ export default function RootLayout({
24
23
  children: React.ReactNode;
25
24
  }>) {
26
25
  return (
27
- <html lang="en">
28
- <body className={`${geistSans.variable} ${geistMono.variable}`}>
29
- {children}
30
- </body>
26
+ <html lang="en" className={`${geistSans.variable} ${geistMono.variable}`}>
27
+ <body>{children}</body>
31
28
  </html>
32
29
  );
33
30
  }
@@ -0,0 +1,7 @@
1
+ import type { NextConfig } from "next";
2
+
3
+ const nextConfig: NextConfig = {
4
+ /* config options here */
5
+ };
6
+
7
+ export default nextConfig;
@@ -6,20 +6,20 @@
6
6
  "dev": "next dev",
7
7
  "build": "next build",
8
8
  "start": "next start",
9
- "lint": "next lint"
9
+ "lint": "eslint"
10
10
  },
11
11
  "dependencies": {
12
12
  "@plasmicapp/loader-nextjs": "^2.0.4",
13
- "next": "14.2.35",
14
- "react": "^18",
15
- "react-dom": "^18"
13
+ "next": "16.2.6",
14
+ "react": "19.2.4",
15
+ "react-dom": "19.2.4"
16
16
  },
17
17
  "devDependencies": {
18
18
  "@types/node": "^20",
19
- "@types/react": "^18",
20
- "@types/react-dom": "^18",
21
- "eslint": "^8",
22
- "eslint-config-next": "14.2.35",
19
+ "@types/react": "^19",
20
+ "@types/react-dom": "^19",
21
+ "eslint": "^9",
22
+ "eslint-config-next": "16.2.6",
23
23
  "typescript": "^5"
24
24
  }
25
25
  }
@@ -1,5 +1,6 @@
1
1
  {
2
2
  "compilerOptions": {
3
+ "target": "ES2017",
3
4
  "lib": ["dom", "dom.iterable", "esnext"],
4
5
  "allowJs": true,
5
6
  "skipLibCheck": true,
@@ -10,7 +11,7 @@
10
11
  "moduleResolution": "bundler",
11
12
  "resolveJsonModule": true,
12
13
  "isolatedModules": true,
13
- "jsx": "preserve",
14
+ "jsx": "react-jsx",
14
15
  "incremental": true,
15
16
  "plugins": [
16
17
  {
@@ -21,6 +22,13 @@
21
22
  "@/*": ["./*"]
22
23
  }
23
24
  },
24
- "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
25
+ "include": [
26
+ "next-env.d.ts",
27
+ "**/*.ts",
28
+ "**/*.tsx",
29
+ ".next/types/**/*.ts",
30
+ ".next/dev/types/**/*.ts",
31
+ "**/*.mts"
32
+ ],
25
33
  "exclude": ["node_modules"]
26
34
  }
@@ -0,0 +1,7 @@
1
+ /** @type {import('next').NextConfig} */
2
+ const nextConfig = {
3
+ trailingSlash: true,
4
+ reactStrictMode: true,
5
+ };
6
+
7
+ export default nextConfig;
@@ -6,17 +6,17 @@
6
6
  "dev": "next dev",
7
7
  "build": "next build",
8
8
  "start": "next start",
9
- "lint": "next lint"
9
+ "lint": "eslint"
10
10
  },
11
11
  "dependencies": {
12
12
  "@plasmicapp/cli": "^0.1.361",
13
13
  "@plasmicapp/react-web": "^1.0.8",
14
- "next": "14.2.35",
15
- "react": "^18",
16
- "react-dom": "^18"
14
+ "next": "16.2.6",
15
+ "react": "19.2.4",
16
+ "react-dom": "19.2.4"
17
17
  },
18
18
  "devDependencies": {
19
- "eslint": "^8",
20
- "eslint-config-next": "14.2.35"
19
+ "eslint": "^9",
20
+ "eslint-config-next": "16.2.6"
21
21
  }
22
22
  }
@@ -0,0 +1,8 @@
1
+ import type { NextConfig } from "next";
2
+
3
+ const nextConfig: NextConfig = {
4
+ trailingSlash: true,
5
+ reactStrictMode: true,
6
+ };
7
+
8
+ export default nextConfig;
@@ -6,21 +6,21 @@
6
6
  "dev": "next dev",
7
7
  "build": "next build",
8
8
  "start": "next start",
9
- "lint": "next lint"
9
+ "lint": "eslint"
10
10
  },
11
11
  "dependencies": {
12
12
  "@plasmicapp/cli": "^0.1.361",
13
13
  "@plasmicapp/react-web": "^1.0.8",
14
- "next": "14.2.35",
15
- "react": "^18",
16
- "react-dom": "^18"
14
+ "next": "16.2.6",
15
+ "react": "19.2.4",
16
+ "react-dom": "19.2.4"
17
17
  },
18
18
  "devDependencies": {
19
19
  "@types/node": "^20",
20
- "@types/react": "^18",
21
- "@types/react-dom": "^18",
22
- "eslint": "^8",
23
- "eslint-config-next": "14.2.35",
20
+ "@types/react": "^19",
21
+ "@types/react-dom": "^19",
22
+ "eslint": "^9",
23
+ "eslint-config-next": "16.2.6",
24
24
  "typescript": "^5"
25
25
  }
26
26
  }
@@ -1,5 +1,6 @@
1
1
  {
2
2
  "compilerOptions": {
3
+ "target": "ES2017",
3
4
  "lib": ["dom", "dom.iterable", "esnext"],
4
5
  "allowJs": true,
5
6
  "skipLibCheck": true,
@@ -10,12 +11,19 @@
10
11
  "moduleResolution": "bundler",
11
12
  "resolveJsonModule": true,
12
13
  "isolatedModules": true,
13
- "jsx": "preserve",
14
+ "jsx": "react-jsx",
14
15
  "incremental": true,
15
16
  "paths": {
16
17
  "@/*": ["./*"]
17
18
  }
18
19
  },
19
- "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
20
+ "include": [
21
+ "next-env.d.ts",
22
+ "**/*.ts",
23
+ "**/*.tsx",
24
+ ".next/types/**/*.ts",
25
+ ".next/dev/types/**/*.ts",
26
+ "**/*.mts"
27
+ ],
20
28
  "exclude": ["node_modules"]
21
29
  }
@@ -0,0 +1,7 @@
1
+ /** @type {import('next').NextConfig} */
2
+ const nextConfig = {
3
+ /* config options here */
4
+ reactStrictMode: true,
5
+ };
6
+
7
+ export default nextConfig;
@@ -6,16 +6,16 @@
6
6
  "dev": "next dev",
7
7
  "build": "next build",
8
8
  "start": "next start",
9
- "lint": "next lint"
9
+ "lint": "eslint"
10
10
  },
11
11
  "dependencies": {
12
12
  "@plasmicapp/loader-nextjs": "^2.0.4",
13
- "next": "14.2.35",
14
- "react": "^18",
15
- "react-dom": "^18"
13
+ "next": "16.2.6",
14
+ "react": "19.2.4",
15
+ "react-dom": "19.2.4"
16
16
  },
17
17
  "devDependencies": {
18
- "eslint": "^8",
19
- "eslint-config-next": "14.2.35"
18
+ "eslint": "^9",
19
+ "eslint-config-next": "16.2.6"
20
20
  }
21
21
  }
@@ -0,0 +1,8 @@
1
+ import type { NextConfig } from "next";
2
+
3
+ const nextConfig: NextConfig = {
4
+ /* config options here */
5
+ reactStrictMode: true,
6
+ };
7
+
8
+ export default nextConfig;
@@ -6,20 +6,20 @@
6
6
  "dev": "next dev",
7
7
  "build": "next build",
8
8
  "start": "next start",
9
- "lint": "next lint"
9
+ "lint": "eslint"
10
10
  },
11
11
  "dependencies": {
12
12
  "@plasmicapp/loader-nextjs": "^2.0.4",
13
- "next": "14.2.35",
14
- "react": "^18",
15
- "react-dom": "^18"
13
+ "next": "16.2.6",
14
+ "react": "19.2.4",
15
+ "react-dom": "19.2.4"
16
16
  },
17
17
  "devDependencies": {
18
18
  "@types/node": "^20",
19
- "@types/react": "^18",
20
- "@types/react-dom": "^18",
21
- "eslint": "^8",
22
- "eslint-config-next": "14.2.35",
19
+ "@types/react": "^19",
20
+ "@types/react-dom": "^19",
21
+ "eslint": "^9",
22
+ "eslint-config-next": "16.2.6",
23
23
  "typescript": "^5"
24
24
  }
25
25
  }
@@ -1,5 +1,6 @@
1
1
  {
2
2
  "compilerOptions": {
3
+ "target": "ES2017",
3
4
  "lib": ["dom", "dom.iterable", "esnext"],
4
5
  "allowJs": true,
5
6
  "skipLibCheck": true,
@@ -10,12 +11,19 @@
10
11
  "moduleResolution": "bundler",
11
12
  "resolveJsonModule": true,
12
13
  "isolatedModules": true,
13
- "jsx": "preserve",
14
+ "jsx": "react-jsx",
14
15
  "incremental": true,
15
16
  "paths": {
16
17
  "@/*": ["./*"]
17
18
  }
18
19
  },
19
- "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
20
+ "include": [
21
+ "next-env.d.ts",
22
+ "**/*.ts",
23
+ "**/*.tsx",
24
+ ".next/types/**/*.ts",
25
+ ".next/dev/types/**/*.ts",
26
+ "**/*.mts"
27
+ ],
20
28
  "exclude": ["node_modules"]
21
29
  }
@@ -42,8 +42,8 @@ exports.nextjsStrategy = {
42
42
  ? "--app"
43
43
  : "--no-app";
44
44
  const templateArg = template ? ` --example ${template}` : "";
45
- // TODO: Change to latest when nextjs stops using react@19-rc
46
- const createCommand = `npx create-next-app@14 ${projectPath} ${typescriptArg} ${experimentalAppArg} ${templateArg}` +
45
+ // NOTE: Not using create-next-app@latest to keep major version bumps deliberate
46
+ const createCommand = `npx create-next-app@16 ${projectPath} ${typescriptArg} ${experimentalAppArg} ${templateArg}` +
47
47
  ` --eslint --no-src-dir --import-alias "@/*" --no-tailwind`;
48
48
  // Default Next.js starter already supports Typescript
49
49
  // See where we `touch tsconfig.json` later on
@@ -60,15 +60,14 @@ exports.nextjsStrategy = {
60
60
  }
61
61
  }),
62
62
  overwriteConfig: (args) => __awaiter(void 0, void 0, void 0, function* () {
63
- const { projectPath, scheme } = args;
64
- const nextjsConfigFile = path_1.default.join(projectPath, "next.config.mjs");
63
+ const { projectPath, scheme, jsOrTs } = args;
65
64
  if (scheme === "codegen") {
66
- yield fs_1.promises.writeFile(nextjsConfigFile, `
67
- /** @type {import('next').NextConfig} */
68
- const nextConfig = {
69
- eslint: {
70
- ignoreDuringBuilds: true,
71
- },
65
+ const isTs = jsOrTs === "ts";
66
+ const typePragma = isTs
67
+ ? `import type { NextConfig } from "next";\n\n`
68
+ : `/** @type {import('next').NextConfig} */\n`;
69
+ const typeAnnotation = isTs ? ": NextConfig" : "";
70
+ yield fs_1.promises.writeFile(path_1.default.join(projectPath, `next.config.${isTs ? "ts" : "mjs"}`), `${typePragma}const nextConfig${typeAnnotation} = {
72
71
  trailingSlash: true,
73
72
  reactStrictMode: true,
74
73
  };
@@ -108,10 +107,6 @@ function generateFilesAppDir(args) {
108
107
  yield fs_1.promises.writeFile(path_1.default.join(projectPath, "app", "[[...catchall]]", `page.${jsOrTs}x`), (0, catchall_page_1.makeCatchallPage_app_loader)(jsOrTs));
109
108
  }
110
109
  else {
111
- // Replace starter layout. Removes app/layout.js in JS projects before writing layout.jsx.
112
- (0, file_utils_1.deleteGlob)(path_1.default.join(projectPath, "app", "layout.*"));
113
- // ./app/layout.tsx
114
- yield fs_1.promises.writeFile(path_1.default.join(projectPath, "app", `layout.${jsOrTs}x`), (0, layout_1.makeLayout_app_codegen)(jsOrTs));
115
110
  // ./plasmic-init-client.tsx
116
111
  yield fs_1.promises.writeFile(path_1.default.join(projectPath, `plasmic-init-client.${jsOrTs}x`), (0, plasmic_init_client_1.makePlasmicInitClient_app_codegen)(jsOrTs));
117
112
  // ./app/plasmic-host/page.tsx
@@ -126,8 +121,20 @@ function generateFilesAppDir(args) {
126
121
  projectApiToken,
127
122
  projectPath,
128
123
  });
129
- // Make an index (/) page if the project didn't have one.
124
+ // Read plasmic.json so we can wire each top-level project's plasmic.css
125
+ // import directly into the root layout template.
130
126
  const config = yield (0, file_utils_1.getPlasmicConfig)(projectPath, "nextjs", scheme);
127
+ const layoutAbsPath = path_1.default.join(projectPath, "app", `layout.${jsOrTs}x`);
128
+ const cssImports = getPlasmicCssImports({
129
+ projectPath,
130
+ rootFileAbsPath: layoutAbsPath,
131
+ config,
132
+ });
133
+ // Replace starter layout. Removes app/layout.js in JS projects before writing layout.jsx.
134
+ (0, file_utils_1.deleteGlob)(path_1.default.join(projectPath, "app", "layout.*"));
135
+ // ./app/layout.tsx
136
+ yield fs_1.promises.writeFile(path_1.default.join(projectPath, "app", `layout.${jsOrTs}x`), (0, layout_1.makeLayout_app_codegen)(jsOrTs, cssImports));
137
+ // Make an index (/) page if the project didn't have one.
131
138
  const plasmicFiles = lodash_1.default.map(lodash_1.default.flatMap(config.projects, (p) => p.components), (c) => c.importSpec.modulePath);
132
139
  if (!plasmicFiles.find((f) => f.includes("app/page."))) {
133
140
  yield fs_1.promises.writeFile(path_1.default.join(projectPath, "app", `page.${jsOrTs}x`), (0, file_utils_1.generateWelcomePage)(config, "nextjs"));
@@ -149,8 +156,6 @@ function generateFilesPagesDir(args) {
149
156
  yield fs_1.promises.writeFile(path_1.default.join(projectPath, "pages", `[[...catchall]].${jsOrTs}x`), (0, catchall_page_2.makeCatchallPage_pages_loader)(jsOrTs));
150
157
  }
151
158
  else {
152
- // ./pages/_app.tsx
153
- yield fs_1.promises.writeFile(path_1.default.join(projectPath, "pages", `_app.${jsOrTs}x`), (0, app_1.makeCustomApp_pages_codegen)(jsOrTs));
154
159
  // ./pages/plasmic-host.tsx
155
160
  yield fs_1.promises.writeFile(path_1.default.join(projectPath, "pages", `plasmic-host.${jsOrTs}x`), (0, plasmic_host_3.makePlasmicHostPage_pages_codegen)());
156
161
  // This should generate
@@ -162,8 +167,18 @@ function generateFilesPagesDir(args) {
162
167
  projectApiToken,
163
168
  projectPath,
164
169
  });
165
- // Make an index page if the project didn't have one.
170
+ // Read plasmic.json so we can wire each top-level project's plasmic.css
171
+ // import directly into the _app template.
166
172
  const config = yield (0, file_utils_1.getPlasmicConfig)(projectPath, "nextjs", scheme);
173
+ const appAbsPath = path_1.default.join(projectPath, "pages", `_app.${jsOrTs}x`);
174
+ const cssImports = getPlasmicCssImports({
175
+ projectPath,
176
+ rootFileAbsPath: appAbsPath,
177
+ config,
178
+ });
179
+ // ./pages/_app.tsx
180
+ yield fs_1.promises.writeFile(appAbsPath, (0, app_1.makeCustomApp_pages_codegen)(jsOrTs, cssImports));
181
+ // Make an index page if the project didn't have one.
167
182
  const plasmicFiles = lodash_1.default.map(lodash_1.default.flatMap(config.projects, (p) => p.components), (c) => c.importSpec.modulePath);
168
183
  if (!plasmicFiles.find((f) => f.includes("/index."))) {
169
184
  yield fs_1.promises.writeFile(path_1.default.join(projectPath, "pages", `index.${jsOrTs}x`), (0, file_utils_1.generateWelcomePage)(config, "nextjs"));
@@ -171,3 +186,29 @@ function generateFilesPagesDir(args) {
171
186
  }
172
187
  });
173
188
  }
189
+ /**
190
+ * Builds the list of `plasmic.css` imports the Next.js root file (Pages Router
191
+ * `_app.{ext}`, App Router `app/layout.{ext}`) needs for every top-level
192
+ * project in `plasmic.json`. Next.js disallows global non-module CSS imports
193
+ * outside of those files.
194
+ *
195
+ * The marker comment in the emitted import (plasmic-import: <id>/projectcss)
196
+ * matches the convention used by @plasmicapp/cli sync, so subsequent syncs
197
+ * can update paths in-place without producing duplicates.
198
+ *
199
+ * @param rootFileAbsPath Absolute path to the Next.js root file (`_app.{ext}`
200
+ * for Pages Router, `app/layout.{ext}` for App Router).
201
+ */
202
+ function getPlasmicCssImports(args) {
203
+ const { projectPath, rootFileAbsPath, config } = args;
204
+ return (config.projects || [])
205
+ .filter((p) => !p.indirect && !!p.cssFilePath)
206
+ .map((p) => {
207
+ const absoluteCssPath = path_1.default.join(projectPath, config.srcDir, p.cssFilePath);
208
+ let relPath = path_1.default.relative(path_1.default.dirname(rootFileAbsPath), absoluteCssPath);
209
+ if (!relPath.startsWith(".")) {
210
+ relPath = `./${relPath}`;
211
+ }
212
+ return { projectId: p.projectId, importPath: relPath };
213
+ });
214
+ }
@@ -1,2 +1,2 @@
1
- import { JsOrTs } from "../../../utils/types";
2
- export declare function makeLayout_app_codegen(jsOrTs: JsOrTs): string;
1
+ import { JsOrTs, PlasmicCssImport } from "../../../utils/types";
2
+ export declare function makeLayout_app_codegen(jsOrTs: JsOrTs, cssImports?: PlasmicCssImport[]): string;
@@ -2,8 +2,14 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.makeLayout_app_codegen = void 0;
4
4
  const file_utils_1 = require("../../../utils/file-utils");
5
- function makeLayout_app_codegen(jsOrTs) {
6
- return `import '@/app/globals.css'
5
+ function makeLayout_app_codegen(jsOrTs, cssImports = []) {
6
+ const plasmicCssImportLines = cssImports
7
+ .map((i) => `import "${i.importPath}"; // plasmic-import: ${i.projectId}/projectcss`)
8
+ .join("\n");
9
+ const plasmicCssImportsBlock = plasmicCssImportLines
10
+ ? `${plasmicCssImportLines}\n`
11
+ : "";
12
+ return `${plasmicCssImportsBlock}import '@/app/globals.css'
7
13
  import { ClientPlasmicRootProvider } from "@/plasmic-init-client";
8
14
 
9
15
  export default function RootLayout({
@@ -1,2 +1,2 @@
1
- import { JsOrTs } from "../../../utils/types";
2
- export declare function makeCustomApp_pages_codegen(jsOrTs: JsOrTs): string;
1
+ import { JsOrTs, PlasmicCssImport } from "../../../utils/types";
2
+ export declare function makeCustomApp_pages_codegen(jsOrTs: JsOrTs, cssImports?: PlasmicCssImport[]): string;
@@ -2,8 +2,14 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.makeCustomApp_pages_codegen = void 0;
4
4
  const file_utils_1 = require("../../../utils/file-utils");
5
- function makeCustomApp_pages_codegen(jsOrTs) {
6
- return `import '@/styles/globals.css'
5
+ function makeCustomApp_pages_codegen(jsOrTs, cssImports = []) {
6
+ const plasmicCssImportLines = cssImports
7
+ .map((i) => `import "${i.importPath}"; // plasmic-import: ${i.projectId}/projectcss`)
8
+ .join("\n");
9
+ const plasmicCssImportsBlock = plasmicCssImportLines
10
+ ? `${plasmicCssImportLines}\n`
11
+ : "";
12
+ return `${plasmicCssImportsBlock}import '@/styles/globals.css'
7
13
  import { PlasmicRootProvider } from "@plasmicapp/react-web";${(0, file_utils_1.ifTs)(jsOrTs, `
8
14
  import type { AppProps } from "next/app";`)}
9
15
  import Head from "next/head";
@@ -6,4 +6,8 @@ export type PlatformOptions = {
6
6
  };
7
7
  };
8
8
  export type SchemeType = "codegen" | "loader";
9
+ export type PlasmicCssImport = {
10
+ projectId: string;
11
+ importPath: string;
12
+ };
9
13
  export declare function platformTypeToString(s: PlatformType): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-plasmic-app",
3
- "version": "0.0.147",
3
+ "version": "0.0.149",
4
4
  "description": "Create Plasmic-powered React apps",
5
5
  "main": "./dist/lib.js",
6
6
  "types": "./dist/lib.d.ts",
@@ -33,7 +33,7 @@
33
33
  "tsx": "^4.21.0"
34
34
  },
35
35
  "dependencies": {
36
- "@plasmicapp/cli": "0.1.361",
36
+ "@plasmicapp/cli": "0.1.362",
37
37
  "@sentry/node": "^6.2.2",
38
38
  "chalk": "^4.1.0",
39
39
  "execa": "^5.0.0",
@@ -47,5 +47,5 @@
47
47
  "validate-npm-package-name": "^3.0.0",
48
48
  "yargs": "^16.2.0"
49
49
  },
50
- "gitHead": "2e811068a089e1c86ca9213174860726042db0a9"
50
+ "gitHead": "2dd9cf093c62331b86ac29449b8e6e33f55c863c"
51
51
  }
@@ -1,3 +1,4 @@
1
+ import { PlasmicConfig } from "@plasmicapp/cli/dist/utils/config-utils";
1
2
  import { promises as fs } from "fs";
2
3
  import L from "lodash";
3
4
  import path from "path";
@@ -11,6 +12,7 @@ import {
11
12
  import { ensure } from "../utils/lang-utils";
12
13
  import { installUpgrade } from "../utils/npm-utils";
13
14
  import { CPAStrategy, GenerateFilesArgs } from "../utils/strategy";
15
+ import { PlasmicCssImport } from "../utils/types";
14
16
  import { makeLayout_app_codegen } from "./templates/app-codegen/layout";
15
17
  import { makePlasmicHostPage_app_codegen } from "./templates/app-codegen/plasmic-host";
16
18
  import { makePlasmicInitClient_app_codegen } from "./templates/app-codegen/plasmic-init-client";
@@ -32,9 +34,9 @@ export const nextjsStrategy: CPAStrategy = {
32
34
  ? "--app"
33
35
  : "--no-app";
34
36
  const templateArg = template ? ` --example ${template}` : "";
35
- // TODO: Change to latest when nextjs stops using react@19-rc
37
+ // NOTE: Not using create-next-app@latest to keep major version bumps deliberate
36
38
  const createCommand =
37
- `npx create-next-app@14 ${projectPath} ${typescriptArg} ${experimentalAppArg} ${templateArg}` +
39
+ `npx create-next-app@16 ${projectPath} ${typescriptArg} ${experimentalAppArg} ${templateArg}` +
38
40
  ` --eslint --no-src-dir --import-alias "@/*" --no-tailwind`;
39
41
 
40
42
  // Default Next.js starter already supports Typescript
@@ -51,17 +53,17 @@ export const nextjsStrategy: CPAStrategy = {
51
53
  }
52
54
  },
53
55
  overwriteConfig: async (args) => {
54
- const { projectPath, scheme } = args;
55
- const nextjsConfigFile = path.join(projectPath, "next.config.mjs");
56
+ const { projectPath, scheme, jsOrTs } = args;
56
57
  if (scheme === "codegen") {
58
+ const isTs = jsOrTs === "ts";
59
+ const typePragma = isTs
60
+ ? `import type { NextConfig } from "next";\n\n`
61
+ : `/** @type {import('next').NextConfig} */\n`;
62
+ const typeAnnotation = isTs ? ": NextConfig" : "";
63
+
57
64
  await fs.writeFile(
58
- nextjsConfigFile,
59
- `
60
- /** @type {import('next').NextConfig} */
61
- const nextConfig = {
62
- eslint: {
63
- ignoreDuringBuilds: true,
64
- },
65
+ path.join(projectPath, `next.config.${isTs ? "ts" : "mjs"}`),
66
+ `${typePragma}const nextConfig${typeAnnotation} = {
65
67
  trailingSlash: true,
66
68
  reactStrictMode: true,
67
69
  };
@@ -119,15 +121,6 @@ async function generateFilesAppDir(args: GenerateFilesArgs) {
119
121
  makeCatchallPage_app_loader(jsOrTs)
120
122
  );
121
123
  } else {
122
- // Replace starter layout. Removes app/layout.js in JS projects before writing layout.jsx.
123
- deleteGlob(path.join(projectPath, "app", "layout.*"));
124
-
125
- // ./app/layout.tsx
126
- await fs.writeFile(
127
- path.join(projectPath, "app", `layout.${jsOrTs}x`),
128
- makeLayout_app_codegen(jsOrTs)
129
- );
130
-
131
124
  // ./plasmic-init-client.tsx
132
125
  await fs.writeFile(
133
126
  path.join(projectPath, `plasmic-init-client.${jsOrTs}x`),
@@ -151,8 +144,26 @@ async function generateFilesAppDir(args: GenerateFilesArgs) {
151
144
  projectPath,
152
145
  });
153
146
 
154
- // Make an index (/) page if the project didn't have one.
147
+ // Read plasmic.json so we can wire each top-level project's plasmic.css
148
+ // import directly into the root layout template.
155
149
  const config = await getPlasmicConfig(projectPath, "nextjs", scheme);
150
+ const layoutAbsPath = path.join(projectPath, "app", `layout.${jsOrTs}x`);
151
+ const cssImports = getPlasmicCssImports({
152
+ projectPath,
153
+ rootFileAbsPath: layoutAbsPath,
154
+ config,
155
+ });
156
+
157
+ // Replace starter layout. Removes app/layout.js in JS projects before writing layout.jsx.
158
+ deleteGlob(path.join(projectPath, "app", "layout.*"));
159
+
160
+ // ./app/layout.tsx
161
+ await fs.writeFile(
162
+ path.join(projectPath, "app", `layout.${jsOrTs}x`),
163
+ makeLayout_app_codegen(jsOrTs, cssImports)
164
+ );
165
+
166
+ // Make an index (/) page if the project didn't have one.
156
167
  const plasmicFiles = L.map(
157
168
  L.flatMap(config.projects, (p) => p.components),
158
169
  (c) => c.importSpec.modulePath
@@ -194,12 +205,6 @@ async function generateFilesPagesDir(args: GenerateFilesArgs) {
194
205
  makeCatchallPage_pages_loader(jsOrTs)
195
206
  );
196
207
  } else {
197
- // ./pages/_app.tsx
198
- await fs.writeFile(
199
- path.join(projectPath, "pages", `_app.${jsOrTs}x`),
200
- makeCustomApp_pages_codegen(jsOrTs)
201
- );
202
-
203
208
  // ./pages/plasmic-host.tsx
204
209
  await fs.writeFile(
205
210
  path.join(projectPath, "pages", `plasmic-host.${jsOrTs}x`),
@@ -216,8 +221,23 @@ async function generateFilesPagesDir(args: GenerateFilesArgs) {
216
221
  projectPath,
217
222
  });
218
223
 
219
- // Make an index page if the project didn't have one.
224
+ // Read plasmic.json so we can wire each top-level project's plasmic.css
225
+ // import directly into the _app template.
220
226
  const config = await getPlasmicConfig(projectPath, "nextjs", scheme);
227
+ const appAbsPath = path.join(projectPath, "pages", `_app.${jsOrTs}x`);
228
+ const cssImports = getPlasmicCssImports({
229
+ projectPath,
230
+ rootFileAbsPath: appAbsPath,
231
+ config,
232
+ });
233
+
234
+ // ./pages/_app.tsx
235
+ await fs.writeFile(
236
+ appAbsPath,
237
+ makeCustomApp_pages_codegen(jsOrTs, cssImports)
238
+ );
239
+
240
+ // Make an index page if the project didn't have one.
221
241
  const plasmicFiles = L.map(
222
242
  L.flatMap(config.projects, (p) => p.components),
223
243
  (c) => c.importSpec.modulePath
@@ -230,3 +250,42 @@ async function generateFilesPagesDir(args: GenerateFilesArgs) {
230
250
  }
231
251
  }
232
252
  }
253
+
254
+ /**
255
+ * Builds the list of `plasmic.css` imports the Next.js root file (Pages Router
256
+ * `_app.{ext}`, App Router `app/layout.{ext}`) needs for every top-level
257
+ * project in `plasmic.json`. Next.js disallows global non-module CSS imports
258
+ * outside of those files.
259
+ *
260
+ * The marker comment in the emitted import (plasmic-import: <id>/projectcss)
261
+ * matches the convention used by @plasmicapp/cli sync, so subsequent syncs
262
+ * can update paths in-place without producing duplicates.
263
+ *
264
+ * @param rootFileAbsPath Absolute path to the Next.js root file (`_app.{ext}`
265
+ * for Pages Router, `app/layout.{ext}` for App Router).
266
+ */
267
+ function getPlasmicCssImports(args: {
268
+ projectPath: string;
269
+ rootFileAbsPath: string;
270
+ config: PlasmicConfig;
271
+ }): PlasmicCssImport[] {
272
+ const { projectPath, rootFileAbsPath, config } = args;
273
+ return (config.projects || [])
274
+ .filter((p) => !p.indirect && !!p.cssFilePath)
275
+ .map((p) => {
276
+ const absoluteCssPath = path.join(
277
+ projectPath,
278
+ config.srcDir,
279
+ p.cssFilePath
280
+ );
281
+ let relPath = path.relative(
282
+ path.dirname(rootFileAbsPath),
283
+ absoluteCssPath
284
+ );
285
+ if (!relPath.startsWith(".")) {
286
+ relPath = `./${relPath}`;
287
+ }
288
+
289
+ return { projectId: p.projectId, importPath: relPath };
290
+ });
291
+ }
@@ -1,8 +1,21 @@
1
1
  import { ifTs } from "../../../utils/file-utils";
2
- import { JsOrTs } from "../../../utils/types";
2
+ import { JsOrTs, PlasmicCssImport } from "../../../utils/types";
3
3
 
4
- export function makeLayout_app_codegen(jsOrTs: JsOrTs): string {
5
- return `import '@/app/globals.css'
4
+ export function makeLayout_app_codegen(
5
+ jsOrTs: JsOrTs,
6
+ cssImports: PlasmicCssImport[] = []
7
+ ): string {
8
+ const plasmicCssImportLines = cssImports
9
+ .map(
10
+ (i) =>
11
+ `import "${i.importPath}"; // plasmic-import: ${i.projectId}/projectcss`
12
+ )
13
+ .join("\n");
14
+ const plasmicCssImportsBlock = plasmicCssImportLines
15
+ ? `${plasmicCssImportLines}\n`
16
+ : "";
17
+
18
+ return `${plasmicCssImportsBlock}import '@/app/globals.css'
6
19
  import { ClientPlasmicRootProvider } from "@/plasmic-init-client";
7
20
 
8
21
  export default function RootLayout({
@@ -1,8 +1,21 @@
1
1
  import { ifTs } from "../../../utils/file-utils";
2
- import { JsOrTs } from "../../../utils/types";
2
+ import { JsOrTs, PlasmicCssImport } from "../../../utils/types";
3
3
 
4
- export function makeCustomApp_pages_codegen(jsOrTs: JsOrTs): string {
5
- return `import '@/styles/globals.css'
4
+ export function makeCustomApp_pages_codegen(
5
+ jsOrTs: JsOrTs,
6
+ cssImports: PlasmicCssImport[] = []
7
+ ): string {
8
+ const plasmicCssImportLines = cssImports
9
+ .map(
10
+ (i) =>
11
+ `import "${i.importPath}"; // plasmic-import: ${i.projectId}/projectcss`
12
+ )
13
+ .join("\n");
14
+ const plasmicCssImportsBlock = plasmicCssImportLines
15
+ ? `${plasmicCssImportLines}\n`
16
+ : "";
17
+
18
+ return `${plasmicCssImportsBlock}import '@/styles/globals.css'
6
19
  import { PlasmicRootProvider } from "@plasmicapp/react-web";${ifTs(
7
20
  jsOrTs,
8
21
  `
@@ -7,6 +7,11 @@ export type PlatformOptions = {
7
7
  };
8
8
  export type SchemeType = "codegen" | "loader";
9
9
 
10
+ export type PlasmicCssImport = {
11
+ projectId: string;
12
+ importPath: string;
13
+ };
14
+
10
15
  export function platformTypeToString(s: PlatformType): string {
11
16
  return s === "nextjs"
12
17
  ? "Next.js"