       #}
       #console.log code
       pirates?.settings = @settings
-      @load require(filename).default ? {}
+      @module = runWithMapping @, -> require filename
+      @load @module.default ? {}
       @walkDeps filename
     else
       ## But if file has been explicitly loaded (e.g. in browser),

svgtiler = {
  Tile, unrecognizedTile,
  Mapping, ASCIIMapping, JSMapping, CoffeeMapping,
  Drawing, ASCIIDrawing, DSVDrawing, SSVDrawing, CSVDrawing, TSVDrawing,
  Drawings, XLSXDrawings,
  Style, CSSStyle, StylusStyle,

class Styles extends ArrayWrapper
  @itemClass: Style

currentMapping = null
getMapping = ->
  ## Returns current `Mapping` object,
  ## when used at top level of a JS/CS mapping file.
  currentMapping
runWithMapping = (mapping, fn) ->
  ## Runs the specified function `fn` as if it were called
  ## at the top level of the specified mapping.
  oldMapping = currentMapping
  currentMapping = mapping
  try
    fn()
  finally
    currentMapping = oldMapping

class Mapping extends Input
  constructor: (...args) ->
    super ...args
