@tailor-platform/sdk-codemod 0.4.2 → 0.5.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/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # @tailor-platform/sdk-codemod
2
2
 
3
+ ## 0.5.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#2023](https://github.com/tailor-platform/sdk/pull/2023) [`9dc826f`](https://github.com/tailor-platform/sdk/commit/9dc826fc0a83aa926de5b07245513f67c1ace877) Thanks [@dqn](https://github.com/dqn)! - Guide users through the v2 type-only import requirement. The CLI loads TypeScript by stripping types from each file in isolation, so a plain import of a type-only export fails at load time with `SyntaxError: ... does not provide an export named '<name>'` and no indication that the import form is the cause.
8
+
9
+ - The CLI now appends a suggestion to that error: import the name with `import type` and set `"verbatimModuleSyntax": true` in tsconfig.json to catch violations at typecheck.
10
+ - Projects scaffolded by `tailor init` now enable `verbatimModuleSyntax` in their tsconfig.json, so new projects catch violations at typecheck instead of at load time.
11
+ - The v2 migration guide gains a `v2/type-only-imports` entry documenting the requirement, the failure mode, and the migration steps, offered by `tailor upgrade` when crossing the v2 boundary.
12
+
3
13
  ## 0.4.2
4
14
 
5
15
  ### Patch Changes
package/dist/index.js CHANGED
@@ -116,6 +116,7 @@ const RENAME_BIN_QUOTED_LEGACY_COMMAND_PATTERN = new RegExp([
116
116
  ].join(""));
117
117
  const V2_NEXT_1 = "2.0.0-next.1";
118
118
  const V2_NEXT_2 = "2.0.0-next.2";
119
+ const V2_NEXT_3 = "2.0.0-next.3";
119
120
  const V2_NEXT_4 = "2.0.0-next.4";
120
121
  const V2_NEXT_5 = "2.0.0-next.5";
121
122
  const V2_NEXT_6 = "2.0.0-next.6";
@@ -124,6 +125,50 @@ const V2_NEXT_9 = "2.0.0-next.9";
124
125
  const V2_NEXT_11 = "2.0.0-next.11";
125
126
  /** All registered codemods, in registration order. */
126
127
  const allCodemods = [
128
+ {
129
+ id: "v2/type-only-imports",
130
+ name: "Type-only imports → `import type`",
131
+ description: [
132
+ "The v2 CLI runs TypeScript by stripping types from each file in isolation,",
133
+ "with no cross-file type information. A plain (non-`type`) import of a",
134
+ "type-only export therefore survives stripping and fails when the module",
135
+ "loads:",
136
+ "",
137
+ "```",
138
+ "SyntaxError: The requested module './types.ts' does not provide an export named 'Row'",
139
+ "```",
140
+ "",
141
+ "`tailor generate` / `tailor deploy` stop at this error before doing any work.",
142
+ "Import types with `import type` (or the inline `type` modifier), and",
143
+ "re-export them with `export type`, in every module the CLI loads. Generated",
144
+ "Kysely types (`DB`, `Insertable`, `Selectable`, table row types) are almost",
145
+ "entirely type-only, so v1 projects typically hit this in many files at once.",
146
+ "Set `\"verbatimModuleSyntax\": true` in tsconfig.json to catch every violation",
147
+ "at typecheck; projects scaffolded by v2 `tailor init` enable it by default."
148
+ ].join("\n"),
149
+ since: "1.0.0",
150
+ until: "2.0.0",
151
+ prereleaseUntil: V2_NEXT_3,
152
+ examples: [{
153
+ before: "import { DB, getDB } from \"./generated/db\";",
154
+ after: "import { type DB, getDB } from \"./generated/db\";"
155
+ }],
156
+ prompt: [
157
+ "In Tailor SDK v2 the CLI loads TypeScript by stripping types from each file",
158
+ "in isolation, so type-only exports do not exist at runtime and plain imports",
159
+ "of them fail to load with \"does not provide an export named '<name>'\".",
160
+ "Migrate the project so every type-only import and re-export is marked:",
161
+ "",
162
+ "1. Add `\"verbatimModuleSyntax\": true` to compilerOptions in tsconfig.json.",
163
+ "2. Run `tsc --noEmit` and fix every reported violation: add the `type`",
164
+ " modifier to type-only named imports (`import type { Row }` or",
165
+ " `import { type Row, marker }`) and change type-only re-exports to",
166
+ " `export type { ... }`.",
167
+ "",
168
+ "Only add `type` modifiers; do not reorder, remove, or otherwise change",
169
+ "imports that are used as values."
170
+ ].join("\n")
171
+ },
127
172
  {
128
173
  id: "v2/define-generators-to-plugins",
129
174
  name: "defineGenerators → definePlugins",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tailor-platform/sdk-codemod",
3
- "version": "0.4.2",
3
+ "version": "0.5.0",
4
4
  "description": "Codemod runner for Tailor Platform SDK upgrades",
5
5
  "license": "MIT",
6
6
  "repository": {