Skip to content

Commit

Permalink
fix(NS6-build): Fix NS v6 Build Problems (#91)
Browse files Browse the repository at this point in the history
* Fix NS v6 build problem. (#90)

* Update Travis-CI OSX image.

* Update cocoapods before updating pod repo.

* Make sure 'six' is installed.
  • Loading branch information
RobertGardner authored Nov 17, 2019
1 parent f5fe908 commit fe25628
Show file tree
Hide file tree
Showing 11 changed files with 75 additions and 28 deletions.
8 changes: 6 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ matrix:
os: osx
env:
- WebPack="iOS"
osx_image: xcode11
osx_image: xcode11.2
language: node_js
node_js: "11"
jdk: oraclejdk8
before_install:
- travis_wait pip install six
- travis_wait gem install cocoapods
- travis_wait pod repo update --silent
script:
- cd src && npm i
Expand Down Expand Up @@ -41,11 +43,13 @@ matrix:
env:
- BuildiOS="11"
- Xcode="11.0"
osx_image: xcode11
osx_image: xcode11.2
language: node_js
node_js: "11"
jdk: oraclejdk8
before_install:
- travis_wait pip install six
- travis_wait gem install cocoapods
- travis_wait pod repo update --silent
script:
- cd src && npm i && npm run tsc && cd ../demo && tns build ios && cd ../demo-angular && tns build ios
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
Changelog

## 6.2.0 (2019, November 16)
### Updates
- Builds correctly on NS v6 (see README note)

### Fixes
- [(# 90)](https://github.com/triniwiz/nativescript-stripe/issues/90) Not building with NS 6

## 6.1.0 (2019, November 6)
### Updates
- Ability to set accountId `stripe.setStripeAccount('xxx')`
Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,15 @@ If you're using the [manual confirmation flow](https://stripe.com/docs/payments/
## Status
`demo-angular` now supports `SetupIntent` and `PaymentIntent` SCA integration. Any credit card verification will be automatically prompted to the user.

# Known Issues

## `const enum` not found
When building with NativeScript v6, it builds using the webpack-only flow in "transpileOnly" mode. A webpack [issue](https://github.com/NativeScript/nativescript-dev-webpack/issues/927) means that `const enum` values cannot be found in the final output.

This problem is not present in Angular projects and likely won't be an issue if you do not use any of the exported enums.

Unfortunately, the only fix I've found for this is to follow the advice in that issue and modify `webpack.config.js` in your app to set `transpileOnly` to `false`.

# TODO
* Android Pay
* Apple Pay (supported by Standard Integration, not by Custom Integration)
8 changes: 4 additions & 4 deletions demo-angular/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
"nativescript": {
"id": "org.nativescript.stripe.demoangular",
"tns-ios": {
"version": "6.0.1"
"version": "6.2.0"
},
"tns-android": {
"version": "6.0.0"
"version": "6.2.0"
}
},
"dependencies": {
Expand All @@ -27,7 +27,7 @@
"nativescript-theme-core": "~1.0.4",
"reflect-metadata": "~0.1.12",
"rxjs": "^6.3.3",
"tns-core-modules": "6.0.1",
"tns-core-modules": "~6.2.0",
"zone.js": "0.9.1"
},
"devDependencies": {
Expand All @@ -38,7 +38,7 @@
"babylon": "6.18.0",
"lazy": "1.0.11",
"nativescript-css-loader": "~0.26.1",
"nativescript-dev-webpack": "1.0.1",
"nativescript-dev-webpack": "~1.3.0",
"tns-platform-declarations": "6.0.1",
"tslint": "~5.4.3",
"typescript": "3.4.5"
Expand Down
2 changes: 1 addition & 1 deletion demo-angular/tsconfig.tns.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"extends": "./tsconfig",
"compilerOptions": {
"module": "es2015",
"module": "esNext",
"moduleResolution": "node"
}
}
31 changes: 23 additions & 8 deletions demo-angular/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const { nsReplaceBootstrap } = require("nativescript-dev-webpack/transformers/ns
const { nsReplaceLazyLoader } = require("nativescript-dev-webpack/transformers/ns-replace-lazy-loader");
const { nsSupportHmrNg } = require("nativescript-dev-webpack/transformers/ns-support-hmr-ng");
const { getMainModulePath } = require("nativescript-dev-webpack/utils/ast-utils");
const { getNoEmitOnErrorFromTSConfig } = require("nativescript-dev-webpack/utils/tsconfig-utils");
const CleanWebpackPlugin = require("clean-webpack-plugin");
const CopyWebpackPlugin = require("copy-webpack-plugin");
const { BundleAnalyzerPlugin } = require("webpack-bundle-analyzer");
Expand Down Expand Up @@ -35,10 +36,9 @@ module.exports = env => {

const {
// The 'appPath' and 'appResourcesPath' values are fetched from
// the nsconfig.json configuration file
// when bundling with `tns run android|ios --bundle`.
appPath = "app",
appResourcesPath = "app/App_Resources",
// the nsconfig.json configuration file.
appPath = "src",
appResourcesPath = "App_Resources",

// You can provide the following flags when running 'tns run android|ios'
aot, // --env.aot
Expand All @@ -51,8 +51,12 @@ module.exports = env => {
hmr, // --env.hmr,
unitTesting, // --env.unitTesting
verbose, // --env.verbose
snapshotInDocker, // --env.snapshotInDocker
skipSnapshotTools, // --env.skipSnapshotTools
compileSnapshot // --env.compileSnapshot
} = env;

const useLibs = compileSnapshot;
const isAnySourceMapEnabled = !!sourceMap || !!hiddenSourceMap;
const externals = nsWebpack.getConvertedExternals(env.externals);
const appFullPath = resolve(projectRoot, appPath);
Expand Down Expand Up @@ -108,6 +112,8 @@ module.exports = env => {
itemsToClean.push(`${join(projectRoot, "platforms", "android", "app", "build", "configurations", "nativescript-android-snapshot")}`);
}

const noEmitOnErrorFromTSConfig = getNoEmitOnErrorFromTSConfig(join(projectRoot, tsConfigName));

nsWebpack.processAppComponents(appComponents, platform);
const config = {
mode: production ? "production" : "development",
Expand Down Expand Up @@ -159,6 +165,7 @@ module.exports = env => {
devtool: hiddenSourceMap ? "hidden-source-map" : (sourceMap ? "inline-source-map" : "none"),
optimization: {
runtimeChunk: "single",
noEmitOnErrors: noEmitOnErrorFromTSConfig,
splitChunks: {
cacheGroups: {
vendor: {
Expand Down Expand Up @@ -197,7 +204,7 @@ module.exports = env => {
module: {
rules: [
{
test: nsWebpack.getEntryPathRegExp(appFullPath, entryPath),
include: join(appFullPath, entryPath),
use: [
// Require all Android app components
platform === "android" && {
Expand All @@ -221,19 +228,24 @@ module.exports = env => {

{ test: /\.html$|\.xml$/, use: "raw-loader" },

// tns-core-modules reads the app.css and its imports using css-loader
{
test: /[\/|\\]app\.css$/,
use: [
"nativescript-dev-webpack/style-hot-loader",
{ loader: "css-loader", options: { url: false } }
{
loader: "nativescript-dev-webpack/css2json-loader",
options: { useForImports: true }
}
]
},
{
test: /[\/|\\]app\.scss$/,
use: [
"nativescript-dev-webpack/style-hot-loader",
{ loader: "css-loader", options: { url: false } },
{
loader: "nativescript-dev-webpack/css2json-loader",
options: { useForImports: true }
},
"sass-loader"
]
},
Expand Down Expand Up @@ -309,6 +321,9 @@ module.exports = env => {
],
projectRoot,
webpackConfig: config,
snapshotInDocker,
skipSnapshotTools,
useLibs
}));
}

Expand Down
8 changes: 4 additions & 4 deletions demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
"nativescript": {
"id": "org.nativescript.stripe.demo",
"tns-ios": {
"version": "6.0.1"
"version": "6.2.0"
},
"tns-android": {
"version": "6.0.0"
"version": "6.2.0"
}
},
"dependencies": {
"nativescript-stripe": "file:../src",
"nativescript-theme-core": "^1.0.4",
"nativescript-unit-test-runner": "0.7.0",
"tns-core-modules": "6.0.1"
"tns-core-modules": "~6.2.0"
},
"devDependencies": {
"awesome-typescript-loader": "~5.2.1",
Expand All @@ -27,7 +27,7 @@
"karma-nativescript-launcher": "^0.4.0",
"lazy": "1.0.11",
"nativescript-css-loader": "~0.26.0",
"nativescript-dev-webpack": "1.0.1",
"nativescript-dev-webpack": "~1.3.0",
"tns-platform-declarations": "6.0.1",
"tslint": "~5.4.3",
"typescript": "3.4.5",
Expand Down
2 changes: 1 addition & 1 deletion demo/tsconfig.tns.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"extends": "./tsconfig",
"compilerOptions": {
"module": "es2015",
"module": "esNext",
"moduleResolution": "node"
}
}
24 changes: 18 additions & 6 deletions demo/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const { join, relative, resolve, sep } = require("path");
const webpack = require("webpack");
const nsWebpack = require("nativescript-dev-webpack");
const nativescriptTarget = require("nativescript-dev-webpack/nativescript-target");
const { getNoEmitOnErrorFromTSConfig } = require("nativescript-dev-webpack/utils/tsconfig-utils");
const CleanWebpackPlugin = require("clean-webpack-plugin");
const CopyWebpackPlugin = require("copy-webpack-plugin");
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
Expand Down Expand Up @@ -31,8 +32,7 @@ module.exports = env => {

const {
// The 'appPath' and 'appResourcesPath' values are fetched from
// the nsconfig.json configuration file
// when bundling with `tns run android|ios --bundle`.
// the nsconfig.json configuration file.
appPath = "app",
appResourcesPath = "app/App_Resources",

Expand All @@ -46,7 +46,12 @@ module.exports = env => {
hmr, // --env.hmr,
unitTesting, // --env.unitTesting,
verbose, // --env.verbose
snapshotInDocker, // --env.snapshotInDocker
skipSnapshotTools, // --env.skipSnapshotTools
compileSnapshot // --env.compileSnapshot
} = env;

const useLibs = compileSnapshot;
const isAnySourceMapEnabled = !!sourceMap || !!hiddenSourceMap;
const externals = nsWebpack.getConvertedExternals(env.externals);

Expand All @@ -72,6 +77,8 @@ module.exports = env => {
itemsToClean.push(`${join(projectRoot, "platforms", "android", "app", "build", "configurations", "nativescript-android-snapshot")}`);
}

const noEmitOnErrorFromTSConfig = getNoEmitOnErrorFromTSConfig(tsConfigPath);

nsWebpack.processAppComponents(appComponents, platform);
const config = {
mode: production ? "production" : "development",
Expand Down Expand Up @@ -125,6 +132,7 @@ module.exports = env => {
devtool: hiddenSourceMap ? "hidden-source-map" : (sourceMap ? "inline-source-map" : "none"),
optimization: {
runtimeChunk: "single",
noEmitOnErrors: noEmitOnErrorFromTSConfig,
splitChunks: {
cacheGroups: {
vendor: {
Expand Down Expand Up @@ -164,7 +172,7 @@ module.exports = env => {
module: {
rules: [
{
test: nsWebpack.getEntryPathRegExp(appFullPath, entryPath),
include: join(appFullPath, entryPath),
use: [
// Require all Android app components
platform === "android" && {
Expand All @@ -184,7 +192,7 @@ module.exports = env => {
},
].filter(loader => !!loader)
},

{
test: /\.(ts|css|scss|html|xml)$/,
use: "nativescript-dev-webpack/hmr/hot-loader"
Expand All @@ -194,13 +202,13 @@ module.exports = env => {

{
test: /\.css$/,
use: { loader: "css-loader", options: { url: false } }
use: "nativescript-dev-webpack/css2json-loader"
},

{
test: /\.scss$/,
use: [
{ loader: "css-loader", options: { url: false } },
"nativescript-dev-webpack/css2json-loader",
"sass-loader"
]
},
Expand Down Expand Up @@ -254,6 +262,7 @@ module.exports = env => {
tsconfig: tsConfigPath,
async: false,
useTypescriptIncrementalApi: true,
checkSyntacticErrors: true,
memoryLimit: 4096
})
],
Expand All @@ -278,6 +287,9 @@ module.exports = env => {
],
projectRoot,
webpackConfig: config,
snapshotInDocker,
skipSnapshotTools,
useLibs
}));
}

Expand Down
2 changes: 1 addition & 1 deletion src/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nativescript-stripe",
"version": "6.1.1",
"version": "6.2.0",
"description": "NativeScript Stripe sdk",
"main": "stripe",
"typings": "index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion src/standard/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export declare const enum StripeBillingAddressFields {
Name = 3
}
/** Available shipping address fields. */
export const enum StripeShippingAddressField {
export declare const enum StripeShippingAddressField {
Name = "name",
PostalAddress = "address",
Phone = "phone",
Expand Down

0 comments on commit fe25628

Please sign in to comment.