-
Notifications
You must be signed in to change notification settings - Fork 312
feature(webpack): webpack bundling support #158
Conversation
@@ -0,0 +1,3 @@ | |||
module.exports = { |
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.
Let's not add another config here. Instead let's have webpack the default, and if a custom rollup config is provided, then to use rollup instead.
return rollup(context, configFile) | ||
.catch(err => { | ||
return createBundle(context, configFile, bundleConfig) | ||
.catch((err: Error) => { |
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's prettier without Error
and that's how it's used everywhere else.
function createBundle(context: BuildContext, configFile: string, bundleConfig: BundleConfig) { | ||
if (bundleConfig.useWebpack) { | ||
return webpack(context, configFile); | ||
} else { |
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.
No else here
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.
Yep, the if->return should be enough to take care for the else case.
.catch( (err: Error) => { | ||
throw new BuildError(err); | ||
}); | ||
} else { |
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.
No else
const bundleConfig = getBundleConfig(context, null); | ||
if (bundleConfig.useWebpack) { | ||
return webpackUpdate(event, path, context, null) | ||
.catch( (err: Error) => { |
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.
Just .catch(err => {
no extra spaces like the rest of Ionic
}); | ||
} else { | ||
return rollupUpdate(event, path, context) | ||
.catch( (err: Error) => { |
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.
.catch(err =>
const rollupConfig = getRollupConfig(context, null); | ||
return rollupConfig.sourceMap; | ||
const bundleConfig = getBundleConfig(context, null); | ||
if (bundleConfig.useWebpack) { |
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.
Change this so if a custom rollup config was provided, then use rollup, otherwise always use webpack.
if (bundleConfig.useWebpack) { | ||
const webpackConfig = getWebpackConfig(context, null); | ||
return webpackGetOutputDest(context, webpackConfig); | ||
} else { |
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.
No else
if (bundleConfig.useWebpack) { | ||
// TODO - read this from webpack config (could be multiple values) | ||
return true; | ||
} else { |
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.
No Else
return bundleConfig; | ||
} | ||
|
||
const taskInfo: TaskInfo = { |
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.
Let's not create a new bundle config
|
||
const transpiledFiles = getCachedTranspiledTsFiles(); | ||
|
||
module.exports = function ionicLoader(source: any, map: any) { |
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.
Let's name this ionCompilerLoader
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.
And rename the file to ion-compiler-loader
import { BuildError, Logger } from './util/logger'; | ||
import { fillConfigDefaults, generateContext, getUserConfigFile, replacePathVars } from './util/config'; | ||
import { isAbsolute, join } from '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.
no new line
} | ||
|
||
|
||
export function createWebpackBundle(context: BuildContext, configFile: string): Promise<any> { |
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.
rename to webpackWorker
Looking good :) |
Hi @danbucholtz, I've just used ionic-app-scripts from this branch to check out if it will work. I'm getting error in sass transform part. Using rollup works just fine. The error I'm getting is:
I've traced the error to generateSassData function in sass.ts anonymous function at line 111. Webpack bundling process seems to add |
} else { | ||
// set the module files used in this bundle | ||
// this reference can be used elsewhere in the build (sass) | ||
const files = stats.compilation.modules.map((webpackObj: any) => { |
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.
@TheLarkInn, any idea why resource
might be null on some modules when I loop over them? I am filtering it out or just using context for my purposes, but it was surprising to have resources
populated correctly 999/1000ish times.
Thanks,
Dan
Publish in NPM last version |
Soon. It's not quite ready yet. Thanks, |
Hello, I'm trying this pull request and i get this error : Running 'run:before' npm script before run
module.js:457 Error: Cannot find module '../dist/index' npm ERR! Darwin 16.0.0 npm ERR! Please include the following file with any support request: Mind letting us know? https://github.com/driftyco/ionic-cli/issues Thanks |
Run Thanks, |
Thanks @danbucholtz it worked |
Hi Dan, It takes about 12seconds for the webpack to bundle. Is this normal ?@danbucholtz |
For the first run? it's very fast. For subsequent runs? it's damn slow. I have a bundle process with webpack and Ionic 2 beta.11 and first run most of the time takes 20~30 depending if i'm in a machine with SSD or not, while subsequent runs take max 4 seconds in non SSD machines. |
@Luchillo All of mine are taking 12seconds + (running on macbook pro with ssd)
|
Which version of webpack, are you using |
It's version: "2.1.0-beta.25" I basically ran this: |
Hmm, i'm about to test this new |
Anyone knows what's up with that |
"@ionic/app-scripts": "0.0.38" loose the ability to show the ts file into browser. we could not debug the code |
@jaspal27, install Thanks |
Thanks it is working with me. On Wed, Nov 2, 2016 at 10:40 PM, Dan Bucholtz notifications@github.com
Thanks, |
No description provided.