create-plasmic-app 0.0.41 → 0.0.44

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/dist/index.js CHANGED
File without changes
@@ -41,8 +41,8 @@ const nextjsStrategy = {
41
41
  }),
42
42
  overwriteConfig: (args) => __awaiter(void 0, void 0, void 0, function* () {
43
43
  const { projectPath, scheme } = args;
44
+ const nextjsConfigFile = path_1.default.join(projectPath, "next.config.js");
44
45
  if (scheme === "codegen") {
45
- const nextjsConfigFile = path_1.default.join(projectPath, "next.config.js");
46
46
  yield fs_1.promises.writeFile(nextjsConfigFile, `
47
47
  module.exports = {
48
48
  eslint: {
@@ -53,6 +53,19 @@ module.exports = {
53
53
  };
54
54
  `);
55
55
  }
56
+ else {
57
+ yield fs_1.promises.writeFile(nextjsConfigFile, `
58
+ /** @type {import('next').NextConfig} */
59
+ const nextConfig = {
60
+ // Turn off React StrictMode for now, as react-aria (used by Plasmic)
61
+ // has some troubles with it. See
62
+ // https://github.com/adobe/react-spectrum/labels/strict%20mode
63
+ reactStrictMode: false,
64
+ }
65
+
66
+ module.exports = nextConfig
67
+ `);
68
+ }
56
69
  }),
57
70
  generateFiles: (args) => __awaiter(void 0, void 0, void 0, function* () {
58
71
  // this is supposed to be called for loader case, so we are supposed to remove
@@ -48,7 +48,7 @@ const PlasmicGatsbyPage = ({ data }${file_utils_1.ifTs(ts, ": PlasmicGatsbyPageP
48
48
  {pageMetadata.description && <meta property="og:description" content={pageMetadata.description} />}
49
49
  {pageMetadata.openGraphImageUrl && <meta property="og:image" content={pageMetadata.openGraphImageUrl} />}
50
50
  </Helmet>
51
- <PlasmicComponent component={pageMeta.name} />
51
+ <PlasmicComponent component={pageMeta.displayName} />
52
52
  </PlasmicRootProvider>
53
53
  );
54
54
  };
@@ -140,16 +140,7 @@ exports.GATSBY_SSR_CONFIG = `
140
140
 
141
141
  const React = require("react")
142
142
 
143
- /**
144
- * Add preamble to allow functional code components in studio.
145
- *
146
- * See: https://docs.plasmic.app/learn/functional-code-components/
147
- */
148
143
  const HeadComponents = [
149
- <script
150
- key="plasmic-preamble"
151
- src="https://static1.plasmic.app/preamble.js"
152
- />,
153
144
  <script
154
145
  key="plasmic-hmr"
155
146
  type="text/javascript"
@@ -58,7 +58,7 @@ export default function PlasmicLoaderPage(props${file_utils_1.ifTs(ts, `: {
58
58
  prefetchedData={plasmicData}
59
59
  prefetchedQueryData={queryCache}
60
60
  >
61
- <PlasmicComponent component={plasmicData.entryCompMetas[0].name} />
61
+ <PlasmicComponent component={plasmicData.entryCompMetas[0].displayName} />
62
62
  </PlasmicRootProvider>
63
63
  );
64
64
  }
@@ -74,7 +74,7 @@ export const getStaticProps${file_utils_1.ifTs(ts, `: GetStaticProps`)} = async
74
74
  // Cache the necessary data fetched for the page
75
75
  const queryCache = await extractPlasmicQueryData(
76
76
  <PlasmicRootProvider loader={PLASMIC} prefetchedData={plasmicData}>
77
- <PlasmicComponent component={plasmicData.entryCompMetas[0].name} />
77
+ <PlasmicComponent component={plasmicData.entryCompMetas[0].displayName} />
78
78
  </PlasmicRootProvider>
79
79
  );
80
80
  // Use revalidate if you want incremental static regeneration
@@ -110,15 +110,7 @@ import { PlasmicCanvasHost } from '@plasmicapp/loader-nextjs';
110
110
  import { PLASMIC } from '../plasmic-init';
111
111
 
112
112
  export default function PlasmicHost() {
113
- return PLASMIC && (
114
- <div>
115
- <Script
116
- src="https://static1.plasmic.app/preamble.js"
117
- strategy="beforeInteractive"
118
- />
119
- <PlasmicCanvasHost />
120
- </div>
121
- );
113
+ return PLASMIC && <PlasmicCanvasHost />;
122
114
  }
123
115
  `;
124
116
  }
@@ -137,15 +129,7 @@ import { PlasmicCanvasHost, registerComponent } from '@plasmicapp/host';
137
129
  // registerComponent(...)
138
130
 
139
131
  export default function PlasmicHost() {
140
- return (
141
- <div>
142
- <Script
143
- src="https://static1.plasmic.app/preamble.js"
144
- strategy="beforeInteractive"
145
- />
146
- <PlasmicCanvasHost />
147
- </div>
148
- );
132
+ return <PlasmicCanvasHost />;
149
133
  }
150
134
  `;
151
135
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-plasmic-app",
3
- "version": "0.0.41",
3
+ "version": "0.0.44",
4
4
  "description": "Create Plasmic-powered React apps",
5
5
  "main": "./dist/lib.js",
6
6
  "types": "./dist/lib.d.ts",
@@ -36,9 +36,8 @@ const nextjsStrategy: CPAStrategy = {
36
36
  },
37
37
  overwriteConfig: async (args) => {
38
38
  const { projectPath, scheme } = args;
39
-
39
+ const nextjsConfigFile = path.join(projectPath, "next.config.js");
40
40
  if (scheme === "codegen") {
41
- const nextjsConfigFile = path.join(projectPath, "next.config.js");
42
41
  await fs.writeFile(
43
42
  nextjsConfigFile,
44
43
  `
@@ -51,6 +50,21 @@ module.exports = {
51
50
  };
52
51
  `
53
52
  );
53
+ } else {
54
+ await fs.writeFile(
55
+ nextjsConfigFile,
56
+ `
57
+ /** @type {import('next').NextConfig} */
58
+ const nextConfig = {
59
+ // Turn off React StrictMode for now, as react-aria (used by Plasmic)
60
+ // has some troubles with it. See
61
+ // https://github.com/adobe/react-spectrum/labels/strict%20mode
62
+ reactStrictMode: false,
63
+ }
64
+
65
+ module.exports = nextConfig
66
+ `
67
+ )
54
68
  }
55
69
  },
56
70
  generateFiles: async (args) => {
@@ -53,7 +53,7 @@ const PlasmicGatsbyPage = ({ data }${ifTs(ts, ": PlasmicGatsbyPageProps")}) => {
53
53
  {pageMetadata.description && <meta property="og:description" content={pageMetadata.description} />}
54
54
  {pageMetadata.openGraphImageUrl && <meta property="og:image" content={pageMetadata.openGraphImageUrl} />}
55
55
  </Helmet>
56
- <PlasmicComponent component={pageMeta.name} />
56
+ <PlasmicComponent component={pageMeta.displayName} />
57
57
  </PlasmicRootProvider>
58
58
  );
59
59
  };
@@ -157,16 +157,7 @@ export const GATSBY_SSR_CONFIG = `
157
157
 
158
158
  const React = require("react")
159
159
 
160
- /**
161
- * Add preamble to allow functional code components in studio.
162
- *
163
- * See: https://docs.plasmic.app/learn/functional-code-components/
164
- */
165
160
  const HeadComponents = [
166
- <script
167
- key="plasmic-preamble"
168
- src="https://static1.plasmic.app/preamble.js"
169
- />,
170
161
  <script
171
162
  key="plasmic-hmr"
172
163
  type="text/javascript"
@@ -235,7 +226,7 @@ export function initPlasmicLoaderWithRegistrations(plasmicOptions${ifTs(
235
226
  `.trim();
236
227
  };
237
228
 
238
- export function wrapAppRootForCodegen() {
229
+ export function wrapAppRootForCodegen(): string {
239
230
  return `
240
231
  import React from "react";
241
232
  import { PlasmicRootProvider } from "@plasmicapp/react-web";
@@ -64,7 +64,7 @@ export default function PlasmicLoaderPage(props${ifTs(
64
64
  prefetchedData={plasmicData}
65
65
  prefetchedQueryData={queryCache}
66
66
  >
67
- <PlasmicComponent component={plasmicData.entryCompMetas[0].name} />
67
+ <PlasmicComponent component={plasmicData.entryCompMetas[0].displayName} />
68
68
  </PlasmicRootProvider>
69
69
  );
70
70
  }
@@ -83,7 +83,7 @@ export const getStaticProps${ifTs(
83
83
  // Cache the necessary data fetched for the page
84
84
  const queryCache = await extractPlasmicQueryData(
85
85
  <PlasmicRootProvider loader={PLASMIC} prefetchedData={plasmicData}>
86
- <PlasmicComponent component={plasmicData.entryCompMetas[0].name} />
86
+ <PlasmicComponent component={plasmicData.entryCompMetas[0].displayName} />
87
87
  </PlasmicRootProvider>
88
88
  );
89
89
  // Use revalidate if you want incremental static regeneration
@@ -120,15 +120,7 @@ import { PlasmicCanvasHost } from '@plasmicapp/loader-nextjs';
120
120
  import { PLASMIC } from '../plasmic-init';
121
121
 
122
122
  export default function PlasmicHost() {
123
- return PLASMIC && (
124
- <div>
125
- <Script
126
- src="https://static1.plasmic.app/preamble.js"
127
- strategy="beforeInteractive"
128
- />
129
- <PlasmicCanvasHost />
130
- </div>
131
- );
123
+ return PLASMIC && <PlasmicCanvasHost />;
132
124
  }
133
125
  `;
134
126
  } else {
@@ -146,21 +138,13 @@ import { PlasmicCanvasHost, registerComponent } from '@plasmicapp/host';
146
138
  // registerComponent(...)
147
139
 
148
140
  export default function PlasmicHost() {
149
- return (
150
- <div>
151
- <Script
152
- src="https://static1.plasmic.app/preamble.js"
153
- strategy="beforeInteractive"
154
- />
155
- <PlasmicCanvasHost />
156
- </div>
157
- );
141
+ return <PlasmicCanvasHost />;
158
142
  }
159
143
  `;
160
144
  }
161
145
  }
162
146
 
163
- export function wrapAppRootForCodegen() {
147
+ export function wrapAppRootForCodegen(): string {
164
148
  return `
165
149
  import '../styles/globals.css'
166
150
  import { PlasmicRootProvider } from "@plasmicapp/react-web";