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

Editor is unable to parse extended scripts #188

Closed
LeXXik opened this issue Oct 23, 2020 · 3 comments
Closed

Editor is unable to parse extended scripts #188

LeXXik opened this issue Oct 23, 2020 · 3 comments
Assignees

Comments

@LeXXik
Copy link

LeXXik commented Oct 23, 2020

Consider the following 2 scripts:

/* jshint esversion: 6 */
class MyBaseScript extends pc.ScriptType {...}
pc.registerScript(MyBaseScript , 'myBaseScript ');
/* jshint esversion: 6 */
class MyDerivedScript extends MyBaseScript {...}
pc.registerScript(MyDerivedScript, 'myDerivedScript');

MyDerivedScript script works fine if the application is launched, but the Editor fails to parse it, when the Parse button is clicked. It complains that "MyBaseScript" is undefined.

@marklundin
Copy link
Member

This has now been addressed in the work for ESM Scripts playcanvas/engine#5963.

The recommended approach for this is as follows

export class MyBaseScript extends pc.ScriptType {}
import { MyDerivedClass } from './MyDerivedClass.mjs';
export class MyDerivedScript extends MyBaseScript {}

@LeXXik
Copy link
Author

LeXXik commented Mar 11, 2024

@marklundin is ./MyDerivedClass.mjs relative to the script that imports it, or is it the assets root?

@marklundin
Copy link
Member

marklundin commented Mar 11, 2024

It's relative to the importing file, although these relative paths depend on a separate editor update which should be happening today next week.

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

No branches or pull requests

3 participants