refactor: migrate to esm#2021
Conversation
|
| if (!('replaceAll' in String.prototype)) { | ||
| require('core-js/actual/string/replace-all'); | ||
| } | ||
| // FIXME: this is not working |
There was a problem hiding this comment.
To be investigated.
| "release": "changeset publish", | ||
| "pack:prepare": "./scripts/local-pack.sh", | ||
| "respect:parser:generate": "pegjs --format commonjs packages/respect-core/src/modules/runtime-expressions/abnf-parser.pegjs", | ||
| "respect:parser:generate": "pegjs --format commonjs --output packages/respect-core/lib/modules/runtime-expressions/abnf-parser.cjs packages/respect-core/src/modules/runtime-expressions/abnf-parser.pegjs && cp packages/respect-core/lib/modules/runtime-expressions/abnf-parser.cjs packages/respect-core/src/modules/runtime-expressions/abnf-parser.cjs", |
There was a problem hiding this comment.
Store abnf-parser.cjs in the lib/ folder (as we actually need it there) but copy it back in src/ so Typescript doesn't fail.
| configDir, | ||
| // Plugins imported from the node_modules in the package install directory (for example, npx cache directory) | ||
| __dirname, | ||
| __dirname, // FIXME: use path.dirname(fileURLToPath(import.meta.url))? |
| const mod = await import(pathToFileURL(absolutePluginPath).href); | ||
| requiredPlugin = mod.default || mod; | ||
| } | ||
| // try { |
There was a problem hiding this comment.
Either remove or fix it.
| // "target": "ESNext", | ||
| // "module": "CommonJS", |
There was a problem hiding this comment.
| // "target": "ESNext", | |
| // "module": "CommonJS", |
| type ArazzoDefinition, | ||
| type ExtendedOperation, | ||
| } from '@redocly/openapi-core/lib/typings/arazzo'; | ||
| } from 'core/src/typings/openapi.js'; |
There was a problem hiding this comment.
Please imiport from '@redocly/openapi-core'
…e analog, delete comments and fixme
* TO_DELETE: tests setup * migration * migrating more files for ESM * migrating more files for ESM * to be continued... * fix lint e2e tests * fix (almost) commands e2e suite * fix most of respect e2e tests (only one remains) * fix most of the unit tests (5 left) * new require * new require * up * update snaphot * revert changes * add extension to the rest of imports in the codebase * use the lib reference instead of src * add exports section to respect-core package.json * remove @redocly/openapi-core/lib/utils.js import in favour of root import * remove @redocly/openapi-core/lib/config/index.js import in favour of root import * remove @redocly/openapi-core/lib/bundle.js import in favour of root import * remove @redocly/openapi-core/lib/typings/openapi.js import in favour of root import * remove @redocly/openapi-core/lib/config/types.js import in favour of root import * remove @redocly/openapi-core/lib/typings/arazzo.js import in favour of root import * Update packages/cli/src/index.ts * Update packages/core/src/format/format.ts * Update packages/respect-core/src/modules/__tests__/flow-runner/run-step.test.ts * Update tsconfig.json * remove core-js lib and relevant things * fixes for the config-resolver.ts: replace __dirname with ESM-comptible analog, delete comments and fixme * unify tsconfig.json builds * remove allowJs from respect-core * replace require.resolve with a compatible analog * package.json for core and respect-core migration to ESM * use relative import instead of absolute one --------- Co-authored-by: Andrii Maryskevych <[email protected]>
What/Why/How?
WIP
Reference
Testing
Screenshots (optional)
Check yourself
Security