Skip to content

Commit 4f095b7

Browse files
author
Christopher Willis-Ford
committed
Fix use of expose-loader in playground
This fixes two problems: - module rules were not being correctly passed to webpack - now that `resolve: { symlinks: false }` has been added to the webpack config, webpack and Node disagree on the path to a module accessed through `npm link`. This means that passing `require.resolve`'s result to webpack is no longer guaranteed to work for a module `test`. Instead we now use `path.resolve` which will match webpack's idea of the path.
1 parent 2f3157b commit 4f095b7

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

webpack.config.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,12 @@ module.exports = [
5151
filename: '[name].js'
5252
},
5353
module: {
54-
rules: [
54+
rules: base.module.rules.concat([
5555
{
5656
test: require.resolve('./src/index.js'),
5757
loader: 'expose-loader?VirtualMachine'
5858
}
59-
]
59+
])
6060
}
6161
}),
6262
// Playground
@@ -84,7 +84,7 @@ module.exports = [
8484
filename: '[name].js'
8585
},
8686
module: {
87-
loaders: [
87+
rules: base.module.rules.concat([
8888
{
8989
test: require.resolve('./src/index.js'),
9090
loader: 'expose-loader?VirtualMachine'
@@ -102,18 +102,18 @@ module.exports = [
102102
loader: 'expose-loader?Blockly'
103103
},
104104
{
105-
test: require.resolve('scratch-audio'),
105+
test: path.resolve(__dirname, 'node_modules', 'scratch-audio', 'src', 'index.js'),
106106
loader: 'expose-loader?AudioEngine'
107107
},
108108
{
109-
test: require.resolve('scratch-render'),
109+
test: path.resolve(__dirname, 'node_modules', 'scratch-render', 'src', 'index.js'),
110110
loader: 'expose-loader?RenderWebGL'
111111
},
112112
{
113-
test: require.resolve('scratch-storage'),
113+
test: path.resolve(__dirname, 'node_modules', 'scratch-storage', 'src', 'index.js'),
114114
loader: 'expose-loader?Scratch.Storage'
115115
}
116-
]
116+
])
117117
},
118118
plugins: base.plugins.concat([
119119
new CopyWebpackPlugin([{

0 commit comments

Comments
 (0)