Replace require(...) with import(...) in typegen (#5495)

* Replace require(...) with import(...) in typegen

* Update metadata

* Adjust & actual run

* Bump API

* Rebuild

* Bump build
This commit is contained in:
Jaco
2023-02-27 16:54:06 +02:00
committed by GitHub
parent cedb1afe6f
commit 5fd6d39aed
45 changed files with 8396 additions and 6972 deletions
-36
View File
@@ -1,36 +0,0 @@
// Copyright 2017-2023 @polkadot/typegen authors & contributors
// SPDX-License-Identifier: Apache-2.0
module.exports = function (file) {
let main;
try {
main = require(`../cjs/${file}.js`).main;
} catch (error) {
// required for dev-only setups
process.env.JEST_WORKER_ID = '123';
// register aliases
require('@babel/register')({
extensions: ['.js', '.ts'],
plugins: [
['module-resolver', {
alias: {
'^@polkadot/api-(augment|base|derive)(.*)': './packages/api-\\1/src\\2',
// eslint-disable-next-line sort-keys
'^@polkadot/api(.*)': './packages/api/src/\\1',
'^@polkadot/rpc-(augment|core|provider)(.*)': './packages/rpc-\\1/src\\2',
'^@polkadot/types-(augment|codec|create|known|metadata|support)(.*)': './packages/types-\\1/src\\2',
// eslint-disable-next-line sort-keys
'^@polkadot/types(.*)': './packages/types/src\\1'
}
}]
]
});
// get ts source
main = require(`../src/${file}.ts`).main;
}
main();
};
@@ -2,4 +2,6 @@
// Copyright 2017-2023 @polkadot/typegen authors & contributors
// SPDX-License-Identifier: Apache-2.0
require('./execWithSrc.cjs')('fromDefs');
import { main } from '@polkadot/typegen/extractChain';
main();
@@ -2,4 +2,6 @@
// Copyright 2017-2023 @polkadot/typegen authors & contributors
// SPDX-License-Identifier: Apache-2.0
require('./execWithSrc.cjs')('extractChain');
import { main } from '@polkadot/typegen/fromChain';
main();
@@ -2,4 +2,6 @@
// Copyright 2017-2023 @polkadot/typegen authors & contributors
// SPDX-License-Identifier: Apache-2.0
require('./execWithSrc.cjs')('interfacesTs');
import { main } from '@polkadot/typegen/fromDefs';
main();
@@ -0,0 +1,7 @@
#!/usr/bin/env node
// Copyright 2017-2023 @polkadot/typegen authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { main } from '@polkadot/typegen/interfacesTs';
main();
@@ -1,5 +0,0 @@
#!/usr/bin/env node
// Copyright 2017-2023 @polkadot/typegen authors & contributors
// SPDX-License-Identifier: Apache-2.0
require('./execWithSrc.cjs')('metadataMd');
@@ -2,4 +2,6 @@
// Copyright 2017-2023 @polkadot/typegen authors & contributors
// SPDX-License-Identifier: Apache-2.0
require('./execWithSrc.cjs')('fromChain');
import { main } from '@polkadot/typegen/metadataMd';
main();