main
Last change
on this file since 0c6b92a was 0c6b92a, checked in by stefan toskovski <stefantoska84@…>, 5 weeks ago |
Pred finalna verzija
|
-
Property mode
set to
100644
|
File size:
1.6 KB
|
Line | |
---|
1 | "use strict";
|
---|
2 |
|
---|
3 | const babelP = import("./lib/index.js");
|
---|
4 | let babel = null;
|
---|
5 | Object.defineProperty(exports, "__ initialize @babel/core cjs proxy __", {
|
---|
6 | set(val) {
|
---|
7 | babel = val;
|
---|
8 | },
|
---|
9 | });
|
---|
10 |
|
---|
11 | exports.version = require("./package.json").version;
|
---|
12 |
|
---|
13 | const functionNames = [
|
---|
14 | "createConfigItem",
|
---|
15 | "loadPartialConfig",
|
---|
16 | "loadOptions",
|
---|
17 | "transform",
|
---|
18 | "transformFile",
|
---|
19 | "transformFromAst",
|
---|
20 | "parse",
|
---|
21 | ];
|
---|
22 | const propertyNames = [
|
---|
23 | "buildExternalHelpers",
|
---|
24 | "types",
|
---|
25 | "tokTypes",
|
---|
26 | "traverse",
|
---|
27 | "template",
|
---|
28 | ];
|
---|
29 |
|
---|
30 | for (const name of functionNames) {
|
---|
31 | exports[name] = function (...args) {
|
---|
32 | if (
|
---|
33 | process.env.BABEL_8_BREAKING &&
|
---|
34 | typeof args[args.length - 1] !== "function"
|
---|
35 | ) {
|
---|
36 | throw new Error(
|
---|
37 | `Starting from Babel 8.0.0, the '${name}' function expects a callback. If you need to call it synchronously, please use '${name}Sync'.`
|
---|
38 | );
|
---|
39 | }
|
---|
40 |
|
---|
41 | babelP.then(babel => {
|
---|
42 | babel[name](...args);
|
---|
43 | });
|
---|
44 | };
|
---|
45 | exports[`${name}Async`] = function (...args) {
|
---|
46 | return babelP.then(babel => babel[`${name}Async`](...args));
|
---|
47 | };
|
---|
48 | exports[`${name}Sync`] = function (...args) {
|
---|
49 | if (!babel) throw notLoadedError(`${name}Sync`, "callable");
|
---|
50 | return babel[`${name}Sync`](...args);
|
---|
51 | };
|
---|
52 | }
|
---|
53 |
|
---|
54 | for (const name of propertyNames) {
|
---|
55 | Object.defineProperty(exports, name, {
|
---|
56 | get() {
|
---|
57 | if (!babel) throw notLoadedError(name, "accessible");
|
---|
58 | return babel[name];
|
---|
59 | },
|
---|
60 | });
|
---|
61 | }
|
---|
62 |
|
---|
63 | function notLoadedError(name, keyword) {
|
---|
64 | return new Error(
|
---|
65 | `The \`${name}\` export of @babel/core is only ${keyword}` +
|
---|
66 | ` from the CommonJS version after that the ESM version is loaded.`
|
---|
67 | );
|
---|
68 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.