Support node16 module resolution

The `node16` module resolution requires imports to use the `.js` file
extension in type definitions.

`@rollup/plugin-typescript` is needed to make this work with the Vite
setup used by Mermaid.

The module option for Mermaid internally is set to `nodenext`. This is
needed to support `.json` imports. Note that setting `module` to
`node16` or `nodenext` implies a matching `moduleResolution` value.
This commit is contained in:
Remco Haszing
2023-03-11 14:54:21 +01:00
parent 273a9e7ad6
commit b7d31adda4
207 changed files with 707 additions and 662 deletions

View File

@@ -1,9 +1,9 @@
// @ts-ignore: TODO Fix ts errors
import parser from './parser/exampleDiagram';
import * as db from './exampleDiagramDb';
import renderer from './exampleDiagramRenderer';
import styles from './styles';
import { injectUtils } from './mermaidUtils';
import parser from './parser/exampleDiagram.jison';
import * as db from './exampleDiagramDb.js';
import renderer from './exampleDiagramRenderer.js';
import styles from './styles.js';
import { injectUtils } from './mermaidUtils.js';
export const diagram = {
db,

View File

@@ -1,6 +1,6 @@
import { parser } from './parser/exampleDiagram';
import * as db from './exampleDiagramDb';
import { injectUtils } from './mermaidUtils';
import { parser } from './parser/exampleDiagram.js';
import * as db from './exampleDiagramDb.js';
import { injectUtils } from './mermaidUtils.js';
// Todo fix utils functions for tests
import {
log,
@@ -8,7 +8,7 @@ import {
getConfig,
sanitizeText,
setupGraphViewBox,
} from '../../mermaid/src/diagram-api/diagramAPI';
} from '../../mermaid/src/diagram-api/diagramAPI.js';
injectUtils(log, setLogLevel, getConfig, sanitizeText, setupGraphViewBox);

View File

@@ -1,5 +1,5 @@
/** Created by knut on 15-01-14. */
import { log } from './mermaidUtils';
import { log } from './mermaidUtils.js';
var message = '';
var info = false;

View File

@@ -1,6 +1,6 @@
/** Created by knut on 14-12-11. */
import { select } from 'd3';
import { log, getConfig, setupGraphViewbox } from './mermaidUtils';
import { log, getConfig, setupGraphViewbox } from './mermaidUtils.js';
/**
* Draws a an info picture in the tag with id: id based on the graph definition in text.

View File

@@ -1,6 +1,5 @@
{
"extends": "../../tsconfig.json",
"module": "esnext",
"compilerOptions": {
"rootDir": "./src",
"outDir": "./dist"