@acebuilder/component-tagger 0.1.1 → 0.1.3
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/README.md +12 -18
- package/index.d.ts +2 -25
- package/index.js +3 -21
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,17 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
Dev-only Next.js loader that injects `data-acebuilder-*` attributes on JSX elements for AceBuilder element selection.
|
|
4
4
|
|
|
5
|
-
Works with **Turbopack** (default `next dev`) and **webpack** (`next dev --webpack`).
|
|
6
|
-
|
|
7
5
|
## Install
|
|
8
6
|
|
|
9
7
|
```bash
|
|
10
8
|
pnpm add -D @acebuilder/component-tagger
|
|
11
9
|
```
|
|
12
10
|
|
|
13
|
-
## Usage
|
|
11
|
+
## Usage
|
|
14
12
|
|
|
15
|
-
Wrap your Next config
|
|
13
|
+
Wrap your Next config (injected automatically in AceBuilder sandboxes):
|
|
16
14
|
|
|
17
15
|
```js
|
|
18
16
|
// next.config.mjs
|
|
@@ -24,26 +22,22 @@ const nextConfig = {}
|
|
|
24
22
|
export default componentTagger()(nextConfig)
|
|
25
23
|
```
|
|
26
24
|
|
|
27
|
-
##
|
|
25
|
+
## Bundler support
|
|
28
26
|
|
|
29
|
-
|
|
27
|
+
| Mode | Tagging |
|
|
28
|
+
|------|---------|
|
|
29
|
+
| `next dev` (Turbopack, default) | Skipped — use runtime fiber resolution in the helper SDK |
|
|
30
|
+
| `next dev --webpack` | Full build-time tagging |
|
|
31
|
+
| `next build` | Full build-time tagging (webpack) |
|
|
30
32
|
|
|
31
|
-
|
|
32
|
-
import componentTagger from '@acebuilder/component-tagger'
|
|
33
|
-
|
|
34
|
-
export default {
|
|
35
|
-
turbopack: {
|
|
36
|
-
rules: componentTagger.turbopackRules,
|
|
37
|
-
},
|
|
38
|
-
// ...rest of next config
|
|
39
|
-
}
|
|
40
|
-
```
|
|
33
|
+
Turbopack custom loader rules are disabled because they currently produce broken module paths (`welcome.tsx.tsx`).
|
|
41
34
|
|
|
42
35
|
## AceBuilder sandboxes
|
|
43
36
|
|
|
44
|
-
Platform deploy injects
|
|
37
|
+
Platform deploy injects automatically:
|
|
45
38
|
|
|
46
39
|
- `package.json` devDependency: `"@acebuilder/component-tagger": "latest"`
|
|
47
40
|
- `next.config` wrapper via AST injection
|
|
41
|
+
- SDK `<Script>` in root layout
|
|
48
42
|
|
|
49
|
-
User
|
|
43
|
+
User templates stay unchanged.
|
package/index.d.ts
CHANGED
|
@@ -5,37 +5,14 @@ export interface AceBuilderComponentTaggerOptions {
|
|
|
5
5
|
test?: RegExp
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
-
export interface AceBuilderTurbopackRule {
|
|
9
|
-
loaders: string[]
|
|
10
|
-
as: string
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export type AceBuilderTurbopackRules = Record<string, AceBuilderTurbopackRule>
|
|
14
|
-
|
|
15
8
|
export type WithAceBuilderComponentTagger = (config: NextConfig) => NextConfig
|
|
16
9
|
|
|
17
10
|
/**
|
|
18
|
-
* Next.js plugin —
|
|
19
|
-
*
|
|
20
|
-
* @example
|
|
21
|
-
* ```js
|
|
22
|
-
* import componentTagger from '@acebuilder/component-tagger'
|
|
23
|
-
* export default componentTagger()(nextConfig)
|
|
24
|
-
* ```
|
|
25
|
-
*
|
|
26
|
-
* Turbopack-only (manual next.config):
|
|
27
|
-
* ```js
|
|
28
|
-
* import componentTagger from '@acebuilder/component-tagger'
|
|
29
|
-
* export default { turbopack: { rules: componentTagger.turbopackRules }, ...nextConfig }
|
|
30
|
-
* ```
|
|
11
|
+
* Next.js plugin — webpack pre-loader for component tagging.
|
|
12
|
+
* Default Turbopack dev skips the loader (avoids `*.tsx.tsx` resolution bugs).
|
|
31
13
|
*/
|
|
32
14
|
declare function withAceBuilderComponentTagger(
|
|
33
15
|
options?: AceBuilderComponentTaggerOptions,
|
|
34
16
|
): WithAceBuilderComponentTagger
|
|
35
17
|
|
|
36
|
-
declare namespace withAceBuilderComponentTagger {
|
|
37
|
-
/** Turbopack loader rules — fast path without wrapping webpack. */
|
|
38
|
-
const turbopackRules: AceBuilderTurbopackRules
|
|
39
|
-
}
|
|
40
|
-
|
|
41
18
|
export default withAceBuilderComponentTagger
|
package/index.js
CHANGED
|
@@ -3,37 +3,20 @@
|
|
|
3
3
|
/**
|
|
4
4
|
* Next.js plugin for AceBuilder component tagging.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* Legacy path: wrap next.config with this plugin (webpack + turbopack rules).
|
|
6
|
+
* Uses a webpack pre-loader (works with `next dev --webpack` and production builds).
|
|
7
|
+
* Turbopack custom loaders currently break module resolution (`*.tsx.tsx`) — not enabled.
|
|
10
8
|
*/
|
|
11
9
|
const TAGGER_LOADER = require.resolve('./lib/loader')
|
|
12
10
|
|
|
13
|
-
// Loader output stays TSX/JSX — `as: '*.js'` breaks `import type` under Turbopack.
|
|
14
|
-
const turbopackRules = {
|
|
15
|
-
'*.tsx': {
|
|
16
|
-
loaders: [TAGGER_LOADER],
|
|
17
|
-
as: '*.tsx',
|
|
18
|
-
},
|
|
19
|
-
'*.jsx': {
|
|
20
|
-
loaders: [TAGGER_LOADER],
|
|
21
|
-
as: '*.jsx',
|
|
22
|
-
},
|
|
23
|
-
}
|
|
24
|
-
|
|
25
11
|
const componentTagger = (pluginOptions = {}) => (inputConfig = {}) => {
|
|
26
12
|
const test = pluginOptions.test || /\.((j|t)sx)$/i
|
|
27
13
|
|
|
28
14
|
/** @type {import('next').NextConfig} */
|
|
29
15
|
const nextConfig = {
|
|
30
16
|
...inputConfig,
|
|
17
|
+
// Next.js 16: webpack hook from this plugin requires an explicit turbopack section.
|
|
31
18
|
turbopack: {
|
|
32
19
|
...(inputConfig.turbopack || {}),
|
|
33
|
-
rules: {
|
|
34
|
-
...(inputConfig.turbopack?.rules || {}),
|
|
35
|
-
...turbopackRules,
|
|
36
|
-
},
|
|
37
20
|
},
|
|
38
21
|
webpack(config, options) {
|
|
39
22
|
config.module.rules.push({
|
|
@@ -55,6 +38,5 @@ const componentTagger = (pluginOptions = {}) => (inputConfig = {}) => {
|
|
|
55
38
|
return nextConfig
|
|
56
39
|
}
|
|
57
40
|
|
|
58
|
-
componentTagger.turbopackRules = turbopackRules
|
|
59
41
|
module.exports = componentTagger
|
|
60
42
|
module.exports.default = componentTagger
|
package/package.json
CHANGED