最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

nrwl nx - Ejs won't allow me to project import statements in my template - Stack Overflow

programmeradmin4浏览0评论

I'm trying to make my component generator more flexible by adding in an option to make it a custom form control. I have the options set up in the schema along with an x-prompt object to provide the options. In my component template I try to do this

<% if( componentType === 'custom form control' ) { %>

<%- import { ReactiveFormsModule } '@angular/forms'; %>

<% } %>

and I get the following error

Cannot use import statement outside a module in C:\path\to\my-folder_name_ponent.ts__tmpl__ while compiling ejs

I tried looking into it and I could only find things regarding the issue on using import in commonjs projects. I set the type property in my package.json file to module and I'm still getting this problem. I'm new to working with this level of NX and am having a hard time finding info that dives deeper into this, can someone help?

I'm trying to make my component generator more flexible by adding in an option to make it a custom form control. I have the options set up in the schema along with an x-prompt object to provide the options. In my component template I try to do this

<% if( componentType === 'custom form control' ) { %>

<%- import { ReactiveFormsModule } '@angular/forms'; %>

<% } %>

and I get the following error

Cannot use import statement outside a module in C:\path\to\my-folder_name_ponent.ts__tmpl__ while compiling ejs

I tried looking into it and I could only find things regarding the issue on using import in commonjs projects. I set the type property in my package.json file to module and I'm still getting this problem. I'm new to working with this level of NX and am having a hard time finding info that dives deeper into this, can someone help?

Share Improve this question asked Mar 11 at 8:57 OptiqOptiq 3,3165 gold badges41 silver badges80 bronze badges 1
  • From which file is this snippet? – GreenSaiko Commented Mar 11 at 11:28
Add a comment  | 

1 Answer 1

Reset to default 1

If

import { ReactiveFormsModule } '@angular/forms';

is the desired output of the template when the conditional is true, then it should not be wrapped in a template tag.

<% if( componentType === 'custom form control' ) { %>

import { ReactiveFormsModule } '@angular/forms';

<% } %>
发布评论

评论列表(0)

  1. 暂无评论