From 9faeac3800b7d6d91e6a1f184c8a8f4e3a198dcc Mon Sep 17 00:00:00 2001 From: brandonocasey Date: Wed, 9 Dec 2020 17:11:53 -0500 Subject: [PATCH] fix: inline json for module files --- index.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 3d81f2c..4d38cd2 100644 --- a/index.js +++ b/index.js @@ -95,6 +95,7 @@ const ORDERED_DEFAULTS = { 'babel' ], module: [ + 'jsonResolve', 'json', 'babel' ], @@ -132,6 +133,7 @@ const ORDERED_DEFAULTS = { primedPlugins: (settings) => ({ babel: babel(settings.babel), commonjs: commonjs({sourceMap: false}), + jsonResolve: resolve({extensions: ['.json']}), json: json(), multiEntry: multiEntry({exports: false}), resolve: resolve({ @@ -216,7 +218,12 @@ const generateRollupConfig = function(options) { // but only if the plugin is a string and not a // primed plugin already. plugins: buildSettings.plugins[buildType].map((p) => typeof p !== 'string' ? p : buildSettings.primedPlugins[p]), - external: (id) => buildSettings.externals[buildType].some((ext) => id.startsWith(ext)), + external: (id) => { + if (buildType === 'module' && path.extname(id) === '.json') { + return false; + } + return buildSettings.externals[buildType].some((ext) => id.startsWith(ext)); + }, input: buildType === 'test' ? buildSettings.testInput : buildSettings.input }, buildOverrides);