@ray-js/builder-mp 0.7.5 → 0.7.7
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.
@@ -0,0 +1,80 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
+
}
|
8
|
+
Object.defineProperty(o, k2, desc);
|
9
|
+
}) : (function(o, m, k, k2) {
|
10
|
+
if (k2 === undefined) k2 = k;
|
11
|
+
o[k2] = m[k];
|
12
|
+
}));
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
15
|
+
}) : function(o, v) {
|
16
|
+
o["default"] = v;
|
17
|
+
});
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
19
|
+
if (mod && mod.__esModule) return mod;
|
20
|
+
var result = {};
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
22
|
+
__setModuleDefault(result, mod);
|
23
|
+
return result;
|
24
|
+
};
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
27
|
+
};
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
29
|
+
const babel = __importStar(require("@babel/core"));
|
30
|
+
const traverse_1 = __importDefault(require("@babel/traverse"));
|
31
|
+
const getMethods = (input, filename) => {
|
32
|
+
const methods = [];
|
33
|
+
const collect = (name) => methods.push(name);
|
34
|
+
const handle = (code, filename) => {
|
35
|
+
const visitor = {
|
36
|
+
Identifier(path, state) {
|
37
|
+
const name = path.node.name;
|
38
|
+
if (name === 'exports' || name === 'module')
|
39
|
+
return;
|
40
|
+
state(name);
|
41
|
+
},
|
42
|
+
};
|
43
|
+
const ast = babel.parse(code, {
|
44
|
+
babelrc: false,
|
45
|
+
configFile: false,
|
46
|
+
sourceType: 'module',
|
47
|
+
});
|
48
|
+
(0, traverse_1.default)(ast, {
|
49
|
+
ExportNamedDeclaration(path) {
|
50
|
+
path.traverse(visitor, collect);
|
51
|
+
},
|
52
|
+
MemberExpression(path) {
|
53
|
+
const { object: { name }, property: { name: key }, } = path.node;
|
54
|
+
if ((name === 'module' && key === 'exports') || name === 'exports') {
|
55
|
+
path.parentPath.traverse(visitor, collect);
|
56
|
+
}
|
57
|
+
},
|
58
|
+
ExportAllDeclaration(path) {
|
59
|
+
path.node.source.value;
|
60
|
+
},
|
61
|
+
});
|
62
|
+
};
|
63
|
+
handle(input, filename);
|
64
|
+
return methods;
|
65
|
+
};
|
66
|
+
exports.default = getMethods;
|
67
|
+
const m = getMethods(`
|
68
|
+
export default {}
|
69
|
+
export * from './b'
|
70
|
+
export const a = 1
|
71
|
+
exports.q = 1
|
72
|
+
a1.xxxx = {
|
73
|
+
a:1,b:2
|
74
|
+
}
|
75
|
+
module.exports = {
|
76
|
+
x:'aaa',
|
77
|
+
y(){},
|
78
|
+
}
|
79
|
+
`, './a.ts');
|
80
|
+
console.log(m);
|
package/lib/build.rjs.d.ts
CHANGED
@@ -13,7 +13,7 @@ export declare class RjsBuilder {
|
|
13
13
|
print: (prefix: string, stats: Stats[]) => void;
|
14
14
|
parentDoneHook(): void;
|
15
15
|
rjsDoneHook(): void;
|
16
|
-
|
16
|
+
recomposeAssets(): void;
|
17
17
|
extractRjsModuleHook(): void;
|
18
18
|
}
|
19
19
|
declare const rjsBuilder: RjsBuilder;
|
package/lib/build.rjs.js
CHANGED
@@ -46,8 +46,13 @@ class RjsBuilder {
|
|
46
46
|
this.init = (parentCompiler, compileOptions) => {
|
47
47
|
this.parentCompiler = parentCompiler;
|
48
48
|
this.compileOptions = compileOptions;
|
49
|
-
this.
|
50
|
-
|
49
|
+
this.parentDoneHook();
|
50
|
+
if (process.env.PLATFORM === 'thing') {
|
51
|
+
this.initWebpack(this.webpackConfig);
|
52
|
+
this.rjsDoneHook();
|
53
|
+
this.recomposeAssets();
|
54
|
+
this.extractRjsModuleHook();
|
55
|
+
}
|
51
56
|
};
|
52
57
|
this.print = (prefix, stats) => {
|
53
58
|
setTimeout(() => {
|
@@ -128,10 +133,7 @@ class RjsBuilder {
|
|
128
133
|
this.print(LOG_PREFIX_RJS, [stats]);
|
129
134
|
});
|
130
135
|
}
|
131
|
-
|
132
|
-
this.initWebpack(this.webpackConfig);
|
133
|
-
this.parentDoneHook();
|
134
|
-
this.rjsDoneHook();
|
136
|
+
recomposeAssets() {
|
135
137
|
const PLUGIN_NAME = 'rjs-building';
|
136
138
|
this.compiler.hooks.thisCompilation.tap('rjs-building', (compilation) => {
|
137
139
|
compilation.hooks.processAssets.tapAsync({
|
package/lib/loaders/rjs/index.js
CHANGED
@@ -5,6 +5,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
6
|
const slash_1 = __importDefault(require("slash"));
|
7
7
|
const RjsLoader = function RjsLoader(source, map) {
|
8
|
-
|
8
|
+
let rjsMethods = '';
|
9
|
+
try {
|
10
|
+
const x = require('@ray-js/rjs-for-wechat');
|
11
|
+
rjsMethods = Object.keys(x).join(', ');
|
12
|
+
}
|
13
|
+
catch (e) { }
|
14
|
+
source =
|
15
|
+
process.env.PLATFORM === 'thing'
|
16
|
+
? `module.exports = __minipack_require__("${(0, slash_1.default)(this._module.resource)}")`
|
17
|
+
: `import { ${rjsMethods} } from '@ray-js/rjs-for-wechat';\n${source}`;
|
18
|
+
this.callback(null, source, map);
|
9
19
|
};
|
10
20
|
exports.default = RjsLoader;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@ray-js/builder-mp",
|
3
|
-
"version": "0.7.
|
3
|
+
"version": "0.7.7",
|
4
4
|
"description": "Ray builder for mini program",
|
5
5
|
"keywords": [
|
6
6
|
"ray"
|
@@ -24,13 +24,13 @@
|
|
24
24
|
"@babel/template": "^7.16.0",
|
25
25
|
"@babel/traverse": "^7.16.3",
|
26
26
|
"@babel/types": "^7.16.0",
|
27
|
-
"@ray-core/babel-preset-remax": "^0.1.
|
28
|
-
"@ray-core/build-store": "^0.1.
|
29
|
-
"@ray-core/cli": "^0.1.
|
30
|
-
"@ray-core/ray": "^0.1.
|
31
|
-
"@ray-js/adapter": "^0.7.
|
32
|
-
"@ray-js/shared": "^0.7.
|
33
|
-
"@ray-js/types": "^0.7.
|
27
|
+
"@ray-core/babel-preset-remax": "^0.1.1",
|
28
|
+
"@ray-core/build-store": "^0.1.1",
|
29
|
+
"@ray-core/cli": "^0.1.1",
|
30
|
+
"@ray-core/ray": "^0.1.1",
|
31
|
+
"@ray-js/adapter": "^0.7.7",
|
32
|
+
"@ray-js/shared": "^0.7.7",
|
33
|
+
"@ray-js/types": "^0.7.7",
|
34
34
|
"babel-loader": "^8.2.3",
|
35
35
|
"babel-plugin-minify-dead-code-elimination": "^0.5.1",
|
36
36
|
"babel-plugin-transform-prune-unused-imports": "^1.0.1",
|
@@ -47,7 +47,7 @@
|
|
47
47
|
"webpack-virtual-modules": "^0.4.4"
|
48
48
|
},
|
49
49
|
"devDependencies": {
|
50
|
-
"@ray-core/types": "^0.1.
|
50
|
+
"@ray-core/types": "^0.1.1",
|
51
51
|
"@types/jest": "^27.0.2",
|
52
52
|
"@types/node": "^16.9.1",
|
53
53
|
"babel-plugin-tester": "^10.1.0",
|
@@ -61,6 +61,6 @@
|
|
61
61
|
"email": "tuyafe@tuya.com"
|
62
62
|
}
|
63
63
|
],
|
64
|
-
"gitHead": "
|
64
|
+
"gitHead": "0ee288ce478ec2b37011ff82aa927c05d78efb09",
|
65
65
|
"repository": {}
|
66
66
|
}
|