atk / solid-register

MIT License
18 stars 1 forks source link

TypeError: _$template is not a function #2

Closed justinvandenberg closed 2 years ago

justinvandenberg commented 3 years ago

Node version: 16.11.0

Script: uvu -r module-alias/register -r solid-register

Relevant config from package.json:

"solid-register": {
  "compile": {
    "solid": { 
      "engine":  "babel", 
      "extensions": [".js", ".jsx"]
    },
    "css": false
  }
},
"_moduleAliases": {
  "#": "src"
}

Error:

TypeError: _$template is not a function
    at Object.<anonymous> (/Users/<user>/Projects/<project_name>/src/workflows/PortalSearchWorkflow/ui/Search/index.jsx:22:16)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Module._compile (/Users/<user>/Projects<project_name>/node_modules/pirates/lib/index.js:99:24)
    at Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at newLoader (/Users/<user>/Projects/<project_name>/node_modules/pirates/lib/index.js:104:7)
    at Object.require.extensions.<computed> [as .jsx] (/Users/<user>/Projects/<project_name>/node_modules/solid-register/dist/compile-aliases.js:34:13)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
atk commented 3 years ago

It seems that your use of module-alias clashes with the filename aliasing in solid-register. There are two ways to go about that; 1. you could add the required paths to the _moduleAliases-config or 2. use node --conditions browser node_modules/.bin/uvu -r module-alias/register -r solid-registerinstead of running uvu directly.

Please tell me if one of these solutions work for you and I will document the issue in the README.

justinvandenberg commented 3 years ago

@atk Thank you! The second solution worked for me. I did have to install @babel/plugin-transform-runtime though.

So, my .babelrc looks like this:

{
  "env": {
    "test": {
      "plugins": ["@babel/plugin-transform-runtime"]
    }
  },
  "presets": ["babel-preset-solid"]
}
atk commented 3 years ago

Please accept my apology for the lacking documentation.