This repository has been archived by the owner on Aug 4, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #92 from rollup/interop-take-2
[WIP] BREAKING: interop, take 2
- Loading branch information
Showing
15 changed files
with
453 additions
and
228 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,24 @@ | ||
{ | ||
"rules": { | ||
"indent": [ 2, "tab", { "SwitchCase": 1 } ], | ||
"quotes": [ 2, "single" ], | ||
"linebreak-style": [ 2, "unix" ], | ||
"semi": [ 2, "always" ], | ||
"space-after-keywords": [ 2, "always" ], | ||
"space-before-blocks": [ 2, "always" ], | ||
"space-before-function-paren": [ 2, "always" ], | ||
"no-mixed-spaces-and-tabs": [ 2, "smart-tabs" ], | ||
"no-cond-assign": [ 0 ] | ||
}, | ||
"env": { | ||
"es6": true, | ||
"browser": true, | ||
"mocha": true, | ||
"node": true | ||
}, | ||
"extends": "eslint:recommended", | ||
"ecmaFeatures": { | ||
"modules": true | ||
} | ||
"rules": { | ||
"indent": [ 2, "tab", { "SwitchCase": 1 } ], | ||
"quotes": [ 2, "single", { "allowTemplateLiterals": true } ], | ||
"linebreak-style": [ 2, "unix" ], | ||
"semi": [ 2, "always" ], | ||
"keyword-spacing": [ 2, { "before": true, "after": true } ], | ||
"space-before-blocks": [ 2, "always" ], | ||
"space-before-function-paren": [ 2, "always" ], | ||
"no-mixed-spaces-and-tabs": [ 2, "smart-tabs" ], | ||
"no-cond-assign": [ 0 ] | ||
}, | ||
"env": { | ||
"es6": true, | ||
"browser": true, | ||
"mocha": true, | ||
"node": true | ||
}, | ||
"extends": "eslint:recommended", | ||
"parserOptions": { | ||
"ecmaVersion": 6, | ||
"sourceType": "module" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import * as fs from 'fs'; | ||
import { dirname, resolve } from 'path'; | ||
|
||
function isFile ( file ) { | ||
try { | ||
const stats = fs.statSync( file ); | ||
return stats.isFile(); | ||
} catch ( err ) { | ||
return false; | ||
} | ||
} | ||
|
||
function addJsExtensionIfNecessary ( file ) { | ||
if ( isFile( file ) ) return file; | ||
|
||
file += '.js'; | ||
if ( isFile( file ) ) return file; | ||
|
||
return null; | ||
} | ||
|
||
const absolutePath = /^(?:\/|(?:[A-Za-z]:)?[\\|\/])/; | ||
|
||
function isAbsolute ( path ) { | ||
return absolutePath.test( path ); | ||
} | ||
|
||
export default function defaultResolver ( importee, importer ) { | ||
// absolute paths are left untouched | ||
if ( isAbsolute( importee ) ) return addJsExtensionIfNecessary( resolve( importee ) ); | ||
|
||
// if this is the entry point, resolve against cwd | ||
if ( importer === undefined ) return addJsExtensionIfNecessary( resolve( process.cwd(), importee ) ); | ||
|
||
// external modules are skipped at this stage | ||
if ( importee[0] !== '.' ) return null; | ||
|
||
return addJsExtensionIfNecessary( resolve( dirname( importer ), importee ) ); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
export const HELPERS_ID = '\0commonjsHelpers'; | ||
|
||
export const HELPERS = ` | ||
export var commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; | ||
export function unwrapExports (x) { | ||
return x && x.__esModule ? x['default'] : x; | ||
} | ||
export function createCommonjsModule(fn, module) { | ||
return module = { exports: {} }, fn(module, module.exports), module.exports; | ||
}`; | ||
|
||
export const PREFIX = '\0commonjs-proxy:'; | ||
export const EXTERNAL = '\0commonjs-external:'; |
Oops, something went wrong.