-
-
Notifications
You must be signed in to change notification settings - Fork 49
feat(livesync): enable webpack with watch #433
Conversation
d30bd90
to
a6b98b3
Compare
lib/before-watchPatterns.js
Outdated
|
||
if (originalPatterns.indexOf(appResourcesDirectoryLocation) === -1) { | ||
originalPatterns.push(appResourcesDirectoryLocation); | ||
} |
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
@@ -8,7 +8,7 @@ module.exports = function ($mobileHelper, $projectData, hookArgs) { | |||
env, | |||
platform, | |||
bundle: appFilesUpdaterOptions.bundle, | |||
watch: false // TODO: Read from CLI options... | |||
watch: false |
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
@@ -4,6 +4,7 @@ const { join, resolve: pathResolve } = require("path"); | |||
const { existsSync } = require("fs"); | |||
const readline = require("readline"); | |||
const { messages } = require("../plugins/WatchStateLoggerPlugin"); | |||
const ProjectSnapshotGenerator = require("../snapshot/android/project-snapshot-generator"); |
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
} | ||
|
||
if (hookArgs.filesToSync && hookArgs.startSyncFilesTimeout) { | ||
// TODO: Might need to get the "app" constant from config file in the future |
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 |
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 As prerequisites for this to work, though, you would need the @next versions of both |
@Mitko-Kerezov thanmks. The nativescript-dev-webpack is at 0.9.2 at npmjs.org, is this identical to @next? |
ah, nevermind. Got it. |
As a reference here: |
@Mitko-Kerezov yep, thanks. I Installed @next versions of However, my Is that the expected behaviour? |
@lambourn first off, thank you for testing this functionality - this feedback is very valuable to us. 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
|
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. |
@Mitko-Kerezov I'll recheck. Presumably, it was either just a In this case, recompilation of the btw, is it ok to hijack this PR comment thread or should I create an issue for it? |
@darkyelox as I said earlier @lambourn I tried changing |
Is this expected behavior than the app is entirely reloaded only when css change ? I see data transfering from webpack ( I'd like to prevent last step, any solution ? Note: I added |
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