Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn't function when run in a package environment #79

Open
MythicalMayhem opened this issue Mar 4, 2025 · 1 comment
Open

Doesn't function when run in a package environment #79

MythicalMayhem opened this issue Mar 4, 2025 · 1 comment

Comments

@MythicalMayhem
Copy link

MythicalMayhem commented Mar 4, 2025

essentially, if the project is built using npm init roblox-ts package, throws this error

Image

here's my work space setup,

Image

index.story.tsx
default.project.json
tsconfig.json
package.json

- index.story.tsx
index.story.tsx
import React from "@rbxts/react";
import ReactRoblox from "@rbxts/react-roblox";

import { CreateReactStory } from "@rbxts/ui-labs";

const story = CreateReactStory(
    {
        react: React,
        reactRoblox: ReactRoblox,
        controls: {},
    },
    (props) => {
        const component = <frame />;
        return component;
    },
);

export = story;
  • default.project.json
 
{
    "name": "New folder",
    "tree": {
        "$className": "DataModel",

        "StarterPlayer": {
            "StarterPlayerScripts": {
                "Client": {
                    "$path": "out"
                }
            }
        },

        "Workspace": {
            "$properties": {
                "FilteringEnabled": true
            },
            "Baseplate": {
                "$className": "Part",
                "$properties": {
                    "Anchored": true,
                    "Color": [0.38823, 0.37254, 0.38823],
                    "Locked": true,
                    "Position": [0, -10, 0],
                    "Size": [512, 20, 512]
                }
            }
        },

}
  • package.json
{
	"name": "@rbxts/new-folder",
	"version": "1.0.0",
	"main": "out/init.lua",
	"scripts": {
		"clean": "del out && del main.rbxl",
		"build": "npm run clean && rbxtsc && rojo build -o main.rbxl",
		"watch": "concurrently \"rojo serve\"   \"rbxtsc -w\" ",
		"game": "start main.rbxl",
		"dev": "npm run build && npm run game && npm run watch"
	},
	"keywords": [],
	"author": "",
	"license": "ISC",
	"description": "",
	"types": "out/index.d.ts",
	"files": [
		"out",
		"!**/*.tsbuildinfo"
	],
	"publishConfig": {
		"access": "public"
	},
	"devDependencies": {
		"@rbxts/compiler-types": "^3.0.0-types.0",
		"@rbxts/types": "^1.0.839",
		"@typescript-eslint/eslint-plugin": "^8.26.0",
		"@typescript-eslint/parser": "^8.26.0",
		"eslint": "^8.57.1",
		"eslint-config-prettier": "^10.0.2",
		"eslint-plugin-prettier": "^5.2.3",
		"eslint-plugin-roblox-ts": "^0.0.36",
		"prettier": "^3.5.3",
		"roblox-ts": "^3.0.0",
		"typescript": "^5.8.2"
	},
	"dependencies": {
		"@rbxts/react": "^17.2.3",
		"@rbxts/react-roblox": "^17.2.3",
		"@rbxts/ui-labs": "^2.3.8",
		"concurrently": "^9.1.2"
	}
}
  • tsconfig.json
{
	"compilerOptions": {
		// required
		"allowSyntheticDefaultImports": true,
		"downlevelIteration": true,
		"jsx": "react",
		"jsxFactory": "React.createElement",
		"jsxFragmentFactory": "React.Fragment",
		"module": "commonjs",
		"moduleResolution": "Node",
		"noLib": true,
		"resolveJsonModule": true,
		"experimentalDecorators": true,
		"forceConsistentCasingInFileNames": true,
		"moduleDetection": "force",
		"strict": true,
		"target": "ESNext",
		"typeRoots": ["node_modules/@rbxts"],

		// configurable
		"rootDir": "src",
		"outDir": "out",
		"incremental": true,
		"tsBuildInfoFile": "out/tsconfig.tsbuildinfo",
		"declaration": true
	}
}
@PepeElToro41
Copy link
Owner

Yes, this will happen. Roblox-ts packages cant run on their own, they need a project that will use them. So, this wouldnt work

Reason for this, is that packages dont know where the RuntimeLib is located at (it doesnt even exist for packages), and so they instead search it inside _G[script], which will not be set unless a game runs.

Potential Fixes:

  • Use a game to run your stories
  • Add your RuntimeLib yourself, create a script that requires this and inserts it inside _G and make it run before any import (not sure how possible this is)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants