Giter Club home page Giter Club logo

exports's People

Contributors

matiasworker avatar uppercod avatar

Stargazers

 avatar

Watchers

 avatar

exports's Issues

Export fails when file extensions are removed

I was trying to convert the example code from base to TypeScript (renaming brand.jsx to brand.tsx and so on), and clean up seemingly unnecessary file extensions. For example:

import { Hello } from "./hello/hello.jsx"

to

import { Hello } from "./hello/hello"

With the other change renaming components.js to components.ts (also in package.json).

The code with these changes does run, but the export script fails:

Exports
[01:06:03] Initializing...
[01:06:03] Generating outputs with esbuild...
[01:06:03] Esbuild completed...
[01:06:03] Preparing package.json...
[01:06:03] Preparing types...
(node:38990) UnhandledPromiseRejectionWarning: Error: Command failed: npx tsc src/components.ts  --moduleResolution Node --target ESNext --listEmittedFiles true --strict true --jsx react-jsx --jsxImportSource atomico --allowJs true --declaration true --emitDeclarationOnly true --outDir ./types --lib ESNext,DOM,DOM.Iterable

    at ChildProcess.exithandler (child_process.js:319:12)
    at ChildProcess.emit (events.js:376:20)
    at maybeClose (internal/child_process.js:1055:16)
    at Socket.<anonymous> (internal/child_process.js:441:11)
    at Socket.emit (events.js:376:20)
    at Pipe.<anonymous> (net.js:673:12)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:38990) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:38990) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

The default export condition must come last

When package.json is generated, the conditional exports are in the wrong order: "default" must be the last one.

The example is from https://github.com/atomicojs/hooks. Here is what is generated:

{
  "exports": {
    ".": {
      "default": "./dist/index.js",
      "types": "./dist/index.d.ts"
    }
  }
}

Here is what is expected instead:

{
  "exports": {
    ".": {
      "types": "./dist/index.d.ts",
      "default": "./dist/index.js"
    }
  }
}

This is a problem because webpack crashes if the default doesn't come last: https://github.com/webpack/enhanced-resolve/blob/v5.15.0/lib/util/entrypoints.js#L475.

Feature: Allow exports to use sub-folder as a name

Description

When using the --exports flag, I would like the sub-folder to name the export as opposed to the filename

For example, I have the following structure:

.
โ”œโ”€โ”€ src              
โ”œโ”€โ”€โ”€โ”€  button
โ”œโ”€โ”€โ”€โ”€โ”€โ”€  index.js

Currently, using the --exports flag will name one of the exports as index instead of button. It would be nice if the index.js is inside a sub-folder to be able to use that as the name so the generated exports in package.json appear as:

"exports": {
   "./button": "./dist/button/index.js"
}

vs

"exports": {
  "./index": "./dist/button/index.js"
}

--dest CLI option is unknown

"@atomico/exports": "^0.36.0",

Relevant documentation: link

Output

> exports src/elements/*/index.ts --dest dist/browser

file:///C:/dev/repo/cc/elements/node_modules/cac/dist/index.mjs:400
          throw new CACError(`Unknown option \`${name.length > 1 ? `--${name}` : `-${name}`}\``);
                ^

CACError: Unknown option `--dest`

Workaround

The --dist flag seems to control the destination path, even though the help message says that it is for "Choose a project type"
image

exports src/elements/*/index.ts --dist dist/browser

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.