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

@loader not defined in slim build #856

Closed
pYr0x opened this issue Sep 28, 2017 · 4 comments
Closed

@loader not defined in slim build #856

pYr0x opened this issue Sep 28, 2017 · 4 comments

Comments

@pYr0x
Copy link
Contributor

pYr0x commented Sep 28, 2017

this PR and this line cause an error after build
https://github.com/stealjs/steal-tools/pull/850/files#diff-970f87aa3e6b874cd244518372a6e3f5R90
moduleId is @loader which is not defined.
the transpiled code looks like this:

		151,
		function(stealRequire, stealExports, stealModule) {
			var atLoader = stealRequire("@loader");
			var steal = {};
			steal.loader = atLoader;
			steal.done = function() {
				return Promise.resolve();
			};
			stealModule.exports = steal;
		}
	],
@m-mujica
Copy link
Contributor

@pYr0x were you able to replicate this in a small app? A breaking example would be awesome.

The slim build should add an "@loader" shim right after "@steal" is added around here https://github.com/stealjs/steal-tools/blob/master/lib/build/slim.js#L64

addAtLoaderShim(),

@m-mujica
Copy link
Contributor

I just hit this issue 🎉 :|

@pYr0x
Copy link
Contributor Author

pYr0x commented Sep 28, 2017

was what it?

@m-mujica
Copy link
Contributor

m-mujica commented Sep 28, 2017

There is a stream called addModuleIds and it adds the numeric ids to the load object of each node in the graph.

That stream also sets a normalize hook so the module identifiers are replaced by transpile

// set a normalize hook for transpile so the regular module identifiers are
// replaced with the short ids set in `node.load.uniqueId`
options.normalize = function(name, load) {
var node = load ? graph[load.name] : null;
return node ? node.load.uniqueId : name;
};

So, we pretty much push the @loader shim node to the graph, and it happens that the load object normalize expects there is undefined. ( in this case, the npm extension is the one calling normalize )

I had to change the function to check if graph[name] is available and get the numeric id from there.

makes sense?

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

2 participants