npm.io
1.2.2 • Published 5 years ago

rbxts-transformer-path

Licence
MIT
Version
1.2.2
Deps
5
Size
185 kB
Vulns
0
Weekly
0
Stars
1
DeprecatedThis package is deprecated

rbxts-transformer-path

A transformer designed for roblox-ts that allows to convert from filesystem project paths to pure Roblox tree structure (rojo required)

import { $path } from "rbxts-transformer-path";

const scripts = $path<Folder>("src/server/scripts");

function getDescendantsWhichIsA<T extends keyof Instances>(
  parent: Instance,
  className: T
) {
  return parent
    .GetDescendants()
    .filter((object): object is Instances[T] => object.IsA(className));
}

getDescendantsWhichIsA(scripts, "ModuleScript").forEach((script) =>
  require(script)
);

Warning

  • Client-side paths are not tested yet but planned in the next version
  • It is designed for games, not plugins
  • It is unhelpful to errors and debugging
  • It defaults to default.project.json
  • It is a bit unstable.
  • It is slow because of function generator (I don't know how to optimize this)

Installation

  1. Run this command below:
npm i rbxts-transformer-path
  1. Head over to the tsconfig.json on your recent project and put the following under compilerOptions:
"plugins": [
	{ "transform": "rbxts-transformer-path" }
]

Credits

Credits for the code to: