Closed sendilkumarn closed 7 years ago
Some things I think worth asking that I'll leave here:
npm
scripts or node scripts. Thoughts?index.html
file is going to be used. I know if Laravel there are .twig
partials which can compile to html markup. This can be a challenge for multipage apps (one I'm trying to solve. Good to know up front how you plan on configuring html-webpack-plugin
which I always recommend using. Do you want to have the webpack configuration (whether it be in a JS file with the node api, or webpack.config.js) to the user?
IMO, I think we have to give that to users, the decision is upto them to use what. We can give an optimum solution but it is upto them to play around.
If this replaces gulp, then the defacto method of running scripts would be through npm scripts or node scripts. Thoughts?
Yes of course, with ng2 we are planning to remove bower
completely. so npm
will be defacto
@TheLarkInn regarding your questions
@TheLarkInn here are the questions I wanted to ask regarding webpack and also will give some insights into our architecture and limitations since its a java app @jhipster/developers please correct me if I'm wrong about anything
a) We have 2 profiles for build dev
and prod
which are triggered by maven/gradle
b) Since we generate a maven/gradle project it needs to follow certain conventions for the frontend assets
src/main/webapp
folder and we have the angular code in the app
folder here along with index.html
. The content folder holds static assets like css, images etc.
test/javascript/
folder. It means the test files are not in same folder as the src like how Angular CLI does. This can be changed if required for JS tests but our users are used to this since the Java/Gatling/Cucumber tests will be in the test
folder alongside src
foldertarget|build/www
folder and all assets including js, css, html, images needs to be here. Thats why currently we use a gulp task to copy the required node_modules folders to the www/vendor
folder. I dont know if there is a way to do this without copying all the node modules here
c) Currently we have ts source in src/main/webapp/app
and we compile this to js into the target|build/www/app
folder with sourcemaps. we would like to keep the src clean without compiled js/sourcemaps there
d) during development we use gulp serve
task to run a browsersync instance with live reload along with gulp watch. Here we do tasks like clean target/www
, copy node_module plugins to target/www/vendor
, wiredep/inject files to index.html
, create ng2 constants, copy i18n files, ts compile, some troubleshooting and finally spawn a browsersync and start a watch which compiles changed ts files, copies html into vendor folder, compiles sass on the fly etc.
e) during production build we do all the above and additionally we do tasks like optimize html files and convert them to a js map template cache, optimize image, svg files, compile sass, auto prefix, minify and uglify css with revisioning and sourcemaps, minify and uglify js into vendor.js and app.js with revisioning and sourcemaps etc. we also copy all the static assets into the www
folder
f) apart from this we also trigger karma and protractor tests from gulp
Hope I covered most use cases
Now my questions
Sorry for such long comment
Thanks for all the questions!! I will be away from the interwebs for most of today (jury duty). So if I don't respond here right away that's why.
@TheLarkInn no worries take your time
@TheLarkInn did you find time to have a look at this?
@flaviencathala I have fixed some issues in the ng2-webpack branch but still there are few as below
Can you try to create a fresh app withh all default options from this branch and try it out.
ERROR in ./src/main/webapp/content/images/logo-jhipster.png
Module build failed: Error: /home/deepu/workspace/temp/jh-webpack/node_modules/pngquant-bin/vendor/pngquant: error while loading shared libraries: libpng12.so.0: cannot open shared object file: No such file or directory
at Promise.all.then.arr (/home/deepu/workspace/temp/jh-webpack/node_modules/execa/index.js:170:11)
at process._tickCallback (internal/process/next_tick.js:103:7)
@ ./~/css-loader!./src/main/webapp/content/css/main.css 6:2439-2477
@ ./src/main/webapp/content/css/main.css
@ ./src/main/webapp/app/vendor.ts
ERROR in ./src/main/webapp/content/images/hipster2x.png
Module build failed: Error: /home/deepu/workspace/temp/jh-webpack/node_modules/pngquant-bin/vendor/pngquant: error while loading shared libraries: libpng12.so.0: cannot open shared object file: No such file or directory
at Promise.all.then.arr (/home/deepu/workspace/temp/jh-webpack/node_modules/execa/index.js:170:11)
at process._tickCallback (internal/process/next_tick.js:103:7)
@ ./~/css-loader!./src/main/webapp/content/css/main.css 6:3803-3837
@ ./src/main/webapp/content/css/main.css
@ ./src/main/webapp/app/vendor.ts
ERROR in ./src/main/webapp/content/images/hipster.png
Module build failed: Error: /home/deepu/workspace/temp/jh-webpack/node_modules/pngquant-bin/vendor/pngquant: error while loading shared libraries: libpng12.so.0: cannot open shared object file: No such file or directory
at Promise.all.then.arr (/home/deepu/workspace/temp/jh-webpack/node_modules/execa/index.js:170:11)
at process._tickCallback (internal/process/next_tick.js:103:7)
@ ./~/css-loader!./src/main/webapp/content/css/main.css 6:3225-3257
@ ./src/main/webapp/content/css/main.css
@ ./src/main/webapp/app/vendor.ts
ERROR in ./src/main/webapp/content/css/main.css
Module build failed: ModuleBuildError: Module build failed: Error: /home/deepu/workspace/temp/jh-webpack/node_modules/pngquant-bin/vendor/pngquant: error while loading shared libraries: libpng12.so.0: cannot open shared object file: No such file or directory
at Promise.all.then.arr (/home/deepu/workspace/temp/jh-webpack/node_modules/execa/index.js:170:11)
at process._tickCallback (internal/process/next_tick.js:103:7)
at /home/deepu/workspace/temp/jh-webpack/node_modules/webpack/lib/NormalModule.js:143:35
at /home/deepu/workspace/temp/jh-webpack/node_modules/loader-runner/lib/LoaderRunner.js:359:11
at /home/deepu/workspace/temp/jh-webpack/node_modules/loader-runner/lib/LoaderRunner.js:225:18
at context.callback (/home/deepu/workspace/temp/jh-webpack/node_modules/loader-runner/lib/LoaderRunner.js:106:13)
at imagemin.buffer.then.catch.err (/home/deepu/workspace/temp/jh-webpack/node_modules/image-webpack-loader/index.js:48:9)
ERROR in /home/deepu/workspace/temp/jh-webpack/node_modules/extract-text-webpack-plugin/loader.js?{"omit":1,"remove":true}!/home/deepu/workspace/temp/jh-webpack/node_modules/style-loader/index.js!/home/deepu/workspace/temp/jh-webpack/node_modules/css-loader/index.js!/home/deepu/workspace/temp/jh-webpack/src/main/webapp/content/css/main.css doesn't export content
ERROR in [default] /home/deepu/workspace/temp/jh-webpack/src/main/webapp/app/blocks/config/localstorage.config.ts:1:9
Module '"/home/deepu/workspace/temp/jh-webpack/node_modules/ng2-webstorage/dist/app"' has no exported member 'KeyStorageHelper'.
ERROR in [default] /home/deepu/workspace/temp/jh-webpack/src/main/webapp/app/shared/language/jhi-missing-translation.config.ts:3:13
Class 'JhiMissingTranslationHandler' incorrectly implements interface 'MissingTranslationHandler'.
Types of property 'handle' are incompatible.
Type '(key: string) => string' is not assignable to type '(params: MissingTranslationHandlerParams) => any'.
Types of parameters 'key' and 'params' are incompatible.
Type 'MissingTranslationHandlerParams' is not assignable to type 'string'.
I merged the PR but i'm keeping the ticket open as we have some things to do. I'm gonna jot them down above
@flaviencathala can you let me know which items in TODO above can be marked as done?
btw really great job @flaviencathala sorry if I was bit tough :)
@TheLarkInn will you be able to take a look at what we done and give your inputs?
@deepu105 Thank you ! :-) Except the migration to webpack nothing is 100% done yet, there is still a few ng1 code :-/ @victorADS is working on interceptors.
Can you mark down if there are more TODO here please
Thanks & regards, Deepu
On 30 Nov 2016 10:21 a.m., "Flavien Cathala" notifications@github.com wrote:
@deepu105 https://github.com/deepu105 Thank you ! :-) Except the migration to webpack nothing is 100% done yet, there is still a few ng1 code :-/ @victorADS https://github.com/victorADS is working on interceptors.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/jhipster/generator-jhipster/issues/4392#issuecomment-263823351, or mute the thread https://github.com/notifications/unsubscribe-auth/ABDlF7j4G9SHUPDWXWSwZTx6GYld322Tks5rDUAcgaJpZM4Kh767 .
[x] Fix current bugs (angular-2 is broken)
[ ] Migrate all ng1 code into ng2 (blocks)
[ ] Remove all the ng1 code left (upgrade adapters)
@deepu105 Are you ok with this ?
Awesome job guys, can't wait to setup my new machine to test this and help you finish it :smile:
@flaviencathala im still getting the same errors with images as above after your fixes as well. I think it has somthing to do with these errors during npm install
BTW im on linux
gifsicle@3.0.4 postinstall /home/deepu/workspace/temp/jh-webpack/node_modules/gifsicle
> node lib/install.js
✔ gifsicle pre-build test passed successfully
> mozjpeg@4.1.1 postinstall /home/deepu/workspace/temp/jh-webpack/node_modules/mozjpeg
> node lib/install.js
âš The `/home/deepu/workspace/temp/jh-webpack/node_modules/mozjpeg/vendor/cjpeg` binary doesn't seem to work correctly
âš mozjpeg pre-build test failed
ℹ compiling from source
✖ Error: autoreconf -fiv && ./configure --disable-shared --prefix="/home/deepu/workspace/temp/jh-webpack/node_modules/mozjpeg/vendor" --bindir="/home/deepu/workspace/temp/jh-webpack/node_modules/mozjpeg/vendor" --libdir="/home/deepu/workspace/temp/jh-webpack/node_modules/mozjpeg/vendor" && make --jobs=8 && make install --jobs=8
Command failed: autoreconf -fiv
/bin/sh: 1: autoreconf: not found
at ChildProcess.exithandler (child_process.js:206:12)
at emitTwo (events.js:106:13)
at ChildProcess.emit (events.js:191:7)
at maybeClose (internal/child_process.js:877:16)
at Socket.<anonymous> (internal/child_process.js:334:11)
at emitOne (events.js:96:13)
at Socket.emit (events.js:188:7)
at Pipe._handle.close [as _onclose] (net.js:498:12)
> optipng-bin@3.1.2 postinstall /home/deepu/workspace/temp/jh-webpack/node_modules/optipng-bin
> node lib/install.js
✔ optipng pre-build test passed successfully
> pngquant-bin@3.1.1 postinstall /home/deepu/workspace/temp/jh-webpack/node_modules/pngquant-bin
> node lib/install.js
âš The `/home/deepu/workspace/temp/jh-webpack/node_modules/pngquant-bin/vendor/pngquant` binary doesn't seem to work correctly
âš pngquant pre-build test failed
ℹ compiling from source
✖ Error: pngquant failed to build, make sure that libpng-dev is installed
at ChildProcess.exithandler (child_process.js:206:12)
at emitTwo (events.js:106:13)
at ChildProcess.emit (events.js:191:7)
at maybeClose (internal/child_process.js:877:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
> yo@1.8.5 postinstall /home/deepu/workspace/temp/jh-webpack/node_modules/yo
> yodoctor
did you forget to add any lib to package.json
This error has been produced with the default settings to the console:
main.bundle.js:44100 EXCEPTION: Cannot read property 'Symbol(Symbol.iterator)' of undefinedErrorHandler.handleError @ main.bundle.js:44100 main.bundle.js:44105 ORIGINAL STACKTRACE:ErrorHandler.handleError @ main.bundle.js:44105 main.bundle.js:44106 TypeError: Cannot read property 'Symbol(Symbol.iterator)' of undefined at Object.subscribeToResult (main.bundle.js:1319) at CatchSubscriber.error (main.bundle.js:80107) at CatchSubscriber.error (main.bundle.js:80102) at XMLHttpRequest.onLoad (main.bundle.js:46249) at ZoneDelegate.invokeTask (polyfills.bundle.js:1589) at Object.onInvokeTask (main.bundle.js:29109) at ZoneDelegate.invokeTask (polyfills.bundle.js:1588) at Zone.runTask (polyfills.bundle.js:1478) at XMLHttpRequest.ZoneTask.invoke (polyfills.bundle.js:1659)ErrorHandler.handleError @ main.bundle.js:44106 main.bundle.js:519 Uncaught TypeError: Cannot read property 'Symbol(Symbol.iterator)' of undefined(…)
@deepu105 No I don't think I forgot a lib, I use image-webpack-loader and it is supposed to install all the dependencies needed itself. This is the first time I hear about this problem.
Did you try a fresh project with node_modules installed from scratch?
Thanks & Regards, Deepu
On Wed, Nov 30, 2016 at 2:12 PM, Flavien Cathala notifications@github.com wrote:
@deepu105 https://github.com/deepu105 No I don't think I forgot a lib, I use image-webpack-loader and it is supposed to install all the dependencies needed itself. This is the first time I hear about this problem.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/jhipster/generator-jhipster/issues/4392#issuecomment-263869988, or mute the thread https://github.com/notifications/unsubscribe-auth/ABDlF0cOnNmlmv570aQ0WG4S5LMSqWA6ks5rDXZUgaJpZM4Kh767 .
@deepu105 Yes I always work this way. A lot of people already tried to clone JHipster from my webpack branch and they never had this problem. As you can see @dimeros don't have it either.
I am running this scenario on windows. Maybe it is a linux issue.
@dimeros I and @victorADS are on Ubuntu, @jdubois is on MacOS... :-/
@dimeros I fixed the critical bug you had.
@flaviencathala @victorADS I'm on ubuntu as well and its defineteley an issue coz of below fails during npm install
are you using npm or yarn? im using npm. I'll try with yarn as well
May be you already have the mozjpeg
and pngquant
binaries compiled in your system
gifsicle@3.0.4 postinstall /home/deepu/workspace/temp/jh-webpack/node_modules/gifsicle
> node lib/install.js
✔ gifsicle pre-build test passed successfully
> mozjpeg@4.1.1 postinstall /home/deepu/workspace/temp/jh-webpack/node_modules/mozjpeg
> node lib/install.js
âš The `/home/deepu/workspace/temp/jh-webpack/node_modules/mozjpeg/vendor/cjpeg` binary doesn't seem to work correctly
âš mozjpeg pre-build test failed
ℹ compiling from source
✖ Error: autoreconf -fiv && ./configure --disable-shared --prefix="/home/deepu/workspace/temp/jh-webpack/node_modules/mozjpeg/vendor" --bindir="/home/deepu/workspace/temp/jh-webpack/node_modules/mozjpeg/vendor" --libdir="/home/deepu/workspace/temp/jh-webpack/node_modules/mozjpeg/vendor" && make --jobs=8 && make install --jobs=8
Command failed: autoreconf -fiv
/bin/sh: 1: autoreconf: not found
at ChildProcess.exithandler (child_process.js:206:12)
at emitTwo (events.js:106:13)
at ChildProcess.emit (events.js:191:7)
at maybeClose (internal/child_process.js:877:16)
at Socket.<anonymous> (internal/child_process.js:334:11)
at emitOne (events.js:96:13)
at Socket.emit (events.js:188:7)
at Pipe._handle.close [as _onclose] (net.js:498:12)
> optipng-bin@3.1.2 postinstall /home/deepu/workspace/temp/jh-webpack/node_modules/optipng-bin
> node lib/install.js
✔ optipng pre-build test passed successfully
> pngquant-bin@3.1.1 postinstall /home/deepu/workspace/temp/jh-webpack/node_modules/pngquant-bin
> node lib/install.js
âš The `/home/deepu/workspace/temp/jh-webpack/node_modules/pngquant-bin/vendor/pngquant` binary doesn't seem to work correctly
âš pngquant pre-build test failed
ℹ compiling from source
✖ Error: pngquant failed to build, make sure that libpng-dev is installed
at ChildProcess.exithandler (child_process.js:206:12)
at emitTwo (events.js:106:13)
at ChildProcess.emit (events.js:191:7)
at maybeClose (internal/child_process.js:877:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
> yo@1.8.5 postinstall /home/deepu/workspace/temp/jh-webpack/node_modules/yo
> yodoctor
Ok seems like an issue with libpng12-0
used by those library. I tried to install with sudo apt-get install libpng12-0
but it says no such release candidate. I'm on Ubuntu 16.10
@deepu105 We use npm. I'm not saying there is no issue I'm saying I can't reproduce it and I have no idea from where it could come. I tried to run mozjpeg
and pngquant
but the system don't know these commands.
I know its strange
may be we can disable imagemin untill we find the source of the issue and add it to our TODO
Ok try to remove this part ?bypassOnDebug&optimizationLevel=7&interlaced=false
in webpack.common.js
line 69.
Or remove the entire line.
@deepu105 I will not be available until Monday, if you have any trouble try to see with @victorADS.
Ok I got the issue solved by installing libpng-dev sudo apt-get install libpng-dev
in ubuntu
I think we need to document this incase anyone else runs into the same
I just created a new project with the angular-2 branch and there's no information on how to run it.
└── UNMET PEER DEPENDENCY zone.js@0.7.2
npm WARN @angular/http@2.2.3 requires a peer of rxjs@5.0.0-beta.12 but none was installed.
npm WARN @angular/core@2.2.3 requires a peer of rxjs@5.0.0-beta.12 but none was installed.
npm WARN @angular/core@2.2.3 requires a peer of zone.js@^0.6.21 but none was installed.
npm WARN string-replace-webpack-plugin@0.0.4 requires a peer of webpack@^1.4.2 but none was installed.
Server app generated successfully.
Client app generated successfully.
I assumed you could run webpack
, but that doesn't work. Shouldn't we make this as simple as possible so user's familiar with webpack can run webpack
or webpack -w
?
[mraible:~/blog] 28m55s $ webpack
No configuration file found and no output filename configured via CLI option.
A configuration file could be named 'webpack.config.js' in the current directory.
Use --help to display the CLI options.
After looking at package.json
, I figured out I needed to run npm run webpack-dev
, which is a lot compared to simply gulp
.
yes we should show more info. I guess we can print the info on how to start webpack-dev or we can just autostart it after npm install
I have installed maven. Executing mvn is installed automatically.
@dimeros what do you mean?
@wmarques @sendilkumarn @jdubois we need more hands testing this
Executing the mvn command, the 'npm run webpack-dev' is executed automatically.
Yes but it doesnt launch a watch server I guess. You still need to run the command to start a watch server dont you?
Thanks & Regards, Deepu
On Wed, Nov 30, 2016 at 5:54 PM, dimeros notifications@github.com wrote:
Executing the mvn command 'npm run webpack-dev' is executed automatically.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/jhipster/generator-jhipster/issues/4392#issuecomment-263928285, or mute the thread https://github.com/notifications/unsubscribe-auth/ABDlFwxmeoA8ekpCGZagFkunnvMqgrUEks5rDapPgaJpZM4Kh767 .
Yes you are right. I need to start it manually.
Does anyone know of a Karma + webpack 2 example? All the webpack + karma projects I can find use webpack v1.
Here's one that looks like it might work: https://github.com/AngularClass/angular2-webpack-starter
@deepu105 I'll try this on the weekend
@sendilkumarn All the following points are done:
@flaviencathala but i dont see anything for error notifications? did i miss anything?
@deepu105 Webpack print errors when it build, I thought you were talking about that.
Nope I was talking about the gulp plugin which shows desktop notifications. its not important though just cool to have :)
Thanks & Regards, Deepu
On Mon, Dec 12, 2016 at 4:58 PM, Flavien Cathala notifications@github.com wrote:
@deepu105 https://github.com/deepu105 Webpack print errors when it build, I thought you were talking about that.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/jhipster/generator-jhipster/issues/4392#issuecomment-266468369, or mute the thread https://github.com/notifications/unsubscribe-auth/ABDlF_cvSu6u7I_O8xI5FZdrY9MpwcHeks5rHW8ggaJpZM4Kh767 .
closing this and moving todo items to #4794
The discussion started from here
Migrating System Js into Webpack, to align more towards angular-cli.
cc @deepu105 @mraible @TheLarkInn
TODO: