-
-
Notifications
You must be signed in to change notification settings - Fork 175
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Use Rollup instead of Babel to generate CJS and ESM bundles * Convert implementation to ESM * Use Vitest instead of Jest for tests * Use memfs instead of mocking specific node:fs functions * Update nps calls to use CJS config
- Loading branch information
1 parent
39a7744
commit 2f68f10
Showing
25 changed files
with
964 additions
and
771 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export default { | ||
arrowParens: 'avoid', | ||
singleQuote: true, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import autoExternal from 'rollup-plugin-auto-external'; | ||
import commonjs from '@rollup/plugin-commonjs'; | ||
import json from '@rollup/plugin-json'; | ||
import { nodeResolve } from '@rollup/plugin-node-resolve'; | ||
|
||
export default { | ||
input: 'src/index.mjs', | ||
output: [ | ||
{ | ||
file: 'dist/cjs/index.js', | ||
format: 'cjs', | ||
name: 'cjs-bundle', | ||
}, | ||
{ | ||
file: 'dist/esm/index.js', | ||
format: 'esm', | ||
name: 'esm-bundle', | ||
}, | ||
], | ||
external: ['fs', 'node:path'], | ||
plugins: [ | ||
autoExternal(), | ||
commonjs({ | ||
include: /node_modules/, | ||
requireReturnsDefault: 'auto', | ||
strictRequires: 'debug', | ||
}), | ||
nodeResolve({ preferBuiltins: true }), | ||
json(), | ||
], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// This follows the advice of the Vitest Mocking guide, and mocks the full | ||
// filesystem with an in-memory replacement. | ||
// https://vitest.dev/guide/mocking#file-system | ||
const { createFsFromVolume, memfs, Volume } = require('memfs'); | ||
import path from 'node:path'; | ||
|
||
const files = [ | ||
'foo.js', | ||
'package.json', | ||
'node_modules/eslint/index.js', | ||
'node_modules/prettier/index.js', | ||
]; | ||
|
||
const volume = new Volume(); | ||
|
||
volume.fromJSON( | ||
Object.fromEntries( | ||
files.map(file => { | ||
return [`./${file}`, `.tests/fixtures/paths/${file}`]; | ||
}), | ||
), | ||
`${path.dirname(__filename)}/../../tests/fixtures/paths`, | ||
); | ||
|
||
export default createFsFromVolume(volume); |
Oops, something went wrong.