From 7b547963b80d3863c234fde31929aea79802ede5 Mon Sep 17 00:00:00 2001 From: AkaraChen <85140972+AkaraChen@users.noreply.github.com> Date: Sat, 10 Jun 2023 00:46:07 +0800 Subject: [PATCH] fix: issues #21 --- package.json | 9 ++++++++- src/workerMiddleware.ts | 4 ++-- tsconfig.json | 2 +- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 7c3e070..4aab72e 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,7 @@ "version": "1.1.0", "description": "A vite plugin for the Monaco Editor", "main": "dist/index.js", + "type": "module", "types": "dist/index.d.ts", "scripts": { "build": "tsc", @@ -48,5 +49,11 @@ }, "peerDependencies": { "monaco-editor": ">=0.33.0" + }, + "exports": { + ".": { + "import": "./dist/index.js", + "types": "./dist/index.d.ts" + } } -} \ No newline at end of file +} diff --git a/src/workerMiddleware.ts b/src/workerMiddleware.ts index d17c7f2..b47d3b0 100644 --- a/src/workerMiddleware.ts +++ b/src/workerMiddleware.ts @@ -1,9 +1,9 @@ import { Connect, ResolvedConfig } from 'vite'; import { getWorks, IMonacoEditorOpts, isCDN, resolveMonacoPath } from './index'; import { IWorkerDefinition, languageWorksByLabel } from './lnaguageWork'; -const esbuild = require('esbuild'); +import * as esbuild from 'esbuild' import * as fs from 'fs'; -import path = require('path'); +import * as path from 'path' export function getFilenameByEntry(entry: string) { entry = path.basename(entry, 'js'); diff --git a/tsconfig.json b/tsconfig.json index 671e42b..4230645 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -3,7 +3,7 @@ "compilerOptions": { "outDir": "dist", "target": "ES6", - "module": "commonjs", + "module": "ES6", "moduleResolution": "node", "declaration": true, }