Giter Club home page Giter Club logo

Comments (7)

mobsense avatar mobsense commented on July 21, 2024

Totally depends on your tsconfig settings. What were they?

from dynamodb-onetable.

hffmnn avatar hffmnn commented on July 21, 2024

More or less the defaults from a tsc --init. I only updated the outDir I think.

{
  "compilerOptions": {
    "target": "es5" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', 'ES2021', or 'ESNEXT'. */,
    "module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */,
    "outDir": "./dist" /* Redirect output structure to the directory. */,
    "strict": true /* Enable all strict type-checking options. */,
    "esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */,
    "skipLibCheck": true /* Skip type checking of declaration files. */,
    "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
  }
}

from dynamodb-onetable.

mobsense avatar mobsense commented on July 21, 2024

You are using module == 'commonjs' so you will load from cjs. If you set module == 'esnext' you should get mjs.

from dynamodb-onetable.

hffmnn avatar hffmnn commented on July 21, 2024

Setting "module": "esnext" gives

src/main.ts:1:23 - error TS2792: Cannot find module 'dynamodb-onetable'. Did you mean to set the 'moduleResolution' option to 'node', or to add aliases to the 'paths' option?

1 import { Table } from "dynamodb-onetable";
                        ~~~~~~~~~~~~~~~~~~~


Found 1 error.

Setting "moduleResolution": "node", gives

(node:87878) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
/Users/christian/Desktop/_ThrowAway/module_example/dist/main.js:1
import { Table } from "dynamodb-onetable";
^^^^^^

SyntaxError: Cannot use import statement outside a module
    at wrapSafe (internal/modules/cjs/loader.js:931:16)
    at Module._compile (internal/modules/cjs/loader.js:979:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1035:10)
    at Module.load (internal/modules/cjs/loader.js:879:32)
    at Function.Module._load (internal/modules/cjs/loader.js:724:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)
    at internal/main/run_main_module.js:17:47
make: *** [run_tsc] Error 1

Setting "type": "module" in package.json gives

hello from mjs

but seems to break esbuild.

I guess I can work around that, so thanks for the quick reply.

from dynamodb-onetable.

mobsense avatar mobsense commented on July 21, 2024

I think you are right. "type": "module" says the current application uses ES modules. tsconfig "module": "commonjs" says transpile the current app to use commonjs modules.

from dynamodb-onetable.

mobsense avatar mobsense commented on July 21, 2024

Is this issue closed for you? or still unresolved?

from dynamodb-onetable.

hffmnn avatar hffmnn commented on July 21, 2024

Yes, all good. Thank you very much!

from dynamodb-onetable.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.