Files
safeImport/src_bundle/index.mjs

41 lines
873 B
JavaScript
Raw Normal View History

2025-07-09 13:26:51 +01:00
import wp from 'webpack';
import path from 'node:path'
const outputPath = path.resolve('./output/');
console.log(outputPath);
2025-07-21 17:01:43 +01:00
const l = 'classnames'
const libraryLocation = import.meta.resolve(l);
console.log(libraryLocation);
// throw Error("5");
2025-07-09 13:26:51 +01:00
const compiler = wp({
2025-07-21 17:01:43 +01:00
entry:libraryLocation,
2025-07-09 13:26:51 +01:00
mode: 'production',
optimization:{
mangleExports: false,
avoidEntryIife: true,
minimize: false
2025-07-21 17:01:43 +01:00
2025-07-09 13:26:51 +01:00
},
2025-07-21 17:01:43 +01:00
// experiments:{}
2025-07-09 13:26:51 +01:00
output: {
path: outputPath,
2025-07-21 17:01:43 +01:00
filename: l+'.bundle.cjs',
clean: true,
iife: false,
library: {
type: 'commonjs2',
// name: l
}
// module: true
2025-07-09 13:26:51 +01:00
}
,
},(err,stats)=>{
if (err || stats.hasErrors()) {
console.log(err?.stack)
2025-07-21 17:01:43 +01:00
console.log(stats?.hasErrors())
console.log(stats?.toJson());
2025-07-09 13:26:51 +01:00
}
})