Skip to content

Commit

Permalink
add all local packages to common externals (#2328)
Browse files Browse the repository at this point in the history
* add all local packages to common externals
so they never get bundled in each other

* use expanded externals syntax

* whitespace
  • Loading branch information
giladgray authored Apr 16, 2018
1 parent d24e88e commit fd70406
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 16 deletions.
42 changes: 42 additions & 0 deletions packages/webpack-build-scripts/externals.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Copyright 2018 Palantir Technologies, Inc. All rights reserved.
* Licensed under the terms of the LICENSE file distributed with this project.
*/

module.exports = externalize({
"@blueprintjs/core": ["Blueprint", "Core"],
"@blueprintjs/icons": ["Blueprint", "Icons"],
"@blueprintjs/datetime": ["Blueprint", "Datetime"],
"@blueprintjs/labs": ["Blueprint", "Labs"],
"@blueprintjs/select": ["Blueprint", "Select"],
"@blueprintjs/table": ["Blueprint", "Table"],
"@blueprintjs/timezone": ["Blueprint", "Timezone"],
"classnames": "classNames",
"dom4": "window",
"jquery": "$",
"moment": "moment",
"moment-timezone": "moment",
"react": "React",
"react-transition-group": "ReactTransitionGroup",
"react-day-picker": "DayPicker",
"react-dom": "ReactDOM",
});

/**
* Generates a full webpack `external` listing declaring names for various module formats.
* @param {Record<string, string | string[]>} externals
*/
function externalize(externals) {
const newExternals = {}
for (const pkgName in externals) {
if (externals.hasOwnProperty(pkgName)) {
newExternals[pkgName] = {
commonjs: pkgName,
commonjs2: pkgName,
amd: pkgName,
root: externals[pkgName],
}
}
}
return newExternals;
}
18 changes: 2 additions & 16 deletions packages/webpack-build-scripts/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,10 @@

const baseConfig = require("./webpack.config.base");
const karmaConfig = require("./webpack.config.karma");
const COMMON_EXTERNALS = require("./externals");

module.exports = {
baseConfig,
karmaConfig,
COMMON_EXTERNALS: {
"@blueprintjs/core": "var Blueprint.Core",
"@blueprintjs/datetime": "var Blueprint.Datetime",
"@blueprintjs/labs": "var Blueprint.Labs",
"@blueprintjs/table": "var Blueprint.Table",
"classnames": "classNames",
"dom4": "window",
"jquery": "$",
"moment": "moment",
"moment-timezone": "moment",
"react": "React",
"react-transition-group": "ReactTransitionGroup",
"react-day-picker": "DayPicker",
"react-dom": "ReactDOM",
"tether": "Tether",
},
COMMON_EXTERNALS,
};

1 comment on commit fd70406

@blueprint-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add all local packages to common externals (#2328)

Preview: documentation | landing | table

Please sign in to comment.