Skip to content

Commit 41a2c39

Browse files
committed
fix(build): babel cache caused DRAGGABLE_DEBUG to ship
That was frustrating to find - babel's cacheIdentifier does not include the contents of webpack config, so changing it may cause you to ship env variables you don't mean to ship
1 parent deb5d9c commit 41a2c39

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ lint:
1616
@$(BIN)/eslint lib/* lib/utils/* specs/*
1717
@$(BIN)/tsc -p typings
1818

19-
build: build-cjs build-esm build-web
19+
build: clean build-cjs build-esm build-web
2020

2121
build-cjs: $(BIN)
2222
$(BIN)/babel --out-dir ./build/cjs ./lib
@@ -38,7 +38,7 @@ test-phantom: $(BIN)
3838
@NODE_ENV=test $(BIN)/karma start karma-phantomjs.conf.js
3939

4040
dev: $(BIN) clean
41-
$(BIN)/webpack-dev-server
41+
env DRAGGABLE_DEBUG=1 $(BIN)/webpack-dev-server
4242

4343
node_modules/.bin: install
4444

webpack.config.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,19 +49,17 @@ module.exports = (env, argv) => ({
4949
test: /\.(?:js|es).?$/,
5050
loader: 'babel-loader',
5151
options: {
52-
cacheDirectory: true,
52+
cacheDirectory: false, // intended, have had bugs with env like DRAGGABLE_DEBUG in the past
5353
},
5454
exclude: /(node_modules)/
5555
}
5656
]
5757
},
5858
plugins: [
5959
new webpack.EnvironmentPlugin({
60-
// Default values
61-
DRAGGABLE_DEBUG: (process.env.DRAGGABLE_DEBUG || ''),
62-
NODE_ENV: ['development', 'production'].includes(argv.mode) ?
63-
argv.mode :
64-
(process.env.NODE_ENV || 'production'),
60+
// these are default values
61+
DRAGGABLE_DEBUG: false,
62+
NODE_ENV: ['development', 'production'].includes(argv.mode) ? argv.mode : 'production'
6563
}),
6664
// Scope hoisting
6765
new webpack.optimize.ModuleConcatenationPlugin(),

0 commit comments

Comments
 (0)