@sapphire/docusaurus-plugin-ts2esm2cjs 1.0.2-next.dfbe36e.0 → 1.0.2

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,486 @@
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 __esm = (fn, res) => function __init() {
9
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
15
10
  };
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
11
+ var __commonJS = (cb, mod) => function __require() {
12
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
13
+ };
14
+ var __export = (target, all) => {
15
+ for (var name in all)
16
+ __defProp(target, name, { get: all[name], enumerable: true });
17
+ };
18
+ var __reExport = (target, module2, copyDefault, desc) => {
19
+ if (module2 && typeof module2 === "object" || typeof module2 === "function") {
20
+ for (let key of __getOwnPropNames(module2))
21
+ if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
22
+ __defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
23
+ }
24
+ return target;
25
+ };
26
+ var __toESM = (module2, isNodeMode) => {
27
+ return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
28
+ };
29
+ var __toCommonJS = /* @__PURE__ */ ((cache) => {
30
+ return (module2, temp) => {
31
+ return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
32
+ };
33
+ })(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
34
+
35
+ // ../../node_modules/tsup/assets/cjs_shims.js
36
+ var init_cjs_shims = __esm({
37
+ "../../node_modules/tsup/assets/cjs_shims.js"() {
38
+ }
25
39
  });
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={[
40
+
41
+ // src/esmToCjs.js
42
+ var require_esmToCjs = __commonJS({
43
+ "src/esmToCjs.js"(exports, module2) {
44
+ init_cjs_shims();
45
+ module2.exports.runTransform = runTransform2;
46
+ var LOOKING_FOR;
47
+ var DISTANCE = 6;
48
+ var defaultOptions = {
49
+ quote: "double",
50
+ lenDestructure: 60,
51
+ lenModuleName: 20,
52
+ lenIdentifier: 20,
53
+ indent: 2
54
+ };
55
+ function runTransform2(str, options = {}) {
56
+ options = { ...defaultOptions, ...options };
57
+ options.quote = options.quote === "single" ? "'" : '"';
58
+ const buffer = [];
59
+ const exportBuffer = {
60
+ items: [],
61
+ requires: []
62
+ };
63
+ let pos = 0;
64
+ for (const token of tokenize(str, options)) {
65
+ buffer.push(str.slice(pos, token.start));
66
+ buffer.push(transform(token, str, exportBuffer, options));
67
+ pos = token.end + 1;
68
+ }
69
+ pos = skipNewLines(str, pos);
70
+ buffer.push(str.slice(pos, str.length));
71
+ if (exportBuffer.items.length) {
72
+ const indent = " ".repeat(options.indent);
73
+ for (const item of exportBuffer.requires) {
74
+ buffer.push(item);
75
+ }
76
+ buffer.push("\nmodule.exports = {\n");
77
+ const exportNames = exportBuffer.items.map((item) => `${indent}${item[0]}${item[1] ? `: ${item[1]}` : ""}`);
78
+ buffer.push(exportNames.join(",\n"));
79
+ buffer.push("\n}");
80
+ }
81
+ buffer.push("\n");
82
+ return buffer.join("");
83
+ }
84
+ function transform(token, str, exportBuffer, { indent }) {
85
+ indent = " ".repeat(indent);
86
+ const { type } = token;
87
+ switch (type) {
88
+ case "import": {
89
+ const identifiers = token.modules.map((s) => s.join(": ")).join(", ");
90
+ return `const { ${identifiers} } = require(${token.moduleName})`;
91
+ }
92
+ case "import*":
93
+ case "importDefault": {
94
+ const { identifier, moduleName } = token;
95
+ return `const ${identifier} = require(${moduleName})${token.isDefaultImport ? ".default" : ""}`;
96
+ }
97
+ case "awaitImport": {
98
+ return `require(${token.moduleName})`;
99
+ }
100
+ case "export": {
101
+ exportBuffer.items.push(token.modules);
102
+ return "";
103
+ }
104
+ case "reExport": {
105
+ const { moduleName } = token;
106
+ if (token.modules.length === 1) {
107
+ const [original, alias] = token.modules[0];
108
+ exportBuffer.items.push([alias ? alias : original, `require(${moduleName}).${original}`]);
109
+ return;
110
+ }
111
+ exportBuffer.requires.push("const {\n");
112
+ const names = token.modules.map(([original]) => `${indent}${original}: __${original}__`).join(",\n");
113
+ exportBuffer.requires.push(names);
114
+ exportBuffer.requires.push(`
115
+ } = require(${moduleName});`);
116
+ for (const [original, alias] of token.modules) {
117
+ exportBuffer.items.push([alias ? alias : original, `__${original}__`]);
118
+ }
119
+ return "";
120
+ }
121
+ case "reExportImported": {
122
+ exportBuffer.items.push(...token.modules);
123
+ return "";
124
+ }
125
+ default:
126
+ throw new Error("should not reach here");
127
+ }
128
+ }
129
+ String.prototype.indexWithin = indexWithin;
130
+ function* tokenize(str, options) {
131
+ const { quote, lenDestructure, lenModuleName, lenIdentifier } = options;
132
+ let start = 0;
133
+ let pos;
134
+ const types = /* @__PURE__ */ new Map([
135
+ ["import", "import "],
136
+ ["export", "export "],
137
+ ["awaitImport", "await import("]
138
+ ]);
139
+ while (types.size !== 0) {
140
+ pos = Number.POSITIVE_INFINITY;
141
+ let type;
142
+ for (const t of types.keys()) {
143
+ const idx = str.indexOf(types.get(t), start);
144
+ if (idx === -1) {
145
+ types.delete(t);
146
+ } else if (idx < pos) {
147
+ pos = idx;
148
+ type = t;
149
+ }
150
+ }
151
+ switch (type) {
152
+ case "import":
153
+ yield handleImport();
154
+ break;
155
+ case "export":
156
+ yield handleExport();
157
+ break;
158
+ case "awaitImport":
159
+ yield handleAwaitImport();
160
+ break;
161
+ }
162
+ }
163
+ function handleImport() {
164
+ LOOKING_FOR = "import names";
165
+ const braceStart = str.indexWithin("{", pos + 7, DISTANCE, false);
166
+ if (braceStart === -1) {
167
+ return handleImportStar();
168
+ }
169
+ const braceEnd = str.indexWithin("}", braceStart + 1, lenDestructure);
170
+ LOOKING_FOR = "name of imported module";
171
+ let moduleStart = str.indexWithin("from ", braceEnd + 1, DISTANCE);
172
+ moduleStart = str.indexWithin(quote, moduleStart + 1, 5);
173
+ const moduleEnd = str.indexWithin(quote, moduleStart + 1, lenModuleName);
174
+ start = moduleEnd + 1;
175
+ return {
176
+ type: "import",
177
+ start: pos,
178
+ end: moduleEnd,
179
+ modules: destructureModules(str.slice(braceStart, braceEnd + 1)),
180
+ moduleName: str.slice(moduleStart, moduleEnd + 1)
181
+ };
182
+ }
183
+ function handleAwaitImport() {
184
+ LOOKING_FOR = "name of imported module for await import()";
185
+ const moduleStart = str.indexWithin("(", pos + 12, 10) + 1;
186
+ const moduleEnd = str.indexWithin(")", moduleStart + 1, lenIdentifier) - 1;
187
+ start = moduleEnd + 2;
188
+ return {
189
+ type: "awaitImport",
190
+ start: pos,
191
+ end: moduleEnd + 1,
192
+ moduleName: str.slice(moduleStart, moduleEnd + 1)
193
+ };
194
+ }
195
+ function handleExport() {
196
+ LOOKING_FOR = "export pattern";
197
+ let skipStart = pos + "export ".length;
198
+ if (str.indexWithin("{", skipStart, 5, false) !== -1) {
199
+ return handleReExport();
200
+ } else if (str.indexWithin("*", skipStart, 5, false) !== -1) {
201
+ return handleExportStar();
202
+ }
203
+ LOOKING_FOR = "identifier type (function|class|const) for export";
204
+ if (str.indexWithin("async ", skipStart, DISTANCE, false) !== -1) {
205
+ skipStart += 6;
206
+ }
207
+ let isDefaultExport = false;
208
+ if (str.indexWithin("default ", skipStart, DISTANCE, false) !== -1) {
209
+ skipStart += 8;
210
+ isDefaultExport = true;
211
+ }
212
+ const typeEnd = str.indexWithin(" ", skipStart, 9);
213
+ const exportType = str.slice(skipStart, typeEnd);
214
+ LOOKING_FOR = "export identifiers";
215
+ const identifierStart = str.indexWithin(" ", skipStart + exportType.length, 5) + 1;
216
+ const identifierEnd = str.indexWithin(exportType === "function" ? "(" : " ", identifierStart, lenIdentifier) - 1;
217
+ const end = pos + 6 + (isDefaultExport ? 8 : 0);
218
+ const modules = isDefaultExport ? ["default", str.slice(identifierStart, identifierEnd + 1)] : [str.slice(identifierStart, identifierEnd + 1)];
219
+ start = end + 1;
220
+ return {
221
+ type: "export",
222
+ start: pos,
223
+ end,
224
+ modules
225
+ };
226
+ }
227
+ function handleImportStar() {
228
+ LOOKING_FOR = "import name for import*";
229
+ let identifierStart = str.indexWithin("* as ", pos + 7, DISTANCE, false);
230
+ if (identifierStart === -1) {
231
+ return handleDefaultImport();
232
+ }
233
+ identifierStart += 5;
234
+ const identifierEnd = str.indexWithin(" ", identifierStart + 1, lenIdentifier);
235
+ LOOKING_FOR = "name of imported module for import*";
236
+ let moduleStart = str.indexWithin("from ", identifierEnd + 1) + "from".length;
237
+ moduleStart = str.indexWithin(quote, moduleStart + 1);
238
+ const moduleEnd = str.indexWithin(quote, moduleStart + 1, lenModuleName);
239
+ start = moduleEnd + 1;
240
+ return {
241
+ type: "import*",
242
+ start: pos,
243
+ end: moduleEnd,
244
+ identifier: str.slice(identifierStart, identifierEnd),
245
+ moduleName: str.slice(moduleStart, moduleEnd + 1)
246
+ };
247
+ }
248
+ function handleDefaultImport() {
249
+ LOOKING_FOR = "import name for default import";
250
+ const identifierStart = pos + 7;
251
+ const identifierEnd = str.indexWithin(" ", identifierStart, DISTANCE);
252
+ LOOKING_FOR = "name of imported module for import*";
253
+ let moduleStart = str.indexWithin("from ", identifierEnd + 1) + "from".length;
254
+ moduleStart = str.indexWithin(quote, moduleStart + 1);
255
+ const moduleEnd = str.indexWithin(quote, moduleStart + 1, lenModuleName);
256
+ start = moduleEnd + 1;
257
+ return {
258
+ type: "importDefault",
259
+ start: pos,
260
+ end: moduleEnd,
261
+ isDefaultImport: true,
262
+ identifier: str.slice(identifierStart, identifierEnd),
263
+ moduleName: str.slice(moduleStart, moduleEnd + 1)
264
+ };
265
+ }
266
+ function handleReExport() {
267
+ LOOKING_FOR = "export pattern for re-export";
268
+ const braceStart = str.indexWithin("{", pos + "export ".length, 5);
269
+ const braceEnd = str.indexWithin("}", braceStart + 1, lenDestructure);
270
+ LOOKING_FOR = "name of re-exported module";
271
+ let moduleStart = str.indexWithin("from ", braceEnd + 1, 10, false);
272
+ if (moduleStart === -1) {
273
+ const end2 = skipNewLines(str, braceEnd);
274
+ start = end2 + 1;
275
+ return {
276
+ type: "reExportImported",
277
+ start: pos,
278
+ end: end2,
279
+ modules: destructureModules(str.slice(braceStart, braceEnd + 1))
280
+ };
281
+ }
282
+ moduleStart = str.indexWithin(quote, moduleStart, "from ".length + 4);
283
+ const moduleEnd = str.indexWithin(quote, moduleStart + 1, lenModuleName);
284
+ const end = skipNewLines(str, moduleEnd);
285
+ start = end + 1;
286
+ return {
287
+ type: "reExport",
288
+ start: pos,
289
+ end,
290
+ modules: destructureModules(str.slice(braceStart, braceEnd + 1)),
291
+ moduleName: str.slice(moduleStart, moduleEnd + 1)
292
+ };
293
+ }
294
+ function handleExportStar() {
295
+ throw new Error("not implemented");
296
+ }
297
+ function destructureModules(objLiteral) {
298
+ return objLiteral.trim().slice(1, -1).split(/,\s*/).map((i) => i.trim()).filter((i) => i).map((i) => i.split(/\s*\bas\b\s*/));
299
+ }
300
+ }
301
+ function indexWithin(needle, from, within = 99, throws = true) {
302
+ for (let i = from, L = from + within, j = 0; i < L; ++i) {
303
+ if (this.charCodeAt(i) === needle.charCodeAt(j)) {
304
+ while (j < needle.length) {
305
+ if (this.charCodeAt(i + j) === needle.charCodeAt(j)) {
306
+ ++j;
307
+ } else {
308
+ j = 0;
309
+ break;
310
+ }
311
+ }
312
+ if (j === needle.length) {
313
+ return i;
314
+ }
315
+ }
316
+ }
317
+ if (throws) {
318
+ throw new Error(`ParseError: Failed to find \`${needle}\` within ${within} characters from position ${from}${LOOKING_FOR ? ` while looking for ${LOOKING_FOR}` : ""}
319
+
320
+ INPUT STRING:
321
+ ${"*".repeat(20)}
322
+ ${this}
323
+ ${"*".repeat(20)}
324
+ `);
325
+ } else {
326
+ return -1;
327
+ }
328
+ }
329
+ function skipNewLines(str, i) {
330
+ if (str.charAt(i + 1) === ";")
331
+ ++i;
332
+ while (i < str.length && /\s/.test(str.charAt(i))) {
333
+ ++i;
334
+ }
335
+ return i;
336
+ }
337
+ }
338
+ });
339
+
340
+ // src/index.ts
341
+ var src_exports = {};
342
+ __export(src_exports, {
343
+ documentationPrettierConfig: () => documentationPrettierConfig,
344
+ escapeNewLines: () => escapeNewLines,
345
+ esmToCjs: () => esmToCjs,
346
+ makeTsCompilerOptions: () => makeTsCompilerOptions,
347
+ prettierFormatCode: () => prettierFormatCode,
348
+ restoreNewLines: () => restoreNewLines,
349
+ ts2esm2cjs: () => ts2esm2cjs,
350
+ tsToEsm: () => tsToEsm
351
+ });
352
+ init_cjs_shims();
353
+ var import_prettier_config = __toESM(require("@sapphire/prettier-config"));
354
+ var import_esmToCjs = __toESM(require_esmToCjs());
355
+ var import_prettier = __toESM(require("prettier"));
356
+ var import_typescript = __toESM(require("typescript"));
357
+ var documentationPrettierConfig = {
358
+ ...import_prettier_config.default,
359
+ tabWidth: 2,
360
+ useTabs: false,
361
+ printWidth: 120,
362
+ parser: "babel"
363
+ };
364
+ var makeTsCompilerOptions = (overrideOptions) => ({
365
+ newLine: import_typescript.default.NewLineKind.LineFeed,
366
+ removeComments: false,
367
+ esModuleInterop: true,
368
+ pretty: true,
369
+ ...overrideOptions,
370
+ module: import_typescript.default.ModuleKind.ESNext,
371
+ moduleResolution: import_typescript.default.ModuleResolutionKind.NodeJs,
372
+ target: import_typescript.default.ScriptTarget.ESNext
373
+ });
374
+ var tsToEsm = (code, options) => import_typescript.default.transpileModule(code, { reportDiagnostics: false, compilerOptions: makeTsCompilerOptions(options.typescriptCompilerOptions) });
375
+ var esmToCjs = (code) => (0, import_esmToCjs.runTransform)(code, { quote: "single", lenDestructure: 512, lenModuleName: 512, lenIdentifier: 512 });
376
+ var escapeNewLines = (code) => code.replace(/\n\n/g, "\n/* :newline: */");
377
+ var restoreNewLines = (code) => code.replace(/\/\* :newline: \*\//g, "\n");
378
+ var prettierFormatCode = (code, prettierConfig) => import_prettier.default.format(code, { ...documentationPrettierConfig, ...prettierConfig }).slice(0, -1);
379
+ var transformNode = (node, options) => {
380
+ const groupIdProp = options.sync ? 'groupId="ts2esm2cjs" ' : "";
381
+ const tsCode = escapeNewLines(node.value);
382
+ const esmCode = tsToEsm(tsCode, { typescriptCompilerOptions: options.typescriptCompilerOptions }).outputText;
383
+ const cjsCode = esmToCjs(esmCode);
384
+ const [, jsHighlight, tsHighlight] = node.meta.split("|");
385
+ return [
386
+ {
387
+ type: "jsx",
388
+ value: `<Tabs defaultValue="typescript" ${groupIdProp}values={[
74
389
  { label: 'JavaScript', value: 'javascript', },
75
390
  { label: 'ESM', value: 'esm', },
76
391
  { label: 'TypeScript', value: 'typescript', },
77
392
  ]}
78
393
  >
79
394
  <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
- ];
395
+ },
396
+ {
397
+ type: node.type,
398
+ lang: node.lang,
399
+ meta: jsHighlight,
400
+ value: prettierFormatCode(restoreNewLines(cjsCode), options.prettierOptions)
401
+ },
402
+ {
403
+ type: "jsx",
404
+ value: '</TabItem>\n<TabItem value="esm">'
405
+ },
406
+ {
407
+ type: node.type,
408
+ lang: node.lang,
409
+ meta: jsHighlight,
410
+ value: prettierFormatCode(restoreNewLines(esmCode), options.prettierOptions)
411
+ },
412
+ {
413
+ type: "jsx",
414
+ value: '</TabItem>\n<TabItem value="typescript">'
415
+ },
416
+ {
417
+ type: node.type,
418
+ lang: node.lang,
419
+ meta: tsHighlight,
420
+ value: node.value
421
+ },
422
+ {
423
+ type: "jsx",
424
+ value: "</TabItem>\n</Tabs>"
425
+ }
426
+ ];
112
427
  };
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';"
428
+ var matchNode = (node) => node.type === "code" && typeof node.meta === "string" && node.meta.startsWith("ts2esm2cjs");
429
+ var nodeForImport = {
430
+ type: "import",
431
+ value: "import Tabs from '@theme/Tabs';\nimport TabItem from '@theme/TabItem';"
117
432
  };
118
433
  function ts2esm2cjs({ sync = true, prettierOptions = {}, typescriptCompilerOptions = {} } = {
119
- sync: true,
120
- prettierOptions: {},
121
- typescriptCompilerOptions: {}
434
+ sync: true,
435
+ prettierOptions: {},
436
+ typescriptCompilerOptions: {}
122
437
  }) {
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;
128
- }
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
- }
438
+ let transformed = false;
439
+ let alreadyImported = false;
440
+ const transformer = (node) => {
441
+ if (node.type === "import" && node.value.includes("@theme/Tabs")) {
442
+ alreadyImported = true;
443
+ }
444
+ if (matchNode(node)) {
445
+ transformed = true;
446
+ return transformNode(node, { sync, prettierOptions, typescriptCompilerOptions });
447
+ }
448
+ if (Array.isArray(node.children)) {
449
+ let index = 0;
450
+ while (index < node.children.length) {
451
+ const result = transformer(node.children[index]);
452
+ if (result) {
453
+ node.children.splice(index, 1, ...result);
454
+ index += result.length;
455
+ } else {
456
+ index += 1;
145
457
  }
146
- if (node.type === 'root' && transformed && !alreadyImported) {
147
- node.children.unshift(nodeForImport);
148
- }
149
- return null;
150
- };
151
- return transformer;
458
+ }
459
+ }
460
+ if (node.type === "root" && transformed && !alreadyImported) {
461
+ node.children.unshift(nodeForImport);
462
+ }
463
+ return null;
464
+ };
465
+ return transformer;
152
466
  }
153
- exports.ts2esm2cjs = ts2esm2cjs;
467
+ module.exports = __toCommonJS(src_exports);
468
+ // Annotate the CommonJS export names for ESM import in node:
469
+ 0 && (module.exports = {
470
+ documentationPrettierConfig,
471
+ escapeNewLines,
472
+ esmToCjs,
473
+ makeTsCompilerOptions,
474
+ prettierFormatCode,
475
+ restoreNewLines,
476
+ ts2esm2cjs,
477
+ tsToEsm
478
+ });
479
+ /**
480
+ * @license MIT
481
+ * @copyright 2018 Sid Vishnoi <sidvishnoi8@gmail.com>
482
+ * @see https://github.com/sidvishnoi/esm-to-cjs/blob/d032518da994b6d28cff5fd38ac2d0b45a13f0d9/src/core.js
483
+ *
484
+ * Modified code is line 340
485
+ */
154
486
  //# sourceMappingURL=index.js.map