babel-plugin-mapples-sid 0.1.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/README.md +14 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.js +29 -0
- package/dist/index.js.map +1 -0
- package/package.json +30 -0
package/README.md
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# babel-plugin-mapples-sid
|
|
2
|
+
|
|
3
|
+
Strips the Mapples tooling JSX props (`$sid`, `$fallback`) from **production** bundles and keeps
|
|
4
|
+
them in development (enables tap-element → select-in-Creator).
|
|
5
|
+
|
|
6
|
+
```js
|
|
7
|
+
// babel.config.js
|
|
8
|
+
module.exports = {
|
|
9
|
+
presets: ['babel-preset-expo'],
|
|
10
|
+
plugins: ['babel-plugin-mapples-sid'],
|
|
11
|
+
};
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Options: `{ strip: boolean }` forces the behavior regardless of `NODE_ENV`.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { PluginObj } from '@babel/core';
|
|
2
|
+
export interface MapplesSidPluginOptions {
|
|
3
|
+
/**
|
|
4
|
+
* Force strip/keep regardless of NODE_ENV. When absent, the plugin strips
|
|
5
|
+
* only when NODE_ENV === 'production'.
|
|
6
|
+
*/
|
|
7
|
+
strip?: boolean;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* babel-plugin-mapples-sid
|
|
11
|
+
*
|
|
12
|
+
* Removes the Mapples tooling JSX attributes from production bundles. In
|
|
13
|
+
* development they are kept so runtime tooling (tap element -> select in
|
|
14
|
+
* Creator) can resolve elements back to canvas nodes.
|
|
15
|
+
*/
|
|
16
|
+
export default function mapplesSidPlugin(): PluginObj<{
|
|
17
|
+
opts: MapplesSidPluginOptions;
|
|
18
|
+
}>;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = mapplesSidPlugin;
|
|
4
|
+
/** The Mapples tooling props: `$sid` (canvas node id) and `$fallback` (Custom node size). */
|
|
5
|
+
const TOOLING_PROPS = new Set(['$sid', '$fallback']);
|
|
6
|
+
/**
|
|
7
|
+
* babel-plugin-mapples-sid
|
|
8
|
+
*
|
|
9
|
+
* Removes the Mapples tooling JSX attributes from production bundles. In
|
|
10
|
+
* development they are kept so runtime tooling (tap element -> select in
|
|
11
|
+
* Creator) can resolve elements back to canvas nodes.
|
|
12
|
+
*/
|
|
13
|
+
function mapplesSidPlugin() {
|
|
14
|
+
return {
|
|
15
|
+
name: 'mapples-sid',
|
|
16
|
+
visitor: {
|
|
17
|
+
JSXAttribute(path, state) {
|
|
18
|
+
const shouldStrip = state.opts.strip ?? process.env.NODE_ENV === 'production';
|
|
19
|
+
if (!shouldStrip)
|
|
20
|
+
return;
|
|
21
|
+
const name = path.node.name;
|
|
22
|
+
if (name.type === 'JSXIdentifier' && TOOLING_PROPS.has(name.name)) {
|
|
23
|
+
path.remove();
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AAoBA,mCAgBC;AA1BD,6FAA6F;AAC7F,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC;AAErD;;;;;;GAMG;AACH,SAAwB,gBAAgB;IAGtC,OAAO;QACL,IAAI,EAAE,aAAa;QACnB,OAAO,EAAE;YACP,YAAY,CAAC,IAAI,EAAE,KAAK;gBACtB,MAAM,WAAW,GAAG,KAAK,CAAC,IAAI,CAAC,KAAK,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,CAAC;gBAC9E,IAAI,CAAC,WAAW;oBAAE,OAAO;gBACzB,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;gBAC5B,IAAI,IAAI,CAAC,IAAI,KAAK,eAAe,IAAI,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;oBAClE,IAAI,CAAC,MAAM,EAAE,CAAC;gBAChB,CAAC;YACH,CAAC;SACF;KACF,CAAC;AACJ,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "babel-plugin-mapples-sid",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Strips $sid props from production bundles; keeps them in dev for tap-to-select.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "Oleksandr Soloviov <oleksolv@gmail.com>",
|
|
7
|
+
"type": "commonjs",
|
|
8
|
+
"main": "./dist/index.js",
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"files": [
|
|
11
|
+
"dist/",
|
|
12
|
+
"README.md"
|
|
13
|
+
],
|
|
14
|
+
"scripts": {
|
|
15
|
+
"build": "tsc -b",
|
|
16
|
+
"clean": "rm -rf dist *.tsbuildinfo"
|
|
17
|
+
},
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"@babel/core": "^7.26.0",
|
|
20
|
+
"@babel/preset-react": "^7.26.3",
|
|
21
|
+
"@types/babel__core": "^7.20.5",
|
|
22
|
+
"typescript": "^5.7.2"
|
|
23
|
+
},
|
|
24
|
+
"peerDependencies": {
|
|
25
|
+
"@babel/core": "^7.0.0"
|
|
26
|
+
},
|
|
27
|
+
"engines": {
|
|
28
|
+
"node": ">=18.18"
|
|
29
|
+
}
|
|
30
|
+
}
|