Repository: vuejs/composition-api (ts)

Issue:
beta22, the useCssModule did'nt adapt the change of getCurrentInstance.
vue version: 2.6.12
@vuejs/composition-api version: 1.0.0-beta.22

beta22, the `useCssModule` did'nt adapt the change of `getCurrentInstance`.
https://github.com/vuejs/composition-api/blob/4b2f1ab9405462da163089616829046b72d86dcb/src/apis/useCssModule.ts#L8-L23

```TypeScript
export const useCSSModule = (name = '$style'): Record<string, string> => {
  const instance = getCurrentInstance()
  if (!instance) {
    __DEV__ && warn(`useCSSModule must be called inside setup()`)
    return EMPTY_OBJ
  }

  const mod = (instance as any)[name]   //Here
  if (!mod) {
    __DEV__ &&
      warn(`Current instance does not have CSS module named "${name}".`)
    return EMPTY_OBJ
  }

  return mod as Record<string, string>
}
```
![image](https://user-images.githubusercontent.com/35187547/103393216-8e375f00-4b5c-11eb-923b-3f4b1c2b50b1.png)



Pull request description:
fix: useCSSModule to adapt the change of getCurrentInstance, close #620
Fix useCSSModule to adapt the change of getCurrentInstance and add test for useCSSModule. #620 

Patch:
diff --git a/src/apis/useCssModule.ts b/src/apis/useCssModule.ts
index 368abd7..335c3d2 100644
--- a/src/apis/useCssModule.ts
+++ b/src/apis/useCssModule.ts
@@ -12,7 +12,7 @@ export const useCSSModule = (name = '$style'): Record<string, string> => {
     return EMPTY_OBJ
   }
 
-  const mod = (instance as any)[name]
+  const mod = (instance.proxy as any)?.[name]
   if (!mod) {
     __DEV__ &&
       warn(`Current instance does not have CSS module named "${name}".`)


Test patch:
diff --git a/test/apis/useCssModule.spec.js b/test/apis/useCssModule.spec.js
new file mode 100644
index 0000000..63c40a8
--- /dev/null
+++ b/test/apis/useCssModule.spec.js
@@ -0,0 +1,31 @@
+const Vue = require('vue/dist/vue.common.js')
+const { useCSSModule } = require('../../src')
+
+const style = { whateverStyle: 'whateverStyle' }
+
+function injectStyles() {
+  Object.defineProperty(this, '$style', {
+    configurable: true,
+    get: function () {
+      return style
+    },
+  })
+}
+
+describe('api/useCssModule', () => {
+  it('should get the same object', (done) => {
+    const vm = new Vue({
+      beforeCreate() {
+        injectStyles.call(this)
+      },
+      template: '<div>{{style}}</div>',
+      setup() {
+        const style = useCSSModule()
+        return { style }
+      },
+    })
+    vm.$mount()
+    expect(vm.style).toBe(style)
+    done()
+  })
+})