-
-
Notifications
You must be signed in to change notification settings - Fork 40
feat(livesync): enable webpack with watch #433
Conversation
d30bd90
to
a6b98b3
Compare
lib/before-watchPatterns.js
Outdated
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.
I think it would be better to keep the appResourcesDirectory in the original watch patterns, instead of adding it manually in the bundler.
lib/before-prepareJS.js
Outdated
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.
We can drop this line since watch is false by default.
lib/compiler.js
Outdated
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.
Unused import
lib/compiler.js
Outdated
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 remove the 'TODO's and create a separate issue, tracking all the changes that may be needed in the plugin after NativeScript/android#944 is merged.
test
06fe266
to
79e274f
Compare
Plug into NativeScript CLI's LiveSync pipeline in order to enable incremental webpacking with watch. Includes: * Instruct CLI to watch `App_Resources` directory only * Launch `webpack` with `--watch` on before-watch hook * Do not launch multiple `webpack` processes
79e274f
to
4fc6deb
Compare
Ping @sis0k0, rebased and addressed some issues found off line
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 an idea -
since we have access to all watch patterns from the CLI, can we use them as follows:
- patterns that webpack should use for watching -> initialize the webpack compiler (and watcher) with them.
- patterns that webpack should ignore -> add them to the 'ignore' options when starting the webpack compiler. That way we can remove the ignore option (./app/App_Resources) from the webpack config.
run ci
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.
Great work!
test branch_cli#kerezov/webpack+livesync
2 similar comments
test branch_cli#kerezov/webpack+livesync
test branch_cli#kerezov/webpack+livesync
lambourn
commented
Feb 28, 2018
nice - do we need to pass --watch to the tns run --bundle call now or is watch active by default?
@lambourn watch is active by default - you only need execute
tns run <platform> --bundle
.
As prerequisites for this to work, though, you would need the @next versions of both nativescript
and nativescript-dev-webpack
lambourn
commented
Feb 28, 2018
@Mitko-Kerezov thanmks. The nativescript-dev-webpack is at 0.9.2 at npmjs.org, is this identical to @next?
lambourn
commented
Feb 28, 2018
ah, nevermind. Got it.
As a reference here:
On every commit in the master
branch of this plugin a new version is published to npm.
You can use the latest of these versions by executing npm install nativescript-dev-webpack@next
lambourn
commented
Feb 28, 2018
@Mitko-Kerezov yep, thanks. I Installed @next versions of nativescript
and nativescript-dev-webpack
and got it running successfully. Very nice.
However, my vendor.ts
file gets recompiled every time, even though nothing changed on that file. It merely lists all 3rd party imports, e.g. angular etc.
Is that the expected behaviour?
@lambourn first off, thank you for testing this functionality - this feedback is very valuable to us.
As to your question - it is expected the vendor chunk be recompiled whenever you make changes to .css
or .scss
files or to app/vendor.ts
itself. This is caused by the fact that css
contents are embedded into the vendor
chunk.
What kind of files do you modify to cause this behavior?
I can test this with a project already created using Nativescript CLI 3.4.2? it's an Angular project; i updated the webpack package and the Nativescript CLI to @next but when i try to run using tns run android --bundle
i get the error:
Executing before-watchPatterns hook from /home/diego/Documents/development/mobile/bridge/NativeScript/Modules/shared-module/hooks/before-watchPatterns/nativescript-dev-webpack.js Cannot read property 'getAppDirectoryRelativePath' of undefined
darkyelox
commented
Feb 28, 2018
I test installing the latest nativescript cli @next and creating an empty project with latest nativescript-dev-webpack @next plugin installed and running gives me the same error, the app compiles and runs in the emulator but the cli crashes when trying to watch.
lambourn
commented
Mar 1, 2018
@Mitko-Kerezov I'll recheck. Presumably, it was either just a component.html
or a component.ts
file, for sure it was not a .css
. The component is part of the bundle.js
In this case, recompilation of the vendor.ts
should not happen, right?
btw, is it ok to hijack this PR comment thread or should I create an issue for it?
@darkyelox as I said earlier @next
versions are published on every commit in the master
branch - the issue you are describing is already resolved in the current @next
of nativescript-dev-webpack
. You can safely try updating the plugin and giving it another go.
@lambourn I tried changing component.ts
as well as component.html
and only my bundle chunk got recompiled. If you still experience have trouble could you create an issue in this repository for this and list the steps to reproduce as detailed as possible and we'll look into it. Providing a demo for reproduction purposes would be even better.
Is this expected behavior than the app is entirely reloaded only when css change ?
I see data transfering from webpack (app.css.js
, package.json
, starter.js
, tns-java-classes.js
), then I see the CSS changes immediately in the app, and after that the app restart.
I'd like to prevent last step, any solution ?
Note: I added app.scss
to the entry
in webpack, if I don't do that, the css is not in the app.
Plug into NativeScript CLI's LiveSync pipeline in order to enable incremental webpacking with watch.
Includes:
App_Resources
directory onlywebpack
with--watch
on before-watch hookwebpack
processesMerge after NativeScript/nativescript-cli#3350
Implements NativeScript/nativescript-cli#3349
Ping @sis0k0 @rosen-vladimirov @KristianDD