Giter Site home page Giter Site logo

Comments (2)

frenzzy avatar frenzzy commented on June 16, 2024
Would be cool to support named exports too

Source code: https://unpkg.com/[email protected]/lib/index.js

IN example:

var ReactRelayContext = require("./ReactRelayContext");
var ReactRelayFragmentContainer = require("./ReactRelayFragmentContainer");
var ReactRelayPaginationContainer = require("./ReactRelayPaginationContainer");
var ReactRelayQueryRenderer = require("./ReactRelayQueryRenderer");
var ReactRelayRefetchContainer = require("./ReactRelayRefetchContainer");
var RelayRuntime = require("relay-runtime");

module.exports = {
  QueryRenderer: ReactRelayQueryRenderer,
  MutationTypes: RelayRuntime.MutationTypes,
  RangeOperations: RelayRuntime.RangeOperations,
  ReactRelayContext: ReactRelayContext,
  applyOptimisticMutation: RelayRuntime.applyOptimisticMutation,
  commitLocalUpdate: RelayRuntime.commitLocalUpdate,
  commitMutation: RelayRuntime.commitMutation,
  createFragmentContainer: ReactRelayFragmentContainer.createContainer,
  createPaginationContainer: ReactRelayPaginationContainer.createContainer,
  createRefetchContainer: ReactRelayRefetchContainer.createContainer,
  fetchQuery: RelayRuntime.fetchQuery,
  graphql: RelayRuntime.graphql,
  requestSubscription: RelayRuntime.requestSubscription
};

OUT actual:

import _relayRuntime from "relay-runtime";
import _ReactRelayRefetchContainer from "./ReactRelayRefetchContainer";
import _ReactRelayQueryRenderer from "./ReactRelayQueryRenderer";
import _ReactRelayPaginationContainer from "./ReactRelayPaginationContainer";
import _ReactRelayFragmentContainer from "./ReactRelayFragmentContainer";
import _ReactRelayContext from "./ReactRelayContext";
var module = {
  exports: {}
};
var exports = module.exports;
var ReactRelayContext = _ReactRelayContext;
var ReactRelayFragmentContainer = _ReactRelayFragmentContainer;
var ReactRelayPaginationContainer = _ReactRelayPaginationContainer;
var ReactRelayQueryRenderer = _ReactRelayQueryRenderer;
var ReactRelayRefetchContainer = _ReactRelayRefetchContainer;
var RelayRuntime = _relayRuntime;

module.exports = {
  QueryRenderer: ReactRelayQueryRenderer,
  MutationTypes: RelayRuntime.MutationTypes,
  RangeOperations: RelayRuntime.RangeOperations,
  ReactRelayContext: ReactRelayContext,
  applyOptimisticMutation: RelayRuntime.applyOptimisticMutation,
  commitLocalUpdate: RelayRuntime.commitLocalUpdate,
  commitMutation: RelayRuntime.commitMutation,
  createFragmentContainer: ReactRelayFragmentContainer.createContainer,
  createPaginationContainer: ReactRelayPaginationContainer.createContainer,
  createRefetchContainer: ReactRelayRefetchContainer.createContainer,
  fetchQuery: RelayRuntime.fetchQuery,
  graphql: RelayRuntime.graphql,
  requestSubscription: RelayRuntime.requestSubscription
};
export default module.exports;

OUT expected:

import _relayRuntime from "relay-runtime";
import _ReactRelayRefetchContainer from "./ReactRelayRefetchContainer";
import _ReactRelayQueryRenderer from "./ReactRelayQueryRenderer";
import _ReactRelayPaginationContainer from "./ReactRelayPaginationContainer";
import _ReactRelayFragmentContainer from "./ReactRelayFragmentContainer";
import _ReactRelayContext from "./ReactRelayContext";
var module = {
  exports: {}
};
var exports = module.exports;
var ReactRelayContext = _ReactRelayContext;
var ReactRelayFragmentContainer = _ReactRelayFragmentContainer;
var ReactRelayPaginationContainer = _ReactRelayPaginationContainer;
var ReactRelayQueryRenderer = _ReactRelayQueryRenderer;
var ReactRelayRefetchContainer = _ReactRelayRefetchContainer;
var RelayRuntime = _relayRuntime;

module.exports = {
  QueryRenderer: ReactRelayQueryRenderer,
  MutationTypes: RelayRuntime.MutationTypes,
  RangeOperations: RelayRuntime.RangeOperations,
  ReactRelayContext: ReactRelayContext,
  applyOptimisticMutation: RelayRuntime.applyOptimisticMutation,
  commitLocalUpdate: RelayRuntime.commitLocalUpdate,
  commitMutation: RelayRuntime.commitMutation,
  createFragmentContainer: ReactRelayFragmentContainer.createContainer,
  createPaginationContainer: ReactRelayPaginationContainer.createContainer,
  createRefetchContainer: ReactRelayRefetchContainer.createContainer,
  fetchQuery: RelayRuntime.fetchQuery,
  graphql: RelayRuntime.graphql,
  requestSubscription: RelayRuntime.requestSubscription
};
export const { // <====== NAMED EXPORTS ADDED
  QueryRenderer,
  MutationTypes,
  RangeOperations,
  ReactRelayContext,
  applyOptimisticMutation,
  commitLocalUpdate,
  commitMutation,
  createFragmentContainer,
  createPaginationContainer,
  createRefetchContainer,
  fetchQuery,
  graphql,
  requestSubscription,
} = module.exports;
export default module.exports;

Is it possible/doable?

See also rollup-plugin-commonjs and its namedExports option for inspiration.

from babel-plugin-transform-commonjs.

screetBloom avatar screetBloom commented on June 16, 2024

Any progress so far?

from babel-plugin-transform-commonjs.

Related Issues (13)

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.