Skip to main content

webdac code — Source Migration

webdac code rewrites your application sources for the current Webda version: it moves imports to the packages that now own them and drops registrations the framework now does for you. It uses ts-morph and edits the files listed by your tsconfig.json in place.

It does not generate code. Accessors, toJSON and behaviours are generated by webdac build through @webda/content-mapper, at build time and never into your sources — see Plugins. Earlier versions of webdac code also wrote accessors, loadParameters() and deserialize() methods into the source; those modules are gone.

When to run it​

Once, when you move an application from an older Webda version. Commit first: it writes in place.

Commands​

webdac code # run every migration module
webdac code --module updateImports # run only one module
webdac code --appPath ../my-app # migrate another application

Migration modules​

updateImports​

Rewrites import paths to reflect package reorganizations between Webda versions. For example:

Old importNew import
@webda/core:FileStore@webda/fs
@webda/core:WebdaQL@webda/ql
@webda/core:JSONUtils@webda/utils
@webda/core:CoreModelDefinition@webda/core:ModelClass
@testdeck/mocha@webda/test

An import whose names have all moved is removed; side-effect imports (import "@webda/core") and default imports are left alone.

capabilities​

Removes registerRequestFilter(this) and registerCORSFilter(this) calls. Services that implement the request-filter or CORS-filter interfaces are now registered automatically from the capabilities section of webda.module.json.

How it works​

WebdaMorpher opens a ts-morph Project from <appPath>/tsconfig.json. Each module is a function (sourceFile: SourceFile) => void, and only files whose text changed are saved.

Options​

FlagDescription
--module <name>Run only these module(s). Repeatable.
--appPathPath to the app directory (default: .)

Verify​

# Run the compiler tests (includes the morpher fixtures in test/4.0)
cd packages/compiler
pnpm test

See also​

  • Build — webdac build compiles TypeScript and regenerates the module manifest
  • Module Manifest — what webdac build produces
  • Plugins — code generation during webdac build