Skip to content

[impit-node] Breaking Changes: Import Path & Headers Format in v0.8.2 #361

@jlalmes

Description

@jlalmes

Upgrading from [email protected] to [email protected] introduced two breaking changes that require code modifications:

  1. Import path change: Must use 'impit/index.js' instead of 'impit'
  2. Headers format change: Headers must be an array of tuples instead of an object

Issue 1: Import Path Breaking Change

Before (v0.7.4)

import { Impit, type ImpitResponse, type RequestInit } from 'impit';

After (v0.8.2)

import { Impit, type ImpitResponse, type RequestInit } from 'impit/index.js';

Impact: All imports break and require manual updates across the codebase.

Issue 2: Headers Format Breaking Change

Before (v0.7.4)

const res = await impit.fetch(url, {
  headers: {
    Accept: '*/*',
    'Accept-Language': 'en',
    ...otherHeaders,
  },
});

Error when using object format:

Error: Given napi value is not an array on RequestInit.headers

The error indicates that the native bindings expect an array format, but this is not documented and breaks the expected Web API fetch-like interface.

Workaround After (v0.8.2)

Currently using this workaround to maintain object-based header merging:

headers: Object.entries({
  Accept: '*/*',
  'Accept-Language': 'en',
  ...init.headers,
}) as [string, string][],

Thank you for maintaining this library!

Metadata

Metadata

Assignees

No one assigned

    Labels

    t-toolingIssues with this label are in the ownership of the tooling team.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions