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

Commit

Permalink
refactor ts-config, update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
aelbore committed Apr 25, 2020
1 parent 7805e64 commit 87c4f50
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 14 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@
"@types/mocha": "^7.0.2",
"@types/mock-fs": "^4.10.0",
"@types/node": "^13.13.2",
"coveralls": "^3.0.14",
"mock-fs": "^4.11.0",
"coveralls": "^3.1.0",
"mock-fs": "^4.12.0",
"mock-require": "^3.0.3",
"sinon": "^9.0.2",
"typescript": "^3.8.2"
Expand Down
2 changes: 0 additions & 2 deletions src/config/ts-rollup-config.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ describe('ts-rollup-config', () => {
expect((plugins as any[]).length).equal(4)
expect(external.length).equal(DEFAULT_VALUES.ROLLUP_EXTERNALS.length)
expect(file).equal(path.resolve(config.output.file))
expect((plugins as any[])[(plugins as any[]).length - 2].name).equal('rpt2')
})

it('should create ts rollup config with plugins is array', () => {
Expand Down Expand Up @@ -73,7 +72,6 @@ describe('ts-rollup-config', () => {
const { plugins } = inputOptions

expect((plugins as any[]).length).equal(5)
expect((plugins as any[])[(plugins as any[]).length - 1].name).equal('rpt2')
})

it('should create rollup-plugin-typescript2 config', () => {
Expand Down
13 changes: 3 additions & 10 deletions src/config/ts-rollup-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export function createTSConfig(options: CreateTSConfigOptions) {
experimentalDecorators: true,
declaration: false,
allowJs: true,
lib: [ 'dom', 'es2015', 'es2017' ],
lib: [ 'dom', 'es2015', 'es2017', 'es2018' ],
module: 'es2015',
moduleResolution: 'node',
target: 'es2018',
Expand Down Expand Up @@ -83,11 +83,7 @@ export function createTSRollupConfig(options: TSRollupConfig) {

export function _createTSRollupConfig(options: CreateRollupConfigOptions) {
const { config, name } = options
const { resolveOpts, commonOpts, input, compress, tsconfig } = config as TSRollupConfig

const insertPlugin = (plugins: any[], index: number, value: any) => {
plugins.splice(index, 0, value)
}
const { resolveOpts, commonOpts, input, tsconfig } = config as TSRollupConfig

const _plugins = (config as TSRollupConfig).plugins
const beforePlugins = Array.isArray(_plugins)
Expand Down Expand Up @@ -118,10 +114,7 @@ export function _createTSRollupConfig(options: CreateRollupConfigOptions) {
const { file } = outputOptions

const pluginValues = inputOptions.plugins as any[]
insertPlugin(pluginValues,
compress ? pluginValues.length - 1: pluginValues.length,
typescript2(createTSConfig({ input, tsconfig, file }))
)
pluginValues.unshift(typescript2(createTSConfig({ input, tsconfig, file })))

const configResult: ConfigResult = {
inputOptions,
Expand Down

0 comments on commit 87c4f50

Please sign in to comment.