@acebuilder/component-tagger 0.1.0 → 0.1.1

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/index.js CHANGED
@@ -10,10 +10,15 @@
10
10
  */
11
11
  const TAGGER_LOADER = require.resolve('./lib/loader')
12
12
 
13
+ // Loader output stays TSX/JSX — `as: '*.js'` breaks `import type` under Turbopack.
13
14
  const turbopackRules = {
14
- '*.{tsx,jsx}': {
15
+ '*.tsx': {
15
16
  loaders: [TAGGER_LOADER],
16
- as: '*.js',
17
+ as: '*.tsx',
18
+ },
19
+ '*.jsx': {
20
+ loaders: [TAGGER_LOADER],
21
+ as: '*.jsx',
17
22
  },
18
23
  }
19
24
 
package/lib/loader.js CHANGED
@@ -52,19 +52,24 @@ function componentTagger(code, map) {
52
52
  }
53
53
  }
54
54
 
55
+ const resourcePath = this.resourcePath || ''
56
+ const rootContext = this.rootContext || this.context || process.cwd()
57
+
55
58
  // Do not process vendor code
56
- if (/node_modules/.test(this.resourcePath)) return done(null, code, inMap)
59
+ if (/node_modules/.test(resourcePath)) return done(null, code, inMap)
57
60
 
58
61
  // Parse with Babel (supports JSX and TypeScript)
59
62
  const ast = parse(code, {
60
63
  sourceType: 'module',
61
64
  plugins: ['jsx', 'typescript'],
62
- sourceFilename: this.resourcePath,
65
+ sourceFilename: resourcePath,
63
66
  })
64
67
 
65
68
  // MagicString allows non-destructive code edits and sourcemap generation
66
69
  const ms = new MagicString(code)
67
- const fileRelative = path.relative(this.rootContext, this.resourcePath)
70
+ const fileRelative = resourcePath
71
+ ? path.relative(rootContext, resourcePath).replace(/\\/g, '/')
72
+ : 'unknown'
68
73
 
69
74
 
70
75
  let mutated = false
@@ -151,9 +156,9 @@ function componentTagger(code, map) {
151
156
  // Create a plain RawSourceMap object for webpack/Turbopack
152
157
  const mapStr = ms.generateMap({
153
158
  hires: true,
154
- source: this.resourcePath,
159
+ source: resourcePath,
155
160
  includeContent: true,
156
- file: this.resourcePath,
161
+ file: resourcePath,
157
162
  }).toString()
158
163
 
159
164
  const outMap = JSON.parse(mapStr)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@acebuilder/component-tagger",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "private": false,
5
5
  "description": "Next.js dev loader to tag React components with AceBuilder metadata (Turbopack + webpack).",
6
6
  "main": "index.js",