mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-02 00:22:43 +08:00
3ed9edfbc6
* phy framework * phy mat * framework/index.ts * a node can have more than one collider * rename physical to physics * fix * fix * support mix ts js * fix * fix problems in issue * fix * remove RigidBodyType, add DataFlow * useGravity, freezeRotation, isKinematic * raycasts * fit buildin-world raycast options * add contact material * lint * add rigid-body-component.ts * some improvements * improvements * fix bug
31 lines
1.1 KiB
JavaScript
31 lines
1.1 KiB
JavaScript
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
|
exports.default = function(babel) {
|
|
return {
|
|
visitor: {
|
|
ImportDeclaration(babelPath, state) {
|
|
const currentFileName = state.filename;
|
|
const currentFileFolder = path.dirname(currentFileName);
|
|
|
|
const source = babelPath.node.source;
|
|
const oldSourcePath = source.value;
|
|
|
|
const destPath = path.resolve(currentFileFolder, oldSourcePath);
|
|
if (!fs.existsSync(`${destPath}.ts`)) {
|
|
return;
|
|
}
|
|
|
|
const newSourcePath = `${oldSourcePath}.ts`;
|
|
const newSource = babel.types.stringLiteral(newSourcePath);
|
|
console.log(`Resolve ${oldSourcePath}(${currentFileName}) to ${newSourcePath}`);
|
|
|
|
const newPath = babel.types.importDeclaration(babelPath.node.specifiers, newSource);
|
|
babelPath.replaceWith(newPath);
|
|
},
|
|
}
|
|
};
|
|
} |