Closed Rich-Harris closed 9 years ago
As per my (half thought out) comment in #163, I'd suggest a warning message for importing any relative static resources like json
since bundling (unless bundling an entire app) is typically only done for module libs?!
closing as wontfix, per #191
Via #163... if you have
import pkg from './package.json'
, or similar, then (#163 notwithstanding) it'll get transpiled to the equivalent CommonJS, which works, because the CommonJS gods decided that that was the right thing to do. The equivalent AMD/UMD generated code won't work, but ¯\ (ツ) /¯.Bundling is a different story however - esperanto doesn't bundle JSON. It just throws an error that it can't find the file (it fails to find
package.json.js
, so looks forpackage.json/index.js
...), which isn't helpful. Which raises the question of whether esperanto should be able to bundle JSON files. And while we're at it, we may as well consider whether it should be able to bundle other text assets (e.g. HTML), and whether it should work out-of-the-box or whether it should be delegated to loader plugins, possibly with hooks for things like compiling templates. (An easy way to achieve this would be allow an array oftransform
functions, rather than just the one. First(contents, path) => {...}
function to return something wins.)