Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support tsconfig.json paths imports / monorepository workspaces #550

Open
KeithGillette opened this issue May 27, 2022 · 0 comments
Open

Comments

@KeithGillette
Copy link

KeithGillette commented May 27, 2022

Current Behavior

Related to this previously reported limitation of Zapier CLI stemming from its design of copying project source code to a temporary directory, zapier build produces Error: Cannot find module when attempting to import from a module defined using the tsconfig.json paths property, as illustrated in the following error generated in our Nx workspace:

Error from zapier build:

✔ Copying project to temp directory
✔ Installing project dependencies
✔ Applying entry point file
✖ Building app definition.json
›   Error: Cannot find module '@tasktrain/shared/core/application/oauth'
›   Require stack:
›   - /private/var/folders/t5/nv32j92n7rngpy281m6gj8n00000gn/T/zapier-fee12db4/lib/applications/zapier/src/triggers/assignee-list.js
›   - /private/var/folders/t5/nv32j92n7rngpy281m6gj8n00000gn/T/zapier-fee12db4/lib/applications/zapier/src/index.js
›   - /private/var/folders/t5/nv32j92n7rngpy281m6gj8n00000gn/T/zapier-fee12db4/index.js
›   - /private/var/folders/t5/nv32j92n7rngpy281m6gj8n00000gn/T/zapier-fee12db4/node_modules/zapier-platform-core/src/tools/create-lambda-handler.js
›   - /private/var/folders/t5/nv32j92n7rngpy281m6gj8n00000gn/T/zapier-fee12db4/node_modules/zapier-platform-core/src/index.js
›   - /private/var/folders/t5/nv32j92n7rngpy281m6gj8n00000gn/T/zapier-fee12db4/node_modules/zapier-platform-core/index.js
›   - /private/var/folders/t5/nv32j92n7rngpy281m6gj8n00000gn/T/zapier-fee12db4/zapierwrapper.js
›   - /path/to/node_modules/zapier-platform-cli/src/utils/build.js
›   - /path/to/node_modules/zapier-platform-cli/src/oclif/commands/build.js
›   - /path/to/node_modules/zapier-platform-cli/src/oclif/commands/push.js
›   - /path/to/node_modules/@oclif/config/lib/plugin.js
›   - /path/to/node_modules/@oclif/config/lib/config.js
›   - /path/to/node_modules/@oclif/config/lib/index.js
›   - /path/to/node_modules/@oclif/command/lib/command.js
›   - /path/to/node_modules/@oclif/command/lib/index.js
›   - /path/to/node_modules/zapier-platform-cli/src/bin/run

applications/zapier/tsconfig.json:

{
  "extends": "../../tsconfig.json",
  "compilerOptions": {
    "baseUrl": "../../",
    "module": "commonjs",
    "outDir": "./lib",
    "target": "es2019"
  }
}

workspace tsconfig.json:

{
  "compileOnSave": false,
  "compilerOptions": {
    "allowSyntheticDefaultImports": true,
    "declaration": false,
    "downlevelIteration": true,
    "emitDecoratorMetadata": true,
    "esModuleInterop": true,
    "experimentalDecorators": true,
    "importHelpers": true,
    "lib": [
      "ES2018",
      "dom"
    ],
    "module": "es2020",
    "moduleResolution": "node",
    "noImplicitAny": true,
    "outDir": "./dist/out-tsc",
    "resolveJsonModule": true,
    "sourceMap": true,
    "strict": true,
    "strictNullChecks": false,
    "suppressImplicitAnyIndexErrors": true,
    "target": "es2015",
    "paths": {
      "@tasktrain/shared/core/application/oauth": [
        "libraries/shared/core/application/oauth/src/index.ts"
      ]
    }
  }
}

Desired Behavior

Zapier CLI would enable DRY code reuse in monorepositories by allowing import of code shared with other projects via tsconfig.json paths (and relative imports from outside of the Zapier project directory, as well as resolution of node_modules libraries from the workspace root so as to not require a local node_modules or symlink to the root node_modules directory).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant