Skip to content

Commit

Permalink
feat: 1.0.0版本
Browse files Browse the repository at this point in the history
  • Loading branch information
mapengda committed Mar 11, 2021
1 parent 067a360 commit f8c1078
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cjs2esmodule",
"version": "0.1.0",
"version": "1.0.0",
"main": "lib/index.js",
"description": "将commonjs转为es module,可在vite中使用,也可直接转换文件",
"license": "MIT",
Expand Down
4 changes: 2 additions & 2 deletions src/scripts.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { readFile, createWriteStream } from 'fs'
import glob from 'glob'
import { relative } from 'path'
import { transformFileBase } from './utils/base'
import { isCjsFile, transformFileBase } from './utils/base'

const ROOT = process.cwd()

Expand All @@ -13,7 +13,7 @@ function _transformFiles(pattern) {
files && files.forEach(file => {
const filename = relative(ROOT, file,)
readFile(filename, (err, content) => {
if (content) {
if (content && isCjsFile(content.toString())) {
const str = content.toString();
const { code } = transformFileBase(str)
createWriteStream(filename).write(code)
Expand Down

0 comments on commit f8c1078

Please sign in to comment.