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

Trouble with Prember & AddonDocs #36

Closed
samselikoff opened this issue Feb 20, 2019 · 5 comments
Closed

Trouble with Prember & AddonDocs #36

samselikoff opened this issue Feb 20, 2019 · 5 comments

Comments

@samselikoff
Copy link

I'm new to Prember and I'm trying to get it working with Mirage's AddonDocs site.

I hit this error after installing prember-middleware and running PREMBER=true ember serve:

Build Error (prember)

Could not find module `fetch` imported from `dummy/instance-initializers/setup-fetch`

I think it has to do with ember-fetch, a dependency from AddonDocs.

I found this issue from ember-fetch but it seems the bug was fixed in the latest version. When I yarn why ember-fetch I see that my project is using 6.4.0, the latest version.

Any ideas what's going on?

I have a simplified reproduction repo here.

Full stack trace
=================================================================================

ENV Summary:

  TIME: Wed Feb 20 2019 09:47:37 GMT-0500 (Eastern Standard Time)
  TITLE: ember
  ARGV:
  - /Users/samselikoff/.nodenv/versions/10.15.0/bin/node
  - /usr/local/bin/ember
  - serve
  EXEC_PATH: /Users/samselikoff/.nodenv/versions/10.15.0/bin/node
  TMPDIR: /var/folders/v5/5bs4trnx5v7bly3f0cg4_sc40000gn/T
  SHELL: /bin/zsh
  PATH:
  - /Users/samselikoff/.nodenv/versions/10.15.0/bin
  - /usr/local/Cellar/nodenv/1.2.0/libexec
  - /Users/samselikoff/.nodenv/shims
  - /Users/samselikoff/.yarn/bin
  - /usr/local/git/bin
  - /Users/samselikoff/bin
  - /usr/local/bin
  - /Library/Frameworks/Python.framework/Versions/2.7/bin
  - /Users/samselikoff/.rbenv/shims
  - /usr/bin
  - /bin
  - /usr/sbin
  - /sbin
  - /usr/local/bin
  - 
  PLATFORM: darwin x64
  FREEMEM: 39874560
  TOTALMEM: 17179869184
  UPTIME: 144082
  LOADAVG: 3.75048828125,2.74853515625,2.447265625
  CPUS:
  - Intel(R) Core(TM) i7-7920HQ CPU @ 3.10GHz - 3100
  - Intel(R) Core(TM) i7-7920HQ CPU @ 3.10GHz - 3100
  - Intel(R) Core(TM) i7-7920HQ CPU @ 3.10GHz - 3100
  - Intel(R) Core(TM) i7-7920HQ CPU @ 3.10GHz - 3100
  - Intel(R) Core(TM) i7-7920HQ CPU @ 3.10GHz - 3100
  - Intel(R) Core(TM) i7-7920HQ CPU @ 3.10GHz - 3100
  - Intel(R) Core(TM) i7-7920HQ CPU @ 3.10GHz - 3100
  - Intel(R) Core(TM) i7-7920HQ CPU @ 3.10GHz - 3100
  ENDIANNESS: LE
  VERSIONS:
  - ares: 1.15.0
  - cldr: 33.1
  - http_parser: 2.8.0
  - icu: 62.1
  - modules: 64
  - napi: 3
  - nghttp2: 1.34.0
  - node: 10.15.0
  - openssl: 1.1.0j
  - tz: 2018e
  - unicode: 11.0
  - uv: 1.23.2
  - v8: 6.8.275.32-node.45
  - zlib: 1.2.11

ERROR Summary:

  - broccoliBuilderErrorStack: Error: Could not find module `fetch` imported from `dummy/instance-initializers/setup-fetch`
    at missingModule (/var/folders/v5/5bs4trnx5v7bly3f0cg4_sc40000gn/T/broccoli-20116vhRr54cSUWsH/out-480-broccoli_merge_trees/assets/vendor/loader/loader.js:247:1)
    at findModule (/var/folders/v5/5bs4trnx5v7bly3f0cg4_sc40000gn/T/broccoli-20116vhRr54cSUWsH/out-480-broccoli_merge_trees/assets/vendor/loader/loader.js:258:1)
    at Module.findDeps (/var/folders/v5/5bs4trnx5v7bly3f0cg4_sc40000gn/T/broccoli-20116vhRr54cSUWsH/out-480-broccoli_merge_trees/assets/vendor/loader/loader.js:168:1)
    at findModule (/var/folders/v5/5bs4trnx5v7bly3f0cg4_sc40000gn/T/broccoli-20116vhRr54cSUWsH/out-480-broccoli_merge_trees/assets/vendor/loader/loader.js:262:1)
    at requireModule (/var/folders/v5/5bs4trnx5v7bly3f0cg4_sc40000gn/T/broccoli-20116vhRr54cSUWsH/out-480-broccoli_merge_trees/assets/vendor/loader/loader.js:24:1)
    at resolveInitializer (/var/folders/v5/5bs4trnx5v7bly3f0cg4_sc40000gn/T/broccoli-20116vhRr54cSUWsH/out-480-broccoli_merge_trees/assets/addon-tree-output/ember-load-initializers/index.js:34:1)
    at registerInstanceInitializers (/var/folders/v5/5bs4trnx5v7bly3f0cg4_sc40000gn/T/broccoli-20116vhRr54cSUWsH/out-480-broccoli_merge_trees/assets/addon-tree-output/ember-load-initializers/index.js:53:1)
    at exports.default (/var/folders/v5/5bs4trnx5v7bly3f0cg4_sc40000gn/T/broccoli-20116vhRr54cSUWsH/out-480-broccoli_merge_trees/assets/addon-tree-output/ember-load-initializers/index.js:29:1)
    at Module.callback (/var/folders/v5/5bs4trnx5v7bly3f0cg4_sc40000gn/T/broccoli-20116vhRr54cSUWsH/out-480-broccoli_merge_trees/assets/dummy/app.js:13:1)
    at Module.exports (/var/folders/v5/5bs4trnx5v7bly3f0cg4_sc40000gn/T/broccoli-20116vhRr54cSUWsH/out-480-broccoli_merge_trees/assets/vendor/loader/loader.js:106:1)
    at Module._reify (/var/folders/v5/5bs4trnx5v7bly3f0cg4_sc40000gn/T/broccoli-20116vhRr54cSUWsH/out-480-broccoli_merge_trees/assets/vendor/loader/loader.js:143:1)
    at Module.reify (/var/folders/v5/5bs4trnx5v7bly3f0cg4_sc40000gn/T/broccoli-20116vhRr54cSUWsH/out-480-broccoli_merge_trees/assets/vendor/loader/loader.js:130:1)
    at Module.exports (/var/folders/v5/5bs4trnx5v7bly3f0cg4_sc40000gn/T/broccoli-20116vhRr54cSUWsH/out-480-broccoli_merge_trees/assets/vendor/loader/loader.js:104:1)
    at Object.requireModule (/var/folders/v5/5bs4trnx5v7bly3f0cg4_sc40000gn/T/broccoli-20116vhRr54cSUWsH/out-480-broccoli_merge_trees/assets/vendor/loader/loader.js:27:1)
    at Object.<anonymous> (/Users/samselikoff/Projects/scratch/prember-addon-test/node_modules/fastboot/src/ember-app.js:179:18)
    at VMSandbox.run (/Users/samselikoff/Projects/scratch/prember-addon-test/node_modules/fastboot/src/vm-sandbox.js:18:15)
    at EmberApp.createEmberApp (/Users/samselikoff/Projects/scratch/prember-addon-test/node_modules/fastboot/src/ember-app.js:178:30)
    at EmberApp.retrieveSandboxedApp (/Users/samselikoff/Projects/scratch/prember-addon-test/node_modules/fastboot/src/ember-app.js:203:17)
    at new EmberApp (/Users/samselikoff/Projects/scratch/prember-addon-test/node_modules/fastboot/src/ember-app.js:59:21)
    at FastBoot._buildEmberApp (/Users/samselikoff/Projects/scratch/prember-addon-test/node_modules/fastboot/src/index.js:114:17)
    at new FastBoot (/Users/samselikoff/Projects/scratch/prember-addon-test/node_modules/fastboot/src/index.js:52:10)
    at Prerender.build (/Users/samselikoff/Projects/scratch/prember-addon-test/node_modules/prember/lib/prerender.js:85:15)
  - code: [undefined]
  - codeFrame: Could not find module `fetch` imported from `dummy/instance-initializers/setup-fetch`
  - errorMessage: Could not find module `fetch` imported from `dummy/instance-initializers/setup-fetch`
        at prember
-~- created here: -~-
    at new Plugin (/Users/samselikoff/Projects/scratch/prember-addon-test/node_modules/broccoli-plugin/index.js:7:31)
    at new Prerender (/Users/samselikoff/Projects/scratch/prember-addon-test/node_modules/prember/lib/prerender.js:20:5)
    at Class.postprocessTree (/Users/samselikoff/Projects/scratch/prember-addon-test/node_modules/prember/index.js:25:9)
    at projectOrAddon.addons.reduce (/Users/samselikoff/Projects/scratch/prember-addon-test/node_modules/ember-cli/lib/utilities/addon-process-tree.js:6:25)
    at Array.reduce (<anonymous>:null:null)
    at addonProcessTree (/Users/samselikoff/Projects/scratch/prember-addon-test/node_modules/ember-cli/lib/utilities/addon-process-tree.js:4:32)
    at EmberAddon.addonPostprocessTree (/Users/samselikoff/Projects/scratch/prember-addon-test/node_modules/ember-cli/lib/broccoli/ember-app.js:843:12)
    at EmberAddon.host.addonPostprocessTree (/Users/samselikoff/Projects/scratch/prember-addon-test/node_modules/ember-auto-import/js/auto-import.js:95:20)
    at EmberAddon.toTree (/Users/samselikoff/Projects/scratch/prember-addon-test/node_modules/ember-cli/lib/broccoli/ember-app.js:1772:17)
    at module.exports (/Users/samselikoff/Projects/scratch/prember-addon-test/ember-cli-build.js:21:14)
    at Builder.readBuildFile (/Users/samselikoff/Projects/scratch/prember-addon-test/node_modules/ember-cli/lib/models/builder.js:52:14)
    at Builder.setupBroccoliBuilder (/Users/samselikoff/Projects/scratch/prember-addon-test/node_modules/ember-cli/lib/models/builder.js:66:22)
    at new Builder (/Users/samselikoff/Projects/scratch/prember-addon-test/node_modules/ember-cli/lib/models/builder.js:32:10)
    at ServeTask.run (/Users/samselikoff/Projects/scratch/prember-addon-test/node_modules/ember-cli/lib/tasks/serve.js:45:55)
    at Promise.resolve.then (/Users/samselikoff/Projects/scratch/prember-addon-test/node_modules/ember-cli/lib/models/command.js:243:46)
    at tryCatcher (/Users/samselikoff/Projects/scratch/prember-addon-test/node_modules/ember-cli/node_modules/rsvp/dist/rsvp.js:323:19)
    at invokeCallback (/Users/samselikoff/Projects/scratch/prember-addon-test/node_modules/ember-cli/node_modules/rsvp/dist/rsvp.js:495:31)
    at /Users/samselikoff/Projects/scratch/prember-addon-test/node_modules/ember-cli/node_modules/rsvp/dist/rsvp.js:559:14
    at flush (/Users/samselikoff/Projects/scratch/prember-addon-test/node_modules/ember-cli/node_modules/rsvp/dist/rsvp.js:2402:5)
    at process._tickCallback (internal/process/next_tick.js:61:11)

-~- (end) -~-
  - errorType: Build Error
  - location:
    - column: [undefined]
    - file: [undefined]
    - line: [undefined]
    - treeDir: [undefined]
  - message: Could not find module `fetch` imported from `dummy/instance-initializers/setup-fetch`
        at prember
-~- created here: -~-
    at new Plugin (/Users/samselikoff/Projects/scratch/prember-addon-test/node_modules/broccoli-plugin/index.js:7:31)
    at new Prerender (/Users/samselikoff/Projects/scratch/prember-addon-test/node_modules/prember/lib/prerender.js:20:5)
    at Class.postprocessTree (/Users/samselikoff/Projects/scratch/prember-addon-test/node_modules/prember/index.js:25:9)
    at projectOrAddon.addons.reduce (/Users/samselikoff/Projects/scratch/prember-addon-test/node_modules/ember-cli/lib/utilities/addon-process-tree.js:6:25)
    at Array.reduce (<anonymous>:null:null)
    at addonProcessTree (/Users/samselikoff/Projects/scratch/prember-addon-test/node_modules/ember-cli/lib/utilities/addon-process-tree.js:4:32)
    at EmberAddon.addonPostprocessTree (/Users/samselikoff/Projects/scratch/prember-addon-test/node_modules/ember-cli/lib/broccoli/ember-app.js:843:12)
    at EmberAddon.host.addonPostprocessTree (/Users/samselikoff/Projects/scratch/prember-addon-test/node_modules/ember-auto-import/js/auto-import.js:95:20)
    at EmberAddon.toTree (/Users/samselikoff/Projects/scratch/prember-addon-test/node_modules/ember-cli/lib/broccoli/ember-app.js:1772:17)
    at module.exports (/Users/samselikoff/Projects/scratch/prember-addon-test/ember-cli-build.js:21:14)
    at Builder.readBuildFile (/Users/samselikoff/Projects/scratch/prember-addon-test/node_modules/ember-cli/lib/models/builder.js:52:14)
    at Builder.setupBroccoliBuilder (/Users/samselikoff/Projects/scratch/prember-addon-test/node_modules/ember-cli/lib/models/builder.js:66:22)
    at new Builder (/Users/samselikoff/Projects/scratch/prember-addon-test/node_modules/ember-cli/lib/models/builder.js:32:10)
    at ServeTask.run (/Users/samselikoff/Projects/scratch/prember-addon-test/node_modules/ember-cli/lib/tasks/serve.js:45:55)
    at Promise.resolve.then (/Users/samselikoff/Projects/scratch/prember-addon-test/node_modules/ember-cli/lib/models/command.js:243:46)
    at tryCatcher (/Users/samselikoff/Projects/scratch/prember-addon-test/node_modules/ember-cli/node_modules/rsvp/dist/rsvp.js:323:19)
    at invokeCallback (/Users/samselikoff/Projects/scratch/prember-addon-test/node_modules/ember-cli/node_modules/rsvp/dist/rsvp.js:495:31)
    at /Users/samselikoff/Projects/scratch/prember-addon-test/node_modules/ember-cli/node_modules/rsvp/dist/rsvp.js:559:14
    at flush (/Users/samselikoff/Projects/scratch/prember-addon-test/node_modules/ember-cli/node_modules/rsvp/dist/rsvp.js:2402:5)
    at process._tickCallback (internal/process/next_tick.js:61:11)

-~- (end) -~-
  - name: BuildError
  - nodeAnnotation: [undefined]
  - nodeName: prember
  - originalErrorMessage: Could not find module `fetch` imported from `dummy/instance-initializers/setup-fetch`
  - stack: Error: Could not find module `fetch` imported from `dummy/instance-initializers/setup-fetch`
    at missingModule (/var/folders/v5/5bs4trnx5v7bly3f0cg4_sc40000gn/T/broccoli-20116vhRr54cSUWsH/out-480-broccoli_merge_trees/assets/vendor/loader/loader.js:247:1)
    at findModule (/var/folders/v5/5bs4trnx5v7bly3f0cg4_sc40000gn/T/broccoli-20116vhRr54cSUWsH/out-480-broccoli_merge_trees/assets/vendor/loader/loader.js:258:1)
    at Module.findDeps (/var/folders/v5/5bs4trnx5v7bly3f0cg4_sc40000gn/T/broccoli-20116vhRr54cSUWsH/out-480-broccoli_merge_trees/assets/vendor/loader/loader.js:168:1)
    at findModule (/var/folders/v5/5bs4trnx5v7bly3f0cg4_sc40000gn/T/broccoli-20116vhRr54cSUWsH/out-480-broccoli_merge_trees/assets/vendor/loader/loader.js:262:1)
    at requireModule (/var/folders/v5/5bs4trnx5v7bly3f0cg4_sc40000gn/T/broccoli-20116vhRr54cSUWsH/out-480-broccoli_merge_trees/assets/vendor/loader/loader.js:24:1)
    at resolveInitializer (/var/folders/v5/5bs4trnx5v7bly3f0cg4_sc40000gn/T/broccoli-20116vhRr54cSUWsH/out-480-broccoli_merge_trees/assets/addon-tree-output/ember-load-initializers/index.js:34:1)
    at registerInstanceInitializers (/var/folders/v5/5bs4trnx5v7bly3f0cg4_sc40000gn/T/broccoli-20116vhRr54cSUWsH/out-480-broccoli_merge_trees/assets/addon-tree-output/ember-load-initializers/index.js:53:1)
    at exports.default (/var/folders/v5/5bs4trnx5v7bly3f0cg4_sc40000gn/T/broccoli-20116vhRr54cSUWsH/out-480-broccoli_merge_trees/assets/addon-tree-output/ember-load-initializers/index.js:29:1)
    at Module.callback (/var/folders/v5/5bs4trnx5v7bly3f0cg4_sc40000gn/T/broccoli-20116vhRr54cSUWsH/out-480-broccoli_merge_trees/assets/dummy/app.js:13:1)
    at Module.exports (/var/folders/v5/5bs4trnx5v7bly3f0cg4_sc40000gn/T/broccoli-20116vhRr54cSUWsH/out-480-broccoli_merge_trees/assets/vendor/loader/loader.js:106:1)
    at Module._reify (/var/folders/v5/5bs4trnx5v7bly3f0cg4_sc40000gn/T/broccoli-20116vhRr54cSUWsH/out-480-broccoli_merge_trees/assets/vendor/loader/loader.js:143:1)
    at Module.reify (/var/folders/v5/5bs4trnx5v7bly3f0cg4_sc40000gn/T/broccoli-20116vhRr54cSUWsH/out-480-broccoli_merge_trees/assets/vendor/loader/loader.js:130:1)
    at Module.exports (/var/folders/v5/5bs4trnx5v7bly3f0cg4_sc40000gn/T/broccoli-20116vhRr54cSUWsH/out-480-broccoli_merge_trees/assets/vendor/loader/loader.js:104:1)
    at Object.requireModule (/var/folders/v5/5bs4trnx5v7bly3f0cg4_sc40000gn/T/broccoli-20116vhRr54cSUWsH/out-480-broccoli_merge_trees/assets/vendor/loader/loader.js:27:1)
    at Object.<anonymous> (/Users/samselikoff/Projects/scratch/prember-addon-test/node_modules/fastboot/src/ember-app.js:179:18)
    at VMSandbox.run (/Users/samselikoff/Projects/scratch/prember-addon-test/node_modules/fastboot/src/vm-sandbox.js:18:15)
    at EmberApp.createEmberApp (/Users/samselikoff/Projects/scratch/prember-addon-test/node_modules/fastboot/src/ember-app.js:178:30)
    at EmberApp.retrieveSandboxedApp (/Users/samselikoff/Projects/scratch/prember-addon-test/node_modules/fastboot/src/ember-app.js:203:17)
    at new EmberApp (/Users/samselikoff/Projects/scratch/prember-addon-test/node_modules/fastboot/src/ember-app.js:59:21)
    at FastBoot._buildEmberApp (/Users/samselikoff/Projects/scratch/prember-addon-test/node_modules/fastboot/src/index.js:114:17)
    at new FastBoot (/Users/samselikoff/Projects/scratch/prember-addon-test/node_modules/fastboot/src/index.js:52:10)
    at Prerender.build (/Users/samselikoff/Projects/scratch/prember-addon-test/node_modules/prember/lib/prerender.js:85:15)

=================================================================================
@samselikoff
Copy link
Author

Installing ember-fetch as a top level devDependency got me unstuck. Think it's related to this issue (I've hit it a few times but don't fully understand what's going on.)

@samselikoff
Copy link
Author

Next question: AddonDocs does some clever rewriting of rootURL. In production we set it to a token ADDON_DOCS_ROOT_URL and replace it at deploy-time.

This is giving Prember trouble when its trying to prerender dynamic routes.

Is it possible to see, from config/environment.js, whether Prember is running/building the app? I tried this

  if (environment === 'production' && !process.env.PREMBER) {
    // Allow ember-cli-addon-docs to update the rootURL in compiled assets
    ENV.rootURL = 'ADDON_DOCS_ROOT_URL';
    // here you can enable a production-specific feature
  }

but process.env.PREMBER is only true if it's specified by the user. What I think I really want access to is app.options.prember.enabled. Is it possible to access this from my config/environment.js?

@mansona
Copy link
Collaborator

mansona commented Feb 21, 2019

👋 I'm really glad you're trying out prember for addon-docs because I've always thought it was a perfect fit 😍

I took a quick look at this myself locally and I see your issue where it's trying to request http://localhost:7784/ADDON_DOCS_ROOT_URL/docs/prember-addon-test.json during the prember build 🤔 I wonder though, would this not also be an issue during a "regular" fastboot render?

It may just be the nature of the things that I have been working on with prember but any time I need to do anything different in the prember render I tend to just use the normal semantics to check if you're in fastboot this.fastboot.isFastBoot or whatever it is 😂

@ef4
Copy link
Owner

ef4 commented Feb 21, 2019 via email

@samselikoff
Copy link
Author

Y'all are correct. We use the ADDON_DOCS_ROOT_URL token so we can do one build but two deploy targets (one at root / and one at /versions/branch-name). We do this to save us from having to build the app twice, I think.

Chatted with @dfreeman about this and I think we probably should remove this "abstraction" of ours, as tools like FastBoot and others (asset map, etc.) all use baseURL for a variety of things, and the way we swap it in at deploy-time (after building the apps) will probably cause more paper cuts down the road.

Thanks so much for Prember, it is very, very cool!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants