Skip to content
This repository has been archived by the owner on Aug 7, 2021. It is now read-only.

0.12 does not correctly include pages and the bundle fails #556

Closed
7 tasks done
PeterStaev opened this issue Jun 5, 2018 · 4 comments
Closed
7 tasks done

0.12 does not correctly include pages and the bundle fails #556

PeterStaev opened this issue Jun 5, 2018 · 4 comments
Labels

Comments

@PeterStaev
Copy link
Contributor

PeterStaev commented Jun 5, 2018

Issue Checklist

  • You are submitting: bug report
  • You verified that this is a real problem by searching the [NativeScript Forum] and the other [issues] in this repo.
  • You checked our [demo apps] and the [documentation] for sample usage.

Tell us about the problem

Upgraded a projects that has a complex structure of pages/fragments. All views are located in their own subfolder under app/views. There are also "fragments" located in their own subfolder under app/fragments. Seems web pack does not include any of those because it has a hardcoded regex check here:

const context = require.context("~/", true, /(root|page)\.(xml|css|js|ts|scss)$/);

And from what I see there is no way to override this from the config file. So unless you are naming your pages with a page somewhere in them and/or put them in a page folder you are stuck.
Also having the rule written like that in case you have done normal build it will double include styles as locally you have both css and scss files.

There should be an option to specify your own regex rule. Or at least have ability to register those modules like we did in previous versions

Local environment

  • Platform Mac
  • Node version 8.9.4
  • NativeScript CLI version 4.1.0

Project data

  • Platform you are building the app for iOS

webpack-ios-crash.zip

@pbgc
Copy link

pbgc commented Jun 5, 2018

@PeterStaev I filed a similar issue #555
You can still register using the bundle-config.js aproach like before:

if (global.TNS_WEBPACK) {
// This will register each page postfixed xml, css, js, ts, scss etc. in the app/ folder
context = require.context("~/", true, /(page|fragment).(xml|css|js|ts|scss|less|sass)$/);
global.registerWebpackModules(context);
}

this (with changes for your case) works .. but there should be a option to specify this on the webpack.config

@PeterStaev
Copy link
Contributor Author

@pbgc nice workaround! I first tried that but also had the register of the plugins in the file, so it crashed and I thought that the functions to register the modules have been removed. After I left only to register xml, ts, sass files it is working like a charm! But I also disabled the automatic registration of pages in my webpack.config.js so it does not do a double registration.

Still think this should allowed as an option in the config file (if possible?) and the docs should indicate that you can still register manually your files in case they don't follow the predefined naming scheme. Otherwise from the blog article you are left with the impression that there is no way to do this.

@pbgc
Copy link

pbgc commented Jun 6, 2018

@PeterStaev
I opted to register only the 'fragment' prefixed assets with bundle-config and leave the automatic registration enabled in webpack.config. This way I do not have to change webpack.config on every TS update and everything still works without double registration.

@PeterStaev
Copy link
Contributor Author

Only if you have your pages suffixed with page. Actually none of my views use this naming scheme, so this is a no-go for me.

@NickIliev NickIliev added the docs label Jun 13, 2018
PeterStaev added a commit to PeterStaev/nativescript-dev-webpack that referenced this issue Jun 23, 2018
sis0k0 pushed a commit that referenced this issue Jun 25, 2018
Adds a registerModules option for the bundle-config-loader that allows users to specify custom regex to register their modules. Also if needed they can set the new option to false completely disabling automatic module registration for non-angular apps.

Closes #556
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants