Thanks to visit codestin.com
Credit goes to github.com

Skip to content

chore: add runtimeDomOverrides for fix webpack @vue/runtime-dom warns #1094

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"devDependencies": {
"@commitlint/cli": "^19.7.1",
"@commitlint/config-conventional": "^19.7.1",
"@nativescript/core": "~8.8.6",
"@nativescript/core": "~8.9.1",
"@nativescript/webpack": "~5.0.22",
"esbuild": "^0.25.0",
"lint-staged": "^15.4.3",
Expand Down
9 changes: 5 additions & 4 deletions src/components/ActionBar.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import {
Page as NSCPage,
ActionBar as NSCActionBar,
NavigationButton as NSCNavigationButton,
ActionItem as NSCActionItem,
NavigationButton as NSCNavigationButton,
Page as NSCPage,
} from '@nativescript/core';
import { defineComponent, h, warn } from '@vue/runtime-core';
import { defineComponent, h } from '@vue/runtime-core';
import { NSVElement, NSVViewFlags } from '../dom';
import { registerElement } from '../registry';
import { logger } from '../util/logger';

registerElement('NSCActionBar', () => NSCActionBar, {
viewFlags: NSVViewFlags.SKIP_ADD_TO_DOM,
Expand Down Expand Up @@ -65,7 +66,7 @@ export const ActionBar = /*#__PURE__*/ defineComponent({
parent.nativeView.actionBar = actionBar;
} else {
if (__DEV__) {
warn(
logger.warn(
`<ActionBar> must be a direct child of a <Page> element - ` +
`got <${parent.nativeView.constructor.name}> instead.`,
);
Expand Down
10 changes: 5 additions & 5 deletions src/components/ListView.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import {
Comment,
defineComponent,
getCurrentInstance,
h,
ref,
VNode,
warn,
watch,
ref,
Comment,
} from '@vue/runtime-core';

import {
Expand All @@ -18,6 +17,7 @@ import {
import { NSVElement, NSVViewFlags } from '../dom';
import { registerElement } from '../registry';
import { ELEMENT_REF } from '../runtimeHelpers';
import { logger } from '../util/logger';

registerElement('NSCListView', () => NSCListView, {
viewFlags: NSVViewFlags.NO_CHILDREN,
Expand Down Expand Up @@ -136,9 +136,9 @@ export const ListView = /*#__PURE__*/ defineComponent({
);

if (nonCommentVnodes.length === 0) {
warn(`ListView template must contain at least one element.`);
logger.warn(`ListView template must contain at least one element.`);
} else if (nonCommentVnodes.length > 1) {
warn(
logger.warn(
`ListView template must contain a single root element. Found: ${vnodes.length}. Only the first one will be used.`,
);
}
Expand Down
13 changes: 7 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,17 @@ declare module '@vue/runtime-core' {

init();

export * from './components';
export * from './dom';
export * from './registry';
export * from './renderer';
export * from './components';
export { ELEMENT_REF, createNativeView } from './runtimeHelpers';
export { createNativeView, ELEMENT_REF } from './runtimeHelpers';

export * from '@vue/runtime-core';
export { vShow } from './directives/vShow';
export { $showModal, $closeModal } from './plugins/modals';
export { $navigateTo, $navigateBack } from './plugins/navigation';
export { $closeModal, $showModal } from './plugins/modals';
export { $navigateBack, $navigateTo } from './plugins/navigation';
export * from './renderer/runtimeDomOverrides';

// creates a special root container that calls resetRoot whenever it's children change
function createAppRoot() {
Expand Down Expand Up @@ -97,10 +98,10 @@ export const createApp = ((...args) => {
app.use(modalsPlugin);
app.use(navigationPlugin);

app.config.errorHandler = (err, instance, info) => {
app.config.errorHandler = (err, instance, info) => {
console.error((info ? `Error during execution of ${info}: ` : ``) + err);

if(__DEV__) {
if (__DEV__) {
throw err;
}
};
Expand Down
5 changes: 2 additions & 3 deletions src/nativescript/elements.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ import {
TabViewItem as NSCTabViewItem,
} from '@nativescript/core';

import { warn } from '@vue/runtime-core';

import { NSVElement, NSVViewFlags } from '../dom';
import { registerElement } from '../registry';
import { logger } from '../util/logger';

export function registerCoreElements() {
// layouts
Expand Down Expand Up @@ -91,7 +90,7 @@ export function registerCoreElements() {
});
} else {
if (__DEV__) {
warn(
logger.warn(
`<Frame> must only contain <Page> elements - ` +
`got <${child.nativeView.constructor.name}> instead.`,
);
Expand Down
8 changes: 8 additions & 0 deletions src/renderer/runtimeDomOverrides.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { logger } from '../util/logger';

export const TransitionGroup = {
new() {
logger.warn('TransitionGroup is not supported');
return { $props: {} };
},
};
9 changes: 9 additions & 0 deletions src/util/logger.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { warn } from '@vue/runtime-core';

const baseLogger = '[NativeScript-Vue]';

export const logger = {
warn(msg: string) {
warn(`${baseLogger} ${msg}`);
},
};
Loading