Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix browser bundling with webpack 5 #1553

Merged
merged 5 commits into from Apr 11, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 8 additions & 2 deletions lib/input.js
Expand Up @@ -130,7 +130,9 @@ class Input {

result.input = { line, column, source: this.css }
if (this.file) {
result.input.url = pathToFileURL(this.file).toString()
if(pathToFileURL) {
barak007 marked this conversation as resolved.
Show resolved Hide resolved
result.input.url = pathToFileURL(this.file).toString()
}
result.input.file = this.file
}

Expand Down Expand Up @@ -162,7 +164,11 @@ class Input {
}

if (fromUrl.protocol === 'file:') {
result.file = fileURLToPath(fromUrl)
if(fileURLToPath){
barak007 marked this conversation as resolved.
Show resolved Hide resolved
result.file = fileURLToPath(fromUrl)
} else {
throw new Error(`file: protocol is not available in this postcss build`);
barak007 marked this conversation as resolved.
Show resolved Hide resolved
}
}

let source = consumer.sourceContentFor(from.source)
Expand Down
8 changes: 6 additions & 2 deletions lib/map-generator.js
Expand Up @@ -4,7 +4,7 @@ let { dirname, resolve, relative, sep } = require('path')
let { pathToFileURL } = require('url')
let mozilla = require('source-map')

let pathAvailable = Boolean(dirname, resolve, relative, sep)
let pathAvailable = Boolean(dirname && resolve && relative && sep)
ai marked this conversation as resolved.
Show resolved Hide resolved

class MapGenerator {
constructor(stringify, root, opts) {
Expand Down Expand Up @@ -202,7 +202,11 @@ class MapGenerator {
if (this.mapOpts.from) {
return this.toUrl(this.mapOpts.from)
} else if (this.mapOpts.absolute) {
return pathToFileURL(node.source.input.from).toString()
if(pathToFileURL) {
barak007 marked this conversation as resolved.
Show resolved Hide resolved
return pathToFileURL(node.source.input.from).toString()
} else {
throw new Error('map option "absolute" is not available in this postcss build')
barak007 marked this conversation as resolved.
Show resolved Hide resolved
}
} else {
return this.toUrl(this.path(node.source.input.from))
}
Expand Down
3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -103,7 +103,8 @@
"./lib/terminal-highlight": false,
"colorette": false,
"fs": false,
"path": false
"path": false,
"url": false
},
"size-limit": [
{
Expand Down