-
Notifications
You must be signed in to change notification settings - Fork 213
@neutrinojs/library externals cause Karma "Uncaught ReferenceError: require is not defined" #1251
Comments
Could you push the branch that's failing so I can take a look? |
Apologies, I should have sent a test case earlier. taskcluster/taskcluster-client-web#38 :) Thanks in advance. |
Thank you for the testcase, I was able to reproduce locally and have tracked it down to the following:
Fixing (1) resolves the original error, but then leaves us with: ...which brings us to:
The options appear to be: ['@neutrinojs/library', {
// ...
babel: {
presets: [
[
require.resolve('@babel/preset-env'),
{
debug: false,
useBuiltIns: 'entry',
targets: {
browsers: [
'last 2 Chrome versions',
'last 2 Firefox versions',
'last 2 Edge versions',
'last 2 Opera versions',
'last 2 Safari versions',
'last 2 iOS versions'
],
}
}
]
],
},
}], (or a -- @neutrinojs/core-contributors - thoughts about (2)? |
Hmm actually, perhaps |
Regarding ['@neutrinojs/library', {
// ...
babel: {
presets: [
[
require.resolve('@babel/preset-env'),
{
debug: false,
useBuiltIns: 'entry',
targets: {
browsers: [
'last 2 Chrome versions',
'last 2 Firefox versions',
'last 2 Edge versions',
'last 2 Opera versions',
'last 2 Safari versions',
'last 2 iOS versions'
],
}
}
]
],
},
}], This would perform a deepmerge instead of overriding. There will still be a |
Makes sense to me. |
This behaviour didn't occur when I tested locally. neutrino/packages/library/index.js Line 33 in 448c82c
|
With ['@neutrinojs/library', {
// ...
babel: {
plugins: [
require.resolve('@babel/plugin-proposal-class-properties'),
],
presets: [
[
// TODO: Override using tap() so as to not have to repeat the
// existing debug/useBuiltIns options. (Or remove entirely if
// @neutrinojs/library stops defaulting to IE 9 target.)
require.resolve('@babel/preset-env'),
{
debug: false,
useBuiltIns: 'entry',
targets: {
// Override browsers from its default value of 'ie 9'
browsers: [
'last 2 Chrome versions',
'last 2 Firefox versions',
'last 2 Edge versions',
'last 2 Opera versions',
'last 2 Safari versions',
'last 2 iOS versions'
],
}
}
]
],
},
}],
use: [
/* neutrino.config.module.rule('compile').use('babel') */
{
loader: '/Users/haali/Documents/Mozilla/projects/taskcluster-client-web/node_modules/@neutrinojs/compile-loader/node_modules/babel-loader/lib/index.js',
options: {
cacheDirectory: true,
babelrc: false,
configFile: false,
presets: [
[
'/Users/haali/Documents/Mozilla/projects/taskcluster-client-web/node_modules/@neutrinojs/library/node_modules/@babel/preset-env/lib/index.js',
{
debug: false,
useBuiltIns: 'entry',
targets: {
browsers: 'ie 9'
}
}
],
[
'/Users/haali/Documents/Mozilla/projects/node_modules/@babel/preset-env/lib/index.js',
{
debug: false,
useBuiltIns: 'entry',
targets: {
browsers: [
'last 2 Chrome versions',
'last 2 Firefox versions',
'last 2 Edge versions',
'last 2 Opera versions',
'last 2 Safari versions',
'last 2 iOS versions'
]
}
}
]
],
plugins: [
'/Users/haali/Documents/Mozilla/projects/taskcluster-client-web/node_modules/@neutrinojs/library/node_modules/@babel/plugin-syntax-dynamic-import/lib/index.js',
'/Users/haali/Documents/Mozilla/projects/taskcluster-client-web/node_modules/@babel/plugin-proposal-class-properties/lib/index.js'
]
}
}
] |
That's not what I get - check for typos? (I also refreshed yarn.lock, try that too?)
|
This wouldn't have affected the merge, but note that |
It's because they are in different directories: I'm presuming due to usage of |
Refreshing |
I've split the IE9/polyfills part out to #1279, leaving this issue to just be about There are two ways to fix this (for more context see: #1251 (comment)):
Arguments for (1) are:
Arguments for (2) are:
I think I'm leaning towards (1). @neutrinojs/core-contributors - thoughts? |
|
I think (1) is acceptable. I just pushed a fix for the double |
Bug
9.0.0-rc.0
@neutrinojs/library@9.0.0-rc.0
@neutrinojs/karma@9.0.0-rc.0
yarn v1.12.3
10.0.0
macOS High Sierra
Migrate a project from v8 to v9
Tests still run
karma start --single-run
throws an error in the terminalThe text was updated successfully, but these errors were encountered: