-
Notifications
You must be signed in to change notification settings - Fork 234
Conversation
src/Config.js
Outdated
@@ -89,6 +90,11 @@ module.exports = class extends ChainedMap { | |||
} | |||
|
|||
case 'entry': { | |||
if (typeof value === 'string') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you provide an example of what the intent is with this? Given a string value of entry, what entries does it generate in the config?
src/Config.js
Outdated
@@ -89,6 +90,11 @@ module.exports = class extends ChainedMap { | |||
} | |||
|
|||
case 'entry': { | |||
if (typeof value === 'string') { | |||
const path = require('path'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move require to the top of the file.
src/Config.js
Outdated
if (typeof value === 'string') { | ||
const path = require('path'); | ||
const name = path.basename(value); | ||
return this.entry(name).merge([value]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Insert line between declaration and return.
src/Config.js
Outdated
const path = require('path'); | ||
const name = path.basename(value); | ||
return this.entry(name).merge([value]); | ||
} | ||
return Object |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Insert line between conditional and return.
src/Config.js
Outdated
@@ -100,6 +106,17 @@ module.exports = class extends ChainedMap { | |||
.forEach(name => this.plugin(name).merge(value[name])); | |||
} | |||
|
|||
case 'plugins': { | |||
if (Array.isArray(value)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to only handle the case when plugins is an array. Is that intended? Is this supposed to fall through to the next case if it's not an array?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes it is intended since plugins can only be an array https://webpack.js.org/configuration/plugins/#plugins
though we could add a warning if it is not an array?
src/Config.js
Outdated
if (Array.isArray(value)) { | ||
return value | ||
.forEach((plugin, index) => { | ||
if (plugin.name) index = plugin.name; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use multiline conditionals:
if (plugin.name) {
// ...
}
src/Config.js
Outdated
if (Array.isArray(value)) { | ||
return value | ||
.forEach((plugin, index) => { | ||
if (plugin.name) index = plugin.name; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So if there is no name, the index becomes the name, i.e. a number?
src/Config.js
Outdated
return value | ||
.forEach((plugin, index) => { | ||
if (plugin.name) index = plugin.name; | ||
if (isClass(plugin)) this.plugin(index).plugin(plugin); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of pulling in another dependency, couldn't this just check if the plugin is a function?
if (typeof plugin === 'function') {
this.plugin(index).plugin(plugin);
}
src/Config.js
Outdated
if (Array.isArray(value)) { | ||
return value | ||
.forEach((plugin, index) => { | ||
if (plugin.name) index = plugin.name; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To save from overwriting the index variable, use a variable, probably name
:
const name = plugin.name || index;
src/Config.js
Outdated
.forEach((plugin, index) => { | ||
if (plugin.name) index = plugin.name; | ||
if (isClass(plugin)) this.plugin(index).plugin(plugin); | ||
else this.plugin(index).init((args) => plugin); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it would be nice to decide on a function here to tap args again if the plugin provides some sort of standard interface for it.
📦⬇ remove is-class dep
👕⚒ fixed linting according to review 🎁 added string merging for output
📝 added todo for using latest webpack as it requires absolute paths
@eliperelman updated |
@@ -23,6 +23,6 @@ | |||
}, | |||
"devDependencies": { | |||
"ava": "^0.18.2", | |||
"webpack": "^2.2.1" | |||
"webpack": "2.2.1" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can leave this change out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if it isn't changed, it breaks unless you install with yarn unless the absolute paths are fixed
src/Config.js
Outdated
@@ -1,3 +1,4 @@ | |||
const path = require('path'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Destructure this into:
const { basename, dirname } = require('path');
* | ||
*/ | ||
case 'output': { | ||
if (typeof value === 'string') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return this.output.merge(typeof value !== 'string' ? value : {
path: dirname(value),
filename: basename(value)
});
src/Config.js
Outdated
case 'entry': { | ||
if (typeof value === 'string') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't understand the rationale for this one. Why should './src/front/index.js'
map to an entry point named index
? Many directories could contain a file named index.js
, without the justification that they should be bundled together. It seems the using the parent directory name would be a better fit, e.g. front
entry. Making this conventional I think will have unintended consequences.
Just need to understand why we should go this route as opposed to using a different name (or whether accepting a string at all here is a good idea).
* merge an array of plugins | ||
*/ | ||
case 'plugins': { | ||
if (Array.isArray(value)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm still having trouble seeing why we need this to be an array, when we already have an dictionary collection. It's essentially this:
plugin: {
name: {
plugin: Plugin,
args: [args]
}
}
versus something like this I'm assuming:
plugins: [
{ name, plugin: Plugin, args: [args] }
]
How is the current plugin interface lacking?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#21 (comment)
if I merge in a config of existing plugins, it does not merge properly
by plugin interface I mean if there is a plugin that results from a .toConfig
, or, from merging in an existing webpack config
@@ -150,6 +216,7 @@ test('validate with entry', t => { | |||
t.is(errors.length, 0); | |||
}); | |||
|
|||
test.todo('resolve entry & output with latest webpack'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There should be a space in-between tests.
@@ -54,6 +54,72 @@ test('entry', t => { | |||
t.deepEqual(config.entryPoints.get('index').values(), ['babel-polyfill', 'src/index.js']); | |||
}); | |||
|
|||
test('merge entry as string with existing entries, with the same prop', t => { | |||
const configObj = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This variable doesn't appear to be used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
test/Config.js
Outdated
|
||
config.merge(configObj); | ||
|
||
const backToObj = config.toConfig(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't appear to be used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
test/Config.js
Outdated
entry: 'src/index.js' | ||
}; | ||
const config = new Config(); | ||
config.merge(configObj); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There should be a blank line between variables and other statements in a function.
@@ -28,6 +28,7 @@ module.exports = class extends ChainedMap { | |||
const value = obj[key]; | |||
|
|||
switch (key) { | |||
case 'rules': |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rules doesn't have a high-level API, so I'm not sure why this is needed. All other high-level API interfaces are singular.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
neutrinojs/neutrino#151 - painfully debug typo in webpack-chain neutrinojs/webpack-chain#21 - update webpack-chain pr neutrinojs/webpack-chain#19 - updating foldername to fliphub from fliphub2 - example/temps working - set rollupdefaults to preset defaults - handle replacing things in rollup that are webpack and fusebox only with entry points - adding resolveall to rollup - update webpack-chain pr again - update presets to use fuse-box instead of fsbx - better resolving with prettier relative paths - splitting and updating node example - splitting and updating canadas example - add .name to chained by default - add outputToString method on bundler config for support from webpack to fusebox and rollup - fix double slash in alias to fusebox - add PresetWeb to move react/inferno/web out of PresetBabel - change .resolve.alias to .alias for fusebox and rollup - add rollup-plugin-alias - updating empty example - update rollup defaults to resolve output paths from webpack... - html preset part 3 - pr updating fuse-box spinner fuse-box/fuse-box#442 - decorating fliplog with .color(text) shorthands - making fliplog implement PSR-3 - making fliplog callable as a fn - make extend-hidden object - fix extra : used in fliplog if no text or title - make does-include module with {any, all} - update fliphub-core pkg json - update flipfile pkgjson - cleaning some folders like yuge into playground - cleaning old flipchain from modules/next - adding missing pkjsons for lerna - pkgjson for emoji-by-name - updating fosho to use extend-hidden - rename extend-hidden to expose-hidden - update inspector-gadget docs - publish packages - make repo for fliplog - update readme badge url for codestyle - update gitter room - update gitter badge - fix some screenshots - publish the modules - push to github # part 55 - mar 27 17 - move .each and .all to izz from fosho - testing other bundlers to ensure output for all :-) - make fusebox default set flipto - make bundlerflipper re-init and re-merge if to is changed - add del to flipfile - add log to fliphub exports - clean neutrino-preset - update neutrino preset toWebpack fn as workflow changes where the config and bundler api are - continue on examples - fix toConfig for contexts -> have them use bundler.api.config if available - neutrino with newest version breaking with immutables, revert some changes, make issue # part 54 - mar 26 17 - going to add tests for bundling, make sure it all works, then good to go :-) - remove generated mocks woops - update todos, remove dist - add isRizzle, add power assert, convert all fuse tests to 10x smaller scoped - test preset inheritence - test multiple apps - test default to webpack - test flipto rollup - verbose reporting for fosho logging diffs and failures - build tests - fix calling .build on context on buildSync op - adding buildSync test - adding buildFast test - adding build output exists test - adding auto calling setup in ops if it was not explicitly called - add safety to stop the spinner in fliplog - starting defaults - adding defaults prop to configs - adding to configDefaulter - adding monorepo mode for resolving easier - fixing alias resolve - fixing preset merging when args exist and they are undefined which triggered falsy condition and did not set them over - extending fusebox default preset - fix regression in merging configs in bundler flipper
Closing as stale, feel free to open a new PR, maybe where we can have an |
"📌"
string entry point[🔌]
plugin array