[ Index ]

PHP Cross Reference of Moodle 310

title

Body

[close]

/ -> babel-plugin-add-module-to-define.js (summary)

This is a babel plugin to add the Moodle module names to the AMD modules as part of the transpiling process. In addition it will also add a return statement for the default export if the module is using default exports. This is a highly specific Moodle thing because we're transpiling to AMD and none of the existing Babel 7 plugins work correctly.

Copyright: 2018 Ryan Wyllie <ryan@moodle.com>
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 169 lines (8 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 2 functions

  getModuleNameFromFileName()
  addModuleExportsDefaults()

Functions
Functions that are not part of a class:

getModuleNameFromFileName(searchFileName)   X-Ref
Search the list of components that match the given file name
and return the Moodle component for that file, if found.

Throw an exception if no matching component is found.

param: {string} searchFileName The file name to look for.
return: {string} Moodle component

addModuleExportsDefaults(path, exportObjectName)   X-Ref
This is heavily inspired by the babel-plugin-add-module-exports plugin.
See: https://github.com/59naga/babel-plugin-add-module-exports

This is used when we detect a module using "export default Foo;" to make
sure the transpiled code just returns Foo directly rather than an object
with the default property (i.e. {default: Foo}).

Note: This means that we can't support modules that combine named exports
with a default export.

param: {String} path
param: {String} exportObjectName



Generated: Wed Jan 22 11:59:49 2025 Cross-referenced by PHPXref 0.7.1