Skip to content

Commit bad4aa4

Browse files
committed
Upgrade pdfjs
1 parent 3f19df0 commit bad4aa4

File tree

8 files changed

+136
-250
lines changed

8 files changed

+136
-250
lines changed

next.config.js

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
const path = require('path')
22

3-
const withWorkers = require('@zeit/next-workers')
4-
const withTM = require('next-transpile-modules')(['pdfjs-dist'])
5-
63
const csp = require('./csp.config')
74
const helpers = require('./utils/helpers')
85

@@ -32,7 +29,7 @@ const nextConfig = {
3229
]
3330
},
3431

35-
webpack: (config) => {
32+
webpack: (config, { defaultLoaders }) => {
3633
const originalEntry = config.entry
3734
config.entry = async () => {
3835
const entries = await originalEntry()
@@ -86,6 +83,22 @@ const nextConfig = {
8683
}
8784
})
8885

86+
config.module.rules.push({
87+
test: /\.+(js|jsx|mjs|ts|tsx)$/,
88+
loader: defaultLoaders.babel,
89+
include: (f) => f.includes('/node_modules/pdfjs-dist/lib/'),
90+
})
91+
92+
rules.push({
93+
test: /\.worker\.(js|ts)$/,
94+
loader: 'worker-loader',
95+
options: {
96+
publicPath: `${nextConfig.assetPrefix}/_next/`,
97+
filename: 'static/[hash].worker.js',
98+
esModule: false,
99+
},
100+
})
101+
89102
Object.assign(config.resolve.alias, {
90103
'@sentry/node': config.isServer ? '@sentry/node' : '@sentry/browser',
91104

@@ -98,9 +111,5 @@ const nextConfig = {
98111
return config
99112
},
100113
}
101-
nextConfig.workerLoaderOptions = {
102-
publicPath: `${nextConfig.assetPrefix}/_next/`,
103-
name: 'static/[hash].worker.js',
104-
}
105114

106-
module.exports = withTM(withWorkers(nextConfig))
115+
module.exports = nextConfig

0 commit comments

Comments
 (0)