Comments (4)
throw a exception in webpack 2.2.1
TypeError: Cannot read property 'plugin' of null
at BowerWebpackPlugin.apply (/Users/dfzq/fastman/fastman-application/node_modules/bower-webpack-plugin/lib/bower-plugin.js:70:30)
at Compiler.apply (/Users/dfzq/fastman/fastman-application/node_modules/tapable/lib/Tapable.js:306:16)
at webpack (/Users/dfzq/fastman/fastman-application/node_modules/webpack/lib/webpack.js:32:19)
at Object. (/Users/dfzq/fastman/fastman-application/server.js:10:22)
at Module._compile (module.js:435:26)
at Object.Module._extensions..js (module.js:442:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:313:12)
at Function.Module.runMain (module.js:467:10)
at startup (node.js:136:18)
from bower-webpack-plugin.
Does it support multiple main
files - I mean the situation when main
field in bower.json
is an array of values?
from bower-webpack-plugin.
I've create a "monster" on my branch and I'm not proud of it, but it somehow "works" with webpack2 - I'm able to compile quite big project with it. It is nowhere near to a pull request. I'm not able to work on it right now so I'm going to shortly describe what I've discovered during my dark magic operation and maybe this will help someone else to create the real solution. I've to also admit that my knowledge of webpack internals is really limited so many of my conclusions can be just wrong. Here it goes (to simplify I'm using standard paths and filenames in this description):
-
This plugin works on two layers of webpack processing:
- during resolution phase - it resolves
request('example-library')
into manifestFile for examplebower_components/example-library/bower.json
, - during compilation phase - it recognizes it's previous resolution (thanks to it's internal cache) and loads all sources (because in
bower.json
in themain
attribute you can have an array of files) compiled into "artificial" javascript module,
- during resolution phase - it resolves
-
In new version of webpack these steps had been separated
- we have
resolve.plugins
option - in such a case pluginapply
method has access toResolver
instance - and main
plugins
option - in this caseapply
receivesComipler
as an argument
- we have
-
I'm not entirely sure, but it seems, that it is not straightforward to mix these two steps in single plugin any more (but I can be wrong and maybe it is possible from the main
plugin
level to register someresolve
plugins), -
On my branch I've just used the same instance in these two places and moved "resolution cache" to the instance level
-
And the last conclusion: It is real fun and pleasure to hack on this plugin because it has really nice test suite (code on my branch passes 50% of tests ;-) and you can check your progress all the time !!!
So here is my limited understanding of this plugin workflow after two hours of hacking on it and here are my modifications - many changes are hacks which are related to the test suite configuration. My branch misses multiple options (it doesn't read global resolve.modules
, it ignores exclude
packages, it doesn't handle custom manifest naming etc.), but the main processing works.
from bower-webpack-plugin.
There is no need for a plugin anymore with webpack 2 --
webpack/webpack#2324 (comment)
{
modules: [path.resolve(__dirname, "app"), "node_modules"]
// (was split into `root`, `modulesDirectories` and `fallback` in the old options)
// In which folders the resolver look for modules
// relative paths are looked up in every parent folder (like node_modules)
// absolute paths are looked up directly
// the order is respected
descriptionFiles: ["package.json", "bower.json"],
// These JSON files are read in directories
mainFields: ["main", "browser"],
// These fields in the description files are looked up when trying to resolve the package directory
mainFiles: ["index"]
// These files are tried when trying to resolve a directory
aliasFields: ["browser"],
// These fields in the description files offer aliasing in this package
// The content of these fields is an object where requests to a key are mapped to the corresponding value
extensions: [".js", ".json"],
// These extensions are tried when resolving a file
enforceExtension: false,
// If false it will also try to use no extension from above
moduleExtensions: ["-loader"],
// These extensions are tried when resolving a module
enforceModuleExtension: false,
// If false it's also try to use no module extension from above
alias: {
jquery: path.resolve(__dirname, "vendor/jquery-2.0.0.js")
}
// These aliasing is used when trying to resolve a module
}
from bower-webpack-plugin.
Related Issues (20)
- Resolving dependencies inside dependencies HOT 8
- Error when npm module contains a bower.json file HOT 5
- BowerWebpackPlugin preventing exposed vars from getting to the window HOT 2
- How to resolve a css file in bower_components HOT 3
- some bower_components can`t require HOT 5
- Resolve priority HOT 4
- Add 'overrides' support HOT 10
- Importing modules with the proper UMD definition messes up globals
- Can't get this working with angular2
- .bowerrc directory setting is not respected
- Example missing css HOT 2
- Ecludes does not seem to work HOT 1
- Multiple manafest files ie ".bower.json" & "bower.json"
- Cannot resolve 'file' or 'directory' ./dist/debug.js HOT 8
- jQuery Plugins
- Following example gives me an import error for jQuery HOT 1
- How to resolve the issue when 'main' field is an array
- When the "main" field is an array.
- MIT License? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bower-webpack-plugin.