@codedesignai/nextjs-live-edit-plugin 1.0.5 → 1.0.7
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/index.js +8 -6
- package/live-edit-handler.js +0 -16
- package/package.json +1 -1
- package/source-mapper-loader.js +0 -5
package/index.js
CHANGED
|
@@ -29,18 +29,14 @@ const path = require('path');
|
|
|
29
29
|
*/
|
|
30
30
|
function withLiveEdit(nextConfig = {}, pluginOptions = {}) {
|
|
31
31
|
const sourceDirs = pluginOptions.sourceDirs || ['app', 'components', 'src'];
|
|
32
|
-
|
|
33
|
-
// Only add source mapping in development mode
|
|
34
|
-
if (process.env.NODE_ENV === 'production') {
|
|
35
|
-
return nextConfig;
|
|
36
|
-
}
|
|
32
|
+
const projectRoot = pluginOptions.projectRoot || process.cwd();
|
|
37
33
|
|
|
38
34
|
const loaderPath = path.resolve(__dirname, 'source-mapper-loader.js');
|
|
39
35
|
const loaderConfig = {
|
|
40
36
|
loader: loaderPath,
|
|
41
37
|
options: {
|
|
42
38
|
sourceDirs,
|
|
43
|
-
projectRoot
|
|
39
|
+
projectRoot,
|
|
44
40
|
},
|
|
45
41
|
};
|
|
46
42
|
|
|
@@ -48,12 +44,18 @@ function withLiveEdit(nextConfig = {}, pluginOptions = {}) {
|
|
|
48
44
|
const existingTurbopack = nextConfig.turbopack || {};
|
|
49
45
|
const existingRules = existingTurbopack.rules || {};
|
|
50
46
|
|
|
47
|
+
// Merge allowedDevOrigins — sandbox domains need cross-origin HMR access
|
|
48
|
+
// for React hydration to complete (which <Script strategy="afterInteractive"> depends on)
|
|
49
|
+
const existingOrigins = nextConfig.allowedDevOrigins || [];
|
|
50
|
+
|
|
51
51
|
return {
|
|
52
52
|
...nextConfig,
|
|
53
|
+
allowedDevOrigins: [...existingOrigins, '.miraqal.com'],
|
|
53
54
|
turbopack: {
|
|
54
55
|
...existingTurbopack,
|
|
55
56
|
rules: {
|
|
56
57
|
...existingRules,
|
|
58
|
+
// Apply our source mapper loader to JSX and TSX files
|
|
57
59
|
'*.jsx': {
|
|
58
60
|
loaders: [loaderConfig],
|
|
59
61
|
},
|
package/live-edit-handler.js
CHANGED
|
@@ -538,16 +538,6 @@ function createLiveEditHandler(options = {}) {
|
|
|
538
538
|
};
|
|
539
539
|
|
|
540
540
|
async function POST(request) {
|
|
541
|
-
// Only allow in development
|
|
542
|
-
if (process.env.NODE_ENV === 'production') {
|
|
543
|
-
return new Response(
|
|
544
|
-
JSON.stringify({
|
|
545
|
-
success: false,
|
|
546
|
-
error: 'Live editing is only available in development mode',
|
|
547
|
-
}),
|
|
548
|
-
{ status: 403, headers: { 'Content-Type': 'application/json', ...corsHeaders } }
|
|
549
|
-
);
|
|
550
|
-
}
|
|
551
541
|
|
|
552
542
|
try {
|
|
553
543
|
const data = await request.json();
|
|
@@ -614,12 +604,6 @@ function createPagesApiHandler(options = {}) {
|
|
|
614
604
|
return;
|
|
615
605
|
}
|
|
616
606
|
|
|
617
|
-
if (process.env.NODE_ENV === 'production') {
|
|
618
|
-
res
|
|
619
|
-
.status(403)
|
|
620
|
-
.json({ success: false, error: 'Live editing is only available in development mode' });
|
|
621
|
-
return;
|
|
622
|
-
}
|
|
623
607
|
|
|
624
608
|
try {
|
|
625
609
|
const data = req.body;
|
package/package.json
CHANGED
package/source-mapper-loader.js
CHANGED
|
@@ -146,11 +146,6 @@ function extractStringFromAttrValue(valueNode) {
|
|
|
146
146
|
* - Inline backgroundImage styles
|
|
147
147
|
*/
|
|
148
148
|
module.exports = function sourceMapperLoader(source) {
|
|
149
|
-
// Only run in development mode
|
|
150
|
-
if (process.env.NODE_ENV === 'production') {
|
|
151
|
-
return source;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
149
|
const resourcePath = this.resourcePath;
|
|
155
150
|
const options = this.getOptions() || {};
|
|
156
151
|
|