require() does not handle JSON files, as other implementations do

Description

to reproduce:
1. add commonmark to project: npm install commonmark
2. require commonmark: commonmark = require('../node_modules/commonmark')
3. build: enyo pack
4. run

expected result: app loads normally

actual result: app fails to load with error:
SyntaxError: missing ; before statement
for the line where enyo pack has treated the required file as if it were executable JavaScript:
{{
,'.../node_modules/commonmark/node_modules/entities/maps/xml':[function (module,exports,global,require,request){
{"amp":"&","apos":"'","gt":">","lt":"<","quot":"\""}
}]
}}

Environment

OS X 10.11.6, Firefox

Activity

Show:
P. Douglas Reeder
September 12, 2016, 3:09 PM

Thanks, that looks like it should work!

I should be able to test it this week.

On Sep 12, 2016 9:43 AM, "Ryan Duffy (JIRA)" <jira@enyojs.atlassian.net>

P. Douglas Reeder
September 13, 2016, 5:15 AM
Edited

I copied the file BundleManifest.js directly over the old version in enyo-dev; is there a more elegant way to install a given git version using npm?

Having done that, I can directly require JSON files, for example
appinfo = require('../appinfo.json’),

It now works for modules that require a JSON file, e.g. entities, which requires xml.json:
entities = require('../node_modules/entities'),

But I haven’t yet got it working for a dependency of a dependency, e.g. commonmark, which requires entities.
commonmark = require('../node_modules/commonmark'),

Doug Reeder
reeder.29@gmail.com
https://twitter.com/reeder29
http://reeder29.livejournal.com/

http://hominidsoftware.com

P. Douglas Reeder
September 14, 2016, 6:08 AM

I just submitted a PR that covers the third case:
https://github.com/enyojs/enyo-dev/pull/44

Ryan Duffy
September 14, 2016, 9:50 PM

LGTM. - Work for you?

Ryan Duffy
September 15, 2016, 3:24 PM

Both PRs have been merged so calling this fixed.

- Thanks for the report and the additional fix. Let us know if you discover anything else!

Assignee

P. Douglas Reeder

Reporter

P. Douglas Reeder

Labels

None

External issue ID

None

Tango Test Run Elements

None

Old Issue Key

None

Components

Fix versions

Affects versions

Priority

None
Configure