-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Let .loadPlugins
return pundle instance
#61
Comments
Sounds rather appealing. The one problem that'll rise up is that while we could make Here's what already works with slight modifications to code :) import Pundle from 'pundle'
// create pundle instance
const pundle = new Pundle({
entry: ['index.js'],
rootDirectory: process.cwd(),
pathType: 'filePath',
moduleDirectories: ['node_modules'],
})
// load plugins
pundle.loadPlugins([
[require.resolve('babel-pundle'), {
config: {
presets: ['steelbrain']
}
}],
require.resolve('pundle-some-magical-plugin'),
])
// compile
.then(function() {
return pundle.compile()
})
// config loaders
.then(function() {
pundle.loadLoaders([
{ extensions: ['.coffee'], loader: require('pundle-coffee') },
{ extensions: ['.less'], loader: require('pundle-less') },
])
return pundle.generate({ sourceMap: true })
})
// output
.then(function(generated) {
FS.writeFileSync('./bundle.js', `${generated.contents}\n//# sourceMappingURL=bundle.js.map`)
FS.writeFileSync('./bundle.js.map', generated.sourceMap)
}).catch(function(error) {
console.error('error', error)
}) |
Fast reply! A few more question (I'm fresh & excite about this project, pardon me I haven't dig enough into the code):
|
At this point I'm honestly not sure what the name of the overwritten loaders would do but I had to find a way to tell people that they overwrote something. We could look into improving that. Pundle has two stages of module compilation
The You shouldn't compile before loaders are loaded because then the extensions those loaders register will not be understood and will likely result in an error :) |
Thanks! I forgot to say, I really love the use of Promise chains, it makes the build script flows like a stream, clean & intuitive, good work! For the overwritten loaders, I think a console warning would be good :) |
Fixed in Pundle v2Alpha1 |
This is a discussion about api: what about let
.loadPlugins
(and.compile()
,.generate()
, etc.) return promise(which resolves a pundle instance), so we can use it like this:This might looks a bit more simpler & consistent than the original example IMHO, what do you think? @steelbrain
The text was updated successfully, but these errors were encountered: