Skip to content

ES modules support #130

@coolroman

Description

@coolroman

Is migration to ESM considered ? I mean "type": "module" in package.json.

There are problems using this library in combination with ES modules based libraries.

If I import a ES modules based library I get this error:

The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("...")' call instead.
To convert this file to an ECMAScript module, change its file extension to '.mts', or add the field "type": "module" to 'package.json'

If I set "type": "module" in my contract's project I get this error running any script with blueprint run:

Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /scripts/deploy.ts
require() of ES modules is not supported.
require() of /scripts/deploy.ts from /node_modules/.pnpm/@ton+blueprint@0.21.0_@ton+core@0.56.3_@ton+crypto@3.2.0__@ton+crypto@3.2.0_@ton[email protected]__xpatvrk3jf337gqa7bbsmwnc7e/node_modules/@ton/blueprint/dist/utils.js is an ES module file as it is a .ts file whose nearest parent package.json contains "type": "module" which defines all .ts files in that package scope as ES modules.
Instead change the requiring code to use import(), or remove "type": "module" from /contract/package.json.

Sub-issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions