Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exports #1

Closed
wants to merge 58 commits into from
Closed

Exports #1

wants to merge 58 commits into from

Conversation

favna
Copy link

@favna favna commented Jul 9, 2023

Warning
You need to rebase your exports branch on top of Krisk/master after which you can properly merge this PR into your exports branch.


This should ensure that all scenarios work

With the following settings in a project that uses fuse.js:

  • JavaScript based projects
    • "type": "common"
      • .cjs file extension
      • .mjs file extension
      • .js file extension
    • "type": "module"
      • .cjs file extension
      • .mjs file extension
      • .js file extension
  • TypeScript based projects
    • "module": "Node16", "moduleResolution": "Node16"
      • "type": "module"
      • "type": "commonjs" fails. But this is expected behaviour because this config states that we're in a strict CJS environment, trying to use an ES module. TS doesn't know that Rollup fully compiled it down to CJS, the fix is really easy for end-users, just use "module: "CommonJS".
        src/index.ts:1:18 - error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("fuse.js")' call instead.
        To convert this file to an ECMAScript module, change its file extension to '.mts' or create a local package.json file with `{ "type": "module" }`.
        
        1 import Fuse from "fuse.js";
                        ~~~~~~~~~
        
        Found 1 error in src/index.ts:1
        
    • "module": "Node16", "moduleResolution": "Node"
      • "type": "module"
      • "type": "commonjs"
    • "module": "CommonJS", "moduleResolution": "Node"
      • "type": "module"
      • "type": "commonjs"

@favna
Copy link
Author

favna commented Jul 9, 2023

Closing this in favour of krisk#727

@favna favna closed this Jul 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants