suid icon indicating copy to clipboard operation
suid copied to clipboard

`@suid/utils` dont work with `solidjs/solid-start` "type":"module"` `package.json`

Open sdykae opened this issue 1 year ago • 2 comments

image ERROR Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/home/sdykae/mythings/readme-niubiz-documentation/node_modules/@suid/utils/deepmerge' imported from /home/sdykae/mythings/readme-niubiz-documentation/node_modules/@suid/utils/cloneObject.js at new NodeError (node:internal/errors:393:5) at finalizeResolution (node:internal/modules/esm/resolve:305:11) at moduleResolve (node:internal/modules/esm/resolve:866:10) at defaultResolve (node:internal/modules/esm/resolve:1074:11) at nextResolve (node:internal/modules/esm/loader:164:28) at ESMLoader.resolve (node:internal/modules/esm/loader:839:30) at ESMLoader.getModuleJob (node:internal/modules/esm/loader:426:18) at ModuleWrap. (node:internal/modules/esm/module_job:76:40) at link (node:internal/modules/esm/module_job:75:36) { code: 'ERR_MODULE_NOT_FOUND'

you have to add import { isPlainObject } from "./deepmerge.js"; to resolve :(

after that change It says

image (node:577599) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension. (Use node --trace-warnings ... to show where the warning was created) ERROR /home/sdykae/mythings/readme-niubiz-documentation/node_modules/@suid/system/colorManipulator.js:21 export function hexToRgb(color) { ^^^^^^

SyntaxError: Unexpected token 'export' at Object.compileFunction (node:vm:360:18) at wrapSafe (node:internal/modules/cjs/loader:1048:15) at Module._compile (node:internal/modules/cjs/loader:1083:27) at Module._extensions..js (node:internal/modules/cjs/loader:1173:10) at Module.load (node:internal/modules/cjs/loader:997:32) at Module._load (node:internal/modules/cjs/loader:838:12) at ModuleWrap. (node:internal/modules/esm/translators:170:29) at ModuleJob.run (node:internal/modules/esm/module_job:193:25) at async Promise.all (index 0) at async ESMLoader.import (node:internal/modules/esm/loader:528:24)

sdykae avatar Sep 04 '22 19:09 sdykae

@suid/utils is no longer a package with "module": "type".

Could you test it again?

juanrgm avatar Sep 07 '22 22:09 juanrgm

image

SyntaxError: Cannot use import statement outside a module
    at Object.compileFunction (node:vm:360:18)
    at wrapSafe (node:internal/modules/cjs/loader:1048:15)
    at Module._compile (node:internal/modules/cjs/loader:1083:27)
    at Module._extensions..js (node:internal/modules/cjs/loader:1173:10)
    at Module.load (node:internal/modules/cjs/loader:997:32)
    at Module._load (node:internal/modules/cjs/loader:838:12)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:170:29)
    at ModuleJob.run (node:internal/modules/esm/module_job:193:25)
    at async Promise.all (index 0)
    at async ESMLoader.import (node:internal/modules/esm/loader:528:24)
ERROR /home/sdykae/mythings/readme-niubiz-documentation/node_modules/@suid/utils/merge.js:1
import cloneObject from "./cloneObject";

project is default from npm init solid@next from https://github.com/solidjs/solid-start not a npx degit solidjs/templates/ts my-app from https://github.com/solidjs/solid

sdykae avatar Sep 08 '22 00:09 sdykae

I am migrating the project to pure ESM for supporting NodeJS 16 without experimental options.

This is the first step for adding support to SSR.

juanrgm avatar Oct 10 '22 06:10 juanrgm

SyntaxError: Cannot use import statement outside a module

same error on npm run test

$ npm run test 

> [email protected] test
> jest

 FAIL  packages/codemod/test/transforms/replaceObjectBinding.test.ts
  ● Test suite failed to run

    Jest encountered an unexpected token

    Jest failed to parse a file. This happens e.g. when your code or its dependencies use non-standard JavaScript syntax, or when Jest is not configured to support such syntax.

    Out of the box Jest supports Babel, which will be used to transform your files into valid JS based on your Babel configuration.

    By default "node_modules" folder is ignored by transformers.

    Here's what you can do:
     • If you are trying to use ECMAScript Modules, see https://jestjs.io/docs/ecmascript-modules for how to enable it.
     • If you are trying to use TypeScript, see https://jestjs.io/docs/getting-started#using-typescript
     • To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" in your config.
     • If you need a custom transformation specify a "transform" option in your config.
     • If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper" config option.

    You'll find more details and examples of these config options in the docs:
    https://jestjs.io/docs/configuration
    For information about custom transformations, see:
    https://jestjs.io/docs/code-transformation

    Details:

    /home/user/src/solid/codemod/suid/packages/codemod/src/navigations/findObjectBindingPatterns.js:1
    ({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,jest){import { ts } from "ts-morph";
                                                                                      ^^^^^^

    SyntaxError: Cannot use import statement outside a module

    > 1 | import findObjectBindingPatterns from "../../src/navigations/findObjectBindingPatterns";
        | ^
      2 | import replaceObjectBinding from "../../src/transforms/replaceObjectBinding";
      3 | import format from "../format";
      4 | import transform from "../transform";

      at Runtime.createScriptFromCode (node_modules/.pnpm/[email protected]/node_modules/jest-runtime/build/index.js:1678:14)
      at Object.<anonymous> (packages/codemod/test/transforms/replaceObjectBinding.test.ts:1:1)

milahu avatar Nov 02 '22 14:11 milahu

same error on npm run test

https://github.com/kulshekhar/ts-jest/issues/2838#issuecomment-1302200603

milahu avatar Nov 03 '22 14:11 milahu