smart-table / smart-table-ng

smart-table binding for angular >= 2
MIT License
9 stars 7 forks source link

Cannot compile Angular 6 with smart-table-ng #5

Closed wjbarber3 closed 6 years ago

wjbarber3 commented 6 years ago

After upgrading to Angular 6, I am unable to compile my application due to the following error:

ERROR in ./node_modules/smart-table-search/dist/bundle/index.mjs
23:36-38 Can't import the named export 're' from non EcmaScript module (only default export is available)

importing into my component as follows:

import { SmartTable, of, SortDirection } from 'smart-table-ng';

I can't find any info on how to resolve this and am wondering if you might be able to help.

lorenzofox3 commented 6 years ago

try npm update or rm -r node_modules package-lock.json && npm install If the problem persists show me your packag.json and package-lock.json (the relevant part of course)

wjbarber3 commented 6 years ago

Thanks for the reply. Tried both of those to no avail. Here's my package.json...

{
  "name": "",
  "version": "0.0.0",
  "license": "MIT",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "6.0.7",
    "@angular/cdk": "6.3.3",
    "@angular/common": "6.0.7",
    "@angular/compiler": "6.0.7",
    "@angular/core": "6.0.7",
    "@angular/flex-layout": "6.0.0-beta.16",
    "@angular/forms": "6.0.7",
    "@angular/http": "6.0.7",
    "@angular/material": "6.3.3",
    "@angular/material-moment-adapter": "6.3.3",
    "@angular/platform-browser": "6.0.7",
    "@angular/platform-browser-dynamic": "6.0.7",
    "@angular/router": "6.0.7",
    "@mat-datetimepicker/core": "2.0.0",
    "@mat-datetimepicker/moment": "2.0.1",
    "adal-angular": "1.0.14",
    "angular-ui-grid": "4.2.2",
    "angular2-moment": "1.9.0",
    "core-js": "2.5.7",
    "file-saver": "1.3.3",
    "font-awesome": "4.7.0",
    "hammerjs": "2.0.8",
    "lodash": "^4.17.10",
    "moment": "2.22.2",
    "ng2-adal": "2.0.0",
    "ngx-svg-icon": "1.0.2",
    "rxjs": "6.2.1",
    "rxjs-compat": "^6.0.0-rc.0",
    "smart-table-ng": "0.0.10",
    "svgxuse": "1.2.6",
    "web-animations-js": "2.3.1",
    "xlsx": "0.13.2",
    "zone.js": "0.8.26"
  },
  "devDependencies": {
    "@angular-devkit/core": "0.0.29",
    "@angular-devkit/schematics": "0.0.52",
    "@angular/cli": "6.0.8",
    "@angular/compiler-cli": "6.0.7",
    "@angular/language-service": "6.0.7",
    "@angular/service-worker": "6.0.7",
    "@types/adal-angular": "1.0.0",
    "@types/jasmine": "2.8.6",
    "@types/jasminewd2": "2.0.3",
    "@types/lodash": "4.14.97",
    "@types/node": "6.0.60",
    "codelyzer": "4.4.2",
    "jasmine-core": "2.6.2",
    "jasmine-spec-reporter": "4.1.0",
    "karma": "^2.0.4",
    "karma-chrome-launcher": "2.1.1",
    "karma-cli": "1.0.1",
    "karma-coverage-istanbul-reporter": "1.2.1",
    "karma-jasmine": "1.1.0",
    "karma-jasmine-html-reporter": "0.2.2",
    "karma-junit-reporter": "1.2.0",
    "karma-parallel": "0.2.6",
    "karma-phantomjs-launcher": "1.0.4",
    "karma-remap-coverage": "0.1.5",
    "ng2-mock-component": "0.1.1",
    "phantomjs-prebuilt": "2.1.16",
    "protractor": "^5.3.2",
    "ts-node": "3.2.0",
    "tslint": "5.10.0",
    "typescript": "2.7.2",
    "@angular-devkit/build-angular": "~0.6.8"
  }
}
lorenzofox3 commented 6 years ago

Difficult to say, I am not able to reproduce, have your deleted your package-lock.json? Maybe a bug with your npm ? Otherwise you can try to force smart-table-search: npm install smart-table-search@latest

wjbarber3 commented 6 years ago

Are you recommending I try deleting my package-lock.json?

lorenzofox3 commented 6 years ago

yes ! Then npm install If you need a minimal set up to try you can have a look at the stackblitz which compiles with all the latest versions

wjbarber3 commented 6 years ago

Yep I tried deletedpackage-lock.json and reinstalling. What's really frustrating is that I made an exact copy of you stackblitz inside my app and I still get the same error.

wjbarber3 commented 6 years ago

If I comment out the following lines:

const providers = [{
  provide: SmartTable, useValue: of<User>(users)
}];

Everything compiles.

lorenzofox3 commented 6 years ago

what is you tsconfig ?

wjbarber3 commented 6 years ago
{
  "compileOnSave": false,
  "compilerOptions": {
    "outDir": "./dist/out-tsc",
    "sourceMap": true,
    "declaration": false,
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "target": "es5",
    "typeRoots": [
      "node_modules/@types"
    ],
    "lib": [
      "es2017",
      "dom"
    ]
  },
  "include": [
    "src",
    "./node_modules/ngx-svg-icon/src/app/ngx-svg-icon/*"
  ]
}
lorenzofox3 commented 6 years ago

try to add "module": "es2015" in your compilerOptions. The thing, is I have already seen that error but don't remember what was the cause :(

wjbarber3 commented 6 years ago

That didn't solve it unfortunately.

lorenzofox3 commented 6 years ago

ok I have to go now but I'll have a look

wjbarber3 commented 6 years ago

Okay, thanks for your help.

wjbarber3 commented 6 years ago

@lorenzofox3 If I change line 58 in smart-table-core/node_modules/smart-table-search/package.json to "module": "./dist/bundle/index.js", (rather than index.mjs) then my app compiles. I know this is obviously not the proper fix but figured it might help you remember what was causing the issue. Any recommendations?

lorenzofox3 commented 6 years ago

Yes, but that is semantically incorrect. Would not be much of an issue here as the dependency is small (re-template-tag). That would fix an "issue" which should not be an issue. I started with fresh install and was able to reproduce. I think it comes from a regression in Angular compiler. I have seen a similar issue with an older version

lorenzofox3 commented 6 years ago

for info: https://github.com/angular/angular-cli/issues/11527

eenlars commented 6 years ago

Is it possible to go back to a previous version of angular where this bug isn't present?

Rhobal commented 6 years ago

Looking forward to the fix in Angular!

After many futile attempts of overriding the npm dependency resolution, including tries with npm-force-resolutions, I finally edited smart-table-search's index.mjs in node_modules and removed the regexp references; now it compiles again. I don't use regexp search. And I hate the npm dependency resolution...

lorenzofox3 commented 6 years ago

I ended up embedding re-template-tag in the bundle of smart-table-search (the author does not want to change its packaging). By updating all your dependencies, the problem should be solved. Please confirm

Rhobal commented 6 years ago

Fixed for me; I can compile fine with 2.0.1