Skip to content

Commit

Permalink
build - fix bify external options and other config
Browse files Browse the repository at this point in the history
  • Loading branch information
kumavis committed Mar 25, 2021
1 parent ad4f3d8 commit f9e8640
Showing 1 changed file with 20 additions and 10 deletions.
30 changes: 20 additions & 10 deletions development/build/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ function createScriptTasks({ browserPlatforms, livereload }) {
createNormalBundle({
label,
filename: `${label}.js`,
dependenciesToBundle: externalDependenciesMap[key],
modulesToExpose: externalDependenciesMap[key],
devMode: false,
browserPlatforms,
}),
Expand All @@ -106,17 +106,17 @@ function createScriptTasks({ browserPlatforms, livereload }) {
];

const standardSubtasks = standardBundles.map((label) => {
let dependenciesToBundle;
let extraEntries;
if (devMode && label === 'ui') {
dependenciesToBundle = ['./development/require-react-devtools.js'];
extraEntries = ['./development/require-react-devtools.js'];
}
return createTask(
`${taskPrefix}:${label}`,
createBundleTaskForBuildJsExtensionNormal({
label,
devMode,
testing,
dependenciesToBundle,
extraEntries,
}),
);
});
Expand Down Expand Up @@ -165,11 +165,13 @@ function createScriptTasks({ browserPlatforms, livereload }) {
label,
devMode,
testing,
extraEntries,
}) {
return createNormalBundle({
label,
filename: `${label}.js`,
filepath: `./app/scripts/${label}.js`,
extraEntries,
externalDependencies: devMode
? undefined
: externalDependenciesMap[label],
Expand Down Expand Up @@ -223,7 +225,8 @@ function createScriptTasks({ browserPlatforms, livereload }) {
function createNormalBundle({
filename,
filepath,
dependenciesToBundle,
extraEntries = [],
modulesToExpose,
externalDependencies,
devMode,
testing,
Expand All @@ -244,14 +247,18 @@ function createNormalBundle({
const { bundlerOpts, events } = buildConfiguration;

// set bundle entry file
bundlerOpts.entries = [filepath];
bundlerOpts.entries = [...extraEntries, filepath];

if (dependenciesToBundle) {
bundlerOpts.require = bundlerOpts.require.concat(dependenciesToBundle);
if (modulesToExpose) {
bundlerOpts.require = bundlerOpts.require.concat(modulesToExpose);
}

if (externalDependencies) {
bundlerOpts.external = bundlerOpts.external.concat(externalDependencies);
// there doesnt seem to be a standard bify option for this
// so we'll put it here but manually call it after bundle
bundlerOpts.manualExternal = bundlerOpts.manualExternal.concat(
externalDependencies,
);
}

// instrument pipeline
Expand Down Expand Up @@ -280,7 +287,8 @@ function createBuildConfiguration() {
transform: [],
plugin: [],
require: [],
external: [],
// not a standard bify option
manualExternal: [],
};
return { bundlerOpts, events };
}
Expand Down Expand Up @@ -345,6 +353,8 @@ function setupBundlerDefaults(
async function bundleIt(buildConfiguration) {
const { bundlerOpts, events } = buildConfiguration;
const bundler = browserify(bundlerOpts);
// manually apply non-standard option
bundler.external(bundlerOpts.manualExternal);
// output build logs to terminal
bundler.on('log', log);
// forward update event (used by watchify)
Expand Down

0 comments on commit f9e8640

Please sign in to comment.