Skip to content

Commit 47b2dba

Browse files
committed
package: fix module bundling when target is node
1 parent 5c7db83 commit 47b2dba

File tree

5 files changed

+13
-6
lines changed

5 files changed

+13
-6
lines changed

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"version": "3.0.9",
44
"description": "Busca por CEP integrado diretamente aos serviços dos Correios e ViaCEP",
55
"main": "dist/cep-promise.min.js",
6-
"module": "dist/cep-promise-browser.min.js",
6+
"module": "dist/cep-promise.min.js",
77
"scripts": {
88
"test": "npm run coverage",
99
"coverage": "babel-node node_modules/.bin/babel-istanbul cover _mocha -- --timeout 60000 test/**/*.spec.js",
@@ -54,6 +54,7 @@
5454
"rollup-plugin-babel": "3.0.3",
5555
"rollup-plugin-commonjs": "8.3.0",
5656
"rollup-plugin-node-resolve": "3.0.3",
57+
"rollup-plugin-replace": "2.2.0",
5758
"standard": "8.6.0",
5859
"uglify-js": "2.7.5"
5960
},
@@ -66,7 +67,8 @@
6667
]
6768
},
6869
"dependencies": {
69-
"isomorphic-unfetch": "3.0.0"
70+
"node-fetch": "2.6.0",
71+
"unfetch": "4.1.0"
7072
},
7173
"files": [
7274
"dist",

rollup.config.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import babel from 'rollup-plugin-babel'
22
import commonjs from 'rollup-plugin-commonjs'
33
import resolve from 'rollup-plugin-node-resolve'
4+
import replace from 'rollup-plugin-replace'
45

56
const input = 'src/cep-promise.js'
67
const defaultPlugins = [
@@ -25,7 +26,11 @@ export default [
2526
},
2627
{
2728
input,
28-
plugins: [].concat(defaultPlugins, [
29+
plugins: [
30+
replace({
31+
'node-fetch': 'unfetch',
32+
})
33+
].concat(defaultPlugins, [
2934
resolve({
3035
browser: true
3136
}),

src/services/correios.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict'
22

3-
import fetch from 'isomorphic-unfetch'
3+
import fetch from 'node-fetch'
44
import ServiceError from '../errors/service.js'
55

66
export default function fetchCorreiosService (cepWithLeftPad, proxyURL = '') {

src/services/viacep.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict'
22

3-
import fetch from 'isomorphic-unfetch'
3+
import fetch from 'node-fetch'
44
import ServiceError from '../errors/service.js'
55

66
export default function fetchViaCepService (cepWithLeftPad, proxyURL = '') {

src/services/widenet.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict'
22

3-
import fetch from 'isomorphic-unfetch'
3+
import fetch from 'node-fetch'
44
import ServiceError from '../errors/service.js'
55

66
export default function fetchWideNetService (cepWithLeftPad, proxyURL = '') {

0 commit comments

Comments
 (0)