Skip to content

Commit

Permalink
fix: disable esModuleInterop & allowSyntheticDefaultImports for TS
Browse files Browse the repository at this point in the history
Otherwise the emitted type definitions may break downstream users who do
not have these options enabled.

Thanks @meteorlxy for spotting this issue.
  • Loading branch information
haoqunjiang committed Nov 18, 2020
1 parent 6ed553f commit c76f5e5
Show file tree
Hide file tree
Showing 12 changed files with 26 additions and 26 deletions.
2 changes: 1 addition & 1 deletion src/formatError.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { generateCodeFrame, CompilerError } from '@vue/compiler-sfc'
import chalk from 'chalk'
import chalk = require('chalk')

export function formatError(
err: SyntaxError | CompilerError,
Expand Down
12 changes: 7 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ try {
)
}

import webpack from 'webpack'
import path from 'path'
import qs from 'querystring'
import hash from 'hash-sum'
import loaderUtils from 'loader-utils'
import webpack = require('webpack')
import * as path from 'path'
import * as qs from 'querystring'
import * as loaderUtils from 'loader-utils'

import hash = require('hash-sum')

import {
parse,
compileScript,
Expand Down
8 changes: 4 additions & 4 deletions src/pitcher.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import webpack from 'webpack'
import qs from 'querystring'
import loaderUtils from 'loader-utils'
import webpack = require('webpack')
import * as qs from 'querystring'
import * as loaderUtils from 'loader-utils'

const selfPath = require.resolve('./index')
// const templateLoaderPath = require.resolve('./templateLoader')
Expand Down Expand Up @@ -69,7 +69,7 @@ export const pitch = function () {
return genProxyModule(
[...afterLoaders, stylePostLoaderPath, ...beforeLoaders],
context,
!! query.module
!!query.module
)
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/plugin.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import webpack from 'webpack'
import webpack = require('webpack')
declare class VueLoaderPlugin implements webpack.Plugin {
static NS: string
apply(compiler: webpack.Compiler): void
Expand Down
4 changes: 2 additions & 2 deletions src/pluginWebpack4.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import qs from 'querystring'
import webpack from 'webpack'
import * as qs from 'querystring'
import webpack = require('webpack')
import { VueLoaderOptions } from './'

const RuleSet = require('webpack/lib/RuleSet')
Expand Down
2 changes: 1 addition & 1 deletion src/pluginWebpack5.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import qs from 'querystring'
import * as qs from 'querystring'
import { VueLoaderOptions } from './'
import { RuleSetRule, Compiler, Plugin } from 'webpack'

Expand Down
2 changes: 1 addition & 1 deletion src/select.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import webpack from 'webpack'
import webpack = require('webpack')
import { SFCDescriptor } from '@vue/compiler-sfc'
import { ParsedUrlQuery } from 'querystring'

Expand Down
4 changes: 2 additions & 2 deletions src/stylePostLoader.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import qs from 'querystring'
import * as qs from 'querystring'
import { compileStyle } from '@vue/compiler-sfc'
import webpack from 'webpack'
import webpack = require('webpack')

// This is a post loader that handles scoped CSS transforms.
// Injected right before css-loader by the global pitcher (../pitch.js)
Expand Down
6 changes: 3 additions & 3 deletions src/templateLoader.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import webpack from 'webpack'
import qs from 'querystring'
import loaderUtils from 'loader-utils'
import webpack = require('webpack')
import * as qs from 'querystring'
import * as loaderUtils from 'loader-utils'
import { VueLoaderOptions } from './'
import { formatError } from './formatError'
import { compileTemplate, TemplateCompiler } from '@vue/compiler-sfc'
Expand Down
2 changes: 1 addition & 1 deletion test/edgeCases.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as path from 'path'
import HTMLPlugin from 'html-webpack-plugin'
import HTMLPlugin = require('html-webpack-plugin')
import { mfs, bundle, mockBundleAndRun, normalizeNewline } from './utils'

// @ts-ignore
Expand Down
6 changes: 3 additions & 3 deletions test/utils.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* env jest */
import path from 'path'
import webpack from 'webpack'
import * as path from 'path'
import webpack = require('webpack')
import merge from 'webpack-merge'
import hash from 'hash-sum'
import hash = require('hash-sum')
// import MiniCssExtractPlugin from 'mini-css-extract-plugin'
import { fs as mfs } from 'memfs'

Expand Down
2 changes: 0 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@
"target": "es2015",
"module": "commonjs",
"moduleResolution": "node",
"esModuleInterop": true,
"declaration": true,
"allowJs": false,
"allowSyntheticDefaultImports": true,
"noUnusedLocals": true,
"strictNullChecks": true,
"noImplicitAny": true,
Expand Down

0 comments on commit c76f5e5

Please sign in to comment.