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

📦 Switch to Yarn workspaces; overhaul build system #1741

Merged
merged 26 commits into from
Nov 16, 2017
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
1b33ffb
Switch to yarn workspaces, upgrade some dev dependencies
adidahiya Oct 19, 2017
738f313
[core] fix typescript compilation
adidahiya Oct 19, 2017
a73de92
Remove require-shim.d.ts files, we now use @types/node
adidahiya Oct 19, 2017
cc924a2
[table] fix typescript compilation
adidahiya Oct 19, 2017
9cf4847
update tsconfig.json files
adidahiya Oct 19, 2017
ea85b65
[docs] fix typescript compilation
adidahiya Oct 19, 2017
0d7765e
[labs] fix typescript compilation
adidahiya Oct 19, 2017
9e88abe
[core] fix some tests
adidahiya Oct 19, 2017
567f51f
bump to webpack 3!
Oct 24, 2017
2e6b4a4
fix ts-loader errors
Oct 24, 2017
80efeb3
clean yarn.lock
Oct 24, 2017
57a6ee0
massage package.json versions to hoist as much as possible
Oct 24, 2017
0670962
upgrade site-landing and table preview to webpack 3
Oct 24, 2017
2eaa4f4
get karma webpacking
Oct 24, 2017
ddc54b0
karma serves/includes correct files
Oct 25, 2017
a127b30
:star: test compile errors now fail the build!
Oct 25, 2017
acac406
fix core and datetime tests
Oct 25, 2017
dba77e7
fix webpack-watch
Oct 25, 2017
9efda93
quick ignore ContextMenu component cuz it's untestable (not exported)
Oct 25, 2017
057f1de
bump range slider test coverage
Oct 25, 2017
98bcc9c
Fix Table test typings
cmslewis Oct 26, 2017
285f318
Comment out broken tests :/
cmslewis Oct 26, 2017
33f5eba
Merge remote-tracking branch 'origin/master' into ad/workspaces
adidahiya Oct 31, 2017
ab3b459
Merge remote-tracking branch 'origin/master' into ad/workspaces
adidahiya Nov 14, 2017
83ffd5e
Refactor build system, remove Gulp (#1786)
adidahiya Nov 16, 2017
1a3d563
Remove Gulpfile.js
adidahiya Nov 16, 2017
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
1 change: 0 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"typescript.tsdk": "./node_modules/typescript/lib",
"files.exclude": {
"**/build": true,
"**/dist": true,
"**/coverage": true,
"docs": true
},
Expand Down
1 change: 1 addition & 0 deletions .yarnrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
workspace-experimental true
15 changes: 0 additions & 15 deletions Gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,21 +97,6 @@ const projects = [
webpack: {
entry: "src/index.tsx",
dest: "dist",
localResolve: [
// locally resolve @blueprintjs packages so example components will compile
// (they all import @blueprint/* but don't actually have themselves in their node_modules)
"@blueprintjs/core",
"@blueprintjs/datetime",
"@blueprintjs/docs",
"@blueprintjs/labs",
"@blueprintjs/table",
"dom4",
"moment",
"normalize.css",
"react",
"react-addons-css-transition-group",
"react-dom",
],
},
copy: {
"resources/favicon.png": { to: ["resources/"], base: "resources/" },
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ The other packages (`site-docs` and `site-landing`) are not published to NPM as
We use [Lerna](https://lernajs.io/) to manage inter-package dependencies in this monorepo.
Builds are orchestrated via [Gulp](http://gulpjs.com/) tasks.

__Prerequisites__: Node.js v6+, Yarn v0.28+
__Prerequisites__: Node.js v8+, Yarn v1.0+

1. `git clone` this repository (or fork if you lack permissions).
1. `yarn` to install dependencies at the root of the repo.
Expand Down
15 changes: 4 additions & 11 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,29 +21,22 @@ machine:
pre:
- mkdir ~/yarn
environment:
YARN_VERSION: 0.28.4
YARN_VERSION: 1.2.1
PATH: $PATH:$HOME/$CIRCLE_PROJECT_REPONAME/node_modules/.bin
node:
version: 7.10.0
version: 8.5.0

dependencies:
cache_directories:
- ~/yarn
- ~/.cache/yarn
- ~/$CIRCLE_PROJECT_REPONAME/packages/core/node_modules
- ~/$CIRCLE_PROJECT_REPONAME/packages/datetime/node_modules
- ~/$CIRCLE_PROJECT_REPONAME/packages/docs/node_modules
- ~/$CIRCLE_PROJECT_REPONAME/packages/labs/node_modules
- ~/$CIRCLE_PROJECT_REPONAME/packages/site-docs/node_modules
- ~/$CIRCLE_PROJECT_REPONAME/packages/site-landing/node_modules
- ~/$CIRCLE_PROJECT_REPONAME/packages/table/node_modules
# non-zero exit codes in `dependencies` group will fail the build early
# so these following commands will block the build and prevent tests
override:
- curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version $YARN_VERSION
- yarn install --pure-lockfile
- echo "Checking if yarn.lock changed..." && git diff --exit-code
- yarn
- yarn bootstrap
- echo "Checking if lockfiles changed..." && git diff --exit-code
- yarn build:gulp

test:
Expand Down
28 changes: 18 additions & 10 deletions gulp/util/karma-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,42 @@
*/
"use strict";

const path = require("path");

const COVERAGE_PERCENT = 80;
const COVERAGE_PERCENT_HIGH = 90;

module.exports = function createConfig(project) {
const webpackConfigGenerator = require("./webpack-config");
const webpackConfig = webpackConfigGenerator.generateWebpackKarmaConfig(project);
// must delete this key in order to resolve root @types packages correctly.
delete webpackConfig.ts.compilerOptions.typeRoots;

const resourcesGlob = (project.id === "core" ? "." : "node_modules/@blueprintjs/*");
const filesToInclude = [
{
included: false,
pattern: "node_modules/**/*.css",
served: true,
included: true,
pattern: path.resolve("node_modules/normalize.css/normalize.css"),
watched: false,
},
// (core files are inserted here below)
{
included: false,
pattern: resourcesGlob + "/resources/**/*",
served: true,
pattern: "resources/**/*",
watched: false,
},
"dist/**/*.css",
"test/index.ts",
];

// include core's CSS in all projects
// in all other projects, include core CSS and expose resources
if (project.id !== "core") {
filesToInclude.push("node_modules/@blueprintjs/core/**/*.css");
filesToInclude.splice(1, 0, {
included: true,
pattern: path.resolve("packages/core/dist/*.css"),
watched: false,
}, {
included: false,
pattern: path.resolve("packages/core/resources/**/*"),
watched: false,
});
}

// disable code coverage for labs package (but still run tests)
Expand Down
92 changes: 46 additions & 46 deletions gulp/util/webpack-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,42 +13,36 @@ const globalName = (id) => upperFirst(camelCase(id));

const DEFAULT_CONFIG = {
devtool: "source-map",
module: {
loaders: [
// always provide JSON loader to support importing data files (see moment-timezone)
{ loader: "json-loader", test: /\.json$/ },
],
},
plugins: [
new webpack.DefinePlugin({
"process.env": {
"NODE_ENV": process.env.NODE_ENV,
},
}),
],
resolve: { extensions: ["", ".js"] },
resolve: { extensions: [".js"] },
};

// Default webpack config options with support for TypeScript files
const TYPESCRIPT_CONFIG = {
devtool: "source-map",
module: {
loaders: [
{ loader: "json-loader", test: /\.json$/ },
{ loader: "source-map-loader", test: /\.js$/ },
{ loader: "ts-loader", test: /\.tsx?$/ },
rules: [
{ test: /\.js$/, use: "source-map-loader" },
{
test: /\.tsx?$/,
use: [{
loader: "ts-loader",
options: {
// do not emit declarations since we are bundling
compilerOptions: { declaration: false },
},
}],
},
],
},
resolve: {
extensions: ["", ".js", ".ts", ".tsx"],
},
ts: {
compilerOptions: {
// do not emit declarations since we are bundling
declaration: false,
// ensure that only @types from this project are used (instead of from local symlinked blueprint)
typeRoots: ["node_modules/@types"],
},
extensions: [".js", ".ts", ".tsx"],
},
};

Expand All @@ -61,6 +55,7 @@ const EXTERNALS = {
"es6-shim": "window",
"jquery": "$",
"moment": "moment",
"moment-timezone": "moment",
"react": "React",
"react-addons-css-transition-group": "React.addons.CSSTransitionGroup",
"react-day-picker": "DayPicker",
Expand Down Expand Up @@ -96,10 +91,10 @@ module.exports = {
},
externals: EXTERNALS,
output: {
filename: `${project.id}.bundle.js`,
filename: `[name].bundle.js`,
library: ["Blueprint", globalName(project.id)],
libraryTarget: "umd",
path: path.join(project.cwd, "dist"),
path: path.resolve(project.cwd, "dist"),
},
}, DEFAULT_CONFIG);

Expand All @@ -115,30 +110,42 @@ module.exports = {
return Object.assign({}, TYPESCRIPT_CONFIG, {
devtool: "inline-source-map",
entry: {
[project.id]: `./${project.cwd}/test/index`,
[project.id]: `./${project.cwd}/test/index.ts`,
},
// these externals necessary for Enzyme harness
externals: {
"cheerio": "window",
"react/addons": true,
"react/lib/ExecutionEnvironment": true,
"react/lib/ReactContext": true,
"react-addons-test-utils": true,
},
module: Object.assign({}, TYPESCRIPT_CONFIG.module, {
postLoaders: [
{
loader: "istanbul-instrumenter",
test: /src\/.*\.tsx?$/,
},
],
}),
resolve: Object.assign({}, TYPESCRIPT_CONFIG.resolve, {
alias: {
// webpack will load react twice because of symlinked node modules
// this makes it only use one copy of React
react: path.resolve(`./${project.cwd}/node_modules/react`),
},
}),
module: {
rules: TYPESCRIPT_CONFIG.module.rules.concat({
enforce: "post",
test: /src\/.*\.tsx?$/,
use: "istanbul-instrumenter-loader",
}),
},
plugins: [
function() {
this.plugin("done", function(stats) {
if (stats.compilation.errors.length > 0) {
// tslint:disable-next-line:no-console
console.error("ERRORS in compilation. See above.");

// Pretend no assets were generated. This prevents the tests
// from running making it clear that there were errors.
stats.stats = [{
assets: [],
toJson: function () { return this; }
}];
}
return stats;
});
}
],
bail: true,
});
},

Expand All @@ -159,19 +166,12 @@ module.exports = {
output: {
filename: `${project.id}.js`,
library: project.webpack.global,
path: `${project.cwd}/${project.webpack.dest}`,
path: path.resolve(project.cwd, project.webpack.dest),
},
}, TYPESCRIPT_CONFIG, {
plugins: DEFAULT_CONFIG.plugins,
});

if (project.webpack.localResolve != null) {
returnVal.resolve.alias = project.webpack.localResolve.reduce((obj, pkg) => {
obj[pkg] = path.resolve(`./${project.cwd}/node_modules/${pkg}`);
return obj;
}, {});
}

return returnVal;
},

Expand Down
2 changes: 1 addition & 1 deletion gulp/webpack.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module.exports = (blueprint, gulp) => {

gulp.task("webpack-docs-watch", (callback) => {
// rely on editor for compiler errors during development--this results in _massive_ speed increase
configuration.ts.transpileOnly = true;
configuration.module.rules[1].use[0].options.transpileOnly = true;
// never invoke callback so it runs forever!
webpack(configuration).watch({}, webpackConfig.webpackDone());
});
Expand Down
3 changes: 2 additions & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"lerna": "2.0.0",
"lerna": "2.4.0",
"npmClient": "yarn",
"useWorkspaces": true,
"version": "independent"
}
Loading