diff --git a/package.json b/package.json index acbfc87..3a0bfd5 100644 --- a/package.json +++ b/package.json @@ -2,13 +2,14 @@ "name": "components-helper", "version": "2.1.5", "description": "Based on the docs to provide code prompt files for vue component library", - "main": "lib/index.js", - "module": "lib/index.es.js", + "type": "module", + "main": "lib/index.cjs", + "module": "lib/index.js", "types": "lib/index.d.ts", "exports": { ".": { - "import": "./lib/index.es.js", - "require": "./lib/index.js" + "import": "./lib/index.js", + "require": "./lib/index.cjs" } }, "scripts": { @@ -44,10 +45,10 @@ }, "homepage": "https://github.com/tolking/components-helper#readme", "engines": { - "node": ">15.0.0" + "node": ">=16.0.0" }, "dependencies": { - "fast-glob": "^3.2.11" + "fast-glob": "^3.3.2" }, "devDependencies": { "@types/node": "^18.0.6", diff --git a/rollup.config.js b/rollup.config.js index 84a25af..970b416 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -2,7 +2,7 @@ import ts from 'rollup-plugin-typescript2' const commonConf = { input: './src/index.ts', - external: ['fast-glob', 'fs', 'path'], + external: ['fast-glob'], plugins: [ ts({ extensions: ['.ts'], @@ -13,13 +13,13 @@ const commonConf = { const list = [ { - file: 'lib/index.es.js', + file: 'lib/index.js', format: 'es', exports: 'named', compact: true, }, { - file: 'lib/index.js', + file: 'lib/index.cjs', format: 'cjs', exports: 'named', compact: true, diff --git a/src/read.ts b/src/read.ts index e70fec4..5c92bf8 100644 --- a/src/read.ts +++ b/src/read.ts @@ -1,4 +1,4 @@ -import { readFileSync } from 'fs' +import { readFileSync } from 'node:fs' export function read(path: string): string { return readFileSync(path, 'utf-8') diff --git a/src/write.ts b/src/write.ts index cc93b05..71c8421 100644 --- a/src/write.ts +++ b/src/write.ts @@ -1,5 +1,5 @@ -import { resolve } from 'path' -import { mkdir, writeFileSync } from 'fs' +import { resolve } from 'node:path' +import { mkdir, writeFileSync } from 'node:fs' import type { Options, Tags, Props, WebTypes } from './type' export function write( diff --git a/test/index.js b/test/index.js index 094444f..32fb6a0 100644 --- a/test/index.js +++ b/test/index.js @@ -1,5 +1,4 @@ -// eslint-disable-next-line @typescript-eslint/no-var-requires -const helper = require('../lib/index').default +import helper from '../lib/index.js' helper({ name: 'test',