iterate-ui-next 0.1.5 → 0.1.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/dist/index.cjs CHANGED
@@ -138,26 +138,52 @@ function withIterate(nextConfig = {}, options = {}) {
138
138
  };
139
139
  }
140
140
  };
141
+ let babelLoaderPath;
142
+ if (babelPluginPath) {
143
+ try {
144
+ babelLoaderPath = _require.resolve("babel-loader");
145
+ } catch {
146
+ console.warn("[iterate] Could not resolve babel-loader \u2014 component names will not be injected");
147
+ }
148
+ }
141
149
  if (!turbopack) {
142
150
  result.webpack = function webpack(config, context) {
143
- if (context.isServer || !context.dev) {
151
+ if (!context.dev) {
144
152
  return nextConfig.webpack?.(config, context) ?? config;
145
153
  }
146
- const originalEntry = config.entry;
147
- config.entry = async () => {
148
- const entries = await (typeof originalEntry === "function" ? originalEntry() : originalEntry);
149
- const injectorPath = createIterateInjector(overlayBundlePath, daemonPort);
150
- if (injectorPath && entries["main-app"]) {
151
- if (Array.isArray(entries["main-app"])) {
152
- entries["main-app"].push(injectorPath);
153
- }
154
- } else if (injectorPath && entries["main"]) {
155
- if (Array.isArray(entries["main"])) {
156
- entries["main"].push(injectorPath);
154
+ if (babelLoaderPath && babelPluginPath) {
155
+ config.module.rules.push({
156
+ test: /\.(tsx?|jsx?)$/,
157
+ exclude: /node_modules/,
158
+ enforce: "pre",
159
+ use: [{
160
+ loader: babelLoaderPath,
161
+ options: {
162
+ plugins: [babelPluginPath],
163
+ parserOpts: { plugins: ["jsx", "typescript"] },
164
+ configFile: false,
165
+ babelrc: false
166
+ }
167
+ }]
168
+ });
169
+ }
170
+ if (!context.isServer) {
171
+ const originalEntry = config.entry;
172
+ config.entry = async () => {
173
+ const entries = await (typeof originalEntry === "function" ? originalEntry() : originalEntry);
174
+ const injectorPath = createIterateInjector(overlayBundlePath, daemonPort);
175
+ if (injectorPath && entries["main-app"]) {
176
+ if (Array.isArray(entries["main-app"])) {
177
+ entries["main-app"].push(injectorPath);
178
+ }
179
+ } else if (injectorPath && entries["main"]) {
180
+ if (Array.isArray(entries["main"])) {
181
+ entries["main"].push(injectorPath);
182
+ }
157
183
  }
158
- }
159
- return entries;
160
- };
184
+ return entries;
185
+ };
186
+ }
161
187
  return nextConfig.webpack?.(config, context) ?? config;
162
188
  };
163
189
  }
package/dist/index.js CHANGED
@@ -116,26 +116,52 @@ function withIterate(nextConfig = {}, options = {}) {
116
116
  };
117
117
  }
118
118
  };
119
+ let babelLoaderPath;
120
+ if (babelPluginPath) {
121
+ try {
122
+ babelLoaderPath = _require.resolve("babel-loader");
123
+ } catch {
124
+ console.warn("[iterate] Could not resolve babel-loader \u2014 component names will not be injected");
125
+ }
126
+ }
119
127
  if (!turbopack) {
120
128
  result.webpack = function webpack(config, context) {
121
- if (context.isServer || !context.dev) {
129
+ if (!context.dev) {
122
130
  return nextConfig.webpack?.(config, context) ?? config;
123
131
  }
124
- const originalEntry = config.entry;
125
- config.entry = async () => {
126
- const entries = await (typeof originalEntry === "function" ? originalEntry() : originalEntry);
127
- const injectorPath = createIterateInjector(overlayBundlePath, daemonPort);
128
- if (injectorPath && entries["main-app"]) {
129
- if (Array.isArray(entries["main-app"])) {
130
- entries["main-app"].push(injectorPath);
131
- }
132
- } else if (injectorPath && entries["main"]) {
133
- if (Array.isArray(entries["main"])) {
134
- entries["main"].push(injectorPath);
132
+ if (babelLoaderPath && babelPluginPath) {
133
+ config.module.rules.push({
134
+ test: /\.(tsx?|jsx?)$/,
135
+ exclude: /node_modules/,
136
+ enforce: "pre",
137
+ use: [{
138
+ loader: babelLoaderPath,
139
+ options: {
140
+ plugins: [babelPluginPath],
141
+ parserOpts: { plugins: ["jsx", "typescript"] },
142
+ configFile: false,
143
+ babelrc: false
144
+ }
145
+ }]
146
+ });
147
+ }
148
+ if (!context.isServer) {
149
+ const originalEntry = config.entry;
150
+ config.entry = async () => {
151
+ const entries = await (typeof originalEntry === "function" ? originalEntry() : originalEntry);
152
+ const injectorPath = createIterateInjector(overlayBundlePath, daemonPort);
153
+ if (injectorPath && entries["main-app"]) {
154
+ if (Array.isArray(entries["main-app"])) {
155
+ entries["main-app"].push(injectorPath);
156
+ }
157
+ } else if (injectorPath && entries["main"]) {
158
+ if (Array.isArray(entries["main"])) {
159
+ entries["main"].push(injectorPath);
160
+ }
135
161
  }
136
- }
137
- return entries;
138
- };
162
+ return entries;
163
+ };
164
+ }
139
165
  return nextConfig.webpack?.(config, context) ?? config;
140
166
  };
141
167
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "iterate-ui-next",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "description": "iterate Next.js plugin — auto-starts daemon and injects overlay",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -37,9 +37,11 @@
37
37
  }
38
38
  },
39
39
  "dependencies": {
40
- "iterate-ui-overlay": "0.1.2",
41
- "iterate-ui-daemon": "0.1.2",
42
- "iterate-ui-babel-plugin": "0.1.1"
40
+ "@babel/core": "^7.24.0",
41
+ "babel-loader": "^10.1.0",
42
+ "iterate-ui-overlay": "0.1.3",
43
+ "iterate-ui-babel-plugin": "0.1.1",
44
+ "iterate-ui-daemon": "0.1.2"
43
45
  },
44
46
  "peerDependencies": {
45
47
  "next": "^14.0.0 || ^15.0.0 || ^16.0.0",