11const path = require ( 'path' )
22
3- const withWorkers = require ( '@zeit/next-workers' )
4- const withTM = require ( 'next-transpile-modules' ) ( [ 'pdfjs-dist' ] )
5-
63const csp = require ( './csp.config' )
74const 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 : / \. + ( j s | j s x | m j s | t s | t s x ) $ / ,
88+ loader : defaultLoaders . babel ,
89+ include : ( f ) => f . includes ( '/node_modules/pdfjs-dist/lib/' ) ,
90+ } )
91+
92+ rules . push ( {
93+ test : / \. w o r k e r \. ( j s | t s ) $ / ,
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