@makano/rew 1.2.88 → 1.2.89
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.
|
@@ -247,7 +247,7 @@ function useImp(token, options){
|
|
|
247
247
|
token.value = dem+packageName+dem;
|
|
248
248
|
const file = packageName.startsWith('./') || packageName.startsWith('../');
|
|
249
249
|
if(!(file) && packageName.match('/')) packageName = packageName.split('/').pop();
|
|
250
|
-
if(file) packageName = packageName.replace(path.extname(packageName), '.h.coffee');
|
|
250
|
+
if(file) packageName = path.extname(packageName) ? packageName.replace(path.extname(packageName), '.h.coffee') : packageName;
|
|
251
251
|
if(file && !packageName.endsWith('.h.coffee')) packageName += '.h.coffee';
|
|
252
252
|
straceLog('IMP() with HEADER for', packageName);
|
|
253
253
|
return includeFile(packageName, options);
|
|
@@ -581,8 +581,9 @@ const cpl = (module.exports.compile = function (file, options = {}) {
|
|
|
581
581
|
...(doJSX ? [[babelReact, { throwIfNamespace: false, pragmaFrag: options.jsxPragmaFrag || execOptions.jsxPragmaFrag, pragma: options.jsxPragma || execOptions.jsxPragma }]] : [])
|
|
582
582
|
],
|
|
583
583
|
plugins: [
|
|
584
|
-
...(doDecorators ? [[require('@babel/plugin-proposal-decorators'), { version: '2023-05' }], [require('@babel/plugin-proposal-class-properties'), { loose: true }], [require('@babel/plugin-transform-class-static-block'), {}]] : [])
|
|
585
|
-
|
|
584
|
+
...(doDecorators ? [[require('@babel/plugin-proposal-decorators'), { version: '2023-05' }], [require('@babel/plugin-proposal-class-properties'), { loose: true }], [require('@babel/plugin-transform-class-static-block'), {}]] : []),
|
|
585
|
+
// doJSX ? require('./jsx') : null
|
|
586
|
+
].filter(Boolean),
|
|
586
587
|
}).code;
|
|
587
588
|
}
|
|
588
589
|
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
// customJSXIdentifierPlugin.js
|
|
2
|
+
module.exports = function customJSXIdentifierPlugin({ types: t }) {
|
|
3
|
+
return {
|
|
4
|
+
visitor: {
|
|
5
|
+
FunctionDeclaration(path) {
|
|
6
|
+
if (containsJSXReturn(path.node.body.body, t)) {
|
|
7
|
+
addJSXReturnFlag(path, path.node.id.name, t);
|
|
8
|
+
}
|
|
9
|
+
},
|
|
10
|
+
FunctionExpression(path) {
|
|
11
|
+
if (containsJSXReturn(path.node.body.body, t)) {
|
|
12
|
+
handleFunctionExpressionOrArrow(path, t);
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
ArrowFunctionExpression(path) {
|
|
16
|
+
if (t.isJSXElement(path.node.body) || (t.isBlockStatement(path.node.body) && containsJSXReturn(path.node.body.body, t))) {
|
|
17
|
+
handleFunctionExpressionOrArrow(path, t);
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
function containsJSXReturn(body, t) {
|
|
25
|
+
return body.some(statement => t.isReturnStatement(statement) && t.isJSXElement(statement.argument));
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function addJSXReturnFlag(path, functionName, t) {
|
|
29
|
+
path.insertAfter(
|
|
30
|
+
t.expressionStatement(
|
|
31
|
+
t.assignmentExpression(
|
|
32
|
+
'=',
|
|
33
|
+
t.memberExpression(t.identifier(functionName), t.identifier('__returnsJSX')),
|
|
34
|
+
t.booleanLiteral(true)
|
|
35
|
+
)
|
|
36
|
+
)
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function handleFunctionExpressionOrArrow(path, t) {
|
|
41
|
+
// Check for variable declaration
|
|
42
|
+
if (t.isVariableDeclarator(path.parent) && t.isIdentifier(path.parent.id)) {
|
|
43
|
+
const functionName = path.parent.id.name;
|
|
44
|
+
path.findParent(p => p.isVariableDeclaration()).insertAfter(
|
|
45
|
+
t.expressionStatement(
|
|
46
|
+
t.assignmentExpression(
|
|
47
|
+
'=',
|
|
48
|
+
t.memberExpression(t.identifier(functionName), t.identifier('__returnsJSX')),
|
|
49
|
+
t.booleanLiteral(true)
|
|
50
|
+
)
|
|
51
|
+
)
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
// Check for variable assignment
|
|
55
|
+
else if (t.isAssignmentExpression(path.parent) && t.isIdentifier(path.parent.left)) {
|
|
56
|
+
const functionName = path.parent.left.name;
|
|
57
|
+
path.parentPath.insertAfter(
|
|
58
|
+
t.expressionStatement(
|
|
59
|
+
t.assignmentExpression(
|
|
60
|
+
'=',
|
|
61
|
+
t.memberExpression(t.identifier(functionName), t.identifier('__returnsJSX')),
|
|
62
|
+
t.booleanLiteral(true)
|
|
63
|
+
)
|
|
64
|
+
)
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
}
|