Skip to content

Commit

Permalink
fix for Deno 2 #52
Browse files Browse the repository at this point in the history
  • Loading branch information
adrai committed Nov 20, 2024
1 parent 05b5d87 commit d3bd196
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 27 deletions.
6 changes: 0 additions & 6 deletions lib/fs.cjs

This file was deleted.

6 changes: 0 additions & 6 deletions lib/path.cjs

This file was deleted.

6 changes: 1 addition & 5 deletions lib/readFile.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
import JSON5 from './formats/json5.js'
// eslint-disable-next-line no-unused-vars
import jsYaml from './formats/yaml.js'
import * as fsMod from './fs.cjs'
// import * as pathMod from './path.cjs'
import extname from './extname.js'
const isDeno = typeof Deno !== 'undefined'
const isBun = typeof Bun !== 'undefined'
const YAML = typeof jsYaml !== 'undefined' && jsYaml.load ? jsYaml : undefined
const fs = fsMod ? (fsMod.default || fsMod) : undefined // because of strange export
// const path = pathMod ? (pathMod.default || pathMod) : undefined
const fs = (!isDeno/* && !isBun */) ? (await import('node:fs')).default : undefined
// eslint-disable-next-line no-eval
const evalAlias = eval

Expand Down
4 changes: 1 addition & 3 deletions lib/writeFile.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import JSON5 from './formats/json5.js'
// eslint-disable-next-line no-unused-vars
import jsYaml from './formats/yaml.js'
import * as fsMod from './fs.cjs'
import extname from './extname.js'
const isDeno = typeof Deno !== 'undefined'
const isBun = typeof Bun !== 'undefined'
const YAML = typeof jsYaml !== 'undefined' && jsYaml.load ? jsYaml : undefined
const fs = fsMod ? (fsMod.default || fsMod) : undefined // because of strange export
const fs = (!isDeno/* && !isBun */) ? (await import('node:fs')).default : undefined

function dirname (path) {
if (path.length === 0) return '.'
Expand Down
18 changes: 11 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,22 @@
"types": "./index.d.mts",
"devDependencies": {
"@babel/cli": "7.25.9",
"@babel/core": "7.25.9",
"@babel/preset-env": "7.25.9",
"@babel/core": "7.26.0",
"@babel/preset-env": "7.26.0",
"babel-plugin-add-module-exports": "1.0.4",
"dtslint": "4.2.1",
"eslint": "8.55.0",
"eslint-config-standard": "17.1.0",
"eslint-plugin-import": "2.29.1",
"eslint-plugin-import": "2.31.0",
"eslint-plugin-n": "16.3.1",
"eslint-plugin-promise": "6.1.1",
"eslint-plugin-require-path-exists": "1.1.9",
"eslint-plugin-standard": "5.0.0",
"expect.js": "0.3.1",
"i18next": "23.16.3",
"i18next": "23.16.6",
"js-yaml": "4.1.0",
"json5": "2.2.3",
"mocha": "10.7.3",
"mocha": "10.8.2",
"tslint": "5.20.1",
"tsd": "0.31.2",
"typescript": "5.6.3",
Expand All @@ -65,13 +65,17 @@
"url": "https://github.com/i18next/i18next-fs-backend/issues"
},
"license": "MIT",
"config": {
"fixcjs": "fs.writeFileSync('cjs/writeFile.js', fs.readFileSync('cjs/writeFile.js').toString().replace(`(await Promise.resolve().then(function () {\n return _interopRequireWildcard(require('node:fs'));\n})).default`, `require('node:fs')`));fs.writeFileSync('cjs/readFile.js', fs.readFileSync('cjs/readFile.js').toString().replace(`(await Promise.resolve().then(function () {\n return _interopRequireWildcard(require('node:fs'));\n})).default`, `require('node:fs')`))"
},
"scripts": {
"copy:json5": "cp node_modules/json5/dist/index.mjs lib/formats/json5.js",
"copy:yaml": "cp node_modules/js-yaml/dist/js-yaml.mjs lib/formats/yaml.js",
"copy": "rm -rf lib/formats && mkdir lib/formats && npm run copy:json5 && npm run copy:yaml",
"lint": "eslint .",
"compile:esm": "rm -rf esm && mkdir esm && BABEL_ENV=esm babel lib -d esm && cp index.d.ts esm/index.d.ts && cp index.d.mts esm/index.d.mts && cp lib/fs.cjs esm/fs.cjs && cp lib/path.cjs esm/path.cjs",
"compile:cjs": "rm -rf cjs && mkdir cjs && BABEL_ENV=cjs babel lib -d cjs && cp index.d.ts cjs/index.d.ts && echo '{\"type\":\"commonjs\"}' > cjs/package.json && cp lib/fs.cjs cjs/fs.js && cp lib/path.cjs cjs/path.js && node -e \"fs.writeFileSync('cjs/readFile.js', fs.readFileSync('cjs/readFile.js').toString().replace('fs.cjs', 'fs.js').replace('path.cjs', 'path.js'))\" && node -e \"fs.writeFileSync('cjs/writeFile.js', fs.readFileSync('cjs/writeFile.js').toString().replace('fs.cjs', 'fs.js'))\"",
"fixcjs": "node -e \"$npm_package_config_fixcjs\"",
"compile:esm": "rm -rf esm && mkdir esm && BABEL_ENV=esm babel lib -d esm && cp index.d.ts esm/index.d.ts && cp index.d.mts esm/index.d.mts",
"compile:cjs": "rm -rf cjs && mkdir cjs && BABEL_ENV=cjs babel lib -d cjs && cp index.d.ts cjs/index.d.ts && echo '{\"type\":\"commonjs\"}' > cjs/package.json && npm run fixcjs",
"compile": "npm run copy && npm run compile:esm && npm run compile:cjs",
"build": "npm run compile",
"test": "npm run lint && npm run build && mocha test -R spec --exit --experimental-modules && npm run test:typescript",
Expand Down

0 comments on commit d3bd196

Please sign in to comment.