Skip to content

Conversation

@tetratorus
Copy link

If you wish to ignore .jsx files, you can explicitly define that in a regex in the dontLoad option

If you wish to ignore .jsx files, you can explicitly define that in a regex in the dontLoad option
@JelteF
Copy link

JelteF commented Dec 12, 2016

I tried this, but I can't get it to work. What does your .tern-project file look like?

for (var prop in this.modules) {
if (prop != parentFile && filter(path, prop, query)) {
if (/\.js$/.test(prop)) prop = prop.slice(0, prop.length - 3)
if (/\.jsx?$/.test(prop)) prop = prop.slice(0, prop.length - 3)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There must be prop.length - 4 because length(".jsx") = 4.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It can be either 3 or 4, so jou would need two different if statements

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and 'else if' is also appreciated because it won't work with "foo.jsx.js" file name.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Preferably, just store the regexp match and use match[0].length to get its actual length

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found replace to work well here:
e.g.
prop = prop.replace(/.jsx?/, '')

@0xMarkian
Copy link

0xMarkian commented Mar 6, 2017

Hi!
Any updates on this issue? ... I can't use tern because I have a lot of .jsx files that it simply doesn't see them.

@0xMarkian
Copy link

@marijnh Can I help with something ... maybe update PR? I really like tern and would like to use it :)

@JelteF
Copy link

JelteF commented Mar 7, 2017

I just used the webpack plugin as I use that anyway, so I didn't have a need for this anymore.

@0xMarkian
Copy link

0xMarkian commented Mar 7, 2017

@JelteF can you describe it more?
Because I also use webpack plugin ... but it doesn't help.

So my .tern-project files looks like this:

{
  "plugins": {
    "webpack": {
      "configPath": "./client/webpack.config.js"
    }
  },
  "libs": [
    "browser"
  ],
  "ecmaVersion": 6
}

webpack.config:

resolve: {
    extensions: [
      '*',
      '.js',
      '.jsx'
    ],
    alias: {
      actions: srcPath + '/actions/',
      components: srcPath + '/components/',
      containers: srcPath + '/containers/',
      reducers: srcPath + '/reducers/',
      store: srcPath + '/store/',
      images: srcPath + '/images',
      config: srcPath + '/config',
      configuredLibraries: srcPath + '/configuredLibraries',
      utils: srcPath + '/utils.js',
    },
  },

Webpack plugin helps tern resolve webpack's aliases, but tern still doesn't see .jsx files. Though it became to see them after .jsx files got edited and saved.

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

Successfully merging this pull request may close these issues.

6 participants