Skip to content
This repository has been archived by the owner on May 22, 2024. It is now read-only.

Tsconfig from parent is used when building Functions from a subdirectory. #988

Open
redmagic opened this issue Jan 31, 2022 · 4 comments
Open
Labels
type: bug code to address defects in shipped code

Comments

@redmagic
Copy link

When building from a subdirectory containing a tsconfig file, the build process seems to parse the tsconfig file from the root directory as well, referring to it as ../tsconfig.json.

image

image

I would expect the build in the subdirectory not to scan parent directories.

Configuration

toml from subdirectory

[dev]
framework = "#static"
functions="functions"

[build]
  base = "api/"
  publish = "_site/"

[functions]
directory = "functions"
external_node_modules = ["fsevents"]
included_files = ["functions/env/*"]

[[plugins]]
package = './plugins/environment'

typescript config from subdirectory (NB no extend from the parent directory is used)

{
    "extends": "@tsconfig/node14/tsconfig.json",
    "compilerOptions": {
        "baseUrl": ".",
        "noImplicitAny": false,
        "esModuleInterop": true,
        "isolatedModules": true,
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true,
        "preserveConstEnums": true,
        "strict": false,
        "typeRoots": [
            "node_modules/@types"
        ],
        "types": [
            "node"
        ],
        "paths": {
            "@shared/*": [
                "../shared/*"
            ],
            "@functions/*": [
                "./functions/*"
            ],
            "@assets/*": [
                "./assets/*"
            ],
            "@lib/*": [
                "./lib/*"
            ]
        }
    }
}
  • Did you run your build through the UI or the CLI?
    Running netlify dev gives no errors, the UI does

Deploy logs
https://app.netlify.com/sites/thuisuitetenapi/deploys/61f7c4c432c30b0008c833a9

@redmagic redmagic added the type: bug code to address defects in shipped code label Jan 31, 2022
@ehmicky
Copy link
Contributor

ehmicky commented Jan 31, 2022

Hi @redmagic,

Thanks for reporting this.
Could you please show the log lines between the two screenshots above? Thanks!

@redmagic
Copy link
Author

4:30:21 PM: Build ready to start
4:30:23 PM: build-image version: 122b31996ccaffd45d820a452d6227f8312110cc (focal)
4:30:23 PM: build-image tag: v4.5.3
4:30:23 PM: buildbot version: b9fe2d4aead91245e5ab227e25498d66c4f1ea02
4:30:24 PM: Building without cache
4:30:24 PM: Starting to prepare the repo for build
4:30:24 PM: No cached dependencies found. Cloning fresh repo
4:30:24 PM: git clone https://github.com/ThuisUitEten/website
4:30:26 PM: Preparing Git Reference refs/heads/monorepo
4:30:27 PM: Parsing package.json dependencies
4:30:27 PM: Different publish path detected, going to use the one specified in the Netlify configuration file: 'api/_site' versus '_site' in the Netlify UI
4:30:27 PM: Different build command detected, going to use the one specified in the Netlify configuration file: 'npm run build' versus '' in the Netlify UI
4:30:28 PM: Starting build script
4:30:28 PM: Installing dependencies
4:30:28 PM: Python version set to 2.7
4:30:29 PM: v16.13.2 is already installed.
4:30:29 PM: Now using node v16.13.2 (npm v8.1.2)
4:30:29 PM: Started restoring cached build plugins
4:30:29 PM: Finished restoring cached build plugins
4:30:30 PM: Attempting ruby version 2.7.2, read from environment
4:30:31 PM: Using ruby version 2.7.2
4:30:32 PM: Using PHP version 8.0
4:30:32 PM: Started restoring cached node modules
4:30:32 PM: Finished restoring cached node modules
4:30:33 PM: Installing NPM modules using NPM version 8.1.2
4:30:55 PM: added 86 packages, and audited 87 packages in 22s
4:30:55 PM: 14 packages are looking for funding
4:30:55 PM:   run `npm fund` for details
4:30:55 PM: found 0 vulnerabilities
4:30:55 PM: NPM modules installed
4:30:56 PM: Started restoring cached go cache
4:30:56 PM: Finished restoring cached go cache
4:30:56 PM: go version go1.16.5 linux/amd64
4:30:56 PM: go version go1.16.5 linux/amd64
4:30:56 PM: Installing missing commands
4:30:56 PM: Verify run directory
4:30:58 PM: ​
4:30:58 PM: ────────────────────────────────────────────────────────────────
4:30:58 PM:   Netlify Build                                                 
4:30:58 PM: ────────────────────────────────────────────────────────────────
4:30:58 PM: ​
4:30:58 PM: ❯ Version
4:30:58 PM:   @netlify/build 26.2.2
4:30:58 PM: ​
4:30:58 PM: ❯ Flags
4:30:58 PM:   baseRelDir: true
4:30:58 PM:   buildId: 61f8008d663ebff998fe4d64
4:30:58 PM:   deployId: 61f8008d663ebff998fe4d66
4:30:58 PM: ​
4:30:58 PM: ❯ Current directory
4:30:58 PM:   /opt/build/repo/api
4:30:58 PM: ​
4:30:58 PM: ❯ Config file
4:30:58 PM:   /opt/build/repo/api/netlify.toml
4:30:58 PM: ​
4:30:58 PM: ❯ Context
4:30:58 PM:   production
4:30:58 PM: ​
4:30:58 PM: ❯ Loading plugins
4:30:58 PM:    - ./plugins/environment@1.0.0 from netlify.toml
4:31:00 PM: ​
4:31:00 PM: ────────────────────────────────────────────────────────────────
4:31:00 PM:   1. ./plugins/environment (onPreBuild event)                   
4:31:00 PM: ────────────────────────────────────────────────────────────────
4:31:00 PM: ​
4:31:00 PM: Replaced 18 ENVs
4:31:00 PM: Written to functions/env/env.txt
4:31:00 PM: ​
4:31:00 PM: (./plugins/environment onPreBuild completed in 16ms)
4:31:00 PM: ​
4:31:00 PM: ────────────────────────────────────────────────────────────────
4:31:00 PM:   2. build.command from netlify.toml                            
4:31:00 PM: ────────────────────────────────────────────────────────────────
4:31:00 PM: ​
4:31:00 PM: $ npm run build
4:31:00 PM: > api@1.0.0 build
4:31:00 PM: > echo "Nothing to build" && exit 0
4:31:00 PM: Nothing to build
4:31:00 PM: ​
4:31:00 PM: (build.command completed in 516ms)
4:31:00 PM: ​
4:31:00 PM: ────────────────────────────────────────────────────────────────
4:31:00 PM:   3. Functions bundling                                         
4:31:00 PM: ────────────────────────────────────────────────────────────────
4:31:00 PM: ​
4:31:00 PM: Packaging Functions from functions directory:
4:31:00 PM:  - api-availability-product.ts
4:31:00 PM:  - api-availability-restaurant.ts
4:31:00 PM:  - api-bo-contact-moment-export-background.ts
4:31:00 PM:  - api-bo-contact-moment.ts
4:31:00 PM:  - api-bo-coupon-generate.ts
4:31:00 PM:  - api-bo-custom-setting.ts
4:31:00 PM:  - api-bo-customer.ts
4:31:00 PM:  - api-bo-download.ts
4:31:00 PM:  - api-bo-invoice-export-background.ts
4:31:00 PM:  - api-bo-invoke-function.ts
4:31:00 PM:  - api-bo-logistics.ts
4:31:00 PM:  - api-bo-order-export-background.ts
4:31:00 PM:  - api-bo-order-line.ts
4:31:00 PM:  - api-bo-order.ts
4:31:00 PM:  - api-bo-qlik-export.ts
4:31:00 PM:  - api-bo-routetitan-export-background.ts
4:31:00 PM:  - api-bo-setting.ts
4:31:00 PM:  - api-bo-stock.ts
4:31:00 PM:  - api-bo-subscriber-export-restaurant-background.ts
4:31:00 PM:  - api-bo-subscriber-export-tue-background.ts
4:31:00 PM:  - api-contact-form.ts
4:31:00 PM:  - api-file-download.ts
4:31:00 PM:  - api-generate-barcode.ts
4:31:00 PM:  - api-generate-pdf-background.ts
4:31:00 PM:  - api-invoice-test.ts
4:31:00 PM:  - api-order-place.ts
4:31:00 PM:  - api-order-status.ts
4:31:00 PM:  - api-order-validate.ts
4:31:00 PM:  - api-rp-dashboard.ts
4:31:00 PM:  - api-rp-order-details.ts
4:31:00 PM:  - api-rp-order-summary.ts
4:31:00 PM:  - api-rp-restaurant-list.ts
4:31:00 PM:  - api-rp-restaurant-totals.ts
4:31:00 PM:  - api-rp-restaurant.ts
4:31:00 PM:  - api-send-email-confirmation.ts
4:31:00 PM:  - api-shipping-methods.ts
4:31:00 PM:  - api-subscribe-newsletter.ts
4:31:00 PM:  - api-test.ts
4:31:00 PM:  - api-zipcode.ts
4:31:00 PM:  - coupon-verify.ts
4:31:00 PM:  - deploy-notification.ts
4:31:00 PM:  - giftcard-check-balance.ts
4:31:00 PM:  - logger.ts
4:31:00 PM:  - payment-mollie-methods.ts
4:31:00 PM:  - payment-mollie-webhook.ts
4:31:00 PM:  - sync-dato-background.ts
4:31:00 PM:  - sync-restaurant-info.ts
4:31:00 PM: ​
4:31:00 PM:  > ../tsconfig.json:2:15: warning: Cannot find base config file "@tsconfig/svelte/tsconfig.json"
4:31:00 PM:     2 │     "extends": "@tsconfig/svelte/tsconfig.json",

@redmagic
Copy link
Author

For some more context, I am trying to migrate to a monorepo where the api folder has only a functions deploy.
I am setting this up using NPM workspaces, but later read this is not supported.

When I import dependencies from outside the subdirecty, they cannot locate their dependencies, but I will file a separate issue for that, or try Yarn workspaces first.

@ehmicky
Copy link
Contributor

ehmicky commented Jan 31, 2022

Interesting, this is happening during Functions bundling. I am transferring this bug to @netlify/zip-it-and-ship-it, which is responsible for this part of the build logic.

@eduardoboucas @netlify-team-account-1 What are your thoughts on this?

@ehmicky ehmicky transferred this issue from netlify/build Jan 31, 2022
@ehmicky ehmicky changed the title Tsconfig from parent is used when building from a subdirectory. Tsconfig from parent is used when building Functions from a subdirectory. Jan 31, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: bug code to address defects in shipped code
Projects
None yet
Development

No branches or pull requests

2 participants