Skip to content

Commit d78542d

Browse files
committed
fix: incorrect typings
1 parent e98f296 commit d78542d

File tree

2 files changed

+16
-22
lines changed

2 files changed

+16
-22
lines changed

src/__tests__/index.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ describe('withPrismaPlugin', () => {
44
it('should keep nextConfig object properties in other phases', () => {
55
const nextConfig = { foo: 'bar' }
66

7-
const newConfig = withPrismaPlugin(nextConfig)('NO_PHASE', {})
7+
const newConfig = withPrismaPlugin(nextConfig)('phase-export', {})
88
expect(newConfig).toEqual(nextConfig)
99
})
1010

1111
it('should call nextConfig function in other phases', () => {
1212
const nextConfig = () => ({ foo: 'bar' })
1313

14-
const newConfig = withPrismaPlugin(nextConfig)('NO_PHASE', {})
14+
const newConfig = withPrismaPlugin(nextConfig)('phase-export', {})
1515
expect(newConfig).toEqual(nextConfig())
1616
})
1717

src/index.ts

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,45 +6,39 @@ const PATH_DELIMITER = '[\\\\/]' // match 2 antislashes or one slash
66
* paths of the modules. So we need to check for \\ and /
77
*/
88
// @ts-ignore
9-
const safePath = module => module.split(/[\\\/]/g).join(PATH_DELIMITER)
9+
const safePath = (module) => module.split(/[\\\/]/g).join(PATH_DELIMITER)
1010

1111
/**
1212
* Actual Next.js plugin
1313
*/
1414

1515
const withPrismaPlugin = (nextConfig = {}) => (
16-
phase:
17-
| "phase-export"
18-
| "phase-production-build"
19-
| "phase-production-server"
20-
| "phase-development-server",
21-
thing: any
16+
phase: 'phase-export' | 'phase-production-build' | 'phase-production-server' | 'phase-development-server',
17+
thing: any
2218
) => {
23-
if (phase === "phase-development-server") {
19+
if (phase === 'phase-development-server') {
2420
return Object.assign({}, nextConfig, {
2521
webpack(config: any, options: any) {
2622
const ignore = ['.prisma/client', '@prisma/client']
2723

2824
// const includes = ignore.map(module => (new RegExp(`${module}(?!.*node_modules)`)));
29-
const excludes = [new RegExp(`node_modules(?!/(${ignore.join('|')})(?!.*node_modules))`)];
30-
const ignored = config.watchOptions.ignored.filter(
31-
(ignored: string) => ignored !== '**/node_modules/**'
32-
).concat(excludes);
25+
const excludes = [new RegExp(`node_modules(?!/(${ignore.join('|')})(?!.*node_modules))`)]
26+
const ignored = config.watchOptions.ignored
27+
.filter((ignored: string) => ignored !== '**/node_modules/**')
28+
.concat(excludes)
3329
return Object.assign(config, {
3430
plugins: [...config.plugins, new PrismaClientReloaderWebpackPlugin()],
3531
watchOptions: {
3632
...config.watchOptions,
37-
ignored
38-
}
33+
ignored,
34+
},
3935
})
40-
}
36+
},
4137
})
4238
}
43-
let internalConfigObj =
44-
typeof nextConfig === "function"
45-
? nextConfig(phase, thing)
46-
: nextConfig;
47-
return internalConfigObj;
39+
let internalConfigObj = typeof nextConfig === 'function' ? nextConfig(phase, thing) : nextConfig
40+
return internalConfigObj
4841
}
4942

5043
module.exports = withPrismaPlugin
44+
export default withPrismaPlugin

0 commit comments

Comments
 (0)