Is there any documentation or example describing how to implement and 'register' a custom bundler that will be called when passing the --bundle option?
The message: Passing --bundle requires a bundling plugin. No bundling plugin found or the specified bundling plugin is invalid. hints that it is possible to develop a bundler plugin other than using webpack.
Thanks!
Hi @clintwood ,
There is no documentation on the subject at the moment. The bundle flag can take string values for alternative bundler only in order to avoid making breaking changes if we have to add another one in the future. In theory in might be possible to implement another, but it is very likely to require changes to the code of the CLI tooling.
I would suggest another approach. Lets say you have a project called "MyApp". You can configure your bundler output to produce the files inside MyApp/bundleOut and configure the nsconfig.json like so:
{
"appResourcesPath": "App_Resources",
"appPath": "bundleOut"
}
Make sure to move the App_Resources folder to the root of of your project at MyApp/App_Resources.
The final step is to make sure you have a MyApp/bundleOut/package.json file which specifies the entry point(main) of your application. For example:
{
"main": "index",
"android": {
"v8Flags": "--expose_gc"
}
}
Where index is the name of your bundled entry point.
Then you can run your application with tns run android without using the --bundle flag. The way this will work is as follows. If you make a change in your MyApp/src folder and start your bundler, it will output files in MyApp/bundleOut. The CLI will detect the changes and sync them to the device.
Hi @KristianDD,
That is very helpful - I will give that a go - thank you!
I'm completely new to {NS} but am looking around to see what changes would be involved to enable bundling with other bundlers. So I have a totally uninformed view of what is going on in the CLI. Having said that, are there plans to support other bundlers and if it proves not too difficult/breaking are you open to PRs for enabling this in the CLI?
Hi @clintwood ,
We currently don't have plans to add support for other bundlers, but we will be glad to review contribution PRs. The changes should not be breaking and if needed there should be code that ensures backward compatibility for at least 3 minor or major versions.
Here you can find the code for the webpack bundler plugin. Here and here you can read about CLI hooks which is one of the major integration points between plugins and CLI.
@KristianDD, awesome I'll take a look at your links - thanks for the info!
Most helpful comment
Hi @clintwood ,
There is no documentation on the subject at the moment. The bundle flag can take string values for alternative bundler only in order to avoid making breaking changes if we have to add another one in the future. In theory in might be possible to implement another, but it is very likely to require changes to the code of the CLI tooling.
I would suggest another approach. Lets say you have a project called "MyApp". You can configure your bundler output to produce the files inside
MyApp/bundleOutand configure thensconfig.jsonlike so:Make sure to move the
App_Resourcesfolder to the root of of your project atMyApp/App_Resources.The final step is to make sure you have a
MyApp/bundleOut/package.jsonfile which specifies the entry point(main) of your application. For example:Where
indexis the name of your bundled entry point.Then you can run your application with
tns run androidwithout using the--bundleflag. The way this will work is as follows. If you make a change in yourMyApp/srcfolder and start your bundler, it will output files inMyApp/bundleOut. The CLI will detect the changes and sync them to the device.