Skip to content
This repository has been archived by the owner on Mar 23, 2019. It is now read-only.

Migrate tc-web to neutrino v9 #157

Merged
merged 9 commits into from Oct 17, 2018
Merged

Conversation

helfi92
Copy link
Contributor

@helfi92 helfi92 commented Oct 10, 2018

Fixes #154.

legacyDecorators: true
}
},
emitWarning: process.env.NODE_ENV === 'development',

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll likely be making this change upstream soon, see:
neutrinojs/neutrino#1131 (comment)

.neutrinorc.js Outdated
'APPLICATION_NAME',
'LOGIN_STRATEGIES',
'TASKCLUSTER_ROOT_URL',
]],
(neutrino) => {
if (process.env.NODE_ENV === 'development') {
neutrino.config.devtool('cheap-module-source-map');

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd move this to the devtool option within @neutrinojs/react, since it ensures terser-webpack-plugin will be configured correctly (switching to terser is currently unreleased; see neutrinojs/neutrino#1158).

Also, the default is cheap-module-eval-source-map, which is likely faster for incremental builds (given eval), so unless there is some issue being encountered, might be best left at the default. See:
https://webpack.js.org/configuration/devtool/#devtool

.neutrinorc.js Outdated
@@ -79,6 +168,10 @@ module.exports = {
bindings: 'bindings'
}));

// TODO: Why is this needed?
neutrino.config.resolve.modules.add(MODULES);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would recommend not adding this. If not having it causes an error, could you include it in the code comment? (And I'm happy to take a look)

.neutrinorc.js Outdated
@@ -96,6 +189,8 @@ module.exports = {
.test(/JSONStream/)
.use('shebang')
.loader('shebang-loader');

console.log(JSON.stringify(neutrino.config.toConfig(), null, 2));
Copy link

@edmorley edmorley Oct 11, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Manually stringifying the config is not neccessary/gives worse output. Try:

neutrino --inspect --mode {development,production}
# or
NODE_ENV={development,production,test} neutrino --inspect

(https://master.neutrinojs.org/usage/#inspecting-the-generated-webpack-config)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

➜  taskcluster-web git:(neutrino-v9) ✗ neutrino --inspect --mode development
/Users/haali/Documents/Mozilla/projects/neutrino-dev/node_modules/webpack-chain/src/Plugin.js:11
      this.init((Plugin, args = []) => new Plugin(...args));
                                       ^

TypeError: Plugin is not a constructor
    at init (/Users/haali/Documents/Mozilla/projects/neutrino-dev/node_modules/webpack-chain/src/Plugin.js:11:40)
    at Object.toConfig (/Users/haali/Documents/Mozilla/projects/neutrino-dev/node_modules/webpack-chain/src/Plugin.js:42:22)
    at clean.Object.assign.plugins.plugins.values.map.plugin (/Users/haali/Documents/Mozilla/projects/neutrino-dev/node_modules/webpack-chain/src/Config.js:125:61)
    at Array.map (<anonymous>)
    at module.exports.toConfig (/Users/haali/Documents/Mozilla/projects/neutrino-dev/node_modules/webpack-chain/src/Config.js:125:40)
    at module.exports.toString (/Users/haali/Documents/Mozilla/projects/neutrino-dev/node_modules/webpack-chain/src/Config.js:137:41)
    at Object.output (/Users/haali/Documents/Mozilla/projects/neutrino-dev/packages/neutrino/index.js:27:37)
    at Object.<anonymous> (/Users/haali/Documents/Mozilla/projects/neutrino-dev/packages/neutrino/bin/neutrino.js:9:20)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like the globally yarn linked version of Neutrino is using an older version of webpack-chain. I would either:

  1. run yarn neutrino ... (in the hope that it favours the copy of Neutrino in the local node_modules)
  2. remove the yarn link for neutrino
  3. update the neutrino-dev source directory to master and run yarn to install the latest version of deps

(I would suggest 1/2, otherwise we'll be debugging Neutrino master rather than the known release version, which is not what yarn start will be using)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I am running a linked version of Neutrino. Running grep "webpack-chain" node_modules/neutrino/package.json shows "webpack-chain": "^4.11.0",. The update to webpack-chain was merged two days ago. Is it possible that it hasn't been published yet?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If neutrino is on PATH (ie neutrino works and not just yarn neutrino), it's a linked copy, or else PATH has been manually adjusted.

That grep command is a red herring, since that will be grepping the local node_modules copy, not the copy that's being used from the linked neutrino.

Try running this:
ls -al $(yarn global bin)/neutrino

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing the linked version of Neutrino works! Many thanks!

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome :-)

karma.conf.js Outdated

process.env.NODE_ENV = process.env.NODE_ENV || 'test';

module.exports = neutrino().karma();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Missing end of file newline)

'react/no-did-mount-set-state': 'off',
}
}
env: [

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it helps, this env option now also supports the object-form that can take defaults for each variable.

.neutrinorc.js Outdated
// TODO: Why is this needed?
neutrino.config.resolve.modules.add(MODULES);
// neutrino.config.resolveLoader.modules.add(MODULES);

neutrino.config.output.publicPath('/');

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be set via the @neutrinojs/react options now, which will also ensure the devserver equivalent option is set to a matching value automatically.

@helfi92
Copy link
Contributor Author

helfi92 commented Oct 12, 2018

Blocked by neutrinojs/neutrino#1166.

package.json Outdated
"build": "yarn create:fragment-matcher && dotenv webpack -- --mode production",
"start": "dotenv webpack-dev-server -- --mode development",
"test": "karma start --single-run",
"lint": "eslint --cache --format codeframe --ext mjs,js src test",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be --ext mjs,jsx,js

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, that was silly from my end. Sorry for that.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't see it the first time I looked either 😆

@helfi92 helfi92 changed the title [WIP] Migrate tc-web to neutrino v9 Migrate tc-web to neutrino v9 Oct 15, 2018
@helfi92 helfi92 force-pushed the neutrino-v9 branch 2 times, most recently from 270c712 to 765547f Compare October 16, 2018 17:45
@helfi92
Copy link
Contributor Author

helfi92 commented Oct 16, 2018

OK, I think this is ready. I'll merge after #160 if there are no objections.

/cc @djmitche.

@djmitche
Copy link
Contributor

None from me!

Copy link

@edmorley edmorley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm :-)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants