webpack.externals relative path causes Unexpected token

277 Views Asked by At

when I add a relative path to webpack.externals array, the output file contains: module.exports = ../path; which causes the error: Unexpected token.

//webpack.config.js
{
 externals: ['../path']
}
//input.ts
import something from '../path';
//output.js
module.exports = ../path;
1

There are 1 best solutions below

0
On

fixed by using a function instead of an object

{
 externals:[  
   function(..){
     //checking
     return callback(null, "commonjs path")
   }
 ]
}