@vercel/microfrontends 1.4.0-canary.7 → 1.4.1

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/CHANGELOG.md CHANGED
@@ -1,27 +1,34 @@
1
1
  # @vercel/microfrontends
2
2
 
3
- ## 1.4.0-canary.7
3
+ ## 1.4.1
4
4
 
5
5
  ### Patch Changes
6
6
 
7
- - Remove custom Image component
7
+ - 10b74ed: Route next/image requests to the correct microfrontends application in the local development proxy.
8
8
 
9
- ## 1.4.0-canary.5
10
-
11
- ### Patch Changes
12
-
13
- - 3797824: Automatically infer location of microfrontends.json in .vercel directory for polyrepo support.
14
-
15
- ## 1.4.0-canary.2
9
+ ## 1.4.0
16
10
 
17
11
  ### Minor Changes
18
12
 
19
- - Remove support for `projectId`. This field was deprecated in a previous version.
20
- - `projectId` is annoying to set up so we hope this simplifies things!
21
- - Ensure the application name matches the corresponding vercel project name, then remove the `projectId`.
22
- - The Vercel project name should ideally also match the application's `package.json` name. If this is not the case, you will need to set the `packageName` field to the `name` from the `package.json` file. This is needed for the local development proxy to work.
23
- - Add performance improvements for `PrefetchCrossZoneLinksProvider`
24
- - Minimise rerenders whenever new links are prefetched with `prefetchHref`.
13
+ - b31a76c: - Improve `PrefetchCrossZoneLinksProvider` performance.
14
+ - Stops components using this context from rerendering every time `prefetchHref` is called on an unseen `href`.
15
+ - Batches multiple prefetch calls together before causing a new render.
16
+ - Improve `MicrofrontendConfigClient` caching.
17
+ - Reuses clients when calling `MicrofrontendConfigClient.fromEnv()` with the same parameters as a previous call. This improves the hit rate of the path cache when there aren't dynamic paths.
18
+ - Caches the `hasDynamicPaths` check so that it doesn't need to be recalculated for each use of the hook.
19
+ - When the promise for the server-fetched config resolves, it stores a cached copy of that directly in a new variable so that future invocations of `useClientConfig()` can have the correct config in their initial render.
20
+ - Adds a `regexpCache` to cache the resulting regex for each path, to avoid calling `pathToRegexp` in most cases beyond the initial few links.
21
+ - Remove the custom `@vercel/microfrontends` `Image` component.
22
+ - The wrapper around Next.js `Image` is no longer needed, as the vercel proxy now handles image optimisation request routing for microfrontends.
23
+ - If you are currently importing `{ Image } from '@vercel/microfrontends/next/client'` you can replace this with `Image from 'next/image'`.
24
+ - Use `defineServer` instead of custom webpack EnvironmentPlugin when the version of Next.js is new enough to support it.
25
+ - [vercel/next.js#79225](https://github.com/vercel/next.js/pull/79225) added support to Next.js for defining server-only compile-time constants independent of the bundler.
26
+ - Like `compiler.define`, this allows users to create compile-time constants both Turbopack and webpack from a single API. `compiler.defineServer` instead only makes these constants available for server or edge environments, not the client environment.
27
+ - The new behaviour is used by default when the version of Next.js is new enough to support it. Otherwise the custom webpack EnvironmentPlugin is used.
28
+ - Optionally, you can specify `preferWebpackEnvironmentPlugin`. This will use the legacy `webpack.EnvironmentPlugin` instead of Next.js's `defineServer` option, even when Next.js is new enough to support it.
29
+ - Remove support for `projectId` in `microfrontends.json`.
30
+ - `projectId` was deprecated in a previous release. This release removes support for the field entirely.
31
+ - If you are still using `projectId`, see the previous release notes in `CHANGELOG.md` for removing it.
25
32
 
26
33
  ## 1.3.0
27
34
 
package/dist/bin/cli.cjs CHANGED
@@ -30,7 +30,7 @@ var import_env = require("@next/env");
30
30
  // package.json
31
31
  var package_default = {
32
32
  name: "@vercel/microfrontends",
33
- version: "1.4.0-canary.7",
33
+ version: "1.4.1",
34
34
  private: false,
35
35
  description: "Defines configuration and utilities for microfrontends development",
36
36
  keywords: [
@@ -2175,7 +2175,7 @@ var ProxyRequestRouter = class {
2175
2175
  path: path7,
2176
2176
  url,
2177
2177
  app: application
2178
- }) || this.checkNextOriginalFrame({ url, referer, applications }) || this.checkNextSourceMap({ url });
2178
+ }) || this.checkNextOriginalFrame({ url, referer, applications }) || this.checkNextSourceMap({ url }) || this.checkNextImage({ url, applications });
2179
2179
  if (builtInRewrite) {
2180
2180
  return builtInRewrite;
2181
2181
  }
@@ -2261,9 +2261,7 @@ var ProxyRequestRouter = class {
2261
2261
  path: `${url.pathname}${url.search}`
2262
2262
  } : null;
2263
2263
  }
2264
- checkNextSourceMap({
2265
- url
2266
- }) {
2264
+ checkNextSourceMap({ url }) {
2267
2265
  const isSourceMap = (0, import_path_to_regexp3.pathToRegexp)("/__nextjs_source-map").test(url.pathname);
2268
2266
  if (!isSourceMap) {
2269
2267
  return null;
@@ -2280,6 +2278,32 @@ var ProxyRequestRouter = class {
2280
2278
  path: `${url.pathname}${url.search}`
2281
2279
  };
2282
2280
  }
2281
+ checkNextImage({
2282
+ url,
2283
+ applications
2284
+ }) {
2285
+ const isNextImage = (0, import_path_to_regexp3.pathToRegexp)("/_next/image").test(url.pathname);
2286
+ if (!isNextImage) {
2287
+ return null;
2288
+ }
2289
+ const imageUrl = url.searchParams.get("url");
2290
+ if (!imageUrl) {
2291
+ mfeDebug("no url parameter found in _next/image request");
2292
+ return null;
2293
+ }
2294
+ const decodedPath = decodeURIComponent(imageUrl);
2295
+ const imageURL = new import_node_url.URL(`http://example.com${decodedPath}`);
2296
+ const imageApp = this.findMatchingApplication({
2297
+ path: decodedPath,
2298
+ url: imageURL,
2299
+ applications
2300
+ });
2301
+ mfeDebug(`routing nextjs image request to ${imageApp?.application}`);
2302
+ return imageApp ? {
2303
+ ...imageApp,
2304
+ path: `${url.pathname}${url.search}`
2305
+ } : null;
2306
+ }
2283
2307
  isDefaultAppLocal() {
2284
2308
  const defaultApp = this.config.getDefaultApplication();
2285
2309
  return Boolean(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/microfrontends",
3
- "version": "1.4.0-canary.7",
3
+ "version": "1.4.1",
4
4
  "private": false,
5
5
  "description": "Defines configuration and utilities for microfrontends development",
6
6
  "keywords": [