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

Early error on missing import #4

Closed
bmeck opened this issue Dec 1, 2017 · 2 comments
Closed

Early error on missing import #4

bmeck opened this issue Dec 1, 2017 · 2 comments

Comments

@bmeck
Copy link
Contributor

bmeck commented Dec 1, 2017

I was unable to figure out the full workflow of xsl to run it without mcconfig quickly, but it seems to not give an error at compile/link time about missing a dependency:

manifest.json

{
	"include": "$(MODDABLE)/examples/manifest_base.json",
	"modules": {
		"*": [
			"./main"
		]
	},
}

main.js

import {message} from "dep";
trace(message + "\n");

dep.js

export const message = "Hello world!";

Will compile "successfully" using mcconfig -d -m -p mac with the output:

> mcconfig -d -m -p mac
# xsl modules
# mcrez resources
# cc mc.resources.c
# cc mc.xs.c
# ld mc.so
> echo $?
0

This error is hidden until runtime as seen in xsbug:

screen shot 2017-12-01 at 1 58 09 pm

The .xsb files contain enough information to provide an early error, but I am unclear on xsl's internals to patch it to output such an error.

@phoddie
Copy link
Collaborator

phoddie commented Dec 1, 2017

If main is set to preload in the manifest, then you will get an error during the build.

{
	"include": "$(MODDABLE)/examples/manifest_base.json",
	"modules": {
		"*": [
			"./main"
		]
	},
	"preload": [
		"main"
	]
}

But, because then the body of main would execute on your computer instead of the device, you need to make the body a function:

import {message} from "dep";
export default function() {
	trace(message +"\n");
};

FWIW - it is theoretically possible that the module "dep" could exist outside of the archive built on the computer, so your main would work on the device. The "dep" module would be installed separate on the device. We haven't completed this support yet, but it is under investigation.

@bmeck
Copy link
Contributor Author

bmeck commented Dec 1, 2017

aha! I was just opening this as I spent more than 10 minutes trying to figure out what was going on.

The explanation makes this seem sane.

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