use es2022 modules

This commit is contained in:
nganhkhoa 2023-03-30 12:05:40 +07:00
parent 82f1edc06e
commit 59411e3be1
10 changed files with 12 additions and 63 deletions

1
.gitignore vendored
View File

@ -11,3 +11,4 @@
#.pnp.*
node_modules/
dist/

38
dist/index.js vendored
View File

@ -1,38 +0,0 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const feature_1 = require("./src/moduleA/feature");
const feature_2 = require("./src/moduleB/feature");
const _a_1 = require("./src/moduleA");
const path = __importStar(require("path"));
const moment_1 = __importDefault(require("moment"));
console.log("from A module", feature_1.A);
console.log("from A module", _a_1.A);
console.log("from B module", feature_2.B);
console.log("testing std node modules", path.delimiter);
console.log("testing installed node_modules", (0, moment_1.default)().format());

View File

@ -1,4 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.A = void 0;
exports.A = 1;

View File

@ -1,5 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.A = void 0;
var feature_1 = require("./feature");
Object.defineProperty(exports, "A", { enumerable: true, get: function () { return feature_1.A; } });

View File

@ -1,4 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.B = void 0;
exports.B = 2;

View File

@ -1,14 +1,11 @@
import { A } from "@a/feature";
import { B } from "@b/feature";
import { A as AA } from "@a";
import { A } from "@a";
import { B } from "@b";
import * as path from "path";
import moment from "moment";
console.log("from A module", A)
console.log("from A module", AA)
console.log("from B module", B)
console.log("testing std node modules", path.delimiter)

View File

@ -1,9 +1,9 @@
{
"name": "a",
"packageManager": "yarn@3.4.1",
"type": "commonjs",
"type": "module",
"scripts": {
"start": "node dist/index.js",
"start": "node --experimental-specifier-resolution=node dist/index.js",
"build": "tsc && tsc-alias",
"build:watch": "tsc && (concurrently \"tsc -w\" \"tsc-alias -w\")"
},

View File

@ -1 +1 @@
export { A } from './feature';
export { A } from "./feature";

1
src/moduleB/index.ts Normal file
View File

@ -0,0 +1 @@
export { B } from "./feature";

View File

@ -26,15 +26,13 @@
// "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
/* Modules */
"module": "commonjs", /* Specify what module code is generated. */
"module": "es2022", /* Specify what module code is generated. */
// "rootDir": "./", /* Specify the root folder within your source files. */
"moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */
"baseUrl": ".", /* Specify the base directory to resolve non-relative module names. */
"paths": {
"@a": ["src/moduleA"],
"@b": ["src/moduleB"],
"@a/*": ["src/moduleA/*"],
"@b/*": ["src/moduleB/*"],
"@b": ["src/moduleB"]
}, /* Specify a set of entries that re-map imports to additional lookup locations. */
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
// "typeRoots": [
@ -115,5 +113,8 @@
/* Completeness */
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
"skipLibCheck": true /* Skip type checking all .d.ts files. */
},
"tsc-alias": {
"resolveFullPaths": true
}
}