Skip to content

Add migration to change ts module to esnext #16094

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

Closed
2 of 15 tasks
alan-agius4 opened this issue Nov 7, 2019 · 3 comments · Fixed by #16097
Closed
2 of 15 tasks

Add migration to change ts module to esnext #16094

alan-agius4 opened this issue Nov 7, 2019 · 3 comments · Fixed by #16097

Comments

@alan-agius4
Copy link
Collaborator

alan-agius4 commented Nov 7, 2019

🐞 Bug report

Command (mark with an x)

  • new
  • build
  • serve
  • test
  • e2e
  • generate
  • add
  • update
  • lint
  • xi18n
  • run
  • config
  • help
  • version
  • doc

Description

In version 9 we are running the lazy-loading syntax migration to change the string based lazy-loading with import().

We however don't have a migration to ensure that that in the workspace tsconfig the module is set to esnext and this will failures at build time.

🔥 Exception or Error

ERROR in app/routing.module.ts:7:38 - error TS1323: Dynamic import is only supported when '--module' flag is 'commonjs' or 'esNext'.

7   {path: 'grid', loadChildren: () => import('./grid/grid.module').then(m => m.DocsGridModule)},
                                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
app/routing.module.ts:8:38 - error TS1323: Dynamic import is only supported when '--module' flag is 'commonjs' or 'esNext'.

8   {path: 'docs', loadChildren: () => import('./layout/layout.module').then(m => m.DocsLayoutModule)},
                                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
app/routing.module.ts:9:44 - error TS1323: Dynamic import is only supported when '--module' flag is 'commonjs' or 'esNext'.

9   {path: 'responsive', loadChildren: () => import('./responsive/responsive.module').then(m => m.DocsResponsiveModule)},
                                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
app/routing.module.ts:10:40 - error TS1323: Dynamic import is only supported when '--module' flag is 'commonjs' or 'esNext'.

10   {path: 'issues', loadChildren: () => import('./github-issues/github-issues.module').then(m => m.DocsGithubIssuesModule)},
                                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
app/routing.module.ts:13:25 - error TS1323: Dynamic import is only supported when '--module' flag is 'commonjs' or 'esNext'.

13     loadChildren: () => import('./stack-overflow/stack-overflow.module').then(m => m.DocsStackOverflowModule)
@filipesilva
Copy link
Contributor

We did those things in the migration to 8 I believe:

} else if (scriptModule.value !== 'esnext') {
const { start, end } = scriptModule;
recorder.remove(start.offset, end.offset - start.offset);
recorder.insertLeft(start.offset, '"esnext"');
}

const fix = `() => import('${path}').then(m => m.${moduleName})`;

@filipesilva filipesilva modified the milestones: Backlog, v9-candidates Nov 7, 2019
@alan-agius4
Copy link
Collaborator Author

Yeah, but in v9 we are re-trigger the update-lazy-module-paths.ts since string based lazy loading doesn't work with Ivy. However, we are not re-trigger the Dl migration.

I have a PR, to address this; #16097

vikerman pushed a commit that referenced this issue Nov 7, 2019
This migration coverts the TypeScript `module` compiler option to `esnext` or `commonjs` which is required when using `import()`.

Fixes: #16094
vikerman pushed a commit that referenced this issue Nov 7, 2019
This migration coverts the TypeScript `module` compiler option to `esnext` or `commonjs` which is required when using `import()`.

Fixes: #16094
@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 Dec 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants