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

Support ESModules for proxy.config file #21623

Closed
1 of 15 tasks
ranwahle opened this issue Aug 22, 2021 · 1 comment · Fixed by #21792
Closed
1 of 15 tasks

Support ESModules for proxy.config file #21623

ranwahle opened this issue Aug 22, 2021 · 1 comment · Fixed by #21792

Comments

@ranwahle
Copy link

🚀 Feature request

Command (mark with an x)

  • new
  • build
  • serve
  • test
  • e2e
  • generate
  • add
  • update
  • lint
  • extract-i18n
  • run
  • config
  • help
  • version
  • doc

Description

Angular CLI now supports proxy configuration for both .json and .js extensions, however, trying to have a proxy with .mjs file, in order to have the javascript file importing other modules, produces an error message.

A clear and concise description of the problem or missing capability...

Describe the solution you'd like

I've discovered that using dynamic import instead of require on addProxyConfig function on dev-server.ts file, does this work.

If you have a solution in mind, please describe it.

Describe alternatives you've considered

I have searched for some flags that will allow me to do so and haven't found any, and the only solution I can find is to go to require.

@ngbot ngbot bot added this to the needsTriage milestone Aug 23, 2021
@alan-agius4 alan-agius4 added the feature Issue that requests a new feature label Aug 23, 2021
@ngbot ngbot bot modified the milestones: needsTriage, Backlog Aug 23, 2021
clydin added a commit to clydin/angular-cli that referenced this issue Sep 22, 2021
…files for the dev server

The `proxyConfig` option now supports loading ESM configuration files in addition to JSON and CommonJS files. ESM files (such as those ending with `.mjs`) must provide a default export with the configuration object.
For example, a `proxy.config.mjs` containing the follow is now possible:
```
export default { "/api/*": { "target": "http://127.0.0.1:5001" } };
```

Closes angular#21623
clydin added a commit to clydin/angular-cli that referenced this issue Sep 23, 2021
…files for the dev server

The `proxyConfig` option now supports loading ESM configuration files in addition to JSON and CommonJS files. ESM files (such as those ending with `.mjs`) must provide a default export with the configuration object.
For example, a `proxy.config.mjs` containing the follow is now possible:
```
export default { "/api/*": { "target": "http://127.0.0.1:5001" } };
```

Closes angular#21623
clydin added a commit to clydin/angular-cli that referenced this issue Sep 23, 2021
…files for the dev server

The `proxyConfig` option now supports loading ESM configuration files in addition to JSON and CommonJS files. ESM files (such as those ending with `.mjs`) must provide a default export with the configuration object.
For example, a `proxy.config.mjs` containing the follow is now possible:
```
export default { "/api/*": { "target": "http://127.0.0.1:5001" } };
```

Closes angular#21623
clydin added a commit to clydin/angular-cli that referenced this issue Sep 23, 2021
…files for the dev server

The `proxyConfig` option now supports loading ESM configuration files in addition to JSON and CommonJS files. ESM files (such as those ending with `.mjs`) must provide a default export with the configuration object.
For example, a `proxy.config.mjs` containing the follow is now possible:
```
export default { "/api/*": { "target": "http://127.0.0.1:5001" } };
```

Closes angular#21623
clydin added a commit that referenced this issue Sep 24, 2021
…files for the dev server

The `proxyConfig` option now supports loading ESM configuration files in addition to JSON and CommonJS files. ESM files (such as those ending with `.mjs`) must provide a default export with the configuration object.
For example, a `proxy.config.mjs` containing the follow is now possible:
```
export default { "/api/*": { "target": "http://127.0.0.1:5001" } };
```

Closes #21623
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Oct 25, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
2 participants