mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-17 04:41:36 +08:00
fix(dev-tools): use app root in getDocument()
This commit is contained in:
@ -16,7 +16,8 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@nativescript/core": "file:../../nativescript-core",
|
"@nativescript/core": "file:../../nativescript-core",
|
||||||
"tns-core-modules": "file:../../dist/tns-core-modules"
|
"tns-core-modules": "file:../../dist/tns-core-modules",
|
||||||
|
"nativescript-theme-core": "^1.0.6"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"nativescript-dev-webpack": "next",
|
"nativescript-dev-webpack": "next",
|
||||||
|
@ -3,6 +3,7 @@ const { join, relative, resolve, sep } = require("path");
|
|||||||
const webpack = require("webpack");
|
const webpack = require("webpack");
|
||||||
const nsWebpack = require("nativescript-dev-webpack");
|
const nsWebpack = require("nativescript-dev-webpack");
|
||||||
const nativescriptTarget = require("nativescript-dev-webpack/nativescript-target");
|
const nativescriptTarget = require("nativescript-dev-webpack/nativescript-target");
|
||||||
|
const { getNoEmitOnErrorFromTSConfig } = require("nativescript-dev-webpack/utils/tsconfig-utils");
|
||||||
const CleanWebpackPlugin = require("clean-webpack-plugin");
|
const CleanWebpackPlugin = require("clean-webpack-plugin");
|
||||||
const CopyWebpackPlugin = require("copy-webpack-plugin");
|
const CopyWebpackPlugin = require("copy-webpack-plugin");
|
||||||
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
|
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
|
||||||
@ -46,8 +47,11 @@ module.exports = env => {
|
|||||||
unitTesting, // --env.unitTesting,
|
unitTesting, // --env.unitTesting,
|
||||||
verbose, // --env.verbose
|
verbose, // --env.verbose
|
||||||
snapshotInDocker, // --env.snapshotInDocker
|
snapshotInDocker, // --env.snapshotInDocker
|
||||||
skipSnapshotTools // --env.skipSnapshotTools
|
skipSnapshotTools, // --env.skipSnapshotTools
|
||||||
|
compileSnapshot // --env.compileSnapshot
|
||||||
} = env;
|
} = env;
|
||||||
|
|
||||||
|
const useLibs = compileSnapshot;
|
||||||
const isAnySourceMapEnabled = !!sourceMap || !!hiddenSourceMap;
|
const isAnySourceMapEnabled = !!sourceMap || !!hiddenSourceMap;
|
||||||
const externals = nsWebpack.getConvertedExternals(env.externals);
|
const externals = nsWebpack.getConvertedExternals(env.externals);
|
||||||
|
|
||||||
@ -73,6 +77,8 @@ module.exports = env => {
|
|||||||
itemsToClean.push(`${join(projectRoot, "platforms", "android", "app", "build", "configurations", "nativescript-android-snapshot")}`);
|
itemsToClean.push(`${join(projectRoot, "platforms", "android", "app", "build", "configurations", "nativescript-android-snapshot")}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const noEmitOnErrorFromTSConfig = getNoEmitOnErrorFromTSConfig(tsConfigPath);
|
||||||
|
|
||||||
nsWebpack.processAppComponents(appComponents, platform);
|
nsWebpack.processAppComponents(appComponents, platform);
|
||||||
const config = {
|
const config = {
|
||||||
mode: production ? "production" : "development",
|
mode: production ? "production" : "development",
|
||||||
@ -126,6 +132,7 @@ module.exports = env => {
|
|||||||
devtool: hiddenSourceMap ? "hidden-source-map" : (sourceMap ? "inline-source-map" : "none"),
|
devtool: hiddenSourceMap ? "hidden-source-map" : (sourceMap ? "inline-source-map" : "none"),
|
||||||
optimization: {
|
optimization: {
|
||||||
runtimeChunk: "single",
|
runtimeChunk: "single",
|
||||||
|
noEmitOnErrors: noEmitOnErrorFromTSConfig,
|
||||||
splitChunks: {
|
splitChunks: {
|
||||||
cacheGroups: {
|
cacheGroups: {
|
||||||
vendor: {
|
vendor: {
|
||||||
@ -195,13 +202,13 @@ module.exports = env => {
|
|||||||
|
|
||||||
{
|
{
|
||||||
test: /\.css$/,
|
test: /\.css$/,
|
||||||
use: { loader: "css-loader", options: { url: false } }
|
use: "nativescript-dev-webpack/css2json-loader"
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
test: /\.scss$/,
|
test: /\.scss$/,
|
||||||
use: [
|
use: [
|
||||||
{ loader: "css-loader", options: { url: false } },
|
"nativescript-dev-webpack/css2json-loader",
|
||||||
"sass-loader"
|
"sass-loader"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@ -255,6 +262,7 @@ module.exports = env => {
|
|||||||
tsconfig: tsConfigPath,
|
tsconfig: tsConfigPath,
|
||||||
async: false,
|
async: false,
|
||||||
useTypescriptIncrementalApi: true,
|
useTypescriptIncrementalApi: true,
|
||||||
|
checkSyntacticErrors: true,
|
||||||
memoryLimit: 4096
|
memoryLimit: 4096
|
||||||
})
|
})
|
||||||
],
|
],
|
||||||
@ -280,7 +288,8 @@ module.exports = env => {
|
|||||||
projectRoot,
|
projectRoot,
|
||||||
webpackConfig: config,
|
webpackConfig: config,
|
||||||
snapshotInDocker,
|
snapshotInDocker,
|
||||||
skipSnapshotTools
|
skipSnapshotTools,
|
||||||
|
useLibs
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ import { ViewBase } from "../ui/core/view-base";
|
|||||||
import { mainThreadify } from "../utils/utils";
|
import { mainThreadify } from "../utils/utils";
|
||||||
|
|
||||||
// Use lazy requires for core modules
|
// Use lazy requires for core modules
|
||||||
const frameTopmost = () => require("../ui/frame").topmost();
|
const getAppRootView = () => require("../application").getRootView();
|
||||||
|
|
||||||
let unsetValue;
|
let unsetValue;
|
||||||
function unsetViewValue(view, name) {
|
function unsetViewValue(view, name) {
|
||||||
@ -27,19 +27,19 @@ function getViewById(nodeId: number): ViewBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function getDocument() {
|
export function getDocument() {
|
||||||
const topMostFrame = frameTopmost();
|
const appRoot = getAppRootView();
|
||||||
if (!topMostFrame) {
|
if (!appRoot) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
topMostFrame.ensureDomNode();
|
appRoot.ensureDomNode();
|
||||||
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log("ERROR in getDocument(): " + e);
|
console.log("ERROR in getDocument(): " + e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return topMostFrame.domNode.toObject();
|
return appRoot.domNode.toObject();
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getComputedStylesForNode(nodeId): Array<{ name: string, value: string }> {
|
export function getComputedStylesForNode(nodeId): Array<{ name: string, value: string }> {
|
||||||
|
Reference in New Issue
Block a user