ef4 / ember-browserify

ember-cli addon for easily loading CommonJS packages from npm via browserify.
MIT License
172 stars 28 forks source link

findAMDImports Error #121

Open iamjstates opened 7 years ago

iamjstates commented 7 years ago

I updated to version 1.2.0 and started getting this error -> downgraded to 1.1.13 and the error is gone.

ember version: ember-cli: 2.15.0-beta.1 node: 6.11.1 os: darwin x64

Error: Error parsing code while looking for "npm:" imports: TypeError: Cannot read property 'elements' of undefined
    at findAMDImports (/Users/admin/Development/Projects/theirry-commerce/node_modules/ember-browserify/lib/stubs.js:114:6)
    at /Users/admin/Development/Projects/theirry-commerce/node_modules/ember-browserify/lib/stubs.js:97:7
    at forEachNode (/Users/admin/Development/Projects/theirry-commerce/node_modules/ember-browserify/lib/stubs.js:74:5)
    at forEachNode (/Users/admin/Development/Projects/theirry-commerce/node_modules/ember-browserify/lib/stubs.js:77:7)
    at forEachNode (/Users/admin/Development/Projects/theirry-commerce/node_modules/ember-browserify/lib/stubs.js:77:7)
    at forEachNode (/Users/admin/Development/Projects/theirry-commerce/node_modules/ember-browserify/lib/stubs.js:77:7)
    at forEachNode (/Users/admin/Development/Projects/theirry-commerce/node_modules/ember-browserify/lib/stubs.js:77:7)
    at forEachNode (/Users/admin/Development/Projects/theirry-commerce/node_modules/ember-browserify/lib/stubs.js:77:7)
    at forEachNode (/Users/admin/Development/Projects/theirry-commerce/node_modules/ember-browserify/lib/stubs.js:77:7)
    at forEachNode (/Users/admin/Development/Projects/theirry-commerce/node_modules/ember-browserify/lib/stubs.js:77:7)
    at importsFor (/Users/admin/Development/Projects/theirry-commerce/node_modules/ember-browserify/lib/stubs.js:67:11)
    at Stub.set (/Users/admin/Development/Projects/theirry-commerce/node_modules/ember-browserify/lib/stubs.js:31:25)
    at StubGenerator.<anonymous> (/Users/admin/Development/Projects/theirry-commerce/node_modules/ember-browserify/lib/stub-generator.js:57:33)
    at Array.forEach (native)
    at StubGenerator.build (/Users/admin/Development/Projects/theirry-commerce/node_modules/ember-browserify/lib/stub-generator.js:49:12)
    at /Users/admin/Development/Projects/theirry-commerce/node_modules/broccoli-plugin/read_compat.js:93:34
    at tryCatch (/Users/admin/Development/Projects/theirry-commerce/node_modules/rsvp/dist/rsvp.js:525:12)
    at invokeCallback (/Users/admin/Development/Projects/theirry-commerce/node_modules/rsvp/dist/rsvp.js:538:13)
    at publish (/Users/admin/Development/Projects/theirry-commerce/node_modules/rsvp/dist/rsvp.js:508:7)
    at flush (/Users/admin/Development/Projects/theirry-commerce/node_modules/rsvp/dist/rsvp.js:2400:5)
stefanpenner commented 7 years ago

could you provide a reproduction? Specifically a list of npm modules + versions that are being browserified. Otherwise its a tad tricky to figure out whatsup

bryanhickerson commented 7 years ago

I'm having the same issue. I'm browserifying autosize 4.0.0 and rails-timezone 1.0.0.

bryanhickerson commented 6 years ago

Still blocked from upgrading due to this issue. Current browserified npm packages:

"@opentok/client": "^2.12.2",
"autosize": "^4.0.0",
"bowser": "^1.8.1",
"pubnub": "^4.17.0",
"uuid": "^3.1.0",
"rails-timezone": "^1.0.0"
ef4 commented 6 years ago

Hi @bryanhickerson, I tried to reproduce the bug using your list but was unable to get the error. Here is the app I used, it has a yarn.lock so you can see what exact versions I used:

https://github.com/ef4/bug-repro/tree/7bcc6b80c58333a67414c9b9c9429697da8a90c1

If you can pare down your app to the smallest thing that still fails, that would help find the problem.

bryanhickerson commented 6 years ago

I'll see what I can do.

bryanhickerson commented 6 years ago

Tried creating a stripped down app with the error, but haven't been able to reproduce so far. I suspect it could one one of our other packages.

bryanhickerson commented 6 years ago

Even with our full package.json it's not occurring, is there anything I can do to debug it myself on our full app?

bryanhickerson commented 6 years ago

It appears to only happen when running ember test, able to build the app normally just fine.

spieker commented 6 years ago

I'm having the same issue when running the server

import countryData from 'npm:country-data'
bryanhickerson commented 6 years ago

@ef4 I was able to reproduce the issue in a small app: https://github.com/bryanhickerson/ember-browserify-import-error. It doesn't actually require any imports, the exception is happening in an ember-data-factory-guy factory definition. I was actually able to figure this out by printing out the full path even when the stack trace existed. I'm going to open a PR for that change.