Я использую JSForce с Typescript с CypressIO, однако каждый раз, когда я пытаюсь запустить свой код, я получаю следующее:
Error: Webpack Compilation Error
./node_modules/csv-parse/lib/es5/sync.d.ts 3:7
Module parse failed: Unexpected token (3:7)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
| import * as csvParse from './index';
|
> export = parse;
|
| declare function parse(input: Buffer | string, options?: csvParse.Options): any;
@ ./node_modules/jsforce/lib/csv.js 5:19-52
@ ./node_modules/jsforce/lib/record-stream.js
@ ./node_modules/jsforce/lib/core.js
@ ./node_modules/jsforce/lib/jsforce.js
@ ./node_modules/jsforce/index.js
@ ./cypress/test/test.ts
./node_modules/csv-parse/lib/es5/index.d.ts 7:7
Module parse failed: Unexpected token (7:7)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
| import * as stream from "stream";
|
> export = parse;
|
| declare function parse(input: Buffer | string, options?: parse.Options, callback?: parse.Callback): parse.Parser;
@ ./node_modules/jsforce/lib/csv.js 4:15-43
@ ./node_modules/jsforce/lib/record-stream.js
@ ./node_modules/jsforce/lib/core.js
@ ./node_modules/jsforce/lib/jsforce.js
@ ./node_modules/jsforce/index.js
@ ./cypress/test/test.ts
Я установил @types/jsforce
. Я также установил ts-loader
и json-loader
(было потенциальное решение, которое я видел), однако не повезло. Мой конфиг веб-пакета в настоящее время выглядит следующим образом:
module.exports = {
resolve: {
extensions: [".ts", ".d.ts", ".js"]
},
module: {
rules: [
{
test: /\.ts$/,
exclude: [/node_modules/],
use: [{
loader: "ts-loader",
options: { transpileOnly: true }
}]
},
{
test: /\.d\.ts$/,
exclude: [/node_modules/],
use: [{
loader: "ts-loader",
options: { transpileOnly: true }
}]
},
{
test: /\.js$/,
exclude: [/node_modules/],
use: [{
loader: "raw-loader",
options: { transpileOnly: true }
}]
},
{
test: /\.json$/,
exclude: [/node_modules/],
use: [{
loader: "json-loader",
options: { transpileOnly: true }
}]
}
]
},
target: 'node',
mode: "development"
};
Я импортирую jsForce как const jsforce: any = require('jsforce');
. Я не уверен, какой другой загрузчик я должен использовать здесь.