@codedesignai/nextjs-live-edit-plugin 1.0.4 → 1.0.6

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 CHANGED
@@ -2,8 +2,11 @@ const path = require('path');
2
2
 
3
3
  /**
4
4
  * Next.js config wrapper that enables the live edit plugin.
5
- * Configures both Turbopack (turbopack.rules) and webpack loaders
6
- * so the source mapper works regardless of which bundler is active.
5
+ * Uses Turbopack's built-in webpack loader support via turbopack.rules.
6
+ *
7
+ * NOTE: Only Turbopack is supported. Adding a `webpack` key to the config
8
+ * causes hydration mismatches in Next.js 16 because the loader would only
9
+ * run on client-side builds, while server-rendered HTML has no data attributes.
7
10
  *
8
11
  * Usage in next.config.js (CommonJS):
9
12
  *
@@ -28,73 +31,34 @@ function withLiveEdit(nextConfig = {}, pluginOptions = {}) {
28
31
  const sourceDirs = pluginOptions.sourceDirs || ['app', 'components', 'src'];
29
32
  const projectRoot = pluginOptions.projectRoot || process.cwd();
30
33
 
31
- // Only add source mapping in development mode
32
- if (process.env.NODE_ENV === 'production') {
33
- return nextConfig;
34
- }
35
-
36
34
  const loaderPath = path.resolve(__dirname, 'source-mapper-loader.js');
37
- const loaderOptions = {
38
- sourceDirs,
39
- projectRoot,
35
+ const loaderConfig = {
36
+ loader: loaderPath,
37
+ options: {
38
+ sourceDirs,
39
+ projectRoot,
40
+ },
40
41
  };
41
42
 
42
- // Preserve the user's existing webpack function if they have one
43
- const existingWebpack = nextConfig.webpack;
44
-
45
43
  // Merge with existing turbopack config
46
44
  const existingTurbopack = nextConfig.turbopack || {};
47
45
  const existingRules = existingTurbopack.rules || {};
48
46
 
49
- const turbopackLoaderConfig = {
50
- loader: loaderPath,
51
- options: loaderOptions,
52
- };
53
-
54
47
  return {
55
48
  ...nextConfig,
56
-
57
- // ── Turbopack (next dev --turbopack) ──────────────────────────────
58
49
  turbopack: {
59
50
  ...existingTurbopack,
60
51
  rules: {
61
52
  ...existingRules,
53
+ // Apply our source mapper loader to JSX and TSX files
62
54
  '*.jsx': {
63
- loaders: [turbopackLoaderConfig],
55
+ loaders: [loaderConfig],
64
56
  },
65
57
  '*.tsx': {
66
- loaders: [turbopackLoaderConfig],
58
+ loaders: [loaderConfig],
67
59
  },
68
60
  },
69
61
  },
70
-
71
- // ── Webpack (next dev without --turbopack) ───────────────────────
72
- webpack: (config, webpackOptions) => {
73
- // Only add to client-side builds (server components don't render in browser)
74
- if (!webpackOptions.isServer) {
75
- // Resolve source directories to absolute paths for the webpack include filter
76
- const includePaths = sourceDirs.map(dir => path.resolve(projectRoot, dir));
77
-
78
- config.module.rules.push({
79
- test: /\.(jsx|tsx)$/,
80
- include: includePaths,
81
- enforce: 'pre',
82
- use: [
83
- {
84
- loader: loaderPath,
85
- options: loaderOptions,
86
- },
87
- ],
88
- });
89
- }
90
-
91
- // Chain with the user's existing webpack config if present
92
- if (typeof existingWebpack === 'function') {
93
- return existingWebpack(config, webpackOptions);
94
- }
95
-
96
- return config;
97
- },
98
62
  };
99
63
  }
100
64
 
@@ -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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codedesignai/nextjs-live-edit-plugin",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "description": "Next.js plugin for live editing React components with AST-powered source mapping",
5
5
  "main": "index.js",
6
6
  "exports": {
@@ -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