Skip to content

Commit

Permalink
feat: add options.mainFields
Browse files Browse the repository at this point in the history
Signed-off-by: Charlike Mike Reagent <[email protected]>
  • Loading branch information
Charlike Mike Reagent committed Jun 10, 2019
1 parent 421c19d commit 2d83d3a
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ module.exports = (
{
cache,
externals = [],
mainFields = [],
minify = false,
sourceMap = false,
sourceMapRegister = true,
Expand Down Expand Up @@ -107,6 +108,8 @@ module.exports = (

let watcher, watchHandler, rebuildHandler;

const fields = [].concat(mainFields).filter(Boolean);

const compiler = webpack({
entry: processedEntry,
cache: cache === false ? undefined : {
Expand Down Expand Up @@ -136,9 +139,9 @@ module.exports = (
},
resolve: {
extensions: SUPPORTED_EXTENSIONS,
// webpack defaults to `module` and `main`, but that's
// not really what node.js supports, so we reset it
mainFields: ["main"],
// Support options.mainFields, otherwise fallback to @zeit/ncc defaults,
// which forces only using the 'main' field.
mainFields: fields.length > 0 ? fields : ['main'],
plugins: resolvePlugins
},
// https://github.com/zeit/ncc/pull/29#pullrequestreview-177152175
Expand Down

0 comments on commit 2d83d3a

Please sign in to comment.