Closed RobertGardner closed 4 years ago
Hey @RobertGardner,
Final note: Everything builds and runs correctly with NS 6.1.
I wasn't able to build and run the demo application with NS 6.1. I received the built time warning
WARNING in ./demo/stripe.service.ts 26:63-89
"export 'StripeShippingAddressField' was not found in 'nativescript-stripe/standard'
@ \b_[\w-]*\.)scss)$ (. sync (?<!\bApp_Resources\b.*)(?<!\.\/\btests\b\/.*?)\.(xml|css|js|(?<!\.d\.)ts|(?<!\b_[\w-]*\.)scss)$)
@ ./app.ts
and the runtime error as well:
JavaScript stack trace:
StripeService(file:///app/demo/stripe.service.ts:34:86)
at navigatingTo(file:///app/demo/std-page.ts:12:35)
...
JavaScript error:
file:///app/demo/stripe.service.ts:34:86: JS ERROR TypeError: undefined is not an object (evaluating 'nativescript_stripe_standard__WEBPACK_IMPORTED_MODULE_0__["StripeShippingAddressField"].PostalAddress')
It seems the issue is reproduced with NS v6+ and introduced with NativeScript v6.0 release since the applications are built only using webpack-only workflow. There is a detailed description of the problem here.
As it is described in the above mentioned thread, the workaround is to set transpileOnly
option of ts-loader
to false
. This way the files will NOT be transpiled one at a time, the compiler will have the whole program information and will know if the reference it is looking at is a const
enum or not.
NOTE: This might decrease the build time performance of your application.
Environment Provide version numbers for the following components (information can be retrieved by running
tns info
in your project folder or by inspecting thepackage.json
of the project):This is happening on iOS. I haven't tried it on Android.
Describe the bug This is happening with the nativescript-stripe plugin, where I am a contributor.
I updated from NS 6.1 to NS 6.2. I then updated the plugin's
/demo
app usingtns update
, and updatedwebpack.config.js
by running the webpack script. This resulted in versions listed above andnativescript-dev-webpack": "~1.3.0"
.When I build, I do not get any compile errors, but I get a webpack warning:
and when I run, I get a runtime error:
The relevant code in the plugin is:
and
Finally, the code in the demo app that calls it is:
The generated bundle code looks correct:
but somehow webpack is unable to find
StripeShippingAddressField
when the demo app is built.Final note: Everything builds and runs correctly with NS 6.1.