Skip to content

Instantly share code, notes, and snippets.

@i-like-robots
Created December 20, 2023 16:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save i-like-robots/29b8662210f6898626f40d49e8e39e68 to your computer and use it in GitHub Desktop.
Save i-like-robots/29b8662210f6898626f40d49e8e39e68 to your computer and use it in GitHub Desktop.
// dist/index.cjs
'use strict';
function Foo() {
}
module.exports = Foo;
// dist/index.d.cts
declare function Foo(): void;
export { Foo as default };
// src/index.ts
export default function Foo() {}
{
"name": "test-case",
"version": "1.0.0",
"exports": {
"require": {
"types": "./dist/index.d.cts",
"default": "./dist/index.cjs"
},
"import": {
"types": "./dist/index.d.mts",
"default": "./dist/index.mjs"
}
},
"scripts": {
"build": "pkgroll"
},
"devDependencies": {
"@types/node": "^18.11.8",
"pkgroll": "^2.0.1",
"typescript": "^5.0.0"
},
"engines": {
"node": ">= 18.0.0"
}
}
// @ts-check
const Foo = require('./dist/index.cjs');
new Foo()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment