Skip to content
This repository has been archived by the owner on Feb 1, 2021. It is now read-only.

utils environmentalize fails with item.replace is not a function #543

Closed
KillerCodeMonkey opened this issue Jan 15, 2020 · 6 comments
Closed

Comments

@KillerCodeMonkey
Copy link

KillerCodeMonkey commented Jan 15, 2020

I think we have a similar problem.
In our case the config type is hops.

The untool version is 1.10.4.

Sadly on the config are two keys with functions on it and calling item.replace on it fails. So our whole project stops to work :(.

The config passed to the environmentalize function.

{
      rootDir: 'xxxx,
      name: 'yyyy',
      version: '0.2.2',
      managerEntries: [Function: managerEntries],
      config: [Function: config],
      browsers: [ '> 0.5%', 'last 2 versions', 'Firefox ESR', 'not dead' ],
      node: 'current',
      ....
}

https://github.com/untool/untool/blob/v1.10.4/packages/core/lib/utils.js#L75

@herschel666
Copy link
Member

herschel666 commented Jan 15, 2020

@KillerCodeMonkey Hi. Could you please paste your actual config object here, not the stringified one?

@KillerCodeMonkey
Copy link
Author

KillerCodeMonkey commented Jan 15, 2020

@herschel666 good question :D. I am really new into that whole thing.

our whole .hopsrc.js looks like this:

module.exports = {
  languageTags: ['native-ads'],
  languages: ['de', 'en'],
};

but sadly i do know where the config in untool comes from.
I debugged the code through hops-config to untool and found that peace of code in @untool/core

So as a noob you have to guide me a little bit. maybe this an issue with hops-config because passing functions are not allowed

@herschel666
Copy link
Member

@KillerCodeMonkey Hmm, that config you pasted obviously lacks the very properties, that are causing the error. Without knowing your codebase, I can't tell where those props are defined. Look for a custom Hops preset, that you are consuming in your main app.

Besides, it would be helpful if you could at least confirm, that there's a piece in your final config object, that looks something like this:

{
  config: () => ({
    prop: '[SOME_ENV_VAR]',
  }),
}

@KillerCodeMonkey
Copy link
Author

@herschel666 thanks for your patience

like i said i am more a noob in the untool/xing world and i do not where the other parts of the config comes from.

Here is the complete output of the config passed to the environmentalize function.

{
      rootDir: '/Users/xxx/dev/xxx/xxx',
      name: '@xingternal/xxx',
      version: '0.3.0',
      managerEntries: [Function: managerEntries],
      config: [Function: config],
      'browsers.0': '> 0.5%',
      'browsers.1': 'last 2 versions',
      'browsers.2': 'Firefox ESR',
      'browsers.3': 'not dead',
      node: 'current',
      locations: [],
      basePath: '',
      assetPath: '/assets/<name>',
      buildDir: '<distDir>',
      serverDir: '<rootDir>/node_modules/.cache/untool',
      serverFile: 'server.js',
      statsFile: 'stats.json',
      https: false,
      host: '[HOST]',
      port: '[PORT]',
      distDir: '<rootDir>/dist',
      gracePeriod: 30000,
      logFormat: ':req[x-forwarded-for] (:remote-addr) - :remote-user [:date[clf]] ":method :url HTTP/:http-version" :status :res[content-length]',
      'logjam.appName': '<name>',
      'logjam.locations': [],
      'userAuth.redirectLoggedOut': true,
      'userAuth.loginAppUrl': null,
      'userAuth.mockLanguageMap.1': 'de',
      'userAuth.mockLanguageMap.2': 'en',
      'userAuth.handleInvalidLoginCookie': true,
      'userAuth.allowSoftLogin': false,
      'languages.0': 'de',
      'languages.1': 'en',
      i18nDir: '<rootDir>/i18n',
      i18nProjectId: '6d96f77dfdb867677f18dd85119815d3',
      'languageTags.0': 'xxx,
      fallbackLanguage: 'en',
      'csrf.trustedOrigins': '.+\\.xing\\.com$',
      'sentry.dsn': '',
      'sentry.environment': '[SENTRY_ENV]',
      'sentry.release': '[APP_REVISION]'
    }

in the repo we are using @xingternal/malt-network, which is using hops-config that calls getConfig with hops as argument.

And the hopsconfig.js in our project is just

module.exports = {
  languageTags: ['native-ads'],
  languages: ['de', 'en'],
};

This is working when i do not upgrade any deps in our yarn.lock. But since one hops dependency updates newer untool versions are used and the problem occurs.

Like i said, maybe it is a hopsconfig problem.

Thanks again mate.

@KillerCodeMonkey
Copy link
Author

nice, thanks man!

@janraasch
Copy link

Hi @herschel666, could you give us an ETA on when this is going to land in a 1.10.x-release?

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

No branches or pull requests

3 participants