create-plasmic-app 0.0.40 → 0.0.43
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 +0 -0
- package/dist/strategies/nextjs.js +14 -1
- package/dist/templates/gatsby.js +1 -10
- package/dist/templates/nextjs.js +6 -24
- package/package.json +1 -1
- package/src/strategies/nextjs.ts +16 -2
- package/src/templates/gatsby.ts +2 -11
- package/src/templates/nextjs.ts +7 -25
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
|
package/dist/templates/gatsby.js
CHANGED
|
@@ -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.
|
|
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"
|
package/dist/templates/nextjs.js
CHANGED
|
@@ -34,15 +34,13 @@ function makeNextjsCatchallPage(format) {
|
|
|
34
34
|
const ts = format === "ts";
|
|
35
35
|
return `
|
|
36
36
|
import * as React from "react";
|
|
37
|
-
import {
|
|
37
|
+
import {
|
|
38
38
|
PlasmicComponent,
|
|
39
39
|
extractPlasmicQueryData,
|
|
40
|
-
} from "@plasmicapp/loader-nextjs";
|
|
41
|
-
${file_utils_1.ifTs(ts, `import { GetStaticPaths, GetStaticProps } from "next";\n`)}
|
|
42
|
-
import {
|
|
43
40
|
ComponentRenderData,
|
|
44
41
|
PlasmicRootProvider,
|
|
45
|
-
} from "@plasmicapp/loader-
|
|
42
|
+
} from "@plasmicapp/loader-nextjs";
|
|
43
|
+
${file_utils_1.ifTs(ts, `import { GetStaticPaths, GetStaticProps } from "next";\n`)}
|
|
46
44
|
import Error from "next/error";
|
|
47
45
|
import { PLASMIC } from "../plasmic-init";
|
|
48
46
|
|
|
@@ -60,7 +58,7 @@ export default function PlasmicLoaderPage(props${file_utils_1.ifTs(ts, `: {
|
|
|
60
58
|
prefetchedData={plasmicData}
|
|
61
59
|
prefetchedQueryData={queryCache}
|
|
62
60
|
>
|
|
63
|
-
<PlasmicComponent component={plasmicData.entryCompMetas[0].
|
|
61
|
+
<PlasmicComponent component={plasmicData.entryCompMetas[0].displayName} />
|
|
64
62
|
</PlasmicRootProvider>
|
|
65
63
|
);
|
|
66
64
|
}
|
|
@@ -112,15 +110,7 @@ import { PlasmicCanvasHost } from '@plasmicapp/loader-nextjs';
|
|
|
112
110
|
import { PLASMIC } from '../plasmic-init';
|
|
113
111
|
|
|
114
112
|
export default function PlasmicHost() {
|
|
115
|
-
return PLASMIC &&
|
|
116
|
-
<div>
|
|
117
|
-
<Script
|
|
118
|
-
src="https://static1.plasmic.app/preamble.js"
|
|
119
|
-
strategy="beforeInteractive"
|
|
120
|
-
/>
|
|
121
|
-
<PlasmicCanvasHost />
|
|
122
|
-
</div>
|
|
123
|
-
);
|
|
113
|
+
return PLASMIC && <PlasmicCanvasHost />;
|
|
124
114
|
}
|
|
125
115
|
`;
|
|
126
116
|
}
|
|
@@ -139,15 +129,7 @@ import { PlasmicCanvasHost, registerComponent } from '@plasmicapp/host';
|
|
|
139
129
|
// registerComponent(...)
|
|
140
130
|
|
|
141
131
|
export default function PlasmicHost() {
|
|
142
|
-
return
|
|
143
|
-
<div>
|
|
144
|
-
<Script
|
|
145
|
-
src="https://static1.plasmic.app/preamble.js"
|
|
146
|
-
strategy="beforeInteractive"
|
|
147
|
-
/>
|
|
148
|
-
<PlasmicCanvasHost />
|
|
149
|
-
</div>
|
|
150
|
-
);
|
|
132
|
+
return <PlasmicCanvasHost />;
|
|
151
133
|
}
|
|
152
134
|
`;
|
|
153
135
|
}
|
package/package.json
CHANGED
package/src/strategies/nextjs.ts
CHANGED
|
@@ -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) => {
|
package/src/templates/gatsby.ts
CHANGED
|
@@ -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.
|
|
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";
|
package/src/templates/nextjs.ts
CHANGED
|
@@ -37,15 +37,13 @@ export function makeNextjsCatchallPage(format: "ts" | "js"): string {
|
|
|
37
37
|
const ts = format === "ts";
|
|
38
38
|
return `
|
|
39
39
|
import * as React from "react";
|
|
40
|
-
import {
|
|
40
|
+
import {
|
|
41
41
|
PlasmicComponent,
|
|
42
42
|
extractPlasmicQueryData,
|
|
43
|
-
} from "@plasmicapp/loader-nextjs";
|
|
44
|
-
${ifTs(ts, `import { GetStaticPaths, GetStaticProps } from "next";\n`)}
|
|
45
|
-
import {
|
|
46
43
|
ComponentRenderData,
|
|
47
44
|
PlasmicRootProvider,
|
|
48
|
-
} from "@plasmicapp/loader-
|
|
45
|
+
} from "@plasmicapp/loader-nextjs";
|
|
46
|
+
${ifTs(ts, `import { GetStaticPaths, GetStaticProps } from "next";\n`)}
|
|
49
47
|
import Error from "next/error";
|
|
50
48
|
import { PLASMIC } from "../plasmic-init";
|
|
51
49
|
|
|
@@ -66,7 +64,7 @@ export default function PlasmicLoaderPage(props${ifTs(
|
|
|
66
64
|
prefetchedData={plasmicData}
|
|
67
65
|
prefetchedQueryData={queryCache}
|
|
68
66
|
>
|
|
69
|
-
<PlasmicComponent component={plasmicData.entryCompMetas[0].
|
|
67
|
+
<PlasmicComponent component={plasmicData.entryCompMetas[0].displayName} />
|
|
70
68
|
</PlasmicRootProvider>
|
|
71
69
|
);
|
|
72
70
|
}
|
|
@@ -122,15 +120,7 @@ import { PlasmicCanvasHost } from '@plasmicapp/loader-nextjs';
|
|
|
122
120
|
import { PLASMIC } from '../plasmic-init';
|
|
123
121
|
|
|
124
122
|
export default function PlasmicHost() {
|
|
125
|
-
return PLASMIC &&
|
|
126
|
-
<div>
|
|
127
|
-
<Script
|
|
128
|
-
src="https://static1.plasmic.app/preamble.js"
|
|
129
|
-
strategy="beforeInteractive"
|
|
130
|
-
/>
|
|
131
|
-
<PlasmicCanvasHost />
|
|
132
|
-
</div>
|
|
133
|
-
);
|
|
123
|
+
return PLASMIC && <PlasmicCanvasHost />;
|
|
134
124
|
}
|
|
135
125
|
`;
|
|
136
126
|
} else {
|
|
@@ -148,21 +138,13 @@ import { PlasmicCanvasHost, registerComponent } from '@plasmicapp/host';
|
|
|
148
138
|
// registerComponent(...)
|
|
149
139
|
|
|
150
140
|
export default function PlasmicHost() {
|
|
151
|
-
return
|
|
152
|
-
<div>
|
|
153
|
-
<Script
|
|
154
|
-
src="https://static1.plasmic.app/preamble.js"
|
|
155
|
-
strategy="beforeInteractive"
|
|
156
|
-
/>
|
|
157
|
-
<PlasmicCanvasHost />
|
|
158
|
-
</div>
|
|
159
|
-
);
|
|
141
|
+
return <PlasmicCanvasHost />;
|
|
160
142
|
}
|
|
161
143
|
`;
|
|
162
144
|
}
|
|
163
145
|
}
|
|
164
146
|
|
|
165
|
-
export function wrapAppRootForCodegen() {
|
|
147
|
+
export function wrapAppRootForCodegen(): string {
|
|
166
148
|
return `
|
|
167
149
|
import '../styles/globals.css'
|
|
168
150
|
import { PlasmicRootProvider } from "@plasmicapp/react-web";
|