build-plugin-main-fields
Advanced tools
Comparing version 1.0.0 to 1.0.1
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const plugin = ({ onGetWebpackConfig }) => { | ||
function getValidOptions(options) { | ||
if (options && typeof options === 'object' && 'mainFields' in options && Array.isArray(options.mainFields)) { | ||
return { | ||
mainFields: options.mainFields | ||
}; | ||
} | ||
return { | ||
mainFields: ['main', 'module'] | ||
}; | ||
} | ||
const plugin = ({ onGetWebpackConfig }, options) => { | ||
onGetWebpackConfig(config => { | ||
config.resolve.mainFields | ||
.clear('.mjs').add('main').add('module'); | ||
const mainFields = getValidOptions(options).mainFields; | ||
const chainable = config.resolve.mainFields | ||
.clear('.mjs'); | ||
for (const field of mainFields) { | ||
chainable.add(field); | ||
} | ||
}); | ||
}; | ||
exports.default = plugin; |
{ | ||
"name": "build-plugin-main-fields", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Build-scripts plugin for config resolve fields of package.json", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2783
26