Matticusau / sqlops-mssql-instance-insights

SqlOps Studio MSSQL Instance Insights Extension
MIT License
16 stars 3 forks source link

Bug: Gulp Build failing with error TS2307: Cannot find module 'sqlops'. #14

Open Matticusau opened 6 years ago

Matticusau commented 6 years ago

Gulp Buld is currently reporting the following yet the build/extension works

PS C:\GitHub\sqlops-mssql-instance-insights> gulp build
[22:43:46] Using gulpfile C:\GitHub\sqlops-mssql-instance-insights\gulpfile.js
[22:43:46] Starting 'build'...
[22:43:46] Starting 'clean'...
[22:43:46] Finished 'clean' after 40 ms
[22:43:46] Starting 'lint'...
[22:43:46] Finished 'lint' after 141 ms
[22:43:46] Starting 'compile'...
[22:43:46] Starting 'compile:src'...
src\apiWrapper.ts(19,23): error TS2307: Cannot find module 'sqlops'.
src\controllers\instanceUtils.ts(13,25): error TS2307: Cannot find module 'sqlops'.
src\controllers\mainController.ts(19,25): error TS2307: Cannot find module 'sqlops'.
src\controllers\mainController.ts(23,22): error TS2497: Module '"C:/GitHub/sqlops-mssql-instance-insights/node_modules/@types/opn/index"' resolves to a non-module entity and cannot be imported using this construct.
src\controllers\mainController.ts(72,19): error TS6133: 'openVersionHealthCheckWebSite2' is declared but its value is never read.
src\data\createInstanceData.ts(19,25): error TS2307: Cannot find module 'sqlops'.
[22:43:48] TypeScript: 6 semantic errors
[22:43:48] TypeScript: emit succeeded (with errors)
[22:43:48] Finished 'compile:src' after 1.98 s
[22:43:48] Starting 'compile:test'...
[22:43:48] Finished 'compile:test' after 4.59 ms
[22:43:48] Finished 'compile' after 1.99 s
[22:43:48] Finished 'build' after 2.17 s
PS C:\GitHub\sqlops-mssql-instance-insights>
Matticusau commented 6 years ago

After comparing the sqlops module with the vscode module, I have found that the issue seems to be due to a missing sqlops.d.ts file in the sqlops npm module that is installed. Copying the sqlops.d.ts from the /src/sql/sqlops.d.ts of the sqlopsstudio repo does remove the error, but creates many more!!! Plus that would be undone by any npm install/update

I'm emailing anthonydresser to find out more.

Matticusau commented 6 years ago

Needed a postinstall step in scripts section of package.json I had the install script referenced in the prepare step but not in the postinstall. This is required as both the vscode and sqlops modules will pull down their *.d.ts files as part of the install script.

was

"scripts": {
        "prepare": "node ./node_modules/sqlops/bin/install",
        "build": "gulp build",
        "compile": "gulp compile",
        "watch": "gulp watch",
        "postinstall": "node ./node_modules/vscode/bin/install"
    },

Needed to be

"scripts": {
        "prepare": "node ./node_modules/sqlops/bin/install",
        "build": "gulp build",
        "compile": "gulp compile",
        "watch": "gulp watch",
        "postinstall": "node ./node_modules/vscode/bin/install && node ./node_modules/sqlops/bin/install"
    },

Then run npm install and it fixes the issue.

Matticusau commented 6 years ago

Side note.... also fixed the import for opn by changing

import * as opn from 'opn';

to

const opn = require('opn');
Matticusau commented 6 years ago

Found that the sample extensions also have an additional task in gulp scripts for copytypings to handle the proposed apis file sqlops.proposed.d.ts.

"scripts": {
        "build": "gulp build",
        "compile": "gulp compile",
        "watch": "gulp watch",
        "typings": "gulp copytypings",
        "postinstall": "node ./node_modules/vscode/bin/install && node ./node_modules/sqlops/bin/install && gulp copytypings"
    },

Also updated the gulp buildtasks file. The step though tries to copy the file from the source so will exclude these for now and stick to manually installing the file.