Skip to content

Commit

Permalink
Use jiti instead of babel to be compatible with Nuxt.js (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
dword-design committed Mar 9, 2021
1 parent 93c8aa8 commit df7f7bd
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 15 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ const options = {
depcheck(process.cwd(), options, unused => {
console.log(unused.dependencies); // an array containing the unused dependencies
console.log(unused.devDependencies); // an array containing the unused devDependencies
console.log(unused.missing); // a lookup containing the dependencies missing in `package.json` and where they are used
console.log(unused.using); // a lookup indicating each dependency is used by which files
console.log(unused.invalidFiles); // files that cannot access or parse
console.log(unused.invalidDirs); // directories that cannot access
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
"test": "base test"
},
"dependencies": {
"@babel/register": "^7.10.4",
"@dword-design/functions": "^1.1.2"
"@dword-design/functions": "^1.1.2",
"jiti": "^1.6.3"
},
"devDependencies": {
"@dword-design/base": "^7.0.0",
Expand Down
7 changes: 4 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import babelRegister from '@babel/register'
import { filter, first, map } from '@dword-design/functions'
import jiti from 'jiti'
import P from 'path'

const jitiInstance = jiti(__filename)

export default filename => {
if (P.basename(filename) === 'nuxt.config.js') {
babelRegister()
const config = require(filename)
const config = jitiInstance(filename).default
const modules = [...(config.modules || []), ...(config.buildModules || [])]
return (
modules
Expand Down
7 changes: 0 additions & 7 deletions src/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,6 @@ import withLocalTmpDir from 'with-local-tmp-dir'
const runTest = config => () =>
withLocalTmpDir(async () => {
await outputFiles({
'.babelrc.json': JSON.stringify(
{
extends: '@dword-design/babel-config',
},
undefined,
2
),
'depcheck.config.js': endent`
const special = require('../src')
module.exports = {
Expand Down
9 changes: 7 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -803,7 +803,7 @@
"@babel/types" "^7.4.4"
esutils "^2.0.2"

"@babel/register@^7.10.4", "@babel/register@^7.6.2":
"@babel/register@^7.6.2":
version "7.12.13"
resolved "https://registry.yarnpkg.com/@babel/register/-/register-7.12.13.tgz#e9cb57618264f2944634da941ba9755088ef9ec5"
integrity sha512-fnCeRXj970S9seY+973oPALQg61TRvAaW0nRDe1f4ytKqM3fZgsNXewTZWmqZedg74LFIRpg/11dsrPZZvYs2g==
Expand Down Expand Up @@ -2986,7 +2986,7 @@ depcheck-parser-babel@^1.2.0:
"@babel/core" "^7.7.7"
fs-extra "^9.0.0"

"depcheck@github:dword-design/depcheck#fork":
depcheck@dword-design/depcheck#fork:
version "0.0.1"
resolved "https://codeload.github.com/dword-design/depcheck/tar.gz/8a9eb41006c2c6f9cbd79e4e68bf265e1c1df1dc"
dependencies:
Expand Down Expand Up @@ -5186,6 +5186,11 @@ jest-regex-util@^26.0.0:
resolved "https://registry.yarnpkg.com/jest-regex-util/-/jest-regex-util-26.0.0.tgz#d25e7184b36e39fd466c3bc41be0971e821fee28"
integrity sha512-Gv3ZIs/nA48/Zvjrl34bf+oD76JHiGDUxNOVgUjh3j890sblXryjY4rss71fPtD/njchl6PSE2hIhvyWa1eT0A==

jiti@^1.6.3:
version "1.6.3"
resolved "https://registry.yarnpkg.com/jiti/-/jiti-1.6.3.tgz#722fb45ee03b01af87314f80aeae07762f9ffb7e"
integrity sha512-4oOM9K5MgVx9kiv8zo2B/8SIpKQ/rkaREskE+H8ymvF08mC8PAKnd0bbZ1FV5DTyoOOto9mapMpvZWA06reWKw==

"js-tokens@^3.0.0 || ^4.0.0", js-tokens@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499"
Expand Down

0 comments on commit df7f7bd

Please sign in to comment.