Closed manuth closed 1 year ago
Look. We have problems with index.d.mts
file.
When we use inside mjs file this code snippet:
import gulpEsbuild, {createGulpEsbuild} from "gulp-esbuild";
console.log(gulpEsbuild);
console.log(createGulpEsbuild);
console.log(gulpEsbuild.createGulpEsbuild);
import("gulp-esbuild")
.then(result => {
console.log('dynamic import');
console.log(result.createGulpEsbuild);
console.log(result.default);
console.log(result.default.createGulpEsbuild);
})
Typescript uses index.d.mts
and shows us, what out package has gulpEsbuild.createGulpEsbuild
. But actually it is not the truth.
[Function: plugin]
[Function: createGulpEsbuild]
undefined
dynamic import
[Function: createGulpEsbuild]
[Function: plugin]
undefined
Should mts
declaration file have import from index.js
file? I think no.
I mean mts declaration file should looks like:
import {Transform} from 'stream'
import {BuildOptions} from 'esbuild'
type Options = Omit<
BuildOptions,
'write' | 'incremental' | 'entryPoints' | 'stdin' | 'watch' | 'allowOverwrite' | 'absWorkingDir' | 'nodePaths'
> & {
metafileName?: string
}
interface CreateOptions {
incremental?: boolean
pipe?: boolean
}
type GulpEsbuild = (options: Options) => Transform
type CreateGulpEsbuild = (options: CreateOptions) => GulpEsbuild
declare const gulpEsbuild: GulpEsbuild;
declare const createGulpEsbuild: CreateGulpEsbuild
export {createGulpEsbuild}
export default gulpEsbuild
Without &
from d.ts
Thanks, I totally missed that one I'll fix it asap
Alright! Fixed it now. Sorry for the inconvenience
Changes made in this PR will add type declarations for the ESModule version of this package. In doing so, this PR will fix #17.