Skip to content

Commit

Permalink
build: Fix URL not avaliable in Node/MiniRacer
Browse files Browse the repository at this point in the history
As there's no way we can get URL in MiniRacer, we have to polyfill.
the polyfill it self needs TextEncoder / TextDecoder.

see #213
  • Loading branch information
albb0920 committed Jul 21, 2021
1 parent 5d1f3b7 commit ce13038
Show file tree
Hide file tree
Showing 4 changed files with 53,591 additions and 235 deletions.
5 changes: 4 additions & 1 deletion build/package.json
Expand Up @@ -7,11 +7,14 @@
"dependencies": {
"autoprefixer": "^10.2.4",
"nop": "^1.0.0",
"postcss": "^8.2.4"
"postcss": "^8.2.4",
"text-encoding": "^0.7.0",
"whatwg-url": "^9.0.0"
},
"devDependencies": {
"@rollup/plugin-alias": "^3.1.1",
"@rollup/plugin-commonjs": "^17.0.0",
"@rollup/plugin-inject": "^4.0.2",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^11.0.1",
"@rollup/plugin-replace": "^2.3.3",
Expand Down
8 changes: 7 additions & 1 deletion build/rollup.config.js
Expand Up @@ -5,6 +5,7 @@ import commonjs from '@rollup/plugin-commonjs'
import json from '@rollup/plugin-json'
import nodePolyfills from 'rollup-plugin-node-polyfills'
import replace from '@rollup/plugin-replace'
import inject from '@rollup/plugin-inject'

export default {
input: 'autoprefixer.js',
Expand Down Expand Up @@ -38,6 +39,11 @@ export default {
preferBuiltins: false,
extensions: [".mjs", ".js", ".json", ".node", ".es6"]
}),
nodePolyfills()
nodePolyfills(),
inject({
URL: ['whatwg-url', 'URL'],
TextEncoder: ['text-encoding', 'TextEncoder'],
TextDecoder: ['text-encoding', 'TextDecoder']
})
]
}
43 changes: 41 additions & 2 deletions build/yarn.lock
Expand Up @@ -22,6 +22,15 @@
magic-string "^0.25.7"
resolve "^1.17.0"

"@rollup/plugin-inject@^4.0.2":
version "4.0.2"
resolved "https://registry.yarnpkg.com/@rollup/plugin-inject/-/plugin-inject-4.0.2.tgz#55b21bb244a07675f7fdde577db929c82fc17395"
integrity sha512-TSLMA8waJ7Dmgmoc8JfPnwUwVZgLjjIAM6MqeIFqPO2ODK36JqE0Cf2F54UTgCUuW8da93Mvoj75a6KAVWgylw==
dependencies:
"@rollup/pluginutils" "^3.0.4"
estree-walker "^1.0.1"
magic-string "^0.25.5"

"@rollup/plugin-json@^4.1.0":
version "4.1.0"
resolved "https://registry.yarnpkg.com/@rollup/plugin-json/-/plugin-json-4.1.0.tgz#54e09867ae6963c593844d8bd7a9c718294496f3"
Expand Down Expand Up @@ -49,7 +58,7 @@
"@rollup/pluginutils" "^3.1.0"
magic-string "^0.25.7"

"@rollup/pluginutils@^3.0.8", "@rollup/pluginutils@^3.1.0":
"@rollup/pluginutils@^3.0.4", "@rollup/pluginutils@^3.0.8", "@rollup/pluginutils@^3.1.0":
version "3.1.0"
resolved "https://registry.yarnpkg.com/@rollup/pluginutils/-/pluginutils-3.1.0.tgz#706b4524ee6dc8b103b3c995533e5ad680c02b9b"
integrity sha512-GksZ6pr6TpIjHm8h9lSQ8pi8BE9VeubNT0OMJ3B5uZJ8pz73NPiqOtCog/x2/QzM1ENChPKxMDhiQuRHsqc+lg==
Expand Down Expand Up @@ -242,7 +251,7 @@ is-reference@^1.2.1:
dependencies:
"@types/estree" "*"

magic-string@^0.25.3, magic-string@^0.25.7:
magic-string@^0.25.3, magic-string@^0.25.5, magic-string@^0.25.7:
version "0.25.7"
resolved "https://registry.yarnpkg.com/magic-string/-/magic-string-0.25.7.tgz#3f497d6fd34c669c6798dcb821f2ef31f5445051"
integrity sha512-4CrMT5DOHTDk4HYDlzmwu4FVCcIYI8gauveasrdCu2IKIFOJ3f0v/8MDGJCDL9oD2ppz/Av1b0Nj345H9M+XIA==
Expand Down Expand Up @@ -312,6 +321,11 @@ postcss@^8.2.4:
nanoid "^3.1.20"
source-map "^0.6.1"

punycode@^2.1.1:
version "2.1.1"
resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.1.1.tgz#b58b010ac40c22c5657616c8d2c2c02c7bf479ec"
integrity sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==

resolve@^1.17.0, resolve@^1.19.0:
version "1.19.0"
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.19.0.tgz#1af5bf630409734a067cae29318aac7fa29a267c"
Expand Down Expand Up @@ -365,6 +379,31 @@ sourcemap-codec@^1.4.4:
resolved "https://registry.yarnpkg.com/sourcemap-codec/-/sourcemap-codec-1.4.8.tgz#ea804bd94857402e6992d05a38ef1ae35a9ab4c4"
integrity sha512-9NykojV5Uih4lgo5So5dtw+f0JgJX30KCNI8gwhz2J9A15wD0Ml6tjHKwf6fTSa6fAdVBdZeNOs9eJ71qCk8vA==

text-encoding@^0.7.0:
version "0.7.0"
resolved "https://registry.yarnpkg.com/text-encoding/-/text-encoding-0.7.0.tgz#f895e836e45990624086601798ea98e8f36ee643"
integrity sha512-oJQ3f1hrOnbRLOcwKz0Liq2IcrvDeZRHXhd9RgLrsT+DjWY/nty1Hi7v3dtkaEYbPYe0mUoOfzRrMwfXXwgPUA==

tr46@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/tr46/-/tr46-2.1.0.tgz#fa87aa81ca5d5941da8cbf1f9b749dc969a4e240"
integrity sha512-15Ih7phfcdP5YxqiB+iDtLoaTz4Nd35+IiAv0kQ5FNKHzXgdWqPoTIqEDDJmXceQt4JZk6lVPT8lnDlPpGDppw==
dependencies:
punycode "^2.1.1"

webidl-conversions@^6.1.0:
version "6.1.0"
resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-6.1.0.tgz#9111b4d7ea80acd40f5270d666621afa78b69514"
integrity sha512-qBIvFLGiBpLjfwmYAaHPXsn+ho5xZnGvyGvsarywGNc8VyQJUMHJ8OBKGGrPER0okBeMDaan4mNBlgBROxuI8w==

whatwg-url@^9.0.0:
version "9.0.0"
resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-9.0.0.tgz#7de99809eaaba2bff7e0a995a516b26aa789fb89"
integrity sha512-KGnRJgaFqeUnHQH/3KbcBh8VB6nKCodfzmBih0lizk+FlETQ+IYti4WbV2GL5D5A0++79nizlMwNaQCtxmwL7w==
dependencies:
tr46 "^2.1.0"
webidl-conversions "^6.1.0"

wrappy@1:
version "1.0.2"
resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f"
Expand Down

0 comments on commit ce13038

Please sign in to comment.