nekr / async-module-loader Goto Github PK
View Code? Open in Web Editor NEWThis project forked from webpack-contrib/bundle-loader
bundle loader for webpack
License: MIT License
This project forked from webpack-contrib/bundle-loader
bundle loader for webpack
License: MIT License
I'm using your fork in a project. It's just what I needed, thanks for this.
But I'm having an issue, I'm always hitting the fail callback. Do the number of modules that return matter or something?
When I do this:
require.ensure(['layouts/admin/admin-layout'], function(require) {
var component = require('layouts/admin/admin-layout');
console.log(component);
}, 'admin');
I get what I expect, the exports object. But when I do this:
require('async-module?name=admin!layouts/admin/admin-layout')(
function success(component) {
console.log('success');
},
function fail() {
console.log('fail');
}
);
I always get the fail.
This is my webpack.config:
var webpack = require('webpack');
var StatsWriterPlugin = require('webpack-stats-plugin').StatsWriterPlugin;
var AsyncModulePlugin = require('async-module-loader/plugin');
var plugins = [
new AsyncModulePlugin(),
new StatsWriterPlugin({
fields: null
})
];
// if (process.env.NODE_ENV === 'production' && !Meteor.isCordova) {
// plugins.push(new webpack.optimize.CommonsChunkPlugin('common', 'common.web.js'));
// }
module.exports = {
entry: './entry',
plugins: plugins,
output: {
chunkFilename: '[name]-[id].non-entry-chunk.web.js'
},
module: {
loaders: [
{ test: /\.jade/, loader: 'template-html-loader' }
]
}
};
Also, the network tab in chrome shows that the chunk was requested, and the response is 200 OK, with this contents (no whitespace above or below), in both scenarios. I repeat, same response in both scenarios. That's what's killing me:
webpackJsonp([1],{
/***/ 96:
/***/ function(module, exports, __webpack_require__) {
/**
* Admin Layout
*
* Default markup shared by all admin entry points
*/
//===== STYLE ================================================================
//===== JS ===================================================================
//===== DEFINE COMPONENT =====================================================
module.exports = MD.Vue.extend({
template: __webpack_require__(97)
});
/***/ },
/***/ 97:
/***/ function(module, exports) {
module.exports = "<div class=\"admin-layout\"><p>This works as the layout for the admin stuff</p><router-view><p>this is content that can be accessed in the routed\ncomponent through the slot tag</p></router-view></div>"
/***/ }
});
//# sourceMappingURL=admin-1.non-entry-chunk.web.js.map
I don't really know if this is expecte behaviour and I just don't get what bundle-loader should be doing, or there's some legitimate issue going on.
Hope it's something small. Again, thanks for your fork, really nice.
i want use the loader load the remote file
require('async-module!http://xx.min.js')(function onLoad(mod) { console.log(mod) // mod.doSomething(); }, function onError() { });
it's not working .
I was trying to use this loader, but encountered this issue: webpack-contrib#17
I have a work around (caching if the module loaded myself), but after debugging, its this plugin that causes the constant refetching, presumably because you want retries after failures. Is it possible to not cause a refetch if the bundle is present?
Also, could you explain the memory leak this helps prevent?
Thanks!
Method require.ensure
in webpack 2.1.0-beta.25 now return a Promise, so with this loader i get exception: Uncaught TypeError: Cannot read property 'catch' of undefined
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.