Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add all local packages to common externals #2328

Merged
merged 3 commits into from
Apr 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
};