Skip to content

Conversation

@nikcub
Copy link

@nikcub nikcub commented Aug 25, 2016

With the AMD module being defined as 'typeahead.js' requirejs configuration attempts to load the module from a relative file path since it assumes it is a file and not module reference.

For config to work with the module being loaded from the baseUrl require the .js extension to be removed from the AMD module definition.

Before:

requirejs.config({
  baseUrl: '/javascripts/',
  paths: {
    'typeahead.js': 'vendor/typeahead.js/dist/typeahead.jquery'
});

// Will attempt to load a file from ./typeahead.js 
require(['typeahead.js']);

renaming it doesn't work since the module is exported as typeahead.js

requirejs.config({
  baseUrl: '/javascripts/',
  paths: {
    'typeahead': 'vendor/typeahead.js/dist/typeahead.jquery'
});

// Won't load since the exported definition is typeahead.js 
require(['typeahead']);

Fixed version:

requirejs.config({
  baseUrl: '/javascripts/',
  paths: {
    'typeahead': 'vendor/typeahead/dist/typeahead.jquery'
});

// Loads
require(['typeahead']);

typeahead is already registered in bower so it will load correctly with nothing more than a definition name change

@nikcub
Copy link
Author

nikcub commented Aug 25, 2016

I only just saw #1438

@CLAassistant
Copy link

CLAassistant commented Jul 18, 2019

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

lynnvaughan added a commit to Beanfield/typeahead.js that referenced this pull request Jul 29, 2019
danielhollas added a commit to KhanovaSkola/khanovaskola-v3 that referenced this pull request Mar 14, 2020
Could not update typehead to 0.11.1 because of:
twitter/typeahead.js#1558
Maybe we could use this fork:
https://github.com/nikcub/typeahead

But according to CHANGELOG, 0.11 was a major rewrite,
so I think we'll stay with the old version
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants