@timvir/macro 0.2.46 → 0.2.48

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.
Files changed (3) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/index.js +0 -32
  3. package/package.json +2 -4
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @timvir/macro
2
2
 
3
+ ## 0.2.48
4
+
5
+ ### Patch Changes
6
+
7
+ - **Drop dependency on Prettier** ([#3656](https://github.com/timvir/timvir/pull/3656)) - Prettier was used in the `@timvir/macro` and `@timvir/mdx` packages to format source code that's injected into MDX files. When Prettier released major version 3, they dropped the synchronous API so we were not able to keep up to date. Many projects are starting to adopt alternative formatters (oxc, biome). Using Prettier introduces divergence between code in files and code that appears in the documentation. Reformatting code makes line highlighting unpredictable. Lines of code that the developer sees in source files may not correspond to lines in the documentation. Due to those reasons, we're dropping dependency on Prettier. Along with that, the macro and MDX plugin `<Sample>` component no longer supports `as="source/component"` or `as="source/markup"`. If you rely on those features, inline the code into your MDX files.
8
+
9
+ ## 0.2.47
10
+
3
11
  ## 0.2.46
4
12
 
5
13
  ## 0.2.45
package/index.js CHANGED
@@ -2,9 +2,7 @@ const { join, dirname } = require("node:path");
2
2
  const fs = require("node:fs");
3
3
  const crypto = require("node:crypto");
4
4
  const { createMacro } = require("babel-plugin-macros");
5
- const { parse } = require("@babel/parser");
6
5
  const generate = require("@babel/generator");
7
- const prettier = require("prettier");
8
6
 
9
7
  let counter = 0;
10
8
 
@@ -103,36 +101,6 @@ module.exports = createMacro(({ references, babel, state }) => {
103
101
 
104
102
  const string = {
105
103
  module: () => source,
106
- component: () => {
107
- const file = parse(source, {
108
- sourceType: "module",
109
- plugins: ["jsx", "typescript"],
110
- });
111
-
112
- const exportDefaultDeclaration = file.program.body.find((node) => t.isExportDefaultDeclaration(node));
113
- const { declaration } = exportDefaultDeclaration;
114
- const { code } = generate.default(declaration);
115
- return prettier.format(code, {
116
- parser: "typescript",
117
- printWidth: 80,
118
- });
119
- },
120
- markup: () => {
121
- const file = parse(source, {
122
- sourceType: "module",
123
- plugins: ["jsx", "typescript"],
124
- });
125
-
126
- const exportDefaultDeclaration = file.program.body.find((node) => t.isExportDefaultDeclaration(node));
127
- const { declaration } = exportDefaultDeclaration;
128
- const body = declaration.body.body;
129
- const returnStatement = body.find((node) => t.isReturnStatement(node));
130
- const { code } = generate.default(returnStatement.argument);
131
- return prettier.format(code, {
132
- parser: "typescript",
133
- printWidth: 80,
134
- });
135
- },
136
104
  }[as]();
137
105
 
138
106
  referencePath.parentPath.parentPath.replaceWith(t.stringLiteral(string));
package/package.json CHANGED
@@ -1,12 +1,10 @@
1
1
  {
2
2
  "name": "@timvir/macro",
3
- "version": "0.2.46",
3
+ "version": "0.2.48",
4
4
  "license": "MIT",
5
5
  "sideEffects": false,
6
6
  "dependencies": {
7
- "@babel/parser": "^7",
8
- "@babel/generator": "^7",
9
- "prettier": "^2"
7
+ "@babel/generator": "^7"
10
8
  },
11
9
  "repository": {
12
10
  "type": "git",