@sapphire/docusaurus-plugin-ts2esm2cjs 1.0.1 → 1.0.2-next.6da8148.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,154 +1,153 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ts2esm2cjs = void 0;
4
- const tslib_1 = require("tslib");
5
- const prettier_config_1 = (0, tslib_1.__importDefault)(require("@sapphire/prettier-config"));
6
- const esm_to_cjs_1 = require("esm-to-cjs");
7
- const prettier_1 = (0, tslib_1.__importDefault)(require("prettier"));
8
- const typescript_1 = (0, tslib_1.__importDefault)(require("typescript"));
9
- const documentationPrettierConfig = {
10
- ...prettier_config_1.default,
11
- tabWidth: 2,
12
- useTabs: false,
13
- printWidth: 120,
14
- parser: 'babel'
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
15
11
  };
16
- const makeTsCompilerOptions = (overrideOptions) => ({
17
- newLine: typescript_1.default.NewLineKind.LineFeed,
18
- removeComments: false,
19
- esModuleInterop: true,
20
- pretty: true,
21
- ...overrideOptions,
22
- module: typescript_1.default.ModuleKind.ESNext,
23
- moduleResolution: typescript_1.default.ModuleResolutionKind.NodeJs,
24
- target: typescript_1.default.ScriptTarget.ESNext
12
+ var __reExport = (target, module2, copyDefault, desc) => {
13
+ if (module2 && typeof module2 === "object" || typeof module2 === "function") {
14
+ for (let key of __getOwnPropNames(module2))
15
+ if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
16
+ __defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
17
+ }
18
+ return target;
19
+ };
20
+ var __toESM = (module2, isNodeMode) => {
21
+ return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
22
+ };
23
+ var __toCommonJS = /* @__PURE__ */ ((cache) => {
24
+ return (module2, temp) => {
25
+ return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
26
+ };
27
+ })(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
28
+
29
+ // src/index.ts
30
+ var src_exports = {};
31
+ __export(src_exports, {
32
+ ts2esm2cjs: () => ts2esm2cjs
25
33
  });
26
- /**
27
- * Transpiles input TypeScript code to ESM code.
28
- * @param code The code to transpile
29
- * @returns Input code transpiled to ESM
30
- */
31
- const tsToEsm = (code, options) => typescript_1.default.transpileModule(code, { reportDiagnostics: false, compilerOptions: makeTsCompilerOptions(options.typescriptCompilerOptions) });
32
- /**
33
- * Transforms input ESM code to CJS code.
34
- * @param code The code to transform
35
- * @returns Input code transformed to CommonJS
36
- */
37
- const esmToCjs = (code) => (0, esm_to_cjs_1.runTransform)(code, { quote: 'single', lenDestructure: 128, lenModuleName: 128, lenIdentifier: 128 });
38
- /**
39
- * Escaped new lines in code with block comments so they can be restored by {@link restoreNewLines}
40
- * @param code The code to escape new lines in
41
- * @returns The same code but with new lines escaped using block comments
42
- */
43
- const escapeNewLines = (code) => code.replace(/\n\n/g, '\n/* :newline: */');
44
- /**
45
- * Reverses {@link escapeNewLines} and restores new lines
46
- * @param code The code with escaped new lines
47
- * @returns The same code with new lines restored
48
- */
49
- const restoreNewLines = (code) => code.replace(/\/\* :newline: \*\//g, '\n');
50
- /**
51
- * Formats the code using Prettier
52
- * @param code The code to prettier format
53
- * @param prettierConfig Additional prettier options to use for formatting
54
- * @returns Prettier formatted code
55
- */
56
- const prettierFormatCode = (code, prettierConfig) => prettier_1.default.format(code, { ...documentationPrettierConfig, ...prettierConfig }).slice(0, -1);
57
- /**
58
- * Transforms a Docusaurus node from TypeScript to ESM and CJS
59
- * @param node The Docusaurus node to transform
60
- * @param isSync Whether the transform should synchronize between all entries of this type
61
- * @returns The transformed node in the form of Tabs.
62
- */
63
- const transformNode = (node, options) => {
64
- const groupIdProp = options.sync ? 'groupId="ts2esm2cjs" ' : '';
65
- const tsCode = escapeNewLines(node.value);
66
- const esmCode = tsToEsm(tsCode, { typescriptCompilerOptions: options.typescriptCompilerOptions }).outputText;
67
- const cjsCode = esmToCjs(esmCode);
68
- const [, jsHighlight, tsHighlight] = node.meta.split('|');
69
- return [
70
- {
71
- type: 'jsx',
72
- value: `<Tabs defaultValue="typescript" ${groupIdProp}` +
73
- `values={[
34
+ var import_prettier_config = __toESM(require("@sapphire/prettier-config"));
35
+ var import_esm_to_cjs = __toESM(require("esm-to-cjs"));
36
+ var import_prettier = __toESM(require("prettier"));
37
+ var import_typescript = __toESM(require("typescript"));
38
+ var documentationPrettierConfig = {
39
+ ...import_prettier_config.default,
40
+ tabWidth: 2,
41
+ useTabs: false,
42
+ printWidth: 120,
43
+ parser: "babel"
44
+ };
45
+ var makeTsCompilerOptions = (overrideOptions) => ({
46
+ newLine: import_typescript.default.NewLineKind.LineFeed,
47
+ removeComments: false,
48
+ esModuleInterop: true,
49
+ pretty: true,
50
+ ...overrideOptions,
51
+ module: import_typescript.default.ModuleKind.ESNext,
52
+ moduleResolution: import_typescript.default.ModuleResolutionKind.NodeJs,
53
+ target: import_typescript.default.ScriptTarget.ESNext
54
+ });
55
+ var tsToEsm = (code, options) => import_typescript.default.transpileModule(code, { reportDiagnostics: false, compilerOptions: makeTsCompilerOptions(options.typescriptCompilerOptions) });
56
+ var esmToCjs = (code) => (0, import_esm_to_cjs.runTransform)(code, { quote: "single", lenDestructure: 128, lenModuleName: 128, lenIdentifier: 128 });
57
+ var escapeNewLines = (code) => code.replace(/\n\n/g, "\n/* :newline: */");
58
+ var restoreNewLines = (code) => code.replace(/\/\* :newline: \*\//g, "\n");
59
+ var prettierFormatCode = (code, prettierConfig) => import_prettier.default.format(code, { ...documentationPrettierConfig, ...prettierConfig }).slice(0, -1);
60
+ var transformNode = (node, options) => {
61
+ const groupIdProp = options.sync ? 'groupId="ts2esm2cjs" ' : "";
62
+ const tsCode = escapeNewLines(node.value);
63
+ const esmCode = tsToEsm(tsCode, { typescriptCompilerOptions: options.typescriptCompilerOptions }).outputText;
64
+ const cjsCode = esmToCjs(esmCode);
65
+ const [, jsHighlight, tsHighlight] = node.meta.split("|");
66
+ return [
67
+ {
68
+ type: "jsx",
69
+ value: `<Tabs defaultValue="typescript" ${groupIdProp}values={[
74
70
  { label: 'JavaScript', value: 'javascript', },
75
71
  { label: 'ESM', value: 'esm', },
76
72
  { label: 'TypeScript', value: 'typescript', },
77
73
  ]}
78
74
  >
79
75
  <TabItem value="javascript">`
80
- },
81
- {
82
- type: node.type,
83
- lang: node.lang,
84
- meta: jsHighlight,
85
- value: prettierFormatCode(restoreNewLines(cjsCode), options.prettierOptions)
86
- },
87
- {
88
- type: 'jsx',
89
- value: '</TabItem>\n<TabItem value="esm">'
90
- },
91
- {
92
- type: node.type,
93
- lang: node.lang,
94
- meta: jsHighlight,
95
- value: prettierFormatCode(restoreNewLines(esmCode), options.prettierOptions)
96
- },
97
- {
98
- type: 'jsx',
99
- value: '</TabItem>\n<TabItem value="typescript">'
100
- },
101
- {
102
- type: node.type,
103
- lang: node.lang,
104
- meta: tsHighlight,
105
- value: node.value
106
- },
107
- {
108
- type: 'jsx',
109
- value: '</TabItem>\n</Tabs>'
110
- }
111
- ];
76
+ },
77
+ {
78
+ type: node.type,
79
+ lang: node.lang,
80
+ meta: jsHighlight,
81
+ value: prettierFormatCode(restoreNewLines(cjsCode), options.prettierOptions)
82
+ },
83
+ {
84
+ type: "jsx",
85
+ value: '</TabItem>\n<TabItem value="esm">'
86
+ },
87
+ {
88
+ type: node.type,
89
+ lang: node.lang,
90
+ meta: jsHighlight,
91
+ value: prettierFormatCode(restoreNewLines(esmCode), options.prettierOptions)
92
+ },
93
+ {
94
+ type: "jsx",
95
+ value: '</TabItem>\n<TabItem value="typescript">'
96
+ },
97
+ {
98
+ type: node.type,
99
+ lang: node.lang,
100
+ meta: tsHighlight,
101
+ value: node.value
102
+ },
103
+ {
104
+ type: "jsx",
105
+ value: "</TabItem>\n</Tabs>"
106
+ }
107
+ ];
112
108
  };
113
- const matchNode = (node) => node.type === 'code' && typeof node.meta === 'string' && node.meta.startsWith('ts2esm2cjs');
114
- const nodeForImport = {
115
- type: 'import',
116
- value: "import Tabs from '@theme/Tabs';\nimport TabItem from '@theme/TabItem';"
109
+ var matchNode = (node) => node.type === "code" && typeof node.meta === "string" && node.meta.startsWith("ts2esm2cjs");
110
+ var nodeForImport = {
111
+ type: "import",
112
+ value: "import Tabs from '@theme/Tabs';\nimport TabItem from '@theme/TabItem';"
117
113
  };
118
114
  function ts2esm2cjs({ sync = true, prettierOptions = {}, typescriptCompilerOptions = {} } = {
119
- sync: true,
120
- prettierOptions: {},
121
- typescriptCompilerOptions: {}
115
+ sync: true,
116
+ prettierOptions: {},
117
+ typescriptCompilerOptions: {}
122
118
  }) {
123
- let transformed = false;
124
- let alreadyImported = false;
125
- const transformer = (node) => {
126
- if (node.type === 'import' && node.value.includes('@theme/Tabs')) {
127
- alreadyImported = true;
119
+ let transformed = false;
120
+ let alreadyImported = false;
121
+ const transformer = (node) => {
122
+ if (node.type === "import" && node.value.includes("@theme/Tabs")) {
123
+ alreadyImported = true;
124
+ }
125
+ if (matchNode(node)) {
126
+ transformed = true;
127
+ return transformNode(node, { sync, prettierOptions, typescriptCompilerOptions });
128
+ }
129
+ if (Array.isArray(node.children)) {
130
+ let index = 0;
131
+ while (index < node.children.length) {
132
+ const result = transformer(node.children[index]);
133
+ if (result) {
134
+ node.children.splice(index, 1, ...result);
135
+ index += result.length;
136
+ } else {
137
+ index += 1;
128
138
  }
129
- if (matchNode(node)) {
130
- transformed = true;
131
- return transformNode(node, { sync, prettierOptions, typescriptCompilerOptions });
132
- }
133
- if (Array.isArray(node.children)) {
134
- let index = 0;
135
- while (index < node.children.length) {
136
- const result = transformer(node.children[index]);
137
- if (result) {
138
- node.children.splice(index, 1, ...result);
139
- index += result.length;
140
- }
141
- else {
142
- index += 1;
143
- }
144
- }
145
- }
146
- if (node.type === 'root' && transformed && !alreadyImported) {
147
- node.children.unshift(nodeForImport);
148
- }
149
- return null;
150
- };
151
- return transformer;
139
+ }
140
+ }
141
+ if (node.type === "root" && transformed && !alreadyImported) {
142
+ node.children.unshift(nodeForImport);
143
+ }
144
+ return null;
145
+ };
146
+ return transformer;
152
147
  }
153
- exports.ts2esm2cjs = ts2esm2cjs;
148
+ module.exports = __toCommonJS(src_exports);
149
+ // Annotate the CommonJS export names for ESM import in node:
150
+ 0 && (module.exports = {
151
+ ts2esm2cjs
152
+ });
154
153
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;AAAA,6FAA+D;AAC/D,2CAA0C;AAC1C,qEAA6C;AAC7C,yEAAiD;AAEjD,MAAM,2BAA2B,GAAY;IAC5C,GAAG,yBAAsB;IACzB,QAAQ,EAAE,CAAC;IACX,OAAO,EAAE,KAAK;IACd,UAAU,EAAE,GAAG;IACf,MAAM,EAAE,OAAO;CACf,CAAC;AAEF,MAAM,qBAAqB,GAAG,CAAC,eAAiC,EAAmB,EAAE,CAAC,CAAC;IACtF,OAAO,EAAE,oBAAE,CAAC,WAAW,CAAC,QAAQ;IAChC,cAAc,EAAE,KAAK;IACrB,eAAe,EAAE,IAAI;IACrB,MAAM,EAAE,IAAI;IACZ,GAAG,eAAe;IAClB,MAAM,EAAE,oBAAE,CAAC,UAAU,CAAC,MAAM;IAC5B,gB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AAC,MAAM,CAAC;iBACvB;qBAAM;oBACN,KAAK,IAAI,CAAC,CAAC;iBACX;aACD;SACD;QAED,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM,IAAI,WAAW,IAAI,CAAC,eAAe,EAAE;YAC5D,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;SACrC;QAED,OAAO,IAAI,CAAC;IACb,CAAC,CAAC;IAEF,OAAO,WAAW,CAAC;AACpB,CAAC;AAzCD,gCAyCC"}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import sapphirePrettierConfig from '@sapphire/prettier-config';\nimport { runTransform } from 'esm-to-cjs';\nimport prettier, { Options } from 'prettier';\nimport ts, { CompilerOptions } from 'typescript';\n\nconst documentationPrettierConfig: Options = {\n\t...sapphirePrettierConfig,\n\ttabWidth: 2,\n\tuseTabs: false,\n\tprintWidth: 120,\n\tparser: 'babel'\n};\n\nconst makeTsCompilerOptions = (overrideOptions?: CompilerOptions): CompilerOptions => ({\n\tnewLine: ts.NewLineKind.LineFeed,\n\tremoveComments: false,\n\tesModuleInterop: true,\n\tpretty: true,\n\t...overrideOptions,\n\tmodule: ts.ModuleKind.ESNext,\n\tmoduleResolution: ts.ModuleResolutionKind.NodeJs,\n\ttarget: ts.ScriptTarget.ESNext\n});\n\n/**\n * Transpiles input TypeScript code to ESM code.\n * @param code The code to transpile\n * @returns Input code transpiled to ESM\n */\nconst tsToEsm = (code: string, options: Pick<PluginOptions, 'typescriptCompilerOptions'>): ts.TranspileOutput =>\n\tts.transpileModule(code, { reportDiagnostics: false, compilerOptions: makeTsCompilerOptions(options.typescriptCompilerOptions) });\n\n/**\n * Transforms input ESM code to CJS code.\n * @param code The code to transform\n * @returns Input code transformed to CommonJS\n */\nconst esmToCjs = (code: string): string => runTransform(code, { quote: 'single', lenDestructure: 128, lenModuleName: 128, lenIdentifier: 128 });\n\n/**\n * Escaped new lines in code with block comments so they can be restored by {@link restoreNewLines}\n * @param code The code to escape new lines in\n * @returns The same code but with new lines escaped using block comments\n */\nconst escapeNewLines = (code: string) => code.replace(/\\n\\n/g, '\\n/* :newline: */');\n\n/**\n * Reverses {@link escapeNewLines} and restores new lines\n * @param code The code with escaped new lines\n * @returns The same code with new lines restored\n */\nconst restoreNewLines = (code: string): string => code.replace(/\\/\\* :newline: \\*\\//g, '\\n');\n\n/**\n * Formats the code using Prettier\n * @param code The code to prettier format\n * @param prettierConfig Additional prettier options to use for formatting\n * @returns Prettier formatted code\n */\nconst prettierFormatCode = (code: string, prettierConfig?: Options) =>\n\tprettier.format(code, { ...documentationPrettierConfig, ...prettierConfig }).slice(0, -1);\n\n/**\n * Transforms a Docusaurus node from TypeScript to ESM and CJS\n * @param node The Docusaurus node to transform\n * @param isSync Whether the transform should synchronize between all entries of this type\n * @returns The transformed node in the form of Tabs.\n */\nconst transformNode = (node: any, options: PluginOptions) => {\n\tconst groupIdProp = options.sync ? 'groupId=\"ts2esm2cjs\" ' : '';\n\n\tconst tsCode = escapeNewLines(node.value);\n\tconst esmCode = tsToEsm(tsCode, { typescriptCompilerOptions: options.typescriptCompilerOptions }).outputText;\n\tconst cjsCode = esmToCjs(esmCode);\n\n\tconst [, jsHighlight, tsHighlight] = node.meta.split('|');\n\n\treturn [\n\t\t{\n\t\t\ttype: 'jsx',\n\t\t\tvalue:\n\t\t\t\t`<Tabs defaultValue=\"typescript\" ${groupIdProp}` +\n\t\t\t\t`values={[\n { label: 'JavaScript', value: 'javascript', },\n { label: 'ESM', value: 'esm', },\n { label: 'TypeScript', value: 'typescript', },\n ]}\n>\n<TabItem value=\"javascript\">`\n\t\t},\n\t\t{\n\t\t\ttype: node.type,\n\t\t\tlang: node.lang,\n\t\t\tmeta: jsHighlight,\n\t\t\tvalue: prettierFormatCode(restoreNewLines(cjsCode), options.prettierOptions)\n\t\t},\n\t\t{\n\t\t\ttype: 'jsx',\n\t\t\tvalue: '</TabItem>\\n<TabItem value=\"esm\">'\n\t\t},\n\t\t{\n\t\t\ttype: node.type,\n\t\t\tlang: node.lang,\n\t\t\tmeta: jsHighlight,\n\t\t\tvalue: prettierFormatCode(restoreNewLines(esmCode), options.prettierOptions)\n\t\t},\n\t\t{\n\t\t\ttype: 'jsx',\n\t\t\tvalue: '</TabItem>\\n<TabItem value=\"typescript\">'\n\t\t},\n\t\t{\n\t\t\ttype: node.type,\n\t\t\tlang: node.lang,\n\t\t\tmeta: tsHighlight,\n\t\t\tvalue: node.value\n\t\t},\n\t\t{\n\t\t\ttype: 'jsx',\n\t\t\tvalue: '</TabItem>\\n</Tabs>'\n\t\t}\n\t];\n};\n\nconst matchNode = (node: any) => node.type === 'code' && typeof node.meta === 'string' && node.meta.startsWith('ts2esm2cjs');\nconst nodeForImport = {\n\ttype: 'import',\n\tvalue: \"import Tabs from '@theme/Tabs';\\nimport TabItem from '@theme/TabItem';\"\n};\n\nexport interface PluginOptions {\n\tsync?: boolean;\n\tprettierOptions?: Options;\n\ttypescriptCompilerOptions?: CompilerOptions;\n}\n\nexport function ts2esm2cjs(\n\t{ sync = true, prettierOptions = {}, typescriptCompilerOptions = {} }: PluginOptions = {\n\t\tsync: true,\n\t\tprettierOptions: {},\n\t\ttypescriptCompilerOptions: {}\n\t}\n) {\n\tlet transformed = false;\n\tlet alreadyImported = false;\n\n\tconst transformer = (node: any) => {\n\t\tif (node.type === 'import' && node.value.includes('@theme/Tabs')) {\n\t\t\talreadyImported = true;\n\t\t}\n\n\t\tif (matchNode(node)) {\n\t\t\ttransformed = true;\n\t\t\treturn transformNode(node, { sync, prettierOptions, typescriptCompilerOptions });\n\t\t}\n\n\t\tif (Array.isArray(node.children)) {\n\t\t\tlet index = 0;\n\t\t\twhile (index < node.children.length) {\n\t\t\t\tconst result = transformer(node.children[index]);\n\t\t\t\tif (result) {\n\t\t\t\t\tnode.children.splice(index, 1, ...result);\n\t\t\t\t\tindex += result.length;\n\t\t\t\t} else {\n\t\t\t\t\tindex += 1;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\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AO,QAAQ,KAAK,SAAS,QAAQ;AACpC,cAAM,SAAS,YAAY,KAAK,SAAS;AACzC,YAAI,QAAQ;AACX,eAAK,SAAS,OAAO,OAAO,GAAG,GAAG;AAClC,mBAAS,OAAO;AAAA,eACV;AACN,mBAAS;AAAA;AAAA;AAAA;AAKZ,QAAI,KAAK,SAAS,UAAU,eAAe,CAAC,iBAAiB;AAC5D,WAAK,SAAS,QAAQ;AAAA;AAGvB,WAAO;AAAA;AAGR,SAAO;AAAA;","names":[]}
package/dist/index.mjs CHANGED
@@ -1,4 +1,119 @@
1
- import mod from "./index.js";
2
-
3
- export default mod;
4
- export const ts2esm2cjs = mod.ts2esm2cjs;
1
+ // src/index.ts
2
+ import sapphirePrettierConfig from "@sapphire/prettier-config";
3
+ import { runTransform } from "esm-to-cjs";
4
+ import prettier from "prettier";
5
+ import ts from "typescript";
6
+ var documentationPrettierConfig = {
7
+ ...sapphirePrettierConfig,
8
+ tabWidth: 2,
9
+ useTabs: false,
10
+ printWidth: 120,
11
+ parser: "babel"
12
+ };
13
+ var makeTsCompilerOptions = (overrideOptions) => ({
14
+ newLine: ts.NewLineKind.LineFeed,
15
+ removeComments: false,
16
+ esModuleInterop: true,
17
+ pretty: true,
18
+ ...overrideOptions,
19
+ module: ts.ModuleKind.ESNext,
20
+ moduleResolution: ts.ModuleResolutionKind.NodeJs,
21
+ target: ts.ScriptTarget.ESNext
22
+ });
23
+ var tsToEsm = (code, options) => ts.transpileModule(code, { reportDiagnostics: false, compilerOptions: makeTsCompilerOptions(options.typescriptCompilerOptions) });
24
+ var esmToCjs = (code) => runTransform(code, { quote: "single", lenDestructure: 128, lenModuleName: 128, lenIdentifier: 128 });
25
+ var escapeNewLines = (code) => code.replace(/\n\n/g, "\n/* :newline: */");
26
+ var restoreNewLines = (code) => code.replace(/\/\* :newline: \*\//g, "\n");
27
+ var prettierFormatCode = (code, prettierConfig) => prettier.format(code, { ...documentationPrettierConfig, ...prettierConfig }).slice(0, -1);
28
+ var transformNode = (node, options) => {
29
+ const groupIdProp = options.sync ? 'groupId="ts2esm2cjs" ' : "";
30
+ const tsCode = escapeNewLines(node.value);
31
+ const esmCode = tsToEsm(tsCode, { typescriptCompilerOptions: options.typescriptCompilerOptions }).outputText;
32
+ const cjsCode = esmToCjs(esmCode);
33
+ const [, jsHighlight, tsHighlight] = node.meta.split("|");
34
+ return [
35
+ {
36
+ type: "jsx",
37
+ value: `<Tabs defaultValue="typescript" ${groupIdProp}values={[
38
+ { label: 'JavaScript', value: 'javascript', },
39
+ { label: 'ESM', value: 'esm', },
40
+ { label: 'TypeScript', value: 'typescript', },
41
+ ]}
42
+ >
43
+ <TabItem value="javascript">`
44
+ },
45
+ {
46
+ type: node.type,
47
+ lang: node.lang,
48
+ meta: jsHighlight,
49
+ value: prettierFormatCode(restoreNewLines(cjsCode), options.prettierOptions)
50
+ },
51
+ {
52
+ type: "jsx",
53
+ value: '</TabItem>\n<TabItem value="esm">'
54
+ },
55
+ {
56
+ type: node.type,
57
+ lang: node.lang,
58
+ meta: jsHighlight,
59
+ value: prettierFormatCode(restoreNewLines(esmCode), options.prettierOptions)
60
+ },
61
+ {
62
+ type: "jsx",
63
+ value: '</TabItem>\n<TabItem value="typescript">'
64
+ },
65
+ {
66
+ type: node.type,
67
+ lang: node.lang,
68
+ meta: tsHighlight,
69
+ value: node.value
70
+ },
71
+ {
72
+ type: "jsx",
73
+ value: "</TabItem>\n</Tabs>"
74
+ }
75
+ ];
76
+ };
77
+ var matchNode = (node) => node.type === "code" && typeof node.meta === "string" && node.meta.startsWith("ts2esm2cjs");
78
+ var nodeForImport = {
79
+ type: "import",
80
+ value: "import Tabs from '@theme/Tabs';\nimport TabItem from '@theme/TabItem';"
81
+ };
82
+ function ts2esm2cjs({ sync = true, prettierOptions = {}, typescriptCompilerOptions = {} } = {
83
+ sync: true,
84
+ prettierOptions: {},
85
+ typescriptCompilerOptions: {}
86
+ }) {
87
+ let transformed = false;
88
+ let alreadyImported = false;
89
+ const transformer = (node) => {
90
+ if (node.type === "import" && node.value.includes("@theme/Tabs")) {
91
+ alreadyImported = true;
92
+ }
93
+ if (matchNode(node)) {
94
+ transformed = true;
95
+ return transformNode(node, { sync, prettierOptions, typescriptCompilerOptions });
96
+ }
97
+ if (Array.isArray(node.children)) {
98
+ let index = 0;
99
+ while (index < node.children.length) {
100
+ const result = transformer(node.children[index]);
101
+ if (result) {
102
+ node.children.splice(index, 1, ...result);
103
+ index += result.length;
104
+ } else {
105
+ index += 1;
106
+ }
107
+ }
108
+ }
109
+ if (node.type === "root" && transformed && !alreadyImported) {
110
+ node.children.unshift(nodeForImport);
111
+ }
112
+ return null;
113
+ };
114
+ return transformer;
115
+ }
116
+ export {
117
+ ts2esm2cjs
118
+ };
119
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import sapphirePrettierConfig from '@sapphire/prettier-config';\nimport { runTransform } from 'esm-to-cjs';\nimport prettier, { Options } from 'prettier';\nimport ts, { CompilerOptions } from 'typescript';\n\nconst documentationPrettierConfig: Options = {\n\t...sapphirePrettierConfig,\n\ttabWidth: 2,\n\tuseTabs: false,\n\tprintWidth: 120,\n\tparser: 'babel'\n};\n\nconst makeTsCompilerOptions = (overrideOptions?: CompilerOptions): CompilerOptions => ({\n\tnewLine: ts.NewLineKind.LineFeed,\n\tremoveComments: false,\n\tesModuleInterop: true,\n\tpretty: true,\n\t...overrideOptions,\n\tmodule: ts.ModuleKind.ESNext,\n\tmoduleResolution: ts.ModuleResolutionKind.NodeJs,\n\ttarget: ts.ScriptTarget.ESNext\n});\n\n/**\n * Transpiles input TypeScript code to ESM code.\n * @param code The code to transpile\n * @returns Input code transpiled to ESM\n */\nconst tsToEsm = (code: string, options: Pick<PluginOptions, 'typescriptCompilerOptions'>): ts.TranspileOutput =>\n\tts.transpileModule(code, { reportDiagnostics: false, compilerOptions: makeTsCompilerOptions(options.typescriptCompilerOptions) });\n\n/**\n * Transforms input ESM code to CJS code.\n * @param code The code to transform\n * @returns Input code transformed to CommonJS\n */\nconst esmToCjs = (code: string): string => runTransform(code, { quote: 'single', lenDestructure: 128, lenModuleName: 128, lenIdentifier: 128 });\n\n/**\n * Escaped new lines in code with block comments so they can be restored by {@link restoreNewLines}\n * @param code The code to escape new lines in\n * @returns The same code but with new lines escaped using block comments\n */\nconst escapeNewLines = (code: string) => code.replace(/\\n\\n/g, '\\n/* :newline: */');\n\n/**\n * Reverses {@link escapeNewLines} and restores new lines\n * @param code The code with escaped new lines\n * @returns The same code with new lines restored\n */\nconst restoreNewLines = (code: string): string => code.replace(/\\/\\* :newline: \\*\\//g, '\\n');\n\n/**\n * Formats the code using Prettier\n * @param code The code to prettier format\n * @param prettierConfig Additional prettier options to use for formatting\n * @returns Prettier formatted code\n */\nconst prettierFormatCode = (code: string, prettierConfig?: Options) =>\n\tprettier.format(code, { ...documentationPrettierConfig, ...prettierConfig }).slice(0, -1);\n\n/**\n * Transforms a Docusaurus node from TypeScript to ESM and CJS\n * @param node The Docusaurus node to transform\n * @param isSync Whether the transform should synchronize between all entries of this type\n * @returns The transformed node in the form of Tabs.\n */\nconst transformNode = (node: any, options: PluginOptions) => {\n\tconst groupIdProp = options.sync ? 'groupId=\"ts2esm2cjs\" ' : '';\n\n\tconst tsCode = escapeNewLines(node.value);\n\tconst esmCode = tsToEsm(tsCode, { typescriptCompilerOptions: options.typescriptCompilerOptions }).outputText;\n\tconst cjsCode = esmToCjs(esmCode);\n\n\tconst [, jsHighlight, tsHighlight] = node.meta.split('|');\n\n\treturn [\n\t\t{\n\t\t\ttype: 'jsx',\n\t\t\tvalue:\n\t\t\t\t`<Tabs defaultValue=\"typescript\" ${groupIdProp}` +\n\t\t\t\t`values={[\n { label: 'JavaScript', value: 'javascript', },\n { label: 'ESM', value: 'esm', },\n { label: 'TypeScript', value: 'typescript', },\n ]}\n>\n<TabItem value=\"javascript\">`\n\t\t},\n\t\t{\n\t\t\ttype: node.type,\n\t\t\tlang: node.lang,\n\t\t\tmeta: jsHighlight,\n\t\t\tvalue: prettierFormatCode(restoreNewLines(cjsCode), options.prettierOptions)\n\t\t},\n\t\t{\n\t\t\ttype: 'jsx',\n\t\t\tvalue: '</TabItem>\\n<TabItem value=\"esm\">'\n\t\t},\n\t\t{\n\t\t\ttype: node.type,\n\t\t\tlang: node.lang,\n\t\t\tmeta: jsHighlight,\n\t\t\tvalue: prettierFormatCode(restoreNewLines(esmCode), options.prettierOptions)\n\t\t},\n\t\t{\n\t\t\ttype: 'jsx',\n\t\t\tvalue: '</TabItem>\\n<TabItem value=\"typescript\">'\n\t\t},\n\t\t{\n\t\t\ttype: node.type,\n\t\t\tlang: node.lang,\n\t\t\tmeta: tsHighlight,\n\t\t\tvalue: node.value\n\t\t},\n\t\t{\n\t\t\ttype: 'jsx',\n\t\t\tvalue: '</TabItem>\\n</Tabs>'\n\t\t}\n\t];\n};\n\nconst matchNode = (node: any) => node.type === 'code' && typeof node.meta === 'string' && node.meta.startsWith('ts2esm2cjs');\nconst nodeForImport = {\n\ttype: 'import',\n\tvalue: \"import Tabs from '@theme/Tabs';\\nimport TabItem from '@theme/TabItem';\"\n};\n\nexport interface PluginOptions {\n\tsync?: boolean;\n\tprettierOptions?: Options;\n\ttypescriptCompilerOptions?: CompilerOptions;\n}\n\nexport function ts2esm2cjs(\n\t{ sync = true, prettierOptions = {}, typescriptCompilerOptions = {} }: PluginOptions = {\n\t\tsync: true,\n\t\tprettierOptions: {},\n\t\ttypescriptCompilerOptions: {}\n\t}\n) {\n\tlet transformed = false;\n\tlet alreadyImported = false;\n\n\tconst transformer = (node: any) => {\n\t\tif (node.type === 'import' && node.value.includes('@theme/Tabs')) {\n\t\t\talreadyImported = true;\n\t\t}\n\n\t\tif (matchNode(node)) {\n\t\t\ttransformed = true;\n\t\t\treturn transformNode(node, { sync, prettierOptions, typescriptCompilerOptions });\n\t\t}\n\n\t\tif (Array.isArray(node.children)) {\n\t\t\tlet index = 0;\n\t\t\twhile (index < node.children.length) {\n\t\t\t\tconst result = transformer(node.children[index]);\n\t\t\t\tif (result) {\n\t\t\t\t\tnode.children.splice(index, 1, ...result);\n\t\t\t\t\tindex += result.length;\n\t\t\t\t} else {\n\t\t\t\t\tindex += 1;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (node.type === 'root' && transformed && !alreadyImported) {\n\t\t\tnode.children.unshift(nodeForImport);\n\t\t}\n\n\t\treturn null;\n\t};\n\n\treturn transformer;\n}\n"],"mappings":";AAAA;AACA;AACA;AACA;AAEA,IAAM,8BAAuC;AAAA,KACzC;AAAA,EACH,UAAU;AAAA,EACV,SAAS;AAAA,EACT,YAAY;AAAA,EACZ,QAAQ;AAAA;AAGT,IAAM,wBAAwB,CAAC,oBAAwD;AAAA,EACtF,SAAS,GAAG,YAAY;AAAA,EACxB,gBAAgB;AAAA,EAChB,iBAAiB;AAAA,EACjB,QAAQ;AAAA,KACL;AAAA,EACH,QAAQ,GAAG,WAAW;AAAA,EACtB,kBAAkB,GAAG,qBAAqB;AAAA,EAC1C,QAAQ,GAAG,aAAa;AAAA;AAQzB,IAAM,UAAU,CAAC,MAAc,YAC9B,GAAG,gBAAgB,MAAM,EAAE,mBAAmB,OAAO,iBAAiB,sBAAsB,QAAQ;AAOrG,IAAM,WAAW,CAAC,SAAyB,aAAa,MAAM,EAAE,OAAO,UAAU,gBAAgB,KAAK,eAAe,KAAK,eAAe;AAOzI,IAAM,iBAAiB,CAAC,SAAiB,KAAK,QAAQ,SAAS;AAO/D,IAAM,kBAAkB,CAAC,SAAyB,KAAK,QAAQ,wBAAwB;AAQvF,IAAM,qBAAqB,CAAC,MAAc,mBACzC,SAAS,OAAO,MAAM,KAAK,gCAAgC,kBAAkB,MAAM,GAAG;AAQvF,IAAM,gBAAgB,CAAC,MAAW,YAA2B;AAC5D,QAAM,cAAc,QAAQ,OAAO,0BAA0B;AAE7D,QAAM,SAAS,eAAe,KAAK;AACnC,QAAM,UAAU,QAAQ,QAAQ,EAAE,2BAA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iBAAiB;AAAA;AAGrD,QAAI,MAAM,QAAQ,KAAK,WAAW;AACjC,UAAI,QAAQ;AACZ,aAAO,QAAQ,KAAK,SAAS,QAAQ;AACpC,cAAM,SAAS,YAAY,KAAK,SAAS;AACzC,YAAI,QAAQ;AACX,eAAK,SAAS,OAAO,OAAO,GAAG,GAAG;AAClC,mBAAS,OAAO;AAAA,eACV;AACN,mBAAS;AAAA;AAAA;AAAA;AAKZ,QAAI,KAAK,SAAS,UAAU,eAAe,CAAC,iBAAiB;AAC5D,WAAK,SAAS,QAAQ;AAAA;AAGvB,WAAO;AAAA;AAGR,SAAO;AAAA;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sapphire/docusaurus-plugin-ts2esm2cjs",
3
- "version": "1.0.1",
3
+ "version": "1.0.2-next.6da8148.0",
4
4
  "description": "Docusaurus Remark plugin for converting TypeScript code to ESM and CJS code",
5
5
  "author": "@sapphire",
6
6
  "license": "MIT",
@@ -13,17 +13,15 @@
13
13
  },
14
14
  "scripts": {
15
15
  "lint": "eslint src --ext ts --fix",
16
- "build": "tsc -b src && gen-esm-wrapper dist/index.js dist/index.mjs",
17
- "clean": "tsc -b src --clean",
18
- "watch": "tsc -b src -w",
16
+ "build": "tsup && tsc -b src",
17
+ "typecheck": "tsc -p tsconfig.eslint.json",
19
18
  "prepublishOnly": "yarn build"
20
19
  },
21
20
  "dependencies": {
22
- "@sapphire/prettier-config": "^1.2.6",
21
+ "@sapphire/prettier-config": "^1.2.7",
23
22
  "esm-to-cjs": "^1.2.0",
24
- "prettier": "^2.5.0",
25
- "tslib": "^2.3.1",
26
- "typescript": "^4.5.2"
23
+ "prettier": "^2.5.1",
24
+ "typescript": "^4.5.4"
27
25
  },
28
26
  "repository": {
29
27
  "type": "git",
@@ -57,8 +55,5 @@
57
55
  "publishConfig": {
58
56
  "access": "public"
59
57
  },
60
- "devDependencies": {
61
- "@types/prettier": "^2"
62
- },
63
- "gitHead": "bf8adb9091117077e24371f84fc5f0b2f064bc1f"
58
+ "gitHead": "6da81481b009796c45e1a90a044f871ffa163b42"
64
59
  }