Skip to content

generate-typescript-typedefs with customFieldTypesParserPath does not work on windows #221

@leifmarcus

Description

@leifmarcus

Current behavior:

When running the following command on windows (power shell, or git bash), the file provided for customFieldTypesParserPath cannot be imported.

storyblok generate-typescript-typedefs \
      --sourceFilePaths ./components.json \
      --destinationFilePath ./components.d.ts \
      --JSONSchemaToTSOptionsPath ./jsonSchema.json \
      --customFieldTypesParserPath ./fieldTypeParser.js`);

Expected behavior:
The generate-typescript-typedefs command should also work on windows machines.

Steps to reproduce:
Run an example with the customFieldTypesParserPath attribute defined.

Related code:
The reason for the problem is a import(resolve(...)), that is used here.

The reason is, that for esm imports posix paths should be used. To fix this, you need to import resolve from node:path/posix like so

import { resolve } from 'node:path/posix';

// ...
const customTypeParser = await import(resolve(path));
// ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions