Open stucox opened 7 years ago
Running Steal code in Node is a general problem. Some times you want it to use the browser
field, such as when you are doing a build, and then some times you want to run the code in a Node context.
I'm not sure how to fix this, to be honest. I plan on making some larger architecture changes and want to outline those in https://github.com/stealjs/rfcs. Leaving this open so I'm sure to consider this case.
Having thought about this a bit, I settled on the following (fairly non-revolutionary) mindset:
system
configs for browser / server. A bit more manual, but more control to the user.P.S. I like the rfcs
repo idea!
Test case — using the facts that:
browser
field in package.json (which I know Steal observes)nunjucks.FileSystemLoader
is only available in the Node environment— so when loading nunjucks on Node (with or without Steal), we’d expect
nunjucks.FileSystemLoader
to be available.I’ve checked with a bit of debugging that Steal is indeed loading
nunjucks/browser/nunjucks.js
, rather thannunjucks/index.js
.Removing the
browser
field from Nunjucks’package.json
and repeating the above throws an error (within Nunjucks) re.fs
not being available, which at least implies it’s loading the version intended for Node (which hopefully I can solve that withsteal-builtins
or similar… anyway, that’s my problem to deal with).