alonrbar / easy-template-x-angular-expressions

Angular expressions support for easy-template-x
MIT License
6 stars 1 forks source link

babel-loader in create-react-app setup not working #1

Open aylabbs opened 2 years ago

aylabbs commented 2 years ago
./node_modules/easy-template-x-angular-expressions/dist/es/easy-template-x-angular-expressions.js 35:57
Module parse failed: Unexpected token (35:57)
File was processed with these loaders:
 * ./node_modules/babel-loader/lib/index.js
You may need an additional loader to handle the result of these loaders.
|
| function printPath(path) {
>   const strPath = (path || []).map(p => `"${strEscape(p ?? '')}"`).join(", ");
|   return `[ ${strPath} ]`;
| }

this is my package.json:

  "dependencies": {
    // ...others,
    "@craco/craco": "^6.1.2",
    "antd": "^4.15.5",
    "craco-antd": "^1.19.0",
    "easy-template-x": "^2.1.0",
    "easy-template-x-angular-expressions": "^0.1.0",
    "react": "^17.0.2",
    "react-dom": "^17.0.2",

    "react-router-dom": "^5.2.0",
    "react-scripts": "^4.0.3",
    "typescript": "^4.3.2"
  },

It is failing to parse the nullish coalescing operator. Idk why. I use them in my react app.

Not sure how build works with dependencies. Any ideas to try?

alonrbar commented 2 years ago

How does your babel.config looks like? Try to compare it with https://github.com/alonrbar/easy-template-x-angular-expressions/blob/master/babel.config.js

aylabbs commented 2 years ago

I don't have one.

It is a regular create-react-app.

I wouldn't know where to find it.

Also, I use that operator just fine in my regular app code.

alonrbar commented 2 years ago

mmm... Sorry it is weird, can't think of anything right now. Since this package is pretty small, what I suggest is that you just copy the source code into your project. The createResolver function is the entry point of the package and is defined here https://github.com/alonrbar/easy-template-x-angular-expressions/blob/ec0896641f0af30303fa61c3ba5b81f5d0b5dae0/src/createResolver.ts The entry point just reference the main logic file, which is here https://github.com/alonrbar/easy-template-x-angular-expressions/blob/ec0896641f0af30303fa61c3ba5b81f5d0b5dae0/src/resolver.ts The other files only contain small utilities that serves the main logical class.

alonrbar commented 2 years ago

Another, more simpler option maybe will be to fork this package and change the offending line (it's here). You can then reference your fork directly from github (see https://stackoverflow.com/questions/16350673/depend-on-a-branch-or-tag-using-a-git-url-in-a-package-json)