nodejs / nodejs/import-in-the-middle

Breaks newer typebox (export * behaviour?)

Open
#269 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
170
Forks
58
Avg merge
3d 19h
Merged PRs (30d)
7

Description

I believe something is mishandling the extensive use of export * in https://github.com/sinclairzx81/typebox/blob/0c31e10b1d080ed95c2a58e52aaf8c517b7aaf18/src/type/types/index.ts , but don't understand enough about either project to provide a better guess.

echo '{"type":"module"}' > package.json
npm i import-in-the-middle typebox

repro.js

import * as Type from 'typebox/type';
import { Value } from 'typebox/value';
import { Type as T } from 'typebox';

console.log('IsTemplateLiteral:', typeof Type.IsTemplateLiteral);
console.log('IsString:', typeof Type.IsString);
console.log('IsObject:', typeof Type.IsObject);

try {
  const unionSchema = T.Object({ level: T.Union([T.Literal('a'), T.Literal('b')]) });
  console.log('Convert union OK:', JSON.stringify(Value.Convert(unionSchema, { level: 'a' })));
} catch (e) {
  console.log('CONVERT union ERROR:', (e).message);
}
$ node repro.js
IsTemplateLiteral: function
IsString: function
IsObject: function
Convert union OK: {"level":"a"}
$ node --loader=import-in-the-middle/hook.mjs repro.js
...
IsTemplateLiteral: undefined
...
CONVERT union ERROR: Type.IsTemplateLiteral is not a function
├── import-in-the-middle@3.3.1
└── typebox@1.3.6

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with repro.js and import-in-the-middle/hook.mjs, then compare the normal and --loader executions against the referenced TypeBox export index. Run the provided npm install and Node commands; done means the loader preserves the exported TypeBox functions and the union conversion succeeds under the hook.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
50/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.