aurelia / i18n

A plugin that provides i18n support.
MIT License
93 stars 70 forks source link

The default backend loader doesn't work with cli+bundler+systemjs #289

Closed 3cp closed 5 years ago

3cp commented 5 years ago

@zewa666 I need to modify this line

https://github.com/aurelia/i18n/blob/b58538378aecc3918fbaa9a357a087784a86c3f6/src/aurelia-i18n-loader.ts#L73

to

const response = await Backend.loader.loadText(SystemJS.normalizeSync(url));

In order to make it work on cli+bundler+systemjs, it is something related to how systemjs normalize module id with plugin subfix.

The aurelia-loader has an abstraction on normalize but I have no reference to 2nd parameter relativeTo. (the 2nd parameter on SystemJS.normalizeSync is optional, but it's required on aurelia loader abstraction)

const response = await Backend.loader.loadText(
  Backend.loader.normalizeSync(url, relativeTo_is_not_accessable_here)
);

requirejs has no such issue.

3cp commented 5 years ago

Looks like this is not aurelia-i18n bug. An easier fix is to remove following code from aurelia-loader-default.

https://github.com/aurelia/loader-default/blob/6bb824869f2969614694a7f568c4dd4c56004001/src/index.js#L211-L224

That code block is unnecessary, as cli+bundler provides systemjs text plugin from npm package systemjs-plugin-text.

It looks like the double definition of text plugin confused systemjs runtime. @EisenbergEffect for that inline text plugin for systemjs, is it designed to support jspm setup?

3cp commented 5 years ago

@EisenbergEffect it looks like jspm setup does not need that inline text plugin either.

https://github.com/aurelia/skeleton-navigation/blob/4cd41380bf0e5e977266fc3793f9a5072d996bac/skeleton-esnext/config.js#L28

EisenbergEffect commented 5 years ago

@huochunpeng Can you submit a PR to address it? If so, I can make a release this week.

3cp commented 5 years ago

@EisenbergEffect is it safe to remove it? I don't know the history.

EisenbergEffect commented 5 years ago

I have no idea. That's been there for years.