Skip to content

Commit 89bd9c7

Browse files
authored
Fix/enforce-type-imports-so-that-bundler-ignores-types (#6132)
* fix: enforce type imports so that the bundler ignores types * chore: add changeset * fix: export types with export type keyword
1 parent ff8a24a commit 89bd9c7

File tree

259 files changed

+664
-500
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

259 files changed

+664
-500
lines changed

.changeset/cuddly-impalas-heal.md

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
---
2+
'tiptap-2-migrate-imports': patch
3+
'tiptap-demos': patch
4+
'@tiptap/core': patch
5+
'@tiptap/extension-blockquote': patch
6+
'@tiptap/extension-bold': patch
7+
'@tiptap/extension-bubble-menu': patch
8+
'@tiptap/extension-bullet-list': patch
9+
'@tiptap/extension-character-count': patch
10+
'@tiptap/extension-code': patch
11+
'@tiptap/extension-code-block': patch
12+
'@tiptap/extension-code-block-lowlight': patch
13+
'@tiptap/extension-collaboration': patch
14+
'@tiptap/extension-collaboration-cursor': patch
15+
'@tiptap/extension-color': patch
16+
'@tiptap/extension-document': patch
17+
'@tiptap/extension-dropcursor': patch
18+
'@tiptap/extension-floating-menu': patch
19+
'@tiptap/extension-focus': patch
20+
'@tiptap/extension-font-family': patch
21+
'@tiptap/extension-gapcursor': patch
22+
'@tiptap/extension-hard-break': patch
23+
'@tiptap/extension-heading': patch
24+
'@tiptap/extension-highlight': patch
25+
'@tiptap/extension-history': patch
26+
'@tiptap/extension-horizontal-rule': patch
27+
'@tiptap/extension-image': patch
28+
'@tiptap/extension-italic': patch
29+
'@tiptap/extension-link': patch
30+
'@tiptap/extension-list': patch
31+
'@tiptap/extension-list-item': patch
32+
'@tiptap/extension-list-keymap': patch
33+
'@tiptap/extension-mention': patch
34+
'@tiptap/extension-ordered-list': patch
35+
'@tiptap/extension-paragraph': patch
36+
'@tiptap/extension-placeholder': patch
37+
'@tiptap/extension-strike': patch
38+
'@tiptap/extension-subscript': patch
39+
'@tiptap/extension-superscript': patch
40+
'@tiptap/extension-table': patch
41+
'@tiptap/extension-table-cell': patch
42+
'@tiptap/extension-table-header': patch
43+
'@tiptap/extension-table-row': patch
44+
'@tiptap/extension-task-item': patch
45+
'@tiptap/extension-task-list': patch
46+
'@tiptap/extension-text': patch
47+
'@tiptap/extension-text-align': patch
48+
'@tiptap/extension-text-style': patch
49+
'@tiptap/extension-typography': patch
50+
'@tiptap/extension-underline': patch
51+
'@tiptap/extension-youtube': patch
52+
'@tiptap/extensions': patch
53+
'@tiptap/html': patch
54+
'@tiptap/pm': patch
55+
'@tiptap/react': patch
56+
'@tiptap/starter-kit': patch
57+
'@tiptap/static-renderer': patch
58+
'@tiptap/suggestion': patch
59+
'@tiptap/vue-2': patch
60+
'@tiptap/vue-3': patch
61+
---
62+
63+
Enforce type imports so that the bundler ignores TypeScript type imports when generating the index.js file of the dist directory

.eslintrc.js

+1
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ module.exports = {
9090
'@typescript-eslint/ban-ts-comment': 'off',
9191
'@typescript-eslint/ban-types': 'off',
9292
'@typescript-eslint/explicit-module-boundary-types': 'off',
93+
'@typescript-eslint/consistent-type-imports': ['error', { disallowTypeAnnotations: false }],
9394
'simple-import-sort/imports': 'error',
9495
'simple-import-sort/exports': 'error',
9596
},

demos/src/Examples/Accessibility/React/InsertMenu.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { Editor, useEditorState } from '@tiptap/react'
1+
import type { Editor } from '@tiptap/react'
2+
import { useEditorState } from '@tiptap/react'
23
import { FloatingMenu } from '@tiptap/react/menus'
34
import React, { useRef } from 'react'
45

demos/src/Examples/Accessibility/React/MenuBar.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Editor } from '@tiptap/core'
1+
import type { Editor } from '@tiptap/core'
22
import { useEditorState } from '@tiptap/react'
33
import React, { useEffect, useRef, useState } from 'react'
44

demos/src/Examples/Accessibility/React/TextMenu.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Selection } from '@tiptap/pm/state'
2-
import { Editor, useEditorState } from '@tiptap/react'
2+
import type { Editor } from '@tiptap/react'
3+
import { useEditorState } from '@tiptap/react'
34
import { BubbleMenu } from '@tiptap/react/menus'
45
import React, { useRef } from 'react'
56

demos/src/Examples/Accessibility/React/useMenubarNav.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import { Editor } from '@tiptap/core'
2-
import React, { useCallback, useEffect, useRef } from 'react'
1+
import type { Editor } from '@tiptap/core'
2+
import type React from 'react'
3+
import { useCallback, useEffect, useRef } from 'react'
34

45
/**
56
* Handle arrow navigation within a menu bar container, and allow to escape to the editor

demos/src/Examples/Default/React/index.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import './styles.scss'
22

33
import { TextStyleKit } from '@tiptap/extension-text-style'
4-
import { Editor, EditorContent, useEditor, useEditorState } from '@tiptap/react'
4+
import type { Editor } from '@tiptap/react'
5+
import { EditorContent, useEditor, useEditorState } from '@tiptap/react'
56
import StarterKit from '@tiptap/starter-kit'
67
import React from 'react'
78

demos/src/Examples/Savvy/React/findColors.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Node } from '@tiptap/pm/model'
1+
import type { Node } from '@tiptap/pm/model'
22
import { Decoration, DecorationSet } from '@tiptap/pm/view'
33

44
export default function (doc: Node): DecorationSet {

demos/src/Examples/Savvy/Vue/findColors.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Node } from '@tiptap/pm/model'
1+
import type { Node } from '@tiptap/pm/model'
22
import { Decoration, DecorationSet } from '@tiptap/pm/view'
33

44
export default function (doc: Node): DecorationSet {

demos/src/Examples/StaticRendering/React/index.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import './styles.scss'
22

3-
import { EditorProvider, JSONContent, useCurrentEditor, useEditorState } from '@tiptap/react'
3+
import type { JSONContent } from '@tiptap/react'
4+
import { EditorProvider, useCurrentEditor, useEditorState } from '@tiptap/react'
45
import StarterKit from '@tiptap/starter-kit'
56
import { renderToHTMLString, renderToMarkdown, renderToReactElement } from '@tiptap/static-renderer'
67
import React, { useState } from 'react'

demos/src/Experiments/CollaborationAnnotation/Vue/extension/AnnotationPlugin.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { Plugin, PluginKey } from '@tiptap/pm/state'
22
import { DecorationSet } from '@tiptap/pm/view'
3-
import * as Y from 'yjs'
3+
import type * as Y from 'yjs'
44

5-
import { AnnotationItem } from './AnnotationItem.js'
5+
import type { AnnotationItem } from './AnnotationItem.js'
66
import { AnnotationState } from './AnnotationState.js'
77

88
export const AnnotationPluginKey = new PluginKey('annotation')

demos/src/Experiments/CollaborationAnnotation/Vue/extension/AnnotationState.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
import { EditorState, Transaction } from '@tiptap/pm/state'
1+
import type { EditorState, Transaction } from '@tiptap/pm/state'
22
import { Decoration, DecorationSet } from '@tiptap/pm/view'
33
import {
44
absolutePositionToRelativePosition,
55
relativePositionToAbsolutePosition,
66
ySyncPluginKey,
77
} from '@tiptap/y-tiptap'
8-
import * as Y from 'yjs'
8+
import type * as Y from 'yjs'
99

1010
import { AnnotationItem } from './AnnotationItem.js'
1111
import { AnnotationPluginKey } from './AnnotationPlugin.js'
12-
import { AddAnnotationAction, DeleteAnnotationAction, UpdateAnnotationAction } from './collaboration-annotation.js'
12+
import type { AddAnnotationAction, DeleteAnnotationAction, UpdateAnnotationAction } from './collaboration-annotation.js'
1313

1414
export interface AnnotationStateOptions {
1515
HTMLAttributes: {

demos/src/Experiments/CollaborationAnnotation/Vue/extension/collaboration-annotation.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Extension } from '@tiptap/core'
2-
import * as Y from 'yjs'
2+
import type * as Y from 'yjs'
33

44
import { AnnotationPlugin, AnnotationPluginKey } from './AnnotationPlugin.js'
55

demos/src/Experiments/Linter/Vue/extension/Linter.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import { Extension } from '@tiptap/core'
2-
import { Node as ProsemirrorNode } from '@tiptap/pm/model'
2+
import type { Node as ProsemirrorNode } from '@tiptap/pm/model'
33
import { Plugin, PluginKey, TextSelection } from '@tiptap/pm/state'
44
import { Decoration, DecorationSet } from '@tiptap/pm/view'
55

6-
import LinterPlugin, { Result as Issue } from './LinterPlugin.js'
6+
import type { Result as Issue } from './LinterPlugin.js'
7+
import type LinterPlugin from './LinterPlugin.js'
78

89
interface IconDivElement extends HTMLDivElement {
910
issue?: Issue

demos/src/Experiments/Linter/Vue/extension/LinterPlugin.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Node as ProsemirrorNode } from '@tiptap/pm/model'
1+
import type { Node as ProsemirrorNode } from '@tiptap/pm/model'
22

33
export interface Result {
44
message: string

demos/src/Experiments/Linter/Vue/extension/plugins/HeadingLevel.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import { EditorView } from '@tiptap/pm/view'
1+
import type { EditorView } from '@tiptap/pm/view'
22

3-
import LinterPlugin, { Result as Issue } from '../LinterPlugin.js'
3+
import type { Result as Issue } from '../LinterPlugin.js'
4+
import LinterPlugin from '../LinterPlugin.js'
45

56
export class HeadingLevel extends LinterPlugin {
67
fixHeader(level: number) {

demos/src/Experiments/Linter/Vue/extension/plugins/Punctuation.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import { EditorView } from '@tiptap/pm/view'
1+
import type { EditorView } from '@tiptap/pm/view'
22

3-
import LinterPlugin, { Result as Issue } from '../LinterPlugin.js'
3+
import type { Result as Issue } from '../LinterPlugin.js'
4+
import LinterPlugin from '../LinterPlugin.js'
45

56
export class Punctuation extends LinterPlugin {
67
public regex = / ([,.!?:]) ?/g

demos/src/GuideMarkViews/ReactComponent/React/Component.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { MarkViewContent, MarkViewRendererProps } from '@tiptap/react'
1+
import type { MarkViewRendererProps } from '@tiptap/react'
2+
import { MarkViewContent } from '@tiptap/react'
23
import React from 'react'
34

45
// eslint-disable-next-line @typescript-eslint/no-unused-vars

demos/src/GuideNodeViews/ReactComponent/React/Component.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { NodeViewProps, NodeViewWrapper } from '@tiptap/react'
1+
import type { NodeViewProps } from '@tiptap/react'
2+
import { NodeViewWrapper } from '@tiptap/react'
23
import React from 'react'
34

45
export default (props: NodeViewProps) => {

demos/src/GuideNodeViews/ReactComponentContext/React/Component.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { NodeViewProps, NodeViewWrapper } from '@tiptap/react'
1+
import type { NodeViewProps } from '@tiptap/react'
2+
import { NodeViewWrapper } from '@tiptap/react'
23
import React, { useContext } from 'react'
34

45
import { Context } from './Context.js'

demos/src/Tutorials/1-1-textarea/React/Note.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { useState } from 'react'
22

3-
import { TNote } from './types.js'
3+
import type { TNote } from './types.js'
44

55
export default ({ note }: { note: TNote }) => {
66
const [modelValue, setModelValue] = useState(note.content)

demos/src/Tutorials/1-1-textarea/React/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import './styles.scss'
33
import React from 'react'
44

55
import Note from './Note.jsx'
6-
import { TNote } from './types.js'
6+
import type { TNote } from './types.js'
77

88
const notes: TNote[] = [
99
{

demos/src/Tutorials/1-1-textarea/Vue/Note.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<script setup lang="ts">
22
import { ref, watch } from 'vue'
33
4-
import { TNote } from './types.js'
4+
import type { TNote } from './types.js'
55
66
const props = defineProps<{ note: TNote }>()
77

demos/src/Tutorials/1-1-textarea/Vue/index.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import './styles.scss'
33
44
import Note from './Note.vue'
5-
import { TNote } from './types.js'
5+
import type { TNote } from './types.js'
66
77
const notes: TNote[] = [
88
{ id: 'note-1', content: 'Some random note text' },

demos/src/Tutorials/1-2-tiptap/React/Note.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { EditorContent, useEditor } from '@tiptap/react'
22
import { StarterKit } from '@tiptap/starter-kit'
33
import React, { useState } from 'react'
44

5-
import { TNote } from './types.js'
5+
import type { TNote } from './types.js'
66

77
export default ({ note }: { note: TNote }) => {
88
const [modelValue, setModelValue] = useState(note.content)

demos/src/Tutorials/1-2-tiptap/React/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import './styles.scss'
33
import React from 'react'
44

55
import Note from './Note.jsx'
6-
import { TNote } from './types.js'
6+
import type { TNote } from './types.js'
77

88
const notes: TNote[] = [
99
{

demos/src/Tutorials/1-2-tiptap/Vue/index.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import './styles.scss'
33
44
import Note from './Note.vue'
5-
import { TNote } from './types.js'
5+
import type { TNote } from './types.js'
66
77
const notes: TNote[] = [
88
{ id: 'note-1', content: 'Some random note text' },

demos/src/Tutorials/1-2-tiptap_lexical/Lexical-React/Note.tsx

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
import './styles.css'
22

3-
import { InitialConfigType, LexicalComposer } from '@lexical/react/LexicalComposer'
3+
import type { InitialConfigType } from '@lexical/react/LexicalComposer'
4+
import { LexicalComposer } from '@lexical/react/LexicalComposer'
45
import { ContentEditable } from '@lexical/react/LexicalContentEditable'
56
import LexicalErrorBoundary from '@lexical/react/LexicalErrorBoundary'
67
import { HistoryPlugin } from '@lexical/react/LexicalHistoryPlugin'
78
import { OnChangePlugin } from '@lexical/react/LexicalOnChangePlugin'
89
import { RichTextPlugin } from '@lexical/react/LexicalRichTextPlugin'
9-
import { EditorState } from 'lexical/LexicalEditorState'
10+
import type { EditorState } from 'lexical/LexicalEditorState'
1011
import React, { useRef } from 'react'
1112

12-
import { TNote } from './types.js'
13+
import type { TNote } from './types.js'
1314

1415
export default ({ note }: { note: TNote }) => {
1516
const editorStateRef = useRef<EditorState>()

demos/src/Tutorials/1-2-tiptap_lexical/Lexical-React/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import './styles.css'
33
import React from 'react'
44

55
import Note from './Note.jsx'
6-
import { TNote } from './types.js'
6+
import type { TNote } from './types.js'
77

88
const notes: TNote[] = [
99
{

demos/src/Tutorials/1-3-yjs/React/Note.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { StarterKit } from '@tiptap/starter-kit'
44
import React from 'react'
55
import * as Y from 'yjs'
66

7-
import { TNote } from './types.js'
7+
import type { TNote } from './types.js'
88

99
export default ({ note }: { note: TNote }) => {
1010
const doc = new Y.Doc()

demos/src/Tutorials/1-3-yjs/React/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import './styles.scss'
33
import React from 'react'
44

55
import Note from './Note.jsx'
6-
import { TNote } from './types.js'
6+
import type { TNote } from './types.js'
77

88
const notes: TNote[] = [
99
{

demos/src/Tutorials/1-3-yjs/Vue/index.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import './styles.scss'
33
44
import Note from './Note.vue'
5-
import { TNote } from './types.js'
5+
import type { TNote } from './types.js'
66
77
const notes: TNote[] = [
88
{ id: 'note-1', defaultContent: 'Some random note text' },

demos/src/Tutorials/1-3-yjs_lexical/Lexical-React/Note.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@ import './styles.css'
22

33
import { TiptapCollabProvider } from '@hocuspocus/provider'
44
import { CollaborationPlugin } from '@lexical/react/LexicalCollaborationPlugin'
5-
import { InitialConfigType, LexicalComposer } from '@lexical/react/LexicalComposer'
5+
import type { InitialConfigType } from '@lexical/react/LexicalComposer'
6+
import { LexicalComposer } from '@lexical/react/LexicalComposer'
67
import { ContentEditable } from '@lexical/react/LexicalContentEditable'
78
import LexicalErrorBoundary from '@lexical/react/LexicalErrorBoundary'
89
import { RichTextPlugin } from '@lexical/react/LexicalRichTextPlugin'
910
import React from 'react'
1011
import * as Y from 'yjs'
1112

12-
import { TNote } from './types.js'
13+
import type { TNote } from './types.js'
1314

1415
export default ({ note }: { note: TNote }) => {
1516
const initialConfig: InitialConfigType = {

demos/src/Tutorials/1-3-yjs_lexical/Lexical-React/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import './styles.css'
33
import React from 'react'
44

55
import Note from './Note.jsx'
6-
import { TNote } from './types.js'
6+
import type { TNote } from './types.js'
77

88
const notes: TNote[] = [
99
{

demos/src/Tutorials/1-4-collab/React/Note.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { StarterKit } from '@tiptap/starter-kit'
55
import React, { useEffect } from 'react'
66
import * as Y from 'yjs'
77

8-
import { TNote } from './types.js'
8+
import type { TNote } from './types.js'
99

1010
export default ({ note }: { note: TNote }) => {
1111
const doc = new Y.Doc()

demos/src/Tutorials/1-4-collab/React/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import './styles.scss'
33
import React from 'react'
44

55
import Note from './Note.jsx'
6-
import { TNote } from './types.js'
6+
import type { TNote } from './types.js'
77

88
const notes: TNote[] = [
99
{

0 commit comments

Comments
 (0)