1
0
mirror of https://github.com/sasjs/adapter.git synced 2026-01-01 17:50:06 +00:00

chore: merge fix

This commit is contained in:
Allan Bowe
2021-06-08 13:18:16 +00:00
11 changed files with 14771 additions and 1559 deletions

16091
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -38,30 +38,31 @@
}, },
"license": "ISC", "license": "ISC",
"devDependencies": { "devDependencies": {
"@types/jest": "^26.0.22", "@types/jest": "^26.0.23",
"@types/tough-cookie": "^4.0.0", "@types/tough-cookie": "^4.0.0",
"cp": "^0.2.0", "cp": "^0.2.0",
"dotenv": "^8.2.0", "dotenv": "^10.0.0",
"jest": "^26.6.3", "jest": "^27.0.4",
"jest-extended": "^0.11.5", "jest-extended": "^0.11.5",
"path": "^0.12.7", "path": "^0.12.7",
"process": "^0.11.10",
"rimraf": "^3.0.2", "rimraf": "^3.0.2",
"semantic-release": "^17.4.2", "semantic-release": "^17.4.3",
"terser-webpack-plugin": "^4.2.3", "terser-webpack-plugin": "^5.1.3",
"ts-jest": "^25.5.1", "ts-jest": "^27.0.2",
"ts-loader": "^9.1.2", "ts-loader": "^9.2.2",
"tslint": "^6.1.3", "tslint": "^6.1.3",
"tslint-config-prettier": "^1.18.0", "tslint-config-prettier": "^1.18.0",
"typedoc": "^0.20.36", "typedoc": "^0.20.36",
"typedoc-neo-theme": "^1.1.0", "typedoc-neo-theme": "^1.1.1",
"typedoc-plugin-external-module-name": "^4.0.6", "typedoc-plugin-external-module-name": "^4.0.6",
"typescript": "^3.9.9", "typescript": "^4.3.2",
"webpack": "^5.33.2", "webpack": "^5.38.1",
"webpack-cli": "^4.7.0" "webpack-cli": "^4.7.0"
}, },
"main": "index.js", "main": "index.js",
"dependencies": { "dependencies": {
"@sasjs/utils": "^2.14.0", "@sasjs/utils": "^2.17.1",
"axios": "^0.21.1", "axios": "^0.21.1",
"axios-cookiejar-support": "^1.0.1", "axios-cookiejar-support": "^1.0.1",
"form-data": "^4.0.0", "form-data": "^4.0.0",

View File

@@ -1,4 +1,6 @@
import axios, { AxiosInstance } from 'axios' import { generateTimestamp } from '@sasjs/utils/time'
import * as NodeFormData from 'form-data'
import { Sas9RequestClient } from './request/Sas9RequestClient'
import { isUrl } from './utils' import { isUrl } from './utils'
/** /**
@@ -6,11 +8,11 @@ import { isUrl } from './utils'
* *
*/ */
export class SAS9ApiClient { export class SAS9ApiClient {
private httpClient: AxiosInstance private requestClient: Sas9RequestClient
constructor(private serverUrl: string) { constructor(private serverUrl: string, private jobsPath: string) {
if (serverUrl) isUrl(serverUrl) if (serverUrl) isUrl(serverUrl)
this.httpClient = axios.create({ baseURL: this.serverUrl }) this.requestClient = new Sas9RequestClient(serverUrl, false)
} }
/** /**
@@ -33,27 +35,52 @@ export class SAS9ApiClient {
/** /**
* Executes code on a SAS9 server. * Executes code on a SAS9 server.
* @param linesOfCode - an array of code lines to execute. * @param linesOfCode - an array of code lines to execute.
* @param serverName - the server to execute the code on. * @param userName - the user name to log into the current SAS server.
* @param repositoryName - the repository to execute the code in. * @param password - the password to log into the current SAS server.
*/ */
public async executeScript( public async executeScript(
linesOfCode: string[], linesOfCode: string[],
serverName: string, userName: string,
repositoryName: string password: string
) { ) {
const requestPayload = linesOfCode.join('\n') await this.requestClient.login(userName, password, this.jobsPath)
const executeScriptResponse = await this.httpClient.put( const formData = generateFileUploadForm(linesOfCode.join('\n'))
`/sas/servers/${serverName}/cmd?repositoryName=${repositoryName}`,
`command=${requestPayload}`, const codeInjectorPath = `/User Folders/${userName}/My Folder/sasjs/runner`
{ const contentType =
headers: { 'multipart/form-data; boundary=' + formData.getBoundary()
Accept: 'application/json' const contentLength = formData.getLengthSync()
},
responseType: 'text' const headers = {
} 'cache-control': 'no-cache',
Accept: '*/*',
'Content-Type': contentType,
'Content-Length': contentLength,
Connection: 'keep-alive'
}
const storedProcessUrl = `${this.jobsPath}/?${
'_program=' + codeInjectorPath + '&_debug=log'
}`
const response = await this.requestClient.post(
storedProcessUrl,
formData,
undefined,
contentType,
headers
) )
return executeScriptResponse.data return response.result as string
} }
} }
const generateFileUploadForm = (data: any): NodeFormData => {
const formData = new NodeFormData()
const filename = `sasjs-execute-sas9-${generateTimestamp('')}.sas`
formData.append(filename, data, {
filename,
contentType: 'text/plain'
})
return formData
}

View File

@@ -28,7 +28,7 @@ import { timestampToYYYYMMDDHHMMSS } from '@sasjs/utils/time'
import { Logger, LogLevel } from '@sasjs/utils/logger' import { Logger, LogLevel } from '@sasjs/utils/logger'
import { isAuthorizeFormRequired } from './auth/isAuthorizeFormRequired' import { isAuthorizeFormRequired } from './auth/isAuthorizeFormRequired'
import { RequestClient } from './request/RequestClient' import { RequestClient } from './request/RequestClient'
import { SasAuthResponse } from '@sasjs/utils/types' import { SasAuthResponse, MacroVar } from '@sasjs/utils/types'
import { prefixMessage } from '@sasjs/utils/error' import { prefixMessage } from '@sasjs/utils/error'
/** /**
@@ -271,6 +271,7 @@ export class SASViyaApiClient {
* @param waitForResult - when set to true, function will return the session * @param waitForResult - when set to true, function will return the session
* @param pollOptions - an object that represents poll interval(milliseconds) and maximum amount of attempts. Object example: { MAX_POLL_COUNT: 24 * 60 * 60, POLL_INTERVAL: 1000 }. * @param pollOptions - an object that represents poll interval(milliseconds) and maximum amount of attempts. Object example: { MAX_POLL_COUNT: 24 * 60 * 60, POLL_INTERVAL: 1000 }.
* @param printPid - a boolean that indicates whether the function should print (PID) of the started job. * @param printPid - a boolean that indicates whether the function should print (PID) of the started job.
* @param variables - an object that represents macro variables.
*/ */
public async executeScript( public async executeScript(
jobPath: string, jobPath: string,
@@ -282,7 +283,8 @@ export class SASViyaApiClient {
expectWebout = false, expectWebout = false,
waitForResult = true, waitForResult = true,
pollOptions?: PollOptions, pollOptions?: PollOptions,
printPid = false printPid = false,
variables?: MacroVar
): Promise<any> { ): Promise<any> {
try { try {
const headers: any = { const headers: any = {
@@ -356,6 +358,8 @@ export class SASViyaApiClient {
: jobPath : jobPath
} }
if (variables) jobVariables = { ...jobVariables, ...variables }
let files: any[] = [] let files: any[] = []
if (data) { if (data) {
@@ -719,13 +723,11 @@ export class SASViyaApiClient {
let formData let formData
if (typeof FormData === 'undefined') { if (typeof FormData === 'undefined') {
formData = new NodeFormData() formData = new NodeFormData()
formData.append('grant_type', 'authorization_code')
formData.append('code', authCode)
} else { } else {
formData = new FormData() formData = new FormData()
formData.append('grant_type', 'authorization_code')
formData.append('code', authCode)
} }
formData.append('grant_type', 'authorization_code')
formData.append('code', authCode)
const authResponse = await this.requestClient const authResponse = await this.requestClient
.post( .post(
@@ -814,6 +816,7 @@ export class SASViyaApiClient {
* @param expectWebout - a boolean indicating whether to expect a _webout response. * @param expectWebout - a boolean indicating whether to expect a _webout response.
* @param pollOptions - an object that represents poll interval(milliseconds) and maximum amount of attempts. Object example: { MAX_POLL_COUNT: 24 * 60 * 60, POLL_INTERVAL: 1000 }. * @param pollOptions - an object that represents poll interval(milliseconds) and maximum amount of attempts. Object example: { MAX_POLL_COUNT: 24 * 60 * 60, POLL_INTERVAL: 1000 }.
* @param printPid - a boolean that indicates whether the function should print (PID) of the started job. * @param printPid - a boolean that indicates whether the function should print (PID) of the started job.
* @param variables - an object that represents macro variables.
*/ */
public async executeComputeJob( public async executeComputeJob(
sasJob: string, sasJob: string,
@@ -824,7 +827,8 @@ export class SASViyaApiClient {
waitForResult = true, waitForResult = true,
expectWebout = false, expectWebout = false,
pollOptions?: PollOptions, pollOptions?: PollOptions,
printPid = false printPid = false,
variables?: MacroVar
) { ) {
if (isRelativePath(sasJob) && !this.rootFolderName) { if (isRelativePath(sasJob) && !this.rootFolderName) {
throw new Error( throw new Error(
@@ -903,7 +907,8 @@ export class SASViyaApiClient {
expectWebout, expectWebout,
waitForResult, waitForResult,
pollOptions, pollOptions,
printPid printPid,
variables
) )
} }

View File

@@ -4,7 +4,7 @@ import { SASViyaApiClient } from './SASViyaApiClient'
import { SAS9ApiClient } from './SAS9ApiClient' import { SAS9ApiClient } from './SAS9ApiClient'
import { FileUploader } from './FileUploader' import { FileUploader } from './FileUploader'
import { AuthManager } from './auth' import { AuthManager } from './auth'
import { ServerType } from '@sasjs/utils/types' import { ServerType, MacroVar } from '@sasjs/utils/types'
import { RequestClient } from './request/RequestClient' import { RequestClient } from './request/RequestClient'
import { import {
JobExecutor, JobExecutor,
@@ -59,15 +59,15 @@ export default class SASjs {
public async executeScriptSAS9( public async executeScriptSAS9(
linesOfCode: string[], linesOfCode: string[],
serverName: string, userName: string,
repositoryName: string password: string
) { ) {
this.isMethodSupported('executeScriptSAS9', ServerType.Sas9) this.isMethodSupported('executeScriptSAS9', ServerType.Sas9)
return await this.sas9ApiClient?.executeScript( return await this.sas9ApiClient?.executeScript(
linesOfCode, linesOfCode,
serverName, userName,
repositoryName password
) )
} }
@@ -624,7 +624,7 @@ export default class SASjs {
) )
sasApiClient.debug = this.sasjsConfig.debug sasApiClient.debug = this.sasjsConfig.debug
} else if (this.sasjsConfig.serverType === ServerType.Sas9) { } else if (this.sasjsConfig.serverType === ServerType.Sas9) {
sasApiClient = new SAS9ApiClient(serverUrl) sasApiClient = new SAS9ApiClient(serverUrl, this.jobsPath)
} }
} else { } else {
let sasClientConfig: any = null let sasClientConfig: any = null
@@ -671,6 +671,7 @@ export default class SASjs {
* @param waitForResult - a boolean that indicates whether the function needs to wait for execution to complete. * @param waitForResult - a boolean that indicates whether the function needs to wait for execution to complete.
* @param pollOptions - an object that represents poll interval(milliseconds) and maximum amount of attempts. Object example: { MAX_POLL_COUNT: 24 * 60 * 60, POLL_INTERVAL: 1000 }. * @param pollOptions - an object that represents poll interval(milliseconds) and maximum amount of attempts. Object example: { MAX_POLL_COUNT: 24 * 60 * 60, POLL_INTERVAL: 1000 }.
* @param printPid - a boolean that indicates whether the function should print (PID) of the started job. * @param printPid - a boolean that indicates whether the function should print (PID) of the started job.
* @param variables - an object that represents macro variables.
*/ */
public async startComputeJob( public async startComputeJob(
sasJob: string, sasJob: string,
@@ -679,7 +680,8 @@ export default class SASjs {
accessToken?: string, accessToken?: string,
waitForResult?: boolean, waitForResult?: boolean,
pollOptions?: PollOptions, pollOptions?: PollOptions,
printPid = false printPid = false,
variables?: MacroVar
) { ) {
config = { config = {
...this.sasjsConfig, ...this.sasjsConfig,
@@ -702,7 +704,8 @@ export default class SASjs {
!!waitForResult, !!waitForResult,
false, false,
pollOptions, pollOptions,
printPid printPid,
variables
) )
} }
@@ -813,7 +816,11 @@ export default class SASjs {
if (this.sasjsConfig.serverType === ServerType.Sas9) { if (this.sasjsConfig.serverType === ServerType.Sas9) {
if (this.sas9ApiClient) if (this.sas9ApiClient)
this.sas9ApiClient!.setConfig(this.sasjsConfig.serverUrl) this.sas9ApiClient!.setConfig(this.sasjsConfig.serverUrl)
else this.sas9ApiClient = new SAS9ApiClient(this.sasjsConfig.serverUrl) else
this.sas9ApiClient = new SAS9ApiClient(
this.sasjsConfig.serverUrl,
this.jobsPath
)
} }
this.fileUploader = new FileUploader( this.fileUploader = new FileUploader(

View File

@@ -57,7 +57,7 @@ describe('AuthManager', () => {
expect((authManager as any).logoutUrl).toEqual('/SASLogon/logout?') expect((authManager as any).logoutUrl).toEqual('/SASLogon/logout?')
}) })
it('should call the auth callback and return when already logged in', async (done) => { it('should call the auth callback and return when already logged in', async () => {
const authManager = new AuthManager( const authManager = new AuthManager(
serverUrl, serverUrl,
serverType, serverType,
@@ -77,10 +77,9 @@ describe('AuthManager', () => {
expect(loginResponse.isLoggedIn).toBeTruthy() expect(loginResponse.isLoggedIn).toBeTruthy()
expect(loginResponse.userName).toEqual(userName) expect(loginResponse.userName).toEqual(userName)
expect(authCallback).toHaveBeenCalledTimes(1) expect(authCallback).toHaveBeenCalledTimes(1)
done()
}) })
it('should post a login request to the server if not logged in', async (done) => { it('should post a login request to the server if not logged in', async () => {
const authManager = new AuthManager( const authManager = new AuthManager(
serverUrl, serverUrl,
serverType, serverType,
@@ -121,10 +120,9 @@ describe('AuthManager', () => {
} }
) )
expect(authCallback).toHaveBeenCalledTimes(1) expect(authCallback).toHaveBeenCalledTimes(1)
done()
}) })
it('should parse and submit the authorisation form when necessary', async (done) => { it('should parse and submit the authorisation form when necessary', async () => {
const authManager = new AuthManager( const authManager = new AuthManager(
serverUrl, serverUrl,
serverType, serverType,
@@ -160,10 +158,9 @@ describe('AuthManager', () => {
expect(requestClient.authorize).toHaveBeenCalledWith( expect(requestClient.authorize).toHaveBeenCalledWith(
mockLoginAuthoriseRequiredResponse mockLoginAuthoriseRequiredResponse
) )
done()
}) })
it('should check and return session information if logged in', async (done) => { it('should check and return session information if logged in', async () => {
const authManager = new AuthManager( const authManager = new AuthManager(
serverUrl, serverUrl,
serverType, serverType,
@@ -189,7 +186,5 @@ describe('AuthManager', () => {
} }
} }
) )
done()
}) })
}) })

View File

@@ -1,3 +1,7 @@
/**
* @jest-environment jsdom
*/
import { FileUploader } from '../FileUploader' import { FileUploader } from '../FileUploader'
import { UploadFile } from '../types' import { UploadFile } from '../types'
import { RequestClient } from '../request/RequestClient' import { RequestClient } from '../request/RequestClient'
@@ -35,41 +39,40 @@ describe('FileUploader', () => {
new RequestClient('https://sample.server.com') new RequestClient('https://sample.server.com')
) )
it('should upload successfully', async (done) => { it('should upload successfully', async () => {
const sasJob = 'test/upload' const sasJob = 'test/upload'
const { files, params } = prepareFilesAndParams() const { files, params } = prepareFilesAndParams()
mockedAxios.post.mockImplementation(() => mockedAxios.post.mockImplementation(() =>
Promise.resolve({ data: sampleResponse }) Promise.resolve({ data: sampleResponse })
) )
fileUploader.uploadFile(sasJob, files, params).then((res: any) => { const res = await fileUploader.uploadFile(sasJob, files, params)
expect(res).toEqual(JSON.parse(sampleResponse))
done() expect(res).toEqual(JSON.parse(sampleResponse))
})
}) })
it('should an error when no files are provided', async (done) => { it('should an error when no files are provided', async () => {
const sasJob = 'test/upload' const sasJob = 'test/upload'
const files: UploadFile[] = [] const files: UploadFile[] = []
const params = { table: 'libtable' } const params = { table: 'libtable' }
fileUploader.uploadFile(sasJob, files, params).catch((err: any) => { const err = await fileUploader
expect(err.error.message).toEqual('At least one file must be provided.') .uploadFile(sasJob, files, params)
done() .catch((err: any) => err)
}) expect(err.error.message).toEqual('At least one file must be provided.')
}) })
it('should throw an error when no sasJob is provided', async (done) => { it('should throw an error when no sasJob is provided', async () => {
const sasJob = '' const sasJob = ''
const { files, params } = prepareFilesAndParams() const { files, params } = prepareFilesAndParams()
fileUploader.uploadFile(sasJob, files, params).catch((err: any) => { const err = await fileUploader
expect(err.error.message).toEqual('sasJob must be provided.') .uploadFile(sasJob, files, params)
done() .catch((err: any) => err)
}) expect(err.error.message).toEqual('sasJob must be provided.')
}) })
it('should throw an error when login is required', async (done) => { it('should throw an error when login is required', async () => {
mockedAxios.post.mockImplementation(() => mockedAxios.post.mockImplementation(() =>
Promise.resolve({ data: '<form action="Logon">' }) Promise.resolve({ data: '<form action="Logon">' })
) )
@@ -77,15 +80,13 @@ describe('FileUploader', () => {
const sasJob = 'test' const sasJob = 'test'
const { files, params } = prepareFilesAndParams() const { files, params } = prepareFilesAndParams()
fileUploader.uploadFile(sasJob, files, params).catch((err: any) => { const err = await fileUploader
expect(err.error.message).toEqual( .uploadFile(sasJob, files, params)
'You must be logged in to upload a file.' .catch((err: any) => err)
) expect(err.error.message).toEqual('You must be logged in to upload a file.')
done()
})
}) })
it('should throw an error when invalid JSON is returned by the server', async (done) => { it('should throw an error when invalid JSON is returned by the server', async () => {
mockedAxios.post.mockImplementation(() => mockedAxios.post.mockImplementation(() =>
Promise.resolve({ data: '{invalid: "json"' }) Promise.resolve({ data: '{invalid: "json"' })
) )
@@ -93,13 +94,13 @@ describe('FileUploader', () => {
const sasJob = 'test' const sasJob = 'test'
const { files, params } = prepareFilesAndParams() const { files, params } = prepareFilesAndParams()
fileUploader.uploadFile(sasJob, files, params).catch((err: any) => { const err = await fileUploader
expect(err.error.message).toEqual('File upload request failed.') .uploadFile(sasJob, files, params)
done() .catch((err: any) => err)
}) expect(err.error.message).toEqual('File upload request failed.')
}) })
it('should throw an error when the server request fails', async (done) => { it('should throw an error when the server request fails', async () => {
mockedAxios.post.mockImplementation(() => mockedAxios.post.mockImplementation(() =>
Promise.reject({ data: '{message: "Server error"}' }) Promise.reject({ data: '{message: "Server error"}' })
) )
@@ -107,10 +108,9 @@ describe('FileUploader', () => {
const sasJob = 'test' const sasJob = 'test'
const { files, params } = prepareFilesAndParams() const { files, params } = prepareFilesAndParams()
fileUploader.uploadFile(sasJob, files, params).catch((err: any) => { const err = await fileUploader
expect(err.error.message).toEqual('File upload request failed.') .uploadFile(sasJob, files, params)
.catch((err: any) => err)
done() expect(err.error.message).toEqual('File upload request failed.')
})
}) })
}) })

View File

@@ -14,7 +14,7 @@ describe('FolderOperations', () => {
beforeEach(() => {}) beforeEach(() => {})
it('should move and rename folder', async (done) => { it('should move and rename folder', async () => {
mockFetchResponse(false) mockFetchResponse(false)
let res: any = await sasViyaApiClient.moveFolder( let res: any = await sasViyaApiClient.moveFolder(
@@ -26,11 +26,9 @@ describe('FolderOperations', () => {
expect(res.folder.name).toEqual('newName') expect(res.folder.name).toEqual('newName')
expect(res.folder.parentFolderUri.split('=')[1]).toEqual('/Test/toFolder') expect(res.folder.parentFolderUri.split('=')[1]).toEqual('/Test/toFolder')
done()
}) })
it('should move and keep the name of folder', async (done) => { it('should move and keep the name of folder', async () => {
mockFetchResponse(true) mockFetchResponse(true)
let res: any = await sasViyaApiClient.moveFolder( let res: any = await sasViyaApiClient.moveFolder(
@@ -42,11 +40,9 @@ describe('FolderOperations', () => {
expect(res.folder.name).toEqual('oldName') expect(res.folder.name).toEqual('oldName')
expect(res.folder.parentFolderUri.split('=')[1]).toEqual('/Test/toFolder') expect(res.folder.parentFolderUri.split('=')[1]).toEqual('/Test/toFolder')
done()
}) })
it('should only rename folder', async (done) => { it('should only rename folder', async () => {
mockFetchResponse(false) mockFetchResponse(false)
let res: any = await sasViyaApiClient.moveFolder( let res: any = await sasViyaApiClient.moveFolder(
@@ -58,8 +54,6 @@ describe('FolderOperations', () => {
expect(res.folder.name).toEqual('newName') expect(res.folder.name).toEqual('newName')
expect(res.folder.parentFolderUri.split('=')[1]).toEqual('/Test/toFolder') expect(res.folder.parentFolderUri.split('=')[1]).toEqual('/Test/toFolder')
done()
}) })
}) })

View File

@@ -1,6 +1,6 @@
import { parseGeneratedCode } from '../../utils/index' import { parseGeneratedCode } from '../../utils/index'
it('should parse generated code', async (done) => { it('should parse generated code', () => {
expect(sampleResponse).toBeTruthy() expect(sampleResponse).toBeTruthy()
const parsedGeneratedCode = parseGeneratedCode(sampleResponse) const parsedGeneratedCode = parseGeneratedCode(sampleResponse)
@@ -15,8 +15,6 @@ it('should parse generated code', async (done) => {
expect(generatedCodeLines[2].startsWith('MPRINT(MM_WEBOUT)')).toBeTruthy() expect(generatedCodeLines[2].startsWith('MPRINT(MM_WEBOUT)')).toBeTruthy()
expect(generatedCodeLines[3].startsWith('MPRINT(MM_WEBRIGHT)')).toBeTruthy() expect(generatedCodeLines[3].startsWith('MPRINT(MM_WEBRIGHT)')).toBeTruthy()
expect(generatedCodeLines[4].startsWith('MPRINT(MM_WEBOUT)')).toBeTruthy() expect(generatedCodeLines[4].startsWith('MPRINT(MM_WEBOUT)')).toBeTruthy()
done()
}) })
/* tslint:disable */ /* tslint:disable */

View File

@@ -1,6 +1,6 @@
import { parseSourceCode } from '../../utils/index' import { parseSourceCode } from '../../utils/index'
it('should parse SAS9 source code', async (done) => { it('should parse SAS9 source code', async () => {
expect(sampleResponse).toBeTruthy() expect(sampleResponse).toBeTruthy()
const parsedSourceCode = parseSourceCode(sampleResponse) const parsedSourceCode = parseSourceCode(sampleResponse)
@@ -15,8 +15,6 @@ it('should parse SAS9 source code', async (done) => {
expect(sourceCodeLines[2].startsWith('8')).toBeTruthy() expect(sourceCodeLines[2].startsWith('8')).toBeTruthy()
expect(sourceCodeLines[3].startsWith('9')).toBeTruthy() expect(sourceCodeLines[3].startsWith('9')).toBeTruthy()
expect(sourceCodeLines[4].startsWith('10')).toBeTruthy() expect(sourceCodeLines[4].startsWith('10')).toBeTruthy()
done()
}) })
/* tslint:disable */ /* tslint:disable */

View File

@@ -7,11 +7,10 @@ const browserConfig = {
devtool: 'inline-source-map', devtool: 'inline-source-map',
mode: 'production', mode: 'production',
optimization: { optimization: {
minimize: true,
minimizer: [ minimizer: [
new terserPlugin({ new terserPlugin({
cache: true,
parallel: true, parallel: true,
sourceMap: true,
terserOptions: {} terserOptions: {}
}) })
] ]
@@ -41,6 +40,9 @@ const browserConfig = {
filename: null, filename: null,
exclude: [/node_modules/], exclude: [/node_modules/],
test: /\.ts($|\?)/i test: /\.ts($|\?)/i
}),
new webpack.ProvidePlugin({
process: 'process/browser'
}) })
] ]
} }