Giter VIP home page Giter VIP logo

Comments (1)

javierbrea avatar javierbrea commented on June 12, 2024 1

Hi @ffind,
For the moment the only possibility for doing such thing is developing a plugin and loading files from a folder different to the "mocks" one.

The server is made with CJS, and it requires a transpiler for converting files in any other format to it before loading them. Converting the files in the "mocks" folder is a responsibility of an element in the core of the server, so, this behavior can't be modified by using a plugin. The server API includes a files.createLoader method that allows to receive file contents from defined folders in the "mocks" path, and implement your own customized behavior when files are loaded or they change, but file contents are received already transpiled in this case, so this method is not valid for your requirement.

So, as mentioned, you could implement a plugin being at charge of loading files from a different folder at your convenience, and then use the mock.createloaders method for adding routes and collections based on their contents. But you would have to implement the whole logic about reading the files and transpile them with your preferred library, and you would be also at charge of watching the files in order to refresh the routes and collections when there is any change, convert YAML files, etc.

The good new is that currently I'm migrating the project to TypeScript, and I'll try to export the project both in CJS and ESM, so, probably in next releases ESM would be supported out of the box, without the need to use any transpiler. But it would be still needed to transpile TypeScript files, so I will take this requirement into account in order to provide also an easier mechanism to use custom transpilers.

from main.

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.