Repository: esperantojs/esperanto Branch: master Commit: 799b307e263d Files: 1161 Total size: 300.9 KB Directory structure: gitextract_0c8mkpe7/ ├── .babelrc ├── .editorconfig ├── .gitignore ├── .jshintrc ├── .travis.yml ├── CHANGELOG.md ├── README.md ├── appveyor.yml ├── bin/ │ ├── handleError.js │ ├── help.md │ ├── index.js │ ├── runEsperanto.js │ └── showHelp.js ├── comparison/ │ ├── README.md │ ├── index.js │ ├── output/ │ │ ├── esperanto/ │ │ │ ├── batchImports.js │ │ │ ├── defaultExport.js │ │ │ ├── defaultImport.js │ │ │ ├── groupedExports.js │ │ │ ├── inlineNamedExports.js │ │ │ ├── mixedImports.js │ │ │ ├── namedExports.js │ │ │ ├── namedImports.js │ │ │ └── renamingImports.js │ │ ├── traceur/ │ │ │ ├── batchImports.js │ │ │ ├── defaultExport.js │ │ │ ├── defaultImport.js │ │ │ ├── groupedExports.js │ │ │ ├── inlineNamedExports.js │ │ │ ├── mixedImports.js │ │ │ ├── namedExports.js │ │ │ ├── namedImports.js │ │ │ └── renamingImports.js │ │ └── transpile/ │ │ ├── batchImports.js │ │ ├── defaultExport.js │ │ ├── defaultImport.js │ │ ├── groupedExports.js │ │ ├── inlineNamedExports.js │ │ ├── mixedImports.js │ │ ├── namedExports.js │ │ ├── namedImports.js │ │ └── renamingImports.js │ ├── package.json │ └── samples/ │ ├── batchImports.js │ ├── defaultExport.js │ ├── defaultImport.js │ ├── groupedExports.js │ ├── inlineNamedExports.js │ ├── mixedImports.js │ ├── namedExports.js │ ├── namedImports.js │ └── renamingImports.js ├── gobblefile.js ├── package.json ├── src/ │ ├── banner.js │ ├── bundler/ │ │ ├── builders/ │ │ │ ├── concat.js │ │ │ ├── defaultsMode/ │ │ │ │ ├── amd.js │ │ │ │ ├── cjs.js │ │ │ │ ├── index.js │ │ │ │ └── umd.js │ │ │ ├── index.js │ │ │ └── strictMode/ │ │ │ ├── amd.js │ │ │ ├── cjs.js │ │ │ ├── index.js │ │ │ ├── umd.js │ │ │ └── utils/ │ │ │ └── getExportBlock.js │ │ ├── combine/ │ │ │ ├── getRenamedImports.js │ │ │ ├── index.js │ │ │ ├── populateExternalModuleImports.js │ │ │ ├── populateIdentifierReplacements.js │ │ │ ├── populateModuleNames.js │ │ │ ├── resolveExports.js │ │ │ ├── topLevelScopeConflicts.js │ │ │ └── transformBody.js │ │ ├── getBundle.js │ │ ├── getModule.js │ │ └── utils/ │ │ ├── resolveChains.js │ │ └── sortModules.js │ ├── esperanto.js │ ├── standalone/ │ │ ├── builders/ │ │ │ ├── defaultsMode/ │ │ │ │ ├── amd.js │ │ │ │ ├── cjs.js │ │ │ │ ├── index.js │ │ │ │ ├── umd.js │ │ │ │ └── utils/ │ │ │ │ └── transformExportDeclaration.js │ │ │ ├── index.js │ │ │ └── strictMode/ │ │ │ ├── amd.js │ │ │ ├── cjs.js │ │ │ ├── index.js │ │ │ ├── umd.js │ │ │ └── utils/ │ │ │ ├── gatherImports.js │ │ │ ├── getExportNames.js │ │ │ ├── getImportSummary.js │ │ │ └── transformBody.js │ │ └── getModule.js │ └── utils/ │ ├── EsperantoError.js │ ├── amd/ │ │ ├── amdIntro.js │ │ ├── getImportSummary.js │ │ ├── processIds.js │ │ └── processName.js │ ├── ast/ │ │ ├── annotate.js │ │ ├── disallowIllegalReassignment.js │ │ ├── findImportsAndExports.js │ │ ├── getUnscopedNames.js │ │ ├── replaceIdentifiers.js │ │ ├── rewriteExportAssignments.js │ │ ├── traverse.js │ │ └── walk.js │ ├── builtins.js │ ├── disallowConflictingImports.js │ ├── getReadOnlyIdentifiers.js │ ├── hasNamedExports.js │ ├── hasNamedImports.js │ ├── hasOwnProp.js │ ├── mappers.js │ ├── packageResult.js │ ├── promiseSequence.js │ ├── resolveId.js │ ├── sanitize.js │ └── umd/ │ ├── requireName.js │ └── umdIntro.js └── test/ ├── .jshintrc ├── bundle/ │ ├── index.js │ ├── input/ │ │ ├── 01/ │ │ │ ├── _config.js │ │ │ ├── foo.js │ │ │ └── main.js │ │ ├── 02/ │ │ │ ├── _config.js │ │ │ ├── foo/ │ │ │ │ └── index.js │ │ │ └── main.js │ │ ├── 03/ │ │ │ ├── _config.js │ │ │ ├── foo.js │ │ │ └── main.js │ │ ├── 04/ │ │ │ ├── _config.js │ │ │ ├── foo.js │ │ │ └── main.js │ │ ├── 05/ │ │ │ ├── _config.js │ │ │ ├── main.js │ │ │ └── numbers.js │ │ ├── 06/ │ │ │ ├── _config.js │ │ │ ├── main.js │ │ │ └── nested/ │ │ │ └── foo.js │ │ ├── 07/ │ │ │ ├── _config.js │ │ │ ├── bar.js │ │ │ ├── foo.js │ │ │ └── main.js │ │ ├── 08/ │ │ │ ├── _config.js │ │ │ └── main.js │ │ ├── 09/ │ │ │ ├── _config.js │ │ │ └── main.js │ │ ├── 10/ │ │ │ ├── _config.js │ │ │ └── main.js │ │ ├── 11/ │ │ │ ├── _config.js │ │ │ ├── a.js │ │ │ ├── b.js │ │ │ └── main.js │ │ ├── 12/ │ │ │ ├── _config.js │ │ │ ├── foo.js │ │ │ └── main.js │ │ ├── 13/ │ │ │ ├── _config.js │ │ │ └── main.js │ │ ├── 14/ │ │ │ ├── _config.js │ │ │ └── main.js │ │ ├── 15/ │ │ │ ├── _config.js │ │ │ └── main.js │ │ ├── 16/ │ │ │ ├── _config.js │ │ │ ├── a.js │ │ │ ├── b.js │ │ │ ├── c.js │ │ │ └── main.js │ │ ├── 17/ │ │ │ ├── _config.js │ │ │ ├── foo.js │ │ │ └── main.js │ │ ├── 18/ │ │ │ ├── _config.js │ │ │ ├── bar.js │ │ │ ├── doThing.js │ │ │ ├── foo.js │ │ │ └── main.js │ │ ├── 19/ │ │ │ ├── _config.js │ │ │ ├── hasOwnProperty.js │ │ │ └── main.js │ │ ├── 20/ │ │ │ ├── _config.js │ │ │ ├── main.js │ │ │ └── objectUtils.js │ │ ├── 21/ │ │ │ ├── _config.js │ │ │ ├── config.js │ │ │ └── main.js │ │ ├── 22/ │ │ │ ├── _config.js │ │ │ ├── foo.js │ │ │ └── main.js │ │ ├── 23/ │ │ │ ├── _config.js │ │ │ ├── foo.js │ │ │ └── main.js │ │ ├── 24/ │ │ │ ├── _config.js │ │ │ ├── bar.js │ │ │ ├── foo.js │ │ │ └── main.js │ │ ├── 25/ │ │ │ ├── _config.js │ │ │ ├── foo.js │ │ │ └── main.js │ │ ├── 26/ │ │ │ ├── _config.js │ │ │ ├── bar.js │ │ │ └── main.js │ │ ├── 27/ │ │ │ ├── _config.js │ │ │ ├── bar.js │ │ │ ├── foo.js │ │ │ └── main.js │ │ ├── 28/ │ │ │ ├── _config.js │ │ │ ├── foo.js │ │ │ └── main.js │ │ ├── 29/ │ │ │ ├── _config.js │ │ │ └── main.js │ │ ├── 30/ │ │ │ ├── _config.js │ │ │ └── main.js │ │ ├── 31/ │ │ │ ├── _config.js │ │ │ ├── exportedX.js │ │ │ ├── main.js │ │ │ └── notExportedX.js │ │ ├── 32/ │ │ │ ├── _config.js │ │ │ └── main.js │ │ ├── 33/ │ │ │ ├── Math.js │ │ │ ├── Promise.js │ │ │ ├── _config.js │ │ │ ├── foo.js │ │ │ └── main.js │ │ ├── 34/ │ │ │ ├── _config.js │ │ │ ├── foo.js │ │ │ └── main.js │ │ ├── 35/ │ │ │ ├── _config.js │ │ │ ├── js_modules/ │ │ │ │ ├── a.js │ │ │ │ ├── c.js │ │ │ │ └── external/ │ │ │ │ ├── js_modules/ │ │ │ │ │ └── b.js │ │ │ │ ├── package.json │ │ │ │ └── src/ │ │ │ │ └── external.js │ │ │ └── main.js │ │ ├── 36/ │ │ │ ├── _config.js │ │ │ ├── js_modules/ │ │ │ │ └── external/ │ │ │ │ ├── package.json │ │ │ │ └── src/ │ │ │ │ ├── dependsOnExternal.js │ │ │ │ └── external.js │ │ │ └── main.js │ │ ├── 37/ │ │ │ ├── _config.js │ │ │ ├── a.js │ │ │ └── main.js │ │ ├── 38/ │ │ │ ├── _config.js │ │ │ ├── foo.js │ │ │ └── main.js │ │ ├── 39/ │ │ │ ├── _config.js │ │ │ ├── bar.js │ │ │ ├── foo.js │ │ │ └── main.js │ │ ├── 40/ │ │ │ ├── _config.js │ │ │ ├── foo.js │ │ │ └── main.js │ │ ├── 42/ │ │ │ ├── _config.js │ │ │ ├── foo.js │ │ │ └── main.js │ │ ├── 43/ │ │ │ ├── _config.js │ │ │ └── main.js │ │ ├── 44/ │ │ │ ├── _config.js │ │ │ ├── a.js │ │ │ ├── b.js │ │ │ └── main.js │ │ ├── 45/ │ │ │ └── _config.js │ │ ├── 46/ │ │ │ └── _config.js │ │ ├── 47/ │ │ │ ├── _config.js │ │ │ └── main.js │ │ ├── 48/ │ │ │ ├── _config.js │ │ │ └── main.js │ │ ├── 49/ │ │ │ ├── _config.js │ │ │ ├── foo.js │ │ │ └── main.js │ │ ├── 50/ │ │ │ ├── A.js │ │ │ ├── B.js │ │ │ ├── C.js │ │ │ ├── D.js │ │ │ ├── _config.js │ │ │ └── main.js │ │ ├── 51/ │ │ │ ├── _config.js │ │ │ ├── foo.js │ │ │ └── main.js │ │ ├── 52/ │ │ │ ├── _config.js │ │ │ ├── bar.js │ │ │ ├── external/ │ │ │ │ ├── baz.js │ │ │ │ └── foo.js │ │ │ └── main.js │ │ ├── 53/ │ │ │ ├── _config.js │ │ │ ├── foo.js │ │ │ └── main.js │ │ ├── 54/ │ │ │ ├── _config.js │ │ │ ├── foo.js │ │ │ └── main.js │ │ ├── 55/ │ │ │ ├── A.js │ │ │ ├── B.js │ │ │ ├── C.js │ │ │ ├── _config.js │ │ │ └── main.js │ │ ├── 56/ │ │ │ ├── _config.js │ │ │ ├── foo.js │ │ │ └── main.js │ │ ├── 57/ │ │ │ ├── _config.js │ │ │ ├── foo.js │ │ │ └── main.js │ │ ├── 58/ │ │ │ ├── _config.js │ │ │ └── main.js │ │ ├── 59/ │ │ │ ├── _config.js │ │ │ ├── foo.js │ │ │ └── main.js │ │ └── 60/ │ │ ├── _config.js │ │ ├── bar.js │ │ ├── foo.js │ │ └── main.js │ └── output/ │ ├── amd/ │ │ ├── 01.js │ │ ├── 02.js │ │ ├── 03.js │ │ ├── 04.js │ │ ├── 05.js │ │ ├── 06.js │ │ ├── 07.js │ │ ├── 08.js │ │ ├── 09.js │ │ ├── 10.js │ │ ├── 11.js │ │ ├── 14.js │ │ ├── 15.js │ │ ├── 16.js │ │ ├── 17.js │ │ ├── 18.js │ │ ├── 19.js │ │ ├── 20.js │ │ ├── 21.js │ │ ├── 22.js │ │ ├── 24.js │ │ ├── 25.js │ │ ├── 26.js │ │ ├── 27.js │ │ ├── 28.js │ │ ├── 29.js │ │ ├── 30.js │ │ ├── 31.js │ │ ├── 32.js │ │ ├── 33.js │ │ ├── 34.js │ │ ├── 35.js │ │ ├── 36.js │ │ ├── 37.js │ │ ├── 38.js │ │ ├── 40.js │ │ ├── 42.js │ │ ├── 43.js │ │ ├── 44.js │ │ ├── 45.js │ │ ├── 46.js │ │ ├── 47.js │ │ ├── 48.js │ │ ├── 49.js │ │ ├── 50.js │ │ ├── 51.js │ │ ├── 52.js │ │ ├── 53.js │ │ ├── 54.js │ │ ├── 55.js │ │ ├── 56.js │ │ ├── 57.js │ │ ├── 58.js │ │ ├── 59.js │ │ └── 60.js │ ├── amdDefaults/ │ │ ├── 01.js │ │ ├── 02.js │ │ ├── 03.js │ │ ├── 04.js │ │ ├── 06.js │ │ ├── 07.js │ │ ├── 08.js │ │ ├── 09.js │ │ ├── 10.js │ │ ├── 14.js │ │ ├── 16.js │ │ ├── 17.js │ │ ├── 18.js │ │ ├── 19.js │ │ ├── 20.js │ │ ├── 21.js │ │ ├── 24.js │ │ ├── 25.js │ │ ├── 26.js │ │ ├── 27.js │ │ ├── 28.js │ │ ├── 30.js │ │ ├── 31.js │ │ ├── 32.js │ │ ├── 33.js │ │ ├── 34.js │ │ ├── 35.js │ │ ├── 36.js │ │ ├── 37.js │ │ ├── 38.js │ │ ├── 40.js │ │ ├── 42.js │ │ ├── 43.js │ │ ├── 44.js │ │ ├── 45.js │ │ ├── 46.js │ │ ├── 47.js │ │ ├── 48.js │ │ ├── 49.js │ │ ├── 50.js │ │ ├── 51.js │ │ ├── 52.js │ │ ├── 53.js │ │ ├── 54.js │ │ ├── 55.js │ │ ├── 56.js │ │ ├── 57.js │ │ ├── 59.js │ │ └── 60.js │ ├── cjs/ │ │ ├── 01.js │ │ ├── 02.js │ │ ├── 03.js │ │ ├── 04.js │ │ ├── 05.js │ │ ├── 06.js │ │ ├── 07.js │ │ ├── 08.js │ │ ├── 09.js │ │ ├── 10.js │ │ ├── 11.js │ │ ├── 14.js │ │ ├── 15.js │ │ ├── 16.js │ │ ├── 17.js │ │ ├── 18.js │ │ ├── 19.js │ │ ├── 20.js │ │ ├── 21.js │ │ ├── 22.js │ │ ├── 24.js │ │ ├── 25.js │ │ ├── 26.js │ │ ├── 27.js │ │ ├── 28.js │ │ ├── 29.js │ │ ├── 30.js │ │ ├── 31.js │ │ ├── 32.js │ │ ├── 33.js │ │ ├── 34.js │ │ ├── 35.js │ │ ├── 36.js │ │ ├── 37.js │ │ ├── 38.js │ │ ├── 40.js │ │ ├── 42.js │ │ ├── 43.js │ │ ├── 44.js │ │ ├── 45.js │ │ ├── 46.js │ │ ├── 47.js │ │ ├── 48.js │ │ ├── 49.js │ │ ├── 50.js │ │ ├── 51.js │ │ ├── 52.js │ │ ├── 53.js │ │ ├── 54.js │ │ ├── 55.js │ │ ├── 56.js │ │ ├── 57.js │ │ ├── 58.js │ │ ├── 59.js │ │ └── 60.js │ ├── cjsDefaults/ │ │ ├── 01.js │ │ ├── 02.js │ │ ├── 03.js │ │ ├── 04.js │ │ ├── 06.js │ │ ├── 07.js │ │ ├── 08.js │ │ ├── 09.js │ │ ├── 10.js │ │ ├── 14.js │ │ ├── 16.js │ │ ├── 17.js │ │ ├── 18.js │ │ ├── 19.js │ │ ├── 20.js │ │ ├── 21.js │ │ ├── 24.js │ │ ├── 25.js │ │ ├── 26.js │ │ ├── 27.js │ │ ├── 28.js │ │ ├── 30.js │ │ ├── 31.js │ │ ├── 32.js │ │ ├── 33.js │ │ ├── 34.js │ │ ├── 35.js │ │ ├── 36.js │ │ ├── 37.js │ │ ├── 38.js │ │ ├── 40.js │ │ ├── 42.js │ │ ├── 43.js │ │ ├── 44.js │ │ ├── 45.js │ │ ├── 46.js │ │ ├── 47.js │ │ ├── 48.js │ │ ├── 49.js │ │ ├── 50.js │ │ ├── 51.js │ │ ├── 52.js │ │ ├── 53.js │ │ ├── 54.js │ │ ├── 55.js │ │ ├── 56.js │ │ ├── 57.js │ │ ├── 59.js │ │ └── 60.js │ ├── concat/ │ │ ├── 01.js │ │ ├── 02.js │ │ ├── 07.js │ │ ├── 16.js │ │ ├── 17.js │ │ ├── 18.js │ │ ├── 19.js │ │ ├── 21.js │ │ ├── 24.js │ │ ├── 25.js │ │ ├── 26.js │ │ ├── 27.js │ │ ├── 28.js │ │ ├── 31.js │ │ ├── 32.js │ │ ├── 33.js │ │ ├── 35.js │ │ ├── 36.js │ │ ├── 38.js │ │ ├── 40.js │ │ ├── 42.js │ │ ├── 45.js │ │ ├── 46.js │ │ ├── 47.js │ │ ├── 49.js │ │ ├── 50.js │ │ ├── 52.js │ │ ├── 55.js │ │ ├── 56.js │ │ ├── 57.js │ │ ├── 59.js │ │ └── 60.js │ ├── umd/ │ │ ├── 01.js │ │ ├── 02.js │ │ ├── 03.js │ │ ├── 04.js │ │ ├── 05.js │ │ ├── 06.js │ │ ├── 07.js │ │ ├── 08.js │ │ ├── 09.js │ │ ├── 10.js │ │ ├── 11.js │ │ ├── 14.js │ │ ├── 15.js │ │ ├── 16.js │ │ ├── 17.js │ │ ├── 18.js │ │ ├── 19.js │ │ ├── 20.js │ │ ├── 21.js │ │ ├── 22.js │ │ ├── 24.js │ │ ├── 25.js │ │ ├── 26.js │ │ ├── 27.js │ │ ├── 28.js │ │ ├── 29.js │ │ ├── 30.js │ │ ├── 31.js │ │ ├── 32.js │ │ ├── 33.js │ │ ├── 34.js │ │ ├── 35.js │ │ ├── 36.js │ │ ├── 37.js │ │ ├── 38.js │ │ ├── 40.js │ │ ├── 42.js │ │ ├── 43.js │ │ ├── 44.js │ │ ├── 45.js │ │ ├── 46.js │ │ ├── 47.js │ │ ├── 48.js │ │ ├── 49.js │ │ ├── 50.js │ │ ├── 51.js │ │ ├── 52.js │ │ ├── 53.js │ │ ├── 54.js │ │ ├── 55.js │ │ ├── 56.js │ │ ├── 57.js │ │ ├── 58.js │ │ ├── 59.js │ │ └── 60.js │ └── umdDefaults/ │ ├── 01.js │ ├── 02.js │ ├── 03.js │ ├── 04.js │ ├── 06.js │ ├── 07.js │ ├── 08.js │ ├── 09.js │ ├── 10.js │ ├── 14.js │ ├── 16.js │ ├── 17.js │ ├── 18.js │ ├── 19.js │ ├── 20.js │ ├── 21.js │ ├── 24.js │ ├── 25.js │ ├── 26.js │ ├── 27.js │ ├── 28.js │ ├── 30.js │ ├── 31.js │ ├── 32.js │ ├── 33.js │ ├── 34.js │ ├── 35.js │ ├── 36.js │ ├── 37.js │ ├── 38.js │ ├── 40.js │ ├── 42.js │ ├── 43.js │ ├── 44.js │ ├── 45.js │ ├── 46.js │ ├── 47.js │ ├── 48.js │ ├── 49.js │ ├── 50.js │ ├── 51.js │ ├── 52.js │ ├── 53.js │ ├── 54.js │ ├── 55.js │ ├── 56.js │ ├── 57.js │ ├── 59.js │ └── 60.js ├── es6-module-transpiler-tests/ │ ├── README.md │ ├── bundled-output/ │ │ ├── bare-import.js │ │ ├── bindings.js │ │ ├── cycles-defaults.js │ │ ├── cycles-immediate.js │ │ ├── cycles.js │ │ ├── export-and-import-reference-share-var.js │ │ ├── export-default-function.js │ │ ├── export-default-named-function.js │ │ ├── export-default.js │ │ ├── export-from-default.js │ │ ├── export-from.js │ │ ├── export-function.js │ │ ├── export-list.js │ │ ├── export-mixins.js │ │ ├── export-var.js │ │ ├── import-as.js │ │ ├── import-chain.js │ │ ├── import-order.js │ │ ├── module-level-declarations.js │ │ ├── named-function-expression.js │ │ ├── namespaces.js │ │ ├── re-export-default-import.js │ │ └── this-binding-undefined.js │ ├── input/ │ │ ├── bare-import/ │ │ │ ├── _config.js │ │ │ ├── exporter.js │ │ │ └── importer.js │ │ ├── bindings/ │ │ │ ├── _config.js │ │ │ ├── exporter.js │ │ │ └── importer.js │ │ ├── cycles/ │ │ │ ├── _config.js │ │ │ ├── a.js │ │ │ ├── b.js │ │ │ └── c.js │ │ ├── cycles-defaults/ │ │ │ ├── _config.js │ │ │ ├── a.js │ │ │ ├── b.js │ │ │ └── importer.js │ │ ├── cycles-immediate/ │ │ │ ├── _config.js │ │ │ ├── evens.js │ │ │ ├── main.js │ │ │ └── odds.js │ │ ├── duplicate-import-fails/ │ │ │ ├── _config.js │ │ │ ├── exporter.js │ │ │ └── importer.js │ │ ├── duplicate-import-specifier-fails/ │ │ │ ├── _config.js │ │ │ ├── exporter.js │ │ │ └── importer.js │ │ ├── export-and-import-reference-share-var/ │ │ │ ├── _config.js │ │ │ ├── first.js │ │ │ └── second.js │ │ ├── export-default/ │ │ │ ├── _config.js │ │ │ ├── exporter.js │ │ │ └── importer.js │ │ ├── export-default-function/ │ │ │ ├── _config.js │ │ │ ├── exporter.js │ │ │ └── importer.js │ │ ├── export-default-named-function/ │ │ │ ├── _config.js │ │ │ ├── exporter.js │ │ │ └── importer.js │ │ ├── export-from/ │ │ │ ├── _config.js │ │ │ ├── first.js │ │ │ ├── second.js │ │ │ └── third.js │ │ ├── export-from-default/ │ │ │ ├── _config.js │ │ │ ├── first.js │ │ │ ├── second.js │ │ │ └── third.js │ │ ├── export-function/ │ │ │ ├── _config.js │ │ │ ├── exporter.js │ │ │ └── importer.js │ │ ├── export-list/ │ │ │ ├── _config.js │ │ │ ├── exporter.js │ │ │ └── importer.js │ │ ├── export-mixins/ │ │ │ ├── _config.js │ │ │ ├── exporter.js │ │ │ └── importer.js │ │ ├── export-not-at-top-level-fails/ │ │ │ ├── _config.js │ │ │ └── index.js │ │ ├── export-var/ │ │ │ ├── _config.js │ │ │ ├── exporter.js │ │ │ └── importer.js │ │ ├── import-as/ │ │ │ ├── _config.js │ │ │ ├── exporter.js │ │ │ └── importer.js │ │ ├── import-chain/ │ │ │ ├── _config.js │ │ │ ├── first.js │ │ │ ├── second.js │ │ │ └── third.js │ │ ├── import-not-at-top-level-fails/ │ │ │ ├── _config.js │ │ │ └── index.js │ │ ├── import-order/ │ │ │ ├── _config.js │ │ │ ├── consumer.js │ │ │ ├── exporter.js │ │ │ └── importer.js │ │ ├── module-level-declarations/ │ │ │ ├── _config.js │ │ │ └── mod.js │ │ ├── named-function-expression/ │ │ │ ├── _config.js │ │ │ ├── exporter.js │ │ │ └── importer.js │ │ ├── namespace-reassign-import-fails/ │ │ │ ├── _config.js │ │ │ ├── exporter.js │ │ │ └── importer.js │ │ ├── namespace-update-import-fails/ │ │ │ ├── _config.js │ │ │ ├── exporter.js │ │ │ └── importer.js │ │ ├── namespaces/ │ │ │ ├── _config.js │ │ │ ├── exporter.js │ │ │ └── importer.js │ │ ├── re-export-default-import/ │ │ │ ├── _config.js │ │ │ ├── first.js │ │ │ ├── second.js │ │ │ └── third.js │ │ ├── reassign-import-fails/ │ │ │ ├── _config.js │ │ │ ├── exporter.js │ │ │ └── importer.js │ │ ├── reassign-import-not-at-top-level-fails/ │ │ │ ├── _config.js │ │ │ ├── exporter.js │ │ │ └── importer.js │ │ ├── this-binding-undefined/ │ │ │ ├── _config.js │ │ │ └── mod.js │ │ └── update-expression-of-import-fails/ │ │ ├── _config.js │ │ ├── exporter.js │ │ └── importer.js │ └── output/ │ ├── bare-import/ │ │ ├── exporter.js │ │ └── importer.js │ ├── bindings/ │ │ ├── exporter.js │ │ └── importer.js │ ├── cycles/ │ │ ├── a.js │ │ ├── b.js │ │ └── c.js │ ├── cycles-defaults/ │ │ ├── a.js │ │ ├── b.js │ │ └── importer.js │ ├── cycles-immediate/ │ │ ├── evens.js │ │ ├── main.js │ │ └── odds.js │ ├── duplicate-import-fails/ │ │ └── exporter.js │ ├── duplicate-import-specifier-fails/ │ │ └── exporter.js │ ├── export-and-import-reference-share-var/ │ │ ├── first.js │ │ └── second.js │ ├── export-default/ │ │ ├── exporter.js │ │ └── importer.js │ ├── export-default-function/ │ │ ├── exporter.js │ │ └── importer.js │ ├── export-default-named-function/ │ │ ├── exporter.js │ │ └── importer.js │ ├── export-from/ │ │ ├── first.js │ │ ├── second.js │ │ └── third.js │ ├── export-from-default/ │ │ ├── first.js │ │ ├── second.js │ │ └── third.js │ ├── export-function/ │ │ ├── exporter.js │ │ └── importer.js │ ├── export-list/ │ │ ├── exporter.js │ │ └── importer.js │ ├── export-mixins/ │ │ ├── exporter.js │ │ └── importer.js │ ├── export-var/ │ │ ├── exporter.js │ │ └── importer.js │ ├── import-as/ │ │ ├── exporter.js │ │ └── importer.js │ ├── import-chain/ │ │ ├── first.js │ │ ├── second.js │ │ └── third.js │ ├── import-order/ │ │ ├── consumer.js │ │ ├── exporter.js │ │ └── importer.js │ ├── module-level-declarations/ │ │ └── mod.js │ ├── named-function-expression/ │ │ ├── exporter.js │ │ └── importer.js │ ├── namespace-reassign-import-fails/ │ │ └── exporter.js │ ├── namespace-update-import-fails/ │ │ └── exporter.js │ ├── namespaces/ │ │ ├── exporter.js │ │ └── importer.js │ ├── re-export-default-import/ │ │ ├── first.js │ │ ├── second.js │ │ └── third.js │ ├── reassign-import-fails/ │ │ └── exporter.js │ ├── reassign-import-not-at-top-level-fails/ │ │ └── exporter.js │ ├── this-binding-undefined/ │ │ └── mod.js │ └── update-expression-of-import-fails/ │ └── exporter.js ├── fastMode/ │ ├── index.js │ └── output/ │ ├── amd/ │ │ ├── absolutePaths.js │ │ ├── banner.js │ │ ├── bannerAndFooter.js │ │ ├── constructor.js │ │ ├── earlyExport.js │ │ ├── emptyImport.js │ │ ├── emptyImportWithDefaultExport.js │ │ ├── escapedSource.js │ │ ├── exportAnonFunction.js │ │ ├── exportClassWithSuper.js │ │ ├── exportDefault.js │ │ ├── exportFunction.js │ │ ├── footer.js │ │ ├── importAll.js │ │ ├── importDefault.js │ │ ├── intermediateSourcemaps.js │ │ ├── multipleImports.js │ │ ├── namedAmdModule.js │ │ ├── preparsed.js │ │ ├── sparseArray.js │ │ ├── trailingEmptyImport.js │ │ └── useStrictFalse.js │ ├── cjs/ │ │ ├── absolutePaths.js │ │ ├── banner.js │ │ ├── bannerAndFooter.js │ │ ├── constructor.js │ │ ├── earlyExport.js │ │ ├── emptyImport.js │ │ ├── emptyImportWithDefaultExport.js │ │ ├── escapedSource.js │ │ ├── exportAnonFunction.js │ │ ├── exportClassWithSuper.js │ │ ├── exportDefault.js │ │ ├── exportFunction.js │ │ ├── footer.js │ │ ├── importAll.js │ │ ├── importDefault.js │ │ ├── intermediateSourcemaps.js │ │ ├── multipleImports.js │ │ ├── namedAmdModule.js │ │ ├── preparsed.js │ │ ├── sparseArray.js │ │ ├── trailingEmptyImport.js │ │ └── useStrictFalse.js │ └── umd/ │ ├── absolutePaths.js │ ├── banner.js │ ├── bannerAndFooter.js │ ├── constructor.js │ ├── earlyExport.js │ ├── emptyImport.js │ ├── emptyImportWithDefaultExport.js │ ├── escapedSource.js │ ├── exportAnonFunction.js │ ├── exportClassWithSuper.js │ ├── exportDefault.js │ ├── exportFunction.js │ ├── footer.js │ ├── importAll.js │ ├── importDefault.js │ ├── intermediateSourcemaps.js │ ├── multipleImports.js │ ├── namedAmdModule.js │ ├── preparsed.js │ ├── sparseArray.js │ ├── trailingEmptyImport.js │ └── useStrictFalse.js ├── samples/ │ ├── absolutePaths/ │ │ ├── _config.js │ │ └── source.js │ ├── banner/ │ │ ├── _config.js │ │ └── source.js │ ├── bannerAndFooter/ │ │ ├── _config.js │ │ └── source.js │ ├── clashingDefaultImports/ │ │ ├── _config.js │ │ └── source.js │ ├── clashingFunctionArguments/ │ │ ├── _config.js │ │ └── source.js │ ├── clashingMixedImports/ │ │ ├── _config.js │ │ └── source.js │ ├── clashingNamedDefaultImports/ │ │ ├── _config.js │ │ └── source.js │ ├── clashingNamedImports/ │ │ ├── _config.js │ │ └── source.js │ ├── clashingNames/ │ │ ├── _config.js │ │ └── source.js │ ├── clashingObjectProperties/ │ │ ├── _config.js │ │ └── source.js │ ├── conditionalExport/ │ │ ├── _config.js │ │ └── source.js │ ├── constructor/ │ │ ├── _config.js │ │ └── source.js │ ├── duplicateImportFalsePositive/ │ │ ├── _config.js │ │ └── source.js │ ├── duplicateImports/ │ │ ├── _config.js │ │ └── source.js │ ├── earlyExport/ │ │ ├── _config.js │ │ └── source.js │ ├── emptyImport/ │ │ ├── _config.js │ │ └── source.js │ ├── emptyImportWithDefaultExport/ │ │ ├── _config.js │ │ └── source.js │ ├── escapedSource/ │ │ ├── _config.js │ │ └── source.js │ ├── exportAnonFunction/ │ │ ├── _config.js │ │ └── source.js │ ├── exportClass/ │ │ ├── _config.js │ │ └── source.js │ ├── exportClassWithSuper/ │ │ ├── _config.js │ │ └── source.js │ ├── exportDefault/ │ │ ├── _config.js │ │ └── source.js │ ├── exportFunction/ │ │ ├── _config.js │ │ └── source.js │ ├── exportInlineFunction/ │ │ ├── _config.js │ │ └── source.js │ ├── exportLet/ │ │ ├── _config.js │ │ └── source.js │ ├── exportNamed/ │ │ ├── _config.js │ │ └── source.js │ ├── exportNamedCollidesWithFunctionExpression/ │ │ ├── _config.js │ │ └── source.js │ ├── exportNamedFromNamedImportES3/ │ │ ├── _config.js │ │ └── source.js │ ├── exportNamedFunction/ │ │ ├── _config.js │ │ └── source.js │ ├── exportVar/ │ │ ├── _config.js │ │ └── source.js │ ├── footer/ │ │ ├── _config.js │ │ └── source.js │ ├── hasExportsVariable/ │ │ ├── _config.js │ │ └── source.js │ ├── importAll/ │ │ ├── _config.js │ │ └── source.js │ ├── importDefault/ │ │ ├── _config.js │ │ └── source.js │ ├── importNamed/ │ │ ├── _config.js │ │ └── source.js │ ├── intermediateSourcemaps/ │ │ ├── _config.js │ │ └── source.js │ ├── mixedImports/ │ │ ├── _config.js │ │ └── source.js │ ├── multipleImports/ │ │ ├── _config.js │ │ └── source.js │ ├── namedAmdModule/ │ │ ├── _config.js │ │ └── source.js │ ├── preparsed/ │ │ ├── _config.js │ │ └── source.js │ ├── reExportES3/ │ │ ├── _config.js │ │ └── source.js │ ├── renamedExport/ │ │ ├── _config.js │ │ └── source.js │ ├── renamedImport/ │ │ ├── _config.js │ │ └── source.js │ ├── safeCommentRemoval/ │ │ ├── _config.js │ │ └── source.js │ ├── shadowedExport/ │ │ ├── _config.js │ │ └── source.js │ ├── shadowedImport/ │ │ ├── _config.js │ │ └── source.js │ ├── sparseArray/ │ │ ├── _config.js │ │ └── source.js │ ├── trailingEmptyImport/ │ │ ├── _config.js │ │ └── source.js │ ├── unscopedNameConflicts/ │ │ ├── _config.js │ │ └── source.js │ ├── updateExportInArgument/ │ │ ├── _config.js │ │ └── source.js │ ├── updateExpressionInFunction/ │ │ ├── _config.js │ │ └── source.js │ └── useStrictFalse/ │ ├── _config.js │ └── source.js ├── sourcemaps/ │ ├── bundle/ │ │ ├── foo.js │ │ └── main.js │ └── index.js ├── strictMode/ │ ├── index.js │ └── output/ │ ├── amd/ │ │ ├── absolutePaths.js │ │ ├── banner.js │ │ ├── bannerAndFooter.js │ │ ├── clashingFunctionArguments.js │ │ ├── clashingMixedImports.js │ │ ├── clashingNames.js │ │ ├── clashingObjectProperties.js │ │ ├── conditionalExport.js │ │ ├── constructor.js │ │ ├── duplicateImportFalsePositive.js │ │ ├── duplicateImports.js │ │ ├── earlyExport.js │ │ ├── emptyImport.js │ │ ├── emptyImportWithDefaultExport.js │ │ ├── escapedSource.js │ │ ├── exportAnonFunction.js │ │ ├── exportClass.js │ │ ├── exportClassWithSuper.js │ │ ├── exportDefault.js │ │ ├── exportFunction.js │ │ ├── exportInlineFunction.js │ │ ├── exportLet.js │ │ ├── exportNamed.js │ │ ├── exportNamedCollidesWithFunctionExpression.js │ │ ├── exportNamedFromNamedImportES3.js │ │ ├── exportNamedFunction.js │ │ ├── exportVar.js │ │ ├── footer.js │ │ ├── hasExportsVariable.js │ │ ├── importAll.js │ │ ├── importDefault.js │ │ ├── importNamed.js │ │ ├── intermediateSourcemaps.js │ │ ├── mixedImports.js │ │ ├── multipleImports.js │ │ ├── namedAmdModule.js │ │ ├── preparsed.js │ │ ├── reExportES3.js │ │ ├── renamedExport.js │ │ ├── renamedImport.js │ │ ├── safeCommentRemoval.js │ │ ├── shadowedExport.js │ │ ├── shadowedImport.js │ │ ├── sparseArray.js │ │ ├── trailingEmptyImport.js │ │ ├── unscopedNameConflicts.js │ │ ├── updateExportInArgument.js │ │ ├── updateExpressionInFunction.js │ │ └── useStrictFalse.js │ ├── cjs/ │ │ ├── absolutePaths.js │ │ ├── banner.js │ │ ├── bannerAndFooter.js │ │ ├── clashingFunctionArguments.js │ │ ├── clashingMixedImports.js │ │ ├── clashingNames.js │ │ ├── clashingObjectProperties.js │ │ ├── conditionalExport.js │ │ ├── constructor.js │ │ ├── duplicateImportFalsePositive.js │ │ ├── duplicateImports.js │ │ ├── earlyExport.js │ │ ├── emptyImport.js │ │ ├── emptyImportWithDefaultExport.js │ │ ├── escapedSource.js │ │ ├── exportAnonFunction.js │ │ ├── exportClass.js │ │ ├── exportClassWithSuper.js │ │ ├── exportDefault.js │ │ ├── exportFunction.js │ │ ├── exportInlineFunction.js │ │ ├── exportLet.js │ │ ├── exportNamed.js │ │ ├── exportNamedCollidesWithFunctionExpression.js │ │ ├── exportNamedFromNamedImportES3.js │ │ ├── exportNamedFunction.js │ │ ├── exportVar.js │ │ ├── footer.js │ │ ├── hasExportsVariable.js │ │ ├── importAll.js │ │ ├── importDefault.js │ │ ├── importNamed.js │ │ ├── intermediateSourcemaps.js │ │ ├── mixedImports.js │ │ ├── multipleImports.js │ │ ├── namedAmdModule.js │ │ ├── preparsed.js │ │ ├── reExportES3.js │ │ ├── renamedExport.js │ │ ├── renamedImport.js │ │ ├── safeCommentRemoval.js │ │ ├── shadowedExport.js │ │ ├── shadowedImport.js │ │ ├── sparseArray.js │ │ ├── trailingEmptyImport.js │ │ ├── unscopedNameConflicts.js │ │ ├── updateExportInArgument.js │ │ ├── updateExpressionInFunction.js │ │ └── useStrictFalse.js │ └── umd/ │ ├── absolutePaths.js │ ├── banner.js │ ├── bannerAndFooter.js │ ├── clashingFunctionArguments.js │ ├── clashingMixedImports.js │ ├── clashingNames.js │ ├── clashingObjectProperties.js │ ├── conditionalExport.js │ ├── constructor.js │ ├── duplicateImportFalsePositive.js │ ├── duplicateImports.js │ ├── earlyExport.js │ ├── emptyImport.js │ ├── emptyImportWithDefaultExport.js │ ├── escapedSource.js │ ├── exportAnonFunction.js │ ├── exportClass.js │ ├── exportClassWithSuper.js │ ├── exportDefault.js │ ├── exportFunction.js │ ├── exportInlineFunction.js │ ├── exportLet.js │ ├── exportNamed.js │ ├── exportNamedCollidesWithFunctionExpression.js │ ├── exportNamedFromNamedImportES3.js │ ├── exportNamedFunction.js │ ├── exportVar.js │ ├── footer.js │ ├── hasExportsVariable.js │ ├── importAll.js │ ├── importDefault.js │ ├── importNamed.js │ ├── intermediateSourcemaps.js │ ├── mixedImports.js │ ├── multipleImports.js │ ├── namedAmdModule.js │ ├── preparsed.js │ ├── reExportES3.js │ ├── renamedExport.js │ ├── renamedImport.js │ ├── safeCommentRemoval.js │ ├── shadowedExport.js │ ├── shadowedImport.js │ ├── sparseArray.js │ ├── trailingEmptyImport.js │ ├── unscopedNameConflicts.js │ ├── updateExportInArgument.js │ ├── updateExpressionInFunction.js │ └── useStrictFalse.js ├── test.js └── utils/ ├── generate.js └── makeWhitespaceVisible.js ================================================ FILE CONTENTS ================================================ ================================================ FILE: .babelrc ================================================ { "whitelist": [ "es3.memberExpressionLiterals", "es3.propertyLiterals", "es6.arrowFunctions", "es6.blockScoping", "es6.constants", "es6.destructuring", "es6.parameters", "es6.properties.shorthand", "es6.templateLiterals", "es6.classes" ], "loose": [ "es6.classes", "es6.destructuring" ] } ================================================ FILE: .editorconfig ================================================ [*.js] indent_style = tab ================================================ FILE: .gitignore ================================================ .DS_Store node_modules sample/output .gobble .gobble-build out demo/dist test/lib lib cli-test sandbox dist ================================================ FILE: .jshintrc ================================================ { "esnext": true, "undef": true, "unused": true, "expr": true, "boss": true, "globals": { "process": true, "__dirname": true, "module": true, "exports": true, "require": true, "console": true, "define": true } } ================================================ FILE: .travis.yml ================================================ sudo: false language: node_js node_js: - "0.10" - "0.11" - "0.12" env: global: - BUILD_TIMEOUT=10000 ================================================ FILE: CHANGELOG.md ================================================ # changelog ## 0.7.6 * Update sander to prevent graceful-fs-opocalypse ([#193](https://github.com/esperantojs/esperanto/issues/193)) ## 0.7.5 * Add a deprecation warning. (This project is deprecated – for one-to-one transformations you should use [Babel](https://babeljs.io/), for bundling you should use [Rollup](https://github.com/rollup/rollup).) ## 0.7.3 * `this` at the top-level is no longer treated as a syntax error ([#151](https://github.com/esperantojs/esperanto/issues/151)) ## 0.7.2 * Fix two bugs with renamed exports ([#170](https://github.com/esperantojs/esperanto/issues/170)) ## 0.7.1 * Fix `export { x as y }` namespace imports within a bundle ([#169](https://github.com/esperantojs/esperanto/issues/169)) * Lock magic-string version to 0.4.9 pending investigation of bug ## 0.7.0 * Where possible, default exports are not renamed ([#166](https://github.com/esperantojs/esperanto/issues/166)) * Some internal tidying up ## 0.6.34 * Improve module sorting algorithm to handle tricky cyclical cases ([#159](https://github.com/esperantojs/esperanto/issues/159)) ## 0.6.33 * Fix a separate 0.6.31 regression with external modules ([#158](https://github.com/esperantojs/esperanto/issues/158)) ## 0.6.32 * Fix regression introduce in 0.6.31, whereby modules within a bundle are prevented from depending on the entry module ## 0.6.31 * Preserve trailing `.js` in external module names (e.g. [highlight.js](https://www.npmjs.com/package/highlight.js)) ([#155](https://github.com/esperantojs/esperanto/issues/155)) * Fix naming bug with modules imported via both `resolvePath` and normal import ([#156](https://github.com/esperantojs/esperanto/issues/156)) ## 0.6.30 * Mutually dependent modules within a bundle are re-ordered based on whether one is referenced at the top level of the other ([#152](https://github.com/esperantojs/esperanto/issues/152)) ## 0.6.29 * Relative source URLs in sourcemaps are correct * `src` directory included in npm package ## 0.6.28 * `resolvePath` option is not required to return a path (e.g. `esperanto.toAmd({ code, ast })`) ([#148](https://github.com/esperantojs/esperanto/issues/148)) ## 0.6.27 * AST can be supplied when doing one-to-one transformations (e.g. `esperanto.toAmd({ code, ast })`) ([#140](https://github.com/esperantojs/esperanto/issues/140)) * Modules can be supplied directly when bundling, rather than reading from disk ([docs here](https://github.com/esperantojs/esperanto/wiki/Bundling-multiple-ES6-modules#modules)) ([#140](https://github.com/esperantojs/esperanto/issues/140)) * 'use strict' pragma is omitted if `useStrict: false` option is supplied ([#141](https://github.com/esperantojs/esperanto/issues/141)) ## 0.6.26 * AST walker handles sparse arrays ([#144](https://github.com/esperantojs/esperanto/issues/144)) ## 0.6.25 * Reliable updating of exported expressions ([#142](https://github.com/esperantojs/esperanto/issues/142)) ## 0.6.24 * Renamed exports (`export { foo as bar }`) works * Internal tidy up/refactoring, resulting in smaller library ## 0.6.23 * Function arguments are considered when naming imports to avoid conflicts ([#119](https://github.com/esperantojs/esperanto/issues/119)) * Bindings are always exported at the end of a module, regardless of re-assignments ([#130](https://github.com/esperantojs/esperanto/issues/130)) * Generated import names cannot be shadowed by non-root-scope declarations ([#133](https://github.com/esperantojs/esperanto/issues/133)) ## 0.6.22 * Allow imports to be re-exported ([#124](https://github.com/esperantojs/esperanto/issues/124)) ## 0.6.21 * Fix npm versioning snafu ## 0.6.20 * Replaced estraverse with internal utility that doesn't depend on hardcoded node types to traverse AST ([#129](https://github.com/esperantojs/esperanto/issues/129)) ## 0.6.19 * Sourcemap comments are removed from bundles as well as one-to-one transformations ([#120](https://github.com/esperantojs/esperanto/issues/120)) ## 0.6.18 * Upgrade to acorn v1.x ([#125](https://github.com/esperantojs/esperanto/issues/125)) * Sourcemap comments from prior transformations are removed ([#120](https://github.com/esperantojs/esperanto/issues/120)) * Named function expressions are not erroneously renamed ([#122](https://github.com/esperantojs/esperanto/issues/122)) ## 0.6.17 * Sourcemap mappings are set explicitly - rather than mapping every single character, the locations from the acorn AST are used. As well as smaller sourcemaps, this results in modest performance improvements internally, and large performance improvements for external tools that work with the sourcemap ## 0.6.16 * Prevent import naming collisions ([#116](https://github.com/esperantojs/esperanto/issues/116)) * Throw error on duplicate imports ([#95](https://github.com/esperantojs/esperanto/issues/95)) * Prevent internal assigment exports clashing within a bundle ([#117](https://github.com/esperantojs/esperanto/issues/117)) * Update chalk to 1.0.0 ## 0.6.15 * Clashes with names for external dependencies are avoided ([#114](https://github.com/esperantojs/esperanto/issues/114)) ## 0.6.14 * The `sourceMapFile` requirement is waived when `options.sourceMap === 'inline'` ([#105](https://github.com/esperantojs/esperanto/issues/105)) ## 0.6.13 * Windows fixes ## 0.6.12 * Bundled external modules are deduplicated in the rare case that they import themselves ([#103](https://github.com/esperantojs/esperanto/issues/103)) ## 0.6.11 * Use robust `module.relativePath` internally rather than `module.file` - necessary for bundled external modules with dependencies of their own * Browser-flavoured version of Esperanto (`dist/esperanto.browser.js`) bundles ES6 dependencies (`magic-string` and its `vlq` dependency), as both a convenience and a form of dogfooding ## 0.6.10 * The `resolvePath` option can be used with `esperanto.bundle()` to locate modules, if they do not exist relative to `base`. It should return an absolute path as a string, or a promise that resolves to one ([#68](https://github.com/esperantojs/esperanto/issues/68)) ## 0.6.9 * `sourceMapFile` can be an absolute path, in which case it is left unchanged ([#101](https://github.com/esperantojs/esperanto/issues/101)) ## 0.6.8 * Module load order is guaranteed by import order - empty imports are represented by `__dep0__` etc within the module, or `undefined` globally ([#92](https://github.com/esperantojs/esperanto/issues/92)) * Fix absolute path resolution in cases like `./../foo` ([#97](https://github.com/esperantojs/esperanto/issues/97)) * If `bundle.concat()` fails due to external dependencies, or exports from the entry module, the error message lists them ## 0.6.7 * Using the `_evilES3SafeReExports` will cause re-exported bindings to be done with direct property assignment rather than `Object.defineProperty()`. In most cases, the resulting behaviour will be no different, but it could result in undefined bindings in cases of cyclical dependencies, and values are fixed at the time of re-export rather than live. ## 0.6.6 * Conflicts between module names and unscoped (i.e. global) names and `exports` are prevented ([#74](https://github.com/esperantojs/esperanto/issues/74)), ([#79](https://github.com/esperantojs/esperanto/issues/79)) * Names in function expressions (as opposed to declarations) are disregarded ([#73](https://github.com/esperantojs/esperanto/issues/73)) * Re-exports remain enumerable * Continuous integration via Travis-CI ## 0.6.5 * Relative AMD dependency paths can be made absolute with `absolutePaths: true` - requires `amdName` to be specified ([#58](https://github.com/esperantojs/esperanto/issues/58)) * Within a bundle, built-in names like `Math` and `Promise` are avoided ([#70](https://github.com/esperantojs/esperanto/issues/70)) * Bundle imports and exports are reported as `bundle.imports` and `bundle.exports` ([#59](https://github.com/esperantojs/esperanto/issues/59)) ## 0.6.4 * Fixes duplicate import bug ([#63](https://github.com/esperantojs/esperanto/issues/63)) * Module names are correctly escaped ([#50](https://github.com/esperantojs/esperanto/issues/50)) * Accessing properties on top-level `this` throws error at parse time * CLI: if no `--output` option is given, bundle is written to stdout (if no separate sourcemap) ([#60](https://github.com/esperantojs/esperanto/issues/60)) * CLI: Better errors ([#66](https://github.com/esperantojs/esperanto/issues/66)) * Test suite refactor ## 0.6.3 * Support for Windows file paths * `bundle.concat()` can be called without an options argument * Options argument passed to `bundle.concat()` can include `intro`, `outro`, `indent` properties which will override defaults (`indent: true` is equivalent to 'automatic', otherwise pass a string) * Bundle transform function can return an empty string ## 0.6.2 * Implement `bundle.concat()` for self-contained bundles ([#48](https://github.com/esperantojs/esperanto/issues/48)) ## 0.6.1 * Fix for ([#45](https://github.com/esperantojs/esperanto/issues/45)) * External modules only have `__default` appended where necessary ([#46](https://github.com/esperantojs/esperanto/issues/46)) ## 0.6.0 * UMD export detects CJS environment *before* AMD ([#42](https://github.com/esperantojs/esperanto/issues/42)) * `this` at module top-level is replaced with `undefined`, as per the spec ([#43](https://github.com/esperantojs/esperanto/issues/43)) * More compact CommonJS export * Bundler transform function receives path as second argument ## 0.5.10 * One-to-one conversions get the same compact UMD form as bundles * Default imports are not hedged unnecessarily ([#40](https://github.com/esperantojs/esperanto/issues/40)) ## 0.5.9 * More concise UMD output ([#36](https://github.com/esperantojs/esperanto/issues/36)) ## 0.5.8 * Functions are always exported early ([#37](https://github.com/esperantojs/esperanto/issues/37)) * Modules can be transformed before bundling with `esperanto.bundle({ transform: someFunction })`, where `someFunction` returns either a string, or a promise that resolves to a string ## 0.5.7 * Classes are exported after declaration, not before ([#33](https://github.com/esperantojs/esperanto/issues/33)) ## 0.5.6 * Support for named AMD modules, via `amdName` option (works for both standalone and bundle conversions) ## 0.5.5 * No actual changes - just shuffling things about so we can separate demo page into separate repo ## 0.5.4 * Performance improvements and internal refactoring ## 0.5.3 * You can specify a `banner` and/or `footer` option when converting or bundling * An error will be thrown if a module attempts to import itself ## 0.5.2 * Imported objects (other than namespace imports) can be assigned properties ([#29](https://github.com/esperantojs/esperanto/issues/29)) * Default imports can be exported as named exports from the entry module in a bundle ## 0.5.1 * Identifiers that match object prototype properties are not mistakenly exported (and garbled) ## 0.5.0 * Chained imports/exports are renamed correctly within a bundle ([#17](https://github.com/esperantojs/esperanto/issues/17)) * Bundle exports are written at assignment time, rather than at the end of the bundle with an `Object.defineProperty` hack * Attempting to import a non-exported identifier within the same bundle throws an error * External modules are imported correctly ([#28](https://github.com/esperantojs/esperanto/issues/28)) * Identifiers are only rewritten as necessary ([#25](https://github.com/esperantojs/esperanto/issues/25)) * Redundant assignments in a bundle (`mod__default = mod__foo`) are avoided ([#14](https://github.com/esperantojs/esperanto/issues/14)) * Shadowed imports are handled ([#18](https://github.com/esperantojs/esperanto/issues/18)) * Modules are indented consistently within a bundle ## 0.4.10 * Update acorn (greater ES6 coverage) and estraverse dependencies - thanks [@leebyron](https://github.com/leebyron) ## 0.4.9 * Adds `class` support - thanks [@leebyron](https://github.com/leebyron) * Use `hasOwnProperty` check to prevent garbled output - thanks [@leebyron](https://github.com/leebyron) ## 0.4.8 * `exports['default']` is used in favour of `exports.default`, for the benefit of IE8 - thanks [@evs-chris](https://github.com/evs-chris/) ## 0.4.7 * In standalone conversions, import names are inferred from the source code where possible (batch/default imports), and will avoid naming collisions ([#15](https://github.com/esperantojs/esperanto/issues/15)) ## 0.4.6 * Fix missing closing parenthesis on strict mode UMD output ## 0.4.5 * Only print `defaultOnly` deprecation warning once, rather than flooding the console ## 0.4.4 * Parse errors (from acorn) are augmented with file info when bundling ## 0.4.3 * Added CLI files to npm package (oops!) ## 0.4.2 * Sourcemap support for bundles ## 0.4.1 * Command line interface * Sourcemap support for one-to-one conversions * Neater UMD exports * Remove `addUseStrict` option (ES6 modules are always in strict mode) ## 0.4.0 * Started maintaining a changelog * Complete rewrite! * Spec-compliance - Esperanto now supports bindings and cycles (only in [strict mode](https://github.com/Rich-Harris/esperanto/wiki/strictMode)) * The `defaultOnly` option has been deprecated - esperanto's standard behaviour is now to import and exports defaults. If you want to use named imports/exports, pass `strict: true` (this basically means that your default export becomes `exports.default` rather than `module.exports`). For more information see the [wiki page on strict mode](https://github.com/Rich-Harris/esperanto/wiki/strictMode) * UMD output: `esperanto.toUmd(es6source, {name:'myModule'}); * Bundling - see the [wiki page on esperanto.bundle()](https://github.com/Rich-Harris/esperanto/wiki/esperanto-bundle) ================================================ FILE: README.md ================================================ # esperanto [![Build Status](https://travis-ci.org/esperantojs/esperanto.svg?branch=master)](https://travis-ci.org/esperantojs/esperanto) ## This project is no longer under active development. To bundle ES6 modules, use [Rollup](https://github.com/rollup/rollup). To convert ES6 modules to another format, use [Babel](https://babeljs.io/docs/usage/modules/). See [#191](https://github.com/esperantojs/esperanto/pull/191) for details. A better way to transpile ES6 modules to AMD and CommonJS: * Easier - no laborious configuration * Simpler - doesn't make dangerous assumptions about your project setup * Smarter - non-destructive source code transformation, no runtime Traceur dependency, and no ES5-only features * Faster - roughly 10x quicker than the alternatives Try it online here: [esperantojs.org](http://esperantojs.org) ## Installation Install esperanto from npm: ```bash npm install esperanto ``` ## Usage You can use Esperanto in one of two modes: * [Converting a single module](https://github.com/esperantojs/esperanto/wiki/Converting-a-single-module) * [Bundling multiple ES6 modules](https://github.com/esperantojs/esperanto/wiki/Bundling-multiple-ES6-modules) ## Why not use existing module transpilers? See [comparisons with other tools](https://github.com/esperantojs/esperanto/wiki/Comparisons-with-other-tools) for some of the reasons to use Esperanto. ## Credits Many thanks to [Marijn Haverbeke](http://marijnhaverbeke.nl/) for [Acorn](https://github.com/marijnh/acorn), which does all the heavy lifting. ## License Copyright 2014 Rich Harris. MIT Licensed. ================================================ FILE: appveyor.yml ================================================ # Test against this version of Node.js environment: matrix: # node.js - nodejs_version: "0.10" - nodejs_version: "0.12" # io.js - nodejs_version: "1.0" # Install scripts. (runs after repo cloning) install: # Get the latest stable version of Node.js or io.js - ps: Install-Product node $env:nodejs_version # install modules - npm install # Post-install test scripts. test_script: # Output useful info for debugging. - node --version - npm --version # run tests - npm test # Don't actually build. build: off ================================================ FILE: bin/handleError.js ================================================ var chalk = require( 'chalk' ); var handlers = { MISSING_INPUT_OPTION: function () { console.error( chalk.red( 'You must specify an --input (-i) option when bundling' ) ); }, MISSING_OUTPUT_OPTION: function () { console.error( chalk.red( 'You must specify an --output (-o) directory option when converting a directory of files' ) ); }, NO_INPUT_DETECTED: function () { console.error( chalk.red( 'No input detected! Try using the --input (-i) option' ) ); }, MISSING_NAME: function ( err ) { console.error( chalk.red( 'You must supply a name for UMD exports (e.g. `--name myModule`)' ) ); } }; module.exports = function handleError ( err ) { var handler; if ( handler = handlers[ err && err.code ] ) { handler( err ); } else { console.error( chalk.red( err.message || err ) ); if ( err.stack ) { console.error( chalk.grey( err.stack ) ); } } console.error( 'Type ' + chalk.cyan( 'esperanto --help' ) + ' for help, or visit https://github.com/esperantojs/esperanto/wiki' ); process.exit( 1 ); }; ================================================ FILE: bin/help.md ================================================ Esperanto version <%= version %> ===================================== Usage: esperanto [options] Basic options: -v, --version Show version number -h, --help Show this help message -i, --input Input file (if absent, reads from stdin) -o, --output Output file (if absent, prints to stdout) -t, --type [amd] Type of output (amd, cjs, umd) -s, --strict Use strict mode -b, --bundle Create a bundle including 's dependencies -n, --name Name for UMD export -a, --amdName Name for AMD module (default is anonymous) -m, --sourcemap Generate sourcemap (`-m inline` for inline map) Additional options when bundling -d, --basedir= Base directory for module resolution -k, --skip= Comma-separated list of files to skip (relative to basedir) Example: esperanto --type=cjs --output=build/app.js --bundle -- src/app.js Notes: * You must supply an --input option when bundling (i.e. no piping from stdin) * Non-inline sourcemaps will be discarded when piping to stdout For more information visit https://github.com/Rich-Harris/esperanto/wiki ================================================ FILE: bin/index.js ================================================ #!/usr/bin/env node var minimist = require( 'minimist' ), command; command = minimist( process.argv.slice( 2 ), { alias: { i: 'input', o: 'output', v: 'version', h: 'help', b: 'bundle', s: 'strict', t: 'type', m: 'sourcemap', n: 'name', d: 'basedir', k: 'skip', a: 'amdName' } }); if ( command.help || ( process.argv.length <= 2 && process.stdin.isTTY ) ) { require( './showHelp' )(); } else if ( command.version ) { console.log( 'Esperanto version ' + require( '../package.json' ).version ); } else { require( './runEsperanto' )( command ); } ================================================ FILE: bin/runEsperanto.js ================================================ var path = require( 'path' ), sander = require( 'sander' ), Promise = sander.Promise, handleError = require( './handleError' ), esperanto = require( '../' ); var methods = { amd: 'toAmd', cjs: 'toCjs', umd: 'toUmd' }; module.exports = function ( options ) { var method; if ( options.type && !methods[ options.type ] ) { console.error( 'The --type (-t) option must be one of amd, cjs, umd' ); process.exit( 1 ); } method = methods[ options.type ] || 'toAmd'; try { if ( options.bundle ) { bundle( options, method ).catch( handleError ); } else { convert( options, method ).catch( handleError ); } } catch ( err ) { handleError( err ); } }; function bundle ( options, method ) { var bundleOptions, file; if ( !options.input ) { handleError({ code: 'MISSING_INPUT_OPTION' }); } bundleOptions = { base: path.resolve( options.basedir || '' ) }; if ( options.skip ) { bundleOptions.skip = options.skip.split( ',' ).map( function ( file ) { return file.replace( /\.js$/, '' ); }); } // entry should be relative to base if ( options.basedir && !sander.existsSync( path.join( bundleOptions.base, options.input ) ) ) { // file doesn't exist relative to base... file = path.resolve( options.input ).replace( bundleOptions.base + '/', '' ); } else { file = path.resolve( bundleOptions.base, options.input ); } bundleOptions.entry = file; return esperanto.bundle( bundleOptions ).then( function ( bundle ) { var transpiled, promises; transpiled = bundle[ method ]({ name: options.name, amdName: options.amdName, strict: options.strict, sourceMap: options.sourcemap, sourceMapFile: options.sourcemap ? path.resolve( options.output ) : null }); if ( options.output ) { promises = [ sander.writeFile( options.output, transpiled.code ) ]; if ( options.sourcemap === true ) { promises.push( sander.writeFile( options.output + '.map', transpiled.map ) ); } return Promise.all( promises ); } else { process.stdout.write( transpiled.code ); } }); } function convert ( options, method ) { if ( options.input ) { return sander.stat( options.input ).then( function ( stats ) { if ( stats.isDirectory() ) { if ( !options.output ) { handleError({ code: 'MISSING_OUTPUT_OPTION' }); } // transpile all the things return sander.lsr( options.input ) .then( filterOutNonJs ) .then( function ( files ) { var promises = files.map( function ( file ) { var input = path.join( options.input, file ); var output = path.join( options.output, file ); var fileOptions = assign( {}, options, { input: input, output: output, sourceMapSource: input, sourceMapFile: output }); return convert( fileOptions, method ); }); return Promise.all( promises ); }); } return sander.readFile( options.input ) .then( String ) .then( run ); }); } else { return readFromStdin().then( run ); } function run ( source ) { var transpiled, promises; transpiled = esperanto[ method ]( source, { strict: options.strict, name: options.name, amdName: options.amdName, sourceMap: options.sourcemap, sourceMapSource: options.input, sourceMapFile: options.output }); if ( options.output ) { promises = [ sander.writeFile( options.output, transpiled.code ) ]; if ( options.sourcemap === true ) { promises.push( sander.writeFile( options.output + '.map', transpiled.map ) ); } return Promise.all( promises ); } process.stdout.write( transpiled.code ); } } function readFromStdin () { return new Promise( function ( fulfil, reject ) { var data = ''; if ( process.stdin.isTTY ) { handleError({ code: 'NO_INPUT_DETECTED' }); } process.stdin.setEncoding( 'utf8' ); process.stdin.on( 'readable', function () { var chunk = process.stdin.read(); if ( chunk !== null ) { data += chunk; } }); process.stdin.on( 'end', function() { fulfil( data ); }); process.stdin.on( 'error', reject ); }); } function assign ( target ) { var sources = [].slice.call( arguments, 1 ); sources.forEach( function ( source ) { var prop; for ( prop in source ) { if ( source.hasOwnProperty( prop ) ) { target[ prop ] = source[ prop ]; } } }); return target; } function filterOutNonJs ( files ) { var isJs = /\.js$/; return files.filter( function ( file ) { return isJs.test( file ); }); } ================================================ FILE: bin/showHelp.js ================================================ var fs = require( 'fs' ), path = require( 'path' ); module.exports = function () { fs.readFile( path.join( __dirname, 'help.md' ), function ( err, result ) { var help; if ( err ) throw err; help = result.toString().replace( '<%= version %>', require( '../package.json' ).version ); console.log( '\n' + help + '\n' ); }); }; ================================================ FILE: comparison/README.md ================================================ # ES6 module transpilers comparison **Parental advisory: benchmarks are nonsense. Do not rely on benchmarks alone to make decisions!** In particular, this test is unfair to traceur, since it is trying to transpile ES6 language features other than module syntax. Since transpile uses traceur under the hood, the same thing probably applies (in some cases, the output from the two transpilers is identical). The esnext/es6-module-transpiler project has been excluded as there doesn't seem to be a way to compile code synchronously from a string - instead the filesystem has to get involved, so it would be misleading and unfair to include the results. (It also errors out if it can't follow the dependency graph of your modules, making it very difficult to test.) Instead, focus on how much nicer, slimmer, and more faithful esperanto's output is. The `output` folder contains the result of transpiling each of the modules in the `input` folder. Note that both transpile and traceur fail to convert certain modules (both fail at `mixedImports.js`, transpile fails at `batchImports.js`). ## Running the tests Inside this folder, do... ```bash node index.js ``` to run the tests with esperanto and transpile. To run the tests with traceur, do ```bash node index.js traceur ``` This is necessary because transpile uses traceur, and you can't have two copies of traceur running simultaneously because it monkey patches stuff, or something. ================================================ FILE: comparison/index.js ================================================ var fs = require( 'fs' ), path = require( 'path' ), esperanto = require( '../lib/esperanto' ), samples, iterations = 1000; samples = fs.readdirSync( path.join( __dirname, 'samples' ) ).map( function ( file ) { return { name: file, code: fs.readFileSync( path.join( __dirname, 'samples', file ) ).toString() }; }); tests = [ { name: 'esperanto', fn: function ( code, filename, type ) { code = esperanto[ type === 'amd' ? 'toAmd' : 'toCjs' ]( code, { strict: true }); return code; } }, { name: 'traceur', skip: process.argv[2] !== 'traceur', before: function () { traceur = require( 'traceur' ); }, fn: function ( code, filename, type ) { return traceur.compile( code, { filename: filename, modules: type, sourceMaps: false }).js; }, after: function () { delete require.cache[ require.resolve( 'traceur' ) ]; }, alias: { cjs: 'commonjs' } }, { name: 'transpile', skip: process.argv[2] === 'traceur', before: function () { transpile = require( 'transpile' ); }, fn: function ( code, filename, type ) { return transpile.to({ name: filename, source: code, metadata: { format: 'es6' } }, type ) }, after: function () { delete require.cache[ require.resolve( 'transpile' ) ]; } } ]; tests.forEach( function ( test ) { var out, type = 'cjs'; if ( test.skip ) { return; } if ( test.alias ) { type = test.alias[ type ] || type; } console.log( '\nRunning %s test...', test.name ); test.before && test.before(); // First, save the result to disk out = path.join( __dirname, 'output', test.name ); try { fs.mkdirSync( out ); } catch ( err ) {} samples.forEach( function ( sample ) { var result = test.fn( sample.code, sample.name, type ); fs.writeFileSync( path.join( out, sample.name ), result ); }); // Then run the tests var start = Date.now(); samples.forEach( function ( sample ) { var i = iterations; while ( i-- ) { test.fn( sample.code, sample.name, type ); } }); console.log( '...finished %s iterations in %sms\n', iterations, Date.now() - start ); test.after && test.after(); }) ================================================ FILE: comparison/output/esperanto/batchImports.js ================================================ (function () { 'use strict'; var fs = require('fs'); // example from http://jsmodules.io fs.unlink(filename, function(err) { /* check errors */ }); }).call(global); ================================================ FILE: comparison/output/esperanto/defaultExport.js ================================================ (function () { 'use strict'; // example from http://jsmodules.io var asap; var isNode = typeof process !== "undefined" && {}.toString.call(process) === "[object process]"; if (isNode) { asap = process.nextTick; } else if (typeof setImmediate !== "undefined") { asap = setImmediate; } else { asap = setTimeout; } exports.default = asap; }).call(global); ================================================ FILE: comparison/output/esperanto/defaultImport.js ================================================ (function () { 'use strict'; var asap = require('asap'); // example from http://jsmodules.io asap.default(function() { console.log("hello async world!"); }); }).call(global); ================================================ FILE: comparison/output/esperanto/groupedExports.js ================================================ (function () { 'use strict'; // example from http://jsmodules.io function getJSON() { // implementation } function postJSON() { // implementation } function animate() { // implementation } exports.getJSON = getJSON; exports.postJSON = postJSON; exports.animate = animate; }).call(global); ================================================ FILE: comparison/output/esperanto/inlineNamedExports.js ================================================ (function () { 'use strict'; exports.requestAnimationFrame = requestAnimationFrame; // example from http://jsmodules.io // exports this function as "requestAnimationFrame" function requestAnimationFrame() { // cross-browser requestAnimationFrame } // exports document.location as "location" var location = document.location; exports.location = location; }).call(global); ================================================ FILE: comparison/output/esperanto/mixedImports.js ================================================ (function () { 'use strict'; var asap = require('asap'); // example from http://jsmodules.io }).call(global); ================================================ FILE: comparison/output/esperanto/namedExports.js ================================================ (function () { 'use strict'; // example from http://jsmodules.io var asap; var isNode = typeof process !== "undefined" && {}.toString.call(process) === "[object process]"; if (isNode) { asap = process.nextTick; } else if (typeof setImmediate !== "undefined") { asap = setImmediate; } else { asap = setTimeout; } exports.default = asap; var later = isNode ? process.setImmediate : asap; exports.later = later; }).call(global); ================================================ FILE: comparison/output/esperanto/namedImports.js ================================================ (function () { 'use strict'; var asap = require('asap'); // example from http://jsmodules.io asap.later(function() { console.log("Running after other network events"); }); }).call(global); ================================================ FILE: comparison/output/esperanto/renamingImports.js ================================================ (function () { 'use strict'; var fs = require('fs'); // example from http://jsmodules.io fs.unlink(filename, function(err) { /* check errors */ }); }).call(global); ================================================ FILE: comparison/output/traceur/batchImports.js ================================================ "use strict"; var $__fs__; var fs = ($__fs__ = require("fs"), $__fs__ && $__fs__.__esModule && $__fs__ || {default: $__fs__}); fs.unlink(filename, function(err) {}); ================================================ FILE: comparison/output/traceur/defaultExport.js ================================================ "use strict"; Object.defineProperties(exports, { default: {get: function() { return $__default; }}, __esModule: {value: true} }); var asap; var isNode = typeof process !== "undefined" && {}.toString.call(process) === "[object process]"; if (isNode) { asap = process.nextTick; } else if (typeof setImmediate !== "undefined") { asap = setImmediate; } else { asap = setTimeout; } var $__default = asap; ================================================ FILE: comparison/output/traceur/defaultImport.js ================================================ "use strict"; var $__asap__; var asap = ($__asap__ = require("asap"), $__asap__ && $__asap__.__esModule && $__asap__ || {default: $__asap__}).default; asap(function() { console.log("hello async world!"); }); ================================================ FILE: comparison/output/traceur/groupedExports.js ================================================ "use strict"; Object.defineProperties(exports, { getJSON: {get: function() { return getJSON; }}, postJSON: {get: function() { return postJSON; }}, animate: {get: function() { return animate; }}, __esModule: {value: true} }); ; function getJSON() {} function postJSON() {} function animate() {} ================================================ FILE: comparison/output/traceur/inlineNamedExports.js ================================================ "use strict"; Object.defineProperties(exports, { requestAnimationFrame: {get: function() { return requestAnimationFrame; }}, location: {get: function() { return location; }}, __esModule: {value: true} }); function requestAnimationFrame() {} var location = document.location; ================================================ FILE: comparison/output/traceur/mixedImports.js ================================================ undefined ================================================ FILE: comparison/output/traceur/namedExports.js ================================================ "use strict"; Object.defineProperties(exports, { default: {get: function() { return $__default; }}, later: {get: function() { return later; }}, __esModule: {value: true} }); var asap; var isNode = typeof process !== "undefined" && {}.toString.call(process) === "[object process]"; if (isNode) { asap = process.nextTick; } else if (typeof setImmediate !== "undefined") { asap = setImmediate; } else { asap = setTimeout; } var $__default = asap; var later = isNode ? process.setImmediate : asap; ================================================ FILE: comparison/output/traceur/namedImports.js ================================================ "use strict"; var $__asap__; var later = ($__asap__ = require("asap"), $__asap__ && $__asap__.__esModule && $__asap__ || {default: $__asap__}).later; later(function() { console.log("Running after other network events"); }); ================================================ FILE: comparison/output/traceur/renamingImports.js ================================================ "use strict"; var $__fs__; var rm = ($__fs__ = require("fs"), $__fs__ && $__fs__.__esModule && $__fs__ || {default: $__fs__}).unlink; rm(filename, function(err) {}); ================================================ FILE: comparison/output/transpile/batchImports.js ================================================ undefined ================================================ FILE: comparison/output/transpile/defaultExport.js ================================================ "use strict"; Object.defineProperties(exports, { default: {get: function() { return $__default; }}, __esModule: {value: true} }); var asap; var isNode = typeof process !== "undefined" && {}.toString.call(process) === "[object process]"; if (isNode) { asap = process.nextTick; } else if (typeof setImmediate !== "undefined") { asap = setImmediate; } else { asap = setTimeout; } var $__default = asap; ================================================ FILE: comparison/output/transpile/defaultImport.js ================================================ "use strict"; var asap = $traceurRuntime.assertObject(require("asap")).default; asap(function() { console.log("hello async world!"); }); ================================================ FILE: comparison/output/transpile/groupedExports.js ================================================ "use strict"; Object.defineProperties(exports, { getJSON: {get: function() { return getJSON; }}, postJSON: {get: function() { return postJSON; }}, animate: {get: function() { return animate; }}, __esModule: {value: true} }); ; function getJSON() {} function postJSON() {} function animate() {} ================================================ FILE: comparison/output/transpile/inlineNamedExports.js ================================================ "use strict"; Object.defineProperties(exports, { requestAnimationFrame: {get: function() { return requestAnimationFrame; }}, location: {get: function() { return location; }}, __esModule: {value: true} }); function requestAnimationFrame() {} var location = document.location; ================================================ FILE: comparison/output/transpile/mixedImports.js ================================================ undefined ================================================ FILE: comparison/output/transpile/namedExports.js ================================================ "use strict"; Object.defineProperties(exports, { default: {get: function() { return $__default; }}, later: {get: function() { return later; }}, __esModule: {value: true} }); var asap; var isNode = typeof process !== "undefined" && {}.toString.call(process) === "[object process]"; if (isNode) { asap = process.nextTick; } else if (typeof setImmediate !== "undefined") { asap = setImmediate; } else { asap = setTimeout; } var $__default = asap; var later = isNode ? process.setImmediate : asap; ================================================ FILE: comparison/output/transpile/namedImports.js ================================================ "use strict"; var later = $traceurRuntime.assertObject(require("asap")).later; later(function() { console.log("Running after other network events"); }); ================================================ FILE: comparison/output/transpile/renamingImports.js ================================================ "use strict"; var rm = $traceurRuntime.assertObject(require("fs")).unlink; rm(filename, function(err) {}); ================================================ FILE: comparison/package.json ================================================ { "name": "esperanto-benchmark", "description": "quick and dirty script to illustrate esperanto speed advantage", "version": "0.1.0", "devDependencies": { "traceur": "0.0.58", "transpile": "~0.2.0", "es6-module-transpiler": "~0.6.0" } } ================================================ FILE: comparison/samples/batchImports.js ================================================ // example from http://jsmodules.io import * as fs from "fs"; fs.unlink(filename, function(err) { /* check errors */ }); ================================================ FILE: comparison/samples/defaultExport.js ================================================ // example from http://jsmodules.io var asap; var isNode = typeof process !== "undefined" && {}.toString.call(process) === "[object process]"; if (isNode) { asap = process.nextTick; } else if (typeof setImmediate !== "undefined") { asap = setImmediate; } else { asap = setTimeout; } export default asap; ================================================ FILE: comparison/samples/defaultImport.js ================================================ // example from http://jsmodules.io import asap from "asap"; asap(function() { console.log("hello async world!"); }); ================================================ FILE: comparison/samples/groupedExports.js ================================================ // example from http://jsmodules.io export { getJSON, postJSON, animate }; function getJSON() { // implementation } function postJSON() { // implementation } function animate() { // implementation } ================================================ FILE: comparison/samples/inlineNamedExports.js ================================================ // example from http://jsmodules.io // exports this function as "requestAnimationFrame" export function requestAnimationFrame() { // cross-browser requestAnimationFrame } // exports document.location as "location" export var location = document.location; ================================================ FILE: comparison/samples/mixedImports.js ================================================ // example from http://jsmodules.io import asap, { later } from "asap"; ================================================ FILE: comparison/samples/namedExports.js ================================================ // example from http://jsmodules.io var asap; var isNode = typeof process !== "undefined" && {}.toString.call(process) === "[object process]"; if (isNode) { asap = process.nextTick; } else if (typeof setImmediate !== "undefined") { asap = setImmediate; } else { asap = setTimeout; } export default asap; export var later = isNode ? process.setImmediate : asap; ================================================ FILE: comparison/samples/namedImports.js ================================================ // example from http://jsmodules.io import { later } from "asap"; later(function() { console.log("Running after other network events"); }); ================================================ FILE: comparison/samples/renamingImports.js ================================================ // example from http://jsmodules.io import { unlink as rm } from "fs"; rm(filename, function(err) { /* check errors */ }); ================================================ FILE: gobblefile.js ================================================ var gobble = require( 'gobble' ); var path = require( 'path' ); var resolve = require( 'resolve' ); var Promise = require( 'sander' ).Promise; gobble.cwd( __dirname ); var banner = require( 'fs' ).readFileSync( __dirname + '/src/banner.js', 'utf-8' ) .replace( '${VERSION}', require( './package.json' ).version ) .replace( '${TODAY}', today() ); var es5 = gobble( 'src' ).transform( 'babel' ); var node = es5 .transform( 'esperanto-bundle', { entry: 'esperanto', type: 'cjs', banner: banner, strict: true, sourceMap: true }); var browser = es5 .transform( 'esperanto-bundle', { entry: 'esperanto', dest: 'esperanto.browser.js', type: 'umd', name: 'esperanto', skip: [ 'bundler/getBundle' ], banner: banner, strict: true, sourceMap: true, // bundle magic-string and its dependency, vlq resolvePath: function ( importee, importer ) { return new Promise( function ( fulfil, reject ) { var callback = function ( err, result ) { if ( err ) { reject( err ); } else { fulfil( result ); } }; resolve( importee, { basedir: path.dirname( importer ), packageFilter: function ( pkg ) { if ( pkg[ 'jsnext:main' ] ) { pkg.main = pkg[ 'jsnext:main' ]; return pkg; } var err = new Error( 'package ' + pkg.name + ' does not supply a jsnext:main field' ); err.code = 'ENOENT'; // hack reject( err ); return {}; } }, callback ); }); } }); module.exports = gobble([ node, browser ]); function today () { var d = new Date(); return [ d.getFullYear(), pad( d.getMonth() + 1 ), pad( d.getDate() ) ].join( '-' ); } function pad ( num ) { return num < 10 ? '0' + num : num; } ================================================ FILE: package.json ================================================ { "name": "esperanto", "description": "An easier way to convert ES6 modules to AMD and CommonJS", "version": "0.7.6", "author": "Rich Harris", "repository": "https://github.com/esperantojs/esperanto", "license": "MIT", "dependencies": { "acorn": "^1.0.1", "chalk": "^1.0.0", "magic-string": "^0.4.9", "minimist": "^1.1.0", "sander": "^0.5.1" }, "main": "dist/esperanto.js", "jsnext:main": "src/esperanto.js", "bin": { "esperanto": "./bin/index.js" }, "devDependencies": { "gobble": "^0.7.2", "gobble-babel": "^5.1.0", "gobble-cli": "^0.4.2", "gobble-esperanto-bundle": "^0.2.0", "gobble-uglifyjs": "^0.1.0", "magic-string": "^0.6.0", "mocha": "^2.1.0", "resolve": "^1.1.0", "source-map": "^0.1.40", "source-map-support": "^0.2.10" }, "files": [ "esperanto.js", "src", "dist", "bin", "README.md" ], "scripts": { "build": "gobble build -f dist", "pretest": "npm run build", "test": "mocha", "prepublish": "npm test" } } ================================================ FILE: src/banner.js ================================================ /* esperanto.js v${VERSION} - ${TODAY} http://esperantojs.org Released under the MIT License. */ ================================================ FILE: src/bundler/builders/concat.js ================================================ import packageResult from 'utils/packageResult'; export default function concat ( bundle, options ) { // This bundle must be self-contained - no imports or exports if ( bundle.externalModules.length || bundle.entryModule.exports.length ) { throw new Error( `bundle.concat() can only be used with bundles that have no imports/exports (imports: [${bundle.externalModules.map(x=>x.id).join(', ')}], exports: [${bundle.entryModule.exports.join(', ')}])` ); } // TODO test these options let intro = 'intro' in options ? options.intro : `(function () { 'use strict';\n\n`; let outro = 'outro' in options ? options.outro : '\n\n})();'; let indent; if ( !( 'indent' in options ) || options.indent === true ) { indent = bundle.body.getIndentString(); } else { indent = options.indent || ''; } bundle.body.trimLines().indent( indent ).prepend( intro ).append( outro ); return packageResult( bundle, bundle.body, options, 'toString', true ); } ================================================ FILE: src/bundler/builders/defaultsMode/amd.js ================================================ import packageResult from '../../../utils/packageResult'; import amdIntro from '../../../utils/amd/amdIntro'; export default function amd ( bundle, options ) { let defaultName = bundle.entryModule.identifierReplacements.default; if ( defaultName ) { bundle.body.append( `\n\nreturn ${defaultName};` ); } let intro = amdIntro({ name: options.amdName, imports: bundle.externalModules, indentStr: bundle.body.getIndentString(), useStrict: options.useStrict !== false }); bundle.body.indent().prepend( intro ).trimLines().append( '\n\n});' ); return packageResult( bundle, bundle.body, options, 'toAmd', true ); } ================================================ FILE: src/bundler/builders/defaultsMode/cjs.js ================================================ import packageResult from 'utils/packageResult'; import { req } from 'utils/mappers'; export default function cjs ( bundle, options ) { let importBlock = bundle.externalModules.map( x => { return `var ${x.name} = ${req(x.id)};`; }).join( '\n' ); if ( importBlock ) { bundle.body.prepend( importBlock + '\n\n' ); } let defaultName = bundle.entryModule.identifierReplacements.default; if ( defaultName ) { bundle.body.append( `\n\nmodule.exports = ${defaultName};` ); } if ( options.useStrict !== false ) { bundle.body.prepend("'use strict';\n\n").trimLines(); } return packageResult( bundle, bundle.body, options, 'toCjs', true ); } ================================================ FILE: src/bundler/builders/defaultsMode/index.js ================================================ import amd from './amd'; import cjs from './cjs'; import umd from './umd'; export default { amd: amd, cjs: cjs, umd: umd }; ================================================ FILE: src/bundler/builders/defaultsMode/umd.js ================================================ import packageResult from 'utils/packageResult'; import umdIntro from 'utils/umd/umdIntro'; import requireName from 'utils/umd/requireName'; export default function umd ( bundle, options ) { requireName( options ); let entry = bundle.entryModule; let intro = umdIntro({ hasExports: entry.exports.length > 0, imports: bundle.externalModules, amdName: options.amdName, name: options.name, indentStr: bundle.body.getIndentString(), useStrict: options.useStrict !== false }); if ( entry.defaultExport ) { bundle.body.append( `\n\nreturn ${entry.identifierReplacements.default};` ); } bundle.body.indent().prepend( intro ).trimLines().append('\n\n}));'); return packageResult( bundle, bundle.body, options, 'toUmd', true ); } ================================================ FILE: src/bundler/builders/index.js ================================================ // TODO rewrite with named imports/exports import defaultsMode from './defaultsMode'; import strictMode from './strictMode'; export default { defaultsMode: defaultsMode, strictMode: strictMode }; ================================================ FILE: src/bundler/builders/strictMode/amd.js ================================================ import packageResult from '../../../utils/packageResult'; import amdIntro from '../../../utils/amd/amdIntro'; import getExportBlock from './utils/getExportBlock'; export default function amd ( bundle, options ) { let externalDefaults = bundle.externalModules.filter( needsDefault ); let entry = bundle.entryModule; if ( externalDefaults.length ) { let defaultsBlock = externalDefaults.map( x => { // Case 1: default is used, and named is not if ( !x.needsNamed ) { return `${x.name} = ('default' in ${x.name} ? ${x.name}['default'] : ${x.name});`; } // Case 2: both default and named are used return `var ${x.name}__default = ('default' in ${x.name} ? ${x.name}['default'] : ${x.name});`; }).join( '\n' ); bundle.body.prepend( defaultsBlock + '\n\n' ); } if ( entry.defaultExport ) { bundle.body.append( '\n\n' + getExportBlock( entry ) ); } let intro = amdIntro({ name: options.amdName, imports: bundle.externalModules, hasExports: entry.exports.length, indentStr: bundle.body.getIndentString(), useStrict: options.useStrict !== false }); bundle.body.indent().prepend( intro ).trimLines().append( '\n\n});' ); return packageResult( bundle, bundle.body, options, 'toAmd', true ); } function needsDefault ( externalModule ) { return externalModule.needsDefault; } ================================================ FILE: src/bundler/builders/strictMode/cjs.js ================================================ import packageResult from 'utils/packageResult'; import getExportBlock from './utils/getExportBlock'; import { req } from 'utils/mappers'; export default function cjs ( bundle, options ) { let entry = bundle.entryModule; let importBlock = bundle.externalModules.map( x => { let statement = `var ${x.name} = ${req(x.id)};`; if ( x.needsDefault ) { statement += '\n' + ( x.needsNamed ? `var ${x.name}__default` : x.name ) + ` = ('default' in ${x.name} ? ${x.name}['default'] : ${x.name});`; } return statement; }).join( '\n' ); if ( importBlock ) { bundle.body.prepend( importBlock + '\n\n' ); } if ( entry.defaultExport ) { bundle.body.append( '\n\n' + getExportBlock( entry ) ); } if ( options.useStrict !== false ) { bundle.body.prepend("'use strict';\n\n").trimLines(); } return packageResult( bundle, bundle.body, options, 'toCjs', true ); } ================================================ FILE: src/bundler/builders/strictMode/index.js ================================================ import amd from './amd'; import cjs from './cjs'; import umd from './umd'; export default { amd: amd, cjs: cjs, umd: umd }; ================================================ FILE: src/bundler/builders/strictMode/umd.js ================================================ import umdIntro from 'utils/umd/umdIntro'; import requireName from 'utils/umd/requireName'; import packageResult from 'utils/packageResult'; import getExportBlock from './utils/getExportBlock'; export default function umd ( bundle, options ) { requireName( options ); let entry = bundle.entryModule; let intro = umdIntro({ hasExports: entry.exports.length > 0, imports: bundle.externalModules, externalDefaults: bundle.externalModules.filter( needsDefault ), amdName: options.amdName, name: options.name, indentStr: bundle.body.getIndentString(), strict: true, useStrict: options.useStrict !== false }); if ( entry.defaultExport ) { bundle.body.append( '\n\n' + getExportBlock( entry ) ); } bundle.body.indent().prepend( intro ).trimLines().append('\n\n}));'); return packageResult( bundle, bundle.body, options, 'toUmd', true ); } function needsDefault ( externalModule ) { return externalModule.needsDefault; } ================================================ FILE: src/bundler/builders/strictMode/utils/getExportBlock.js ================================================ export default function getExportBlock ( entry ) { let name = entry.identifierReplacements.default; return `exports['default'] = ${name};`; } ================================================ FILE: src/bundler/combine/getRenamedImports.js ================================================ export default function getRenamedImports ( mod ) { let renamed = []; mod.imports.forEach( x => { if ( x.specifiers ) { x.specifiers.forEach( s => { if ( s.name !== s.as && !~renamed.indexOf( s.name ) ) { renamed.push( s.name ); } }); } }); return renamed; } ================================================ FILE: src/bundler/combine/index.js ================================================ import MagicString from 'magic-string'; import populateModuleNames from './populateModuleNames'; import populateExternalModuleImports from './populateExternalModuleImports'; import populateIdentifierReplacements from './populateIdentifierReplacements'; import resolveExports from './resolveExports'; import transformBody from './transformBody'; export default function combine ( bundle ) { bundle.body = new MagicString.Bundle({ separator: '\n\n' }); // give each module in the bundle a unique name populateModuleNames( bundle ); // determine which specifiers are imported from // external modules populateExternalModuleImports( bundle ); // determine which identifiers need to be replaced // inside this bundle populateIdentifierReplacements( bundle ); bundle.exports = resolveExports( bundle ); bundle.modules.forEach( mod => { // verify that this module doesn't import non-exported identifiers mod.imports.forEach( x => { const imported = x.module; if ( imported.isExternal || imported.isSkipped || x.isBatch ) { return; } x.specifiers.forEach( s => { if ( !imported.doesExport[ s.name ] ) { throw new Error( `Module '${imported.id}' does not export '${s.name}' (imported by '${mod.id}')` ); } }); }); bundle.body.addSource({ filename: mod.path, content: transformBody( bundle, mod, mod.body ), indentExclusionRanges: mod.ast._templateLiteralRanges }); }); } ================================================ FILE: src/bundler/combine/populateExternalModuleImports.js ================================================ export default function populateExternalModuleImports ( bundle ) { bundle.modules.forEach( mod => { mod.imports.forEach( x => { const externalModule = x.module; if ( !externalModule.isExternal ) { return; } x.specifiers.forEach( s => { if ( s.isDefault ) { externalModule.needsDefault = true; } else { externalModule.needsNamed = true; } }); }); }); } ================================================ FILE: src/bundler/combine/populateIdentifierReplacements.js ================================================ import hasOwnProp from 'utils/hasOwnProp'; import topLevelScopeConflicts from './topLevelScopeConflicts'; /** * Figures out which identifiers need to be rewritten within a bundle to avoid conflicts * @param {object} bundle - the bundle * @returns {object} */ export default function populateIdentifierReplacements ( bundle ) { // first, discover conflicts let conflicts = topLevelScopeConflicts( bundle ); // then figure out what identifiers need to be created // for default exports bundle.modules.forEach( mod => { let x = mod.defaultExport; if ( x ) { let result; if ( x.hasDeclaration && x.name ) { result = hasOwnProp.call( conflicts, x.name ) || otherModulesDeclare( mod, x.name ) ? `${mod.name}__${x.name}` : x.name; } else { result = hasOwnProp.call( conflicts, mod.name ) || ( x.value !== mod.name && ~mod.ast._topLevelNames.indexOf( mod.name )) || otherModulesDeclare( mod, mod.name ) ? `${mod.name}__default` : mod.name; } mod.identifierReplacements.default = result; } }); // then determine which existing identifiers // need to be replaced bundle.modules.forEach( mod => { let moduleIdentifiers = mod.identifierReplacements; mod.ast._topLevelNames.forEach( n => { moduleIdentifiers[n] = hasOwnProp.call( conflicts, n ) ? `${mod.name}__${n}` : n; }); mod.imports.forEach( x => { if ( x.passthrough ) { return; } const imported = x.module; x.specifiers.forEach( s => { let replacement; if ( s.isBatch ) { replacement = x.module.name; } else { let mod; let specifierName; if ( s.origin ) { // chained bindings mod = s.origin.module; specifierName = s.origin.name; } else { mod = imported; specifierName = s.name; } const moduleName = mod && mod.name; if ( specifierName === 'default' ) { // if it's an external module, always use __default if the // bundle also uses named imports if ( imported.isExternal ) { replacement = imported.needsNamed ? `${moduleName}__default` : moduleName; } // TODO We currently need to check for the existence of `mod`, because modules // can be skipped. Would be better to replace skipped modules with dummies // - see https://github.com/Rich-Harris/esperanto/issues/32 else if ( mod && !mod.isSkipped ) { replacement = mod.identifierReplacements.default; } } else if ( !imported.isExternal ) { replacement = hasOwnProp.call( conflicts, specifierName ) ? `${moduleName}__${specifierName}` : specifierName; } else { replacement = moduleName + '.' + specifierName; } } if ( replacement !== s.as ) { moduleIdentifiers[ s.as ] = replacement; } }); }); }); function otherModulesDeclare ( mod, replacement ) { var i, otherMod; i = bundle.modules.length; while ( i-- ) { otherMod = bundle.modules[i]; if ( mod === otherMod ) { continue; } if ( hasOwnProp.call( otherMod.ast._declared, replacement ) ) { return true; } } } } ================================================ FILE: src/bundler/combine/populateModuleNames.js ================================================ import hasOwnProp from 'utils/hasOwnProp'; import builtins from 'utils/builtins'; import { default as sanitize, splitPath } from 'utils/sanitize'; export default function getUniqueNames ( bundle ) { let { modules, externalModules } = bundle; let userNames = bundle.names; let names = {}; let used = modules.reduce( ( declared, mod ) => { const defaultExport = mod.defaultExport; const defaultExportName = defaultExport && !defaultExport.unsafe && defaultExport.type === 'expression' && defaultExport.node.declaration && defaultExport.node.declaration.type === 'Identifier' && defaultExport.node.declaration.name; Object.keys( mod.ast._declared ).forEach( x => { // special case - `export default foo` if ( x === defaultExportName ) return; declared[x] = true; }); return declared; }, {} ); // copy builtins builtins.forEach( n => used[n] = true ); // copy user-specified names if ( userNames ) { Object.keys( userNames ).forEach( id => { names[ id ] = userNames[ id ]; used[ userNames[ id ] ] = true; }); } // infer names from default imports - e.g. with `import _ from './utils'`, // use '_' instead of generating a name from 'utils' function inferName ( x ) { if ( x.isDefault && !hasOwnProp.call( names, x.module.id ) && !hasOwnProp.call( used, x.as ) ) { names[ x.module.id ] = x.as; used[ x.as ] = true; } } modules.forEach( mod => { mod.imports.forEach( inferName ); }); // for the rest, make names as compact as possible without // introducing conflicts modules.concat( externalModules ).forEach( mod => { // is this already named? if ( hasOwnProp.call( names, mod.id ) ) { mod.name = names[ mod.id ]; return; } let name; let parts = splitPath( mod.id ); let i = parts.length; while ( i-- ) { name = sanitize( parts.slice( i ).join( '_' ) ); if ( !hasOwnProp.call( used, name ) ) { break; } } while ( hasOwnProp.call( used, name ) ) { name = '_' + name; } used[ name ] = true; mod.name = name; }); return names; } ================================================ FILE: src/bundler/combine/resolveExports.js ================================================ export default function resolveExports ( bundle ) { let bundleExports = {}; bundle.entryModule.exports.forEach( x => { if ( x.specifiers ) { x.specifiers.forEach( s => { let module; let name; if ( s.origin ) { module = s.origin.module; name = s.origin.name; } else { module = bundle.entryModule; name = s.name; } addExport( module, name, s.as ); }); } else if ( !x.isDefault && x.name ) { addExport( bundle.entryModule, x.name, x.name ); } }); function addExport ( module, name, as ) { if ( !bundleExports[ module.id ] ) { bundleExports[ module.id ] = {}; } bundleExports[ module.id ][ name ] = as; } return bundleExports; } ================================================ FILE: src/bundler/combine/topLevelScopeConflicts.js ================================================ import hasOwnProp from 'utils/hasOwnProp'; import builtins from 'utils/builtins'; import getUnscopedNames from 'utils/ast/getUnscopedNames'; import { getName } from 'utils/mappers'; import getRenamedImports from './getRenamedImports'; export default function topLevelScopeConflicts ( bundle ) { let conflicts = {}; let inBundle = {}; let importNames = bundle.externalModules.map( getName ); bundle.modules.forEach( mod => { let names = builtins // all top defined identifiers are in top scope .concat( mod.ast._topLevelNames ) // all unattributed identifiers could collide with top scope .concat( getUnscopedNames( mod ) ) .concat( importNames ) .concat( getRenamedImports( mod ) ); if ( mod._exportsNamespace ) { conflicts[ mod.name ] = true; } // merge this module's top scope with bundle top scope names.forEach( name => { if ( hasOwnProp.call( inBundle, name ) ) { conflicts[ name ] = true; } else { inBundle[ name ] = true; } }); }); return conflicts; } ================================================ FILE: src/bundler/combine/transformBody.js ================================================ import hasOwnProp from 'utils/hasOwnProp'; import getReadOnlyIdentifiers from 'utils/getReadOnlyIdentifiers'; import traverseAst from 'utils/ast/traverse'; export default function transformBody ( bundle, mod, body ) { let identifierReplacements = mod.identifierReplacements; let [ importedBindings, importedNamespaces ] = getReadOnlyIdentifiers( mod.imports ); let exportNames = hasOwnProp.call( bundle.exports, mod.id ) && bundle.exports[ mod.id ]; traverseAst( mod.ast, body, identifierReplacements, importedBindings, importedNamespaces, exportNames ); // Remove import statements mod.imports.forEach( x => { if ( !x.passthrough ) { body.remove( x.start, x.next ); } }); let shouldExportEarly = {}; // Remove export statements mod.exports.forEach( x => { var name; if ( x.isDefault ) { if ( x.type === 'namedFunction' || x.type === 'namedClass' ) { // if you have a default export like // // export default function foo () {...} // // you need to rewrite it as // // function foo () {...} // exports.default = foo; // // as the `foo` reference may be used elsewhere // remove the `export default `, keep the rest body.remove( x.start, x.valueStart ); } else if ( x.node.declaration && ( name = x.node.declaration.name ) ) { if ( name === identifierReplacements.default ) { body.remove( x.start, x.end ); } else { let original = hasOwnProp.call( identifierReplacements, name ) ? identifierReplacements[ name ] : name; body.replace( x.start, x.end, `var ${identifierReplacements.default} = ${original};` ); } } else { body.replace( x.start, x.valueStart, `var ${identifierReplacements.default} = ` ); } return; } if ( x.hasDeclaration ) { if ( x.type === 'namedFunction' ) { shouldExportEarly[ x.name ] = true; // TODO what about `function foo () {}; export { foo }`? } body.remove( x.start, x.valueStart ); } else { body.remove( x.start, x.next ); } }); // If this module exports a namespace - i.e. another module does // `import * from 'foo'` - then we need to make all this module's // exports available, using Object.defineProperty var indentStr = body.getIndentString(); if ( mod._exportsNamespace ) { let namespaceExportBlock = `var ${mod.name} = {\n`, namespaceExports = []; mod.exports.forEach( x => { if ( x.hasDeclaration ) { namespaceExports.push( indentStr + `get ${x.name} () { return ${identifierReplacements[x.name]}; }` ); } else if ( x.isDefault ) { namespaceExports.push( indentStr + `get default () { return ${identifierReplacements.default}; }` ); } else { x.specifiers.forEach( s => { let original = hasOwnProp.call( identifierReplacements, s.name ) ? identifierReplacements[ s.name ] : s.name; namespaceExports.push( indentStr + `get ${s.as} () { return ${original}; }` ); }); } }); namespaceExportBlock += namespaceExports.join( ',\n' ) + '\n};\n\n'; body.prepend( namespaceExportBlock ); } // If this module is responsible for one of the bundle's exports // (it doesn't have to be the entry module, which could re-export // a binding from another module), we write exports here if ( exportNames ) { let exportBlock = []; Object.keys( exportNames ).forEach( name => { var exportAs = exportNames[ name ]; exportBlock.push( `exports.${exportAs} = ${identifierReplacements[name]};` ); }); if ( exportBlock.length ) { body.trim().append( '\n\n' + exportBlock.join( '\n' ) ); } } return body.trim(); } ================================================ FILE: src/bundler/getBundle.js ================================================ import { relative, resolve, sep } from 'path'; import hasOwnProp from 'utils/hasOwnProp'; import resolveId from 'utils/resolveId'; import promiseSequence from 'utils/promiseSequence'; import sortModules from './utils/sortModules'; import resolveChains from './utils/resolveChains'; import combine from './combine'; import { readFile, stat, Promise } from 'sander'; import getModule from './getModule'; export default function getBundle ( options ) { let entry = options.entry.replace( /\.js$/, '' ); let userModules = options.modules || {}; let modules = []; let moduleLookup = {}; let promiseByPath = {}; let skip = options.skip; let names = options.names; let base = ( options.base ? resolve( options.base ) : process.cwd() ) + '/'; let externalModules = []; let externalModuleLookup = {}; if ( !entry.indexOf( base ) ) { entry = entry.substring( base.length ); } // resolve user module paths options.modules && Object.keys( options.modules ).forEach( relativePath => { userModules[ resolve( base, relativePath ) ] = options.modules[ relativePath ]; }); let cyclicalModules = []; return resolvePath( base, userModules, entry, null ).then( absolutePath => { return fetchModule( entry, absolutePath ).then( entryModule => { return Promise.all( cyclicalModules ).then( () => { // if the bundle contains cyclical modules, // we may need to sort it again if ( cyclicalModules.length ) { modules = sortModules( entryModule ); } let bundle = { entryModule, modules, externalModules, names }; resolveChains( modules, moduleLookup ); combine( bundle ); return bundle; }); }); }, function ( err ) { if ( err.code === 'ENOENT' ) { throw new Error( 'Could not find entry module (' + entry + ')' ); } throw err; }); function fetchModule ( moduleId, absolutePath ) { if ( !hasOwnProp.call( promiseByPath, absolutePath ) ) { promiseByPath[ absolutePath ] = ( hasOwnProp.call( userModules, absolutePath ) ? Promise.resolve( userModules[ absolutePath ] ) : readFile( absolutePath ).then( String ) ).then( function ( source ) { let code, ast; // normalise if ( typeof source === 'object' ) { code = source.code; ast = source.ast; } else { code = source; ast = null; } if ( options.transform ) { code = options.transform( code, absolutePath ); if ( typeof code !== 'string' && !isThenable( code ) ) { throw new Error( 'transform should return String or Promise' ); } } let module = getModule({ id: moduleId, path: absolutePath, code, ast }); moduleLookup[ moduleId ] = module; return promiseSequence( module.imports, x => { const id = resolveId( x.path, module.path ).replace( base.replace(/\\/g, '/'), '' ); if ( id === moduleId ) { throw new Error( `A module (${moduleId}) cannot import itself` ); } // Some modules can be skipped if ( skip && ~skip.indexOf( id ) ) { const skippedModule = { id, isSkipped: true }; x.module = skippedModule; return skippedModule; } return resolvePath( base, userModules, id, absolutePath, options.resolvePath ).then( absolutePath => { let promise = hasOwnProp.call( promiseByPath, absolutePath ) && promiseByPath[ absolutePath ]; let cyclical = !!promise; if ( cyclical ) { // ensure all modules are set before we // create the bundle... cyclicalModules.push( promise.then( module => x.module = module ) ); // ...then short-circuit return; } return fetchModule( id, absolutePath ).then( module => x.module = module ); }, function handleError ( err ) { if ( err.code === 'ENOENT' ) { // Most likely an external module let externalModule = hasOwnProp.call( externalModuleLookup, id ) && externalModuleLookup[ id ]; if ( !externalModule ) { externalModule = { id, isExternal: true }; externalModules.push( externalModule ); externalModuleLookup[ id ] = externalModule; } x.module = externalModule; } else { throw err; } } ); }) .then( () => modules.push( module ) ) .then( () => module ); }); } return promiseByPath[ absolutePath ]; } } function resolvePath ( base, userModules, moduleId, importerPath, resolver ) { const noExt = moduleId.replace( /\.js$/, '' ); return tryPath( base, noExt + '.js', userModules ) .catch( () => tryPath( base, noExt + sep + 'index.js', userModules ) ) .catch( function ( err ) { const resolvedPromise = resolver && Promise.resolve( resolver( moduleId, importerPath ) ); if ( resolvedPromise ) { return resolvedPromise.then( resolvedPath => { if ( !resolvedPath ) { // hack but whatevs, it saves handling real ENOENTs differently let err = new Error(); err.code = 'ENOENT'; throw err; } return stat( resolvedPath ).then( () => resolve( base, resolvedPath ) ); }); } else { throw err; } }); } function tryPath ( base, filename, userModules ) { const absolutePath = resolve( base, filename ); if ( hasOwnProp.call( userModules, absolutePath ) ) { return Promise.resolve( absolutePath ); } return stat( absolutePath ).then( () => absolutePath ); } function isThenable ( obj ) { return obj && typeof obj.then === 'function'; } ================================================ FILE: src/bundler/getModule.js ================================================ import { parse } from 'acorn'; import MagicString from 'magic-string'; import findImportsAndExports from 'utils/ast/findImportsAndExports'; import annotateAst from 'utils/ast/annotate'; import disallowConflictingImports from '../utils/disallowConflictingImports'; export default function getModule ( mod ) { mod.body = new MagicString( mod.code ); let toRemove = []; let comments = []; try { mod.ast = mod.ast || ( parse( mod.code, { ecmaVersion: 6, sourceType: 'module', onComment ( block, text, start, end ) { // sourceMappingURL comments should be removed if ( !block && /^# sourceMappingURL=/.test( text ) ) { toRemove.push({ start, end }); } else { comments.push({ start, end }); } } })); } catch ( err ) { // If there's a parse error, attach file info // before throwing the error if ( err.loc ) { err.file = mod.path; } throw err; } // remove sourceMappingURL comments toRemove.forEach( ({ start, end }) => mod.body.remove( start, end ) ); let { imports, exports, defaultExport } = findImportsAndExports( mod.ast, mod.code, comments ); disallowConflictingImports( imports ); mod.imports = imports; mod.exports = exports; mod.defaultExport = defaultExport; const defaultExportIdentifier = defaultExport && defaultExport.type === 'expression' && defaultExport.node.declaration && defaultExport.node.declaration.type === 'Identifier' && defaultExport.node.declaration; // if the default export is an expression like `export default foo`, we // can *probably* just use `foo` to refer to said export throughout the // bundle. Tracking assignments to `foo` allows us to be sure that that's // the case (i.e. that the module doesn't assign a different value to foo // after it's been exported) annotateAst( mod.ast, { trackAssignments: defaultExportIdentifier }); if ( defaultExportIdentifier && defaultExportIdentifier._assignments ) { let i = defaultExportIdentifier._assignments.length; while ( i-- ) { const assignment = defaultExportIdentifier._assignments[i]; // if either a) the assignment happens inside a function body, or // b) it happens after the `export default ...`, then it's unsafe to // use the identifier, and we need to essentially do `var _foo = foo` if ( assignment.scope.parent || assignment.node.start > defaultExport.start ) { defaultExport.unsafe = true; // TODO better property name than 'unsafe' break; } } } // identifiers to replace within this module // (gets filled in later, once bundle is combined) mod.identifierReplacements = {}; // collect exports by name, for quick lookup when verifying // that this module exports a given identifier mod.doesExport = {}; exports.forEach( x => { if ( x.isDefault ) { mod.doesExport.default = true; } else if ( x.name ) { mod.doesExport[ x.name ] = true; } else if ( x.specifiers ) { x.specifiers.forEach( s => { mod.doesExport[ s.as ] = true; }); } else { throw new Error( 'Unexpected export type' ); } }); return mod; } ================================================ FILE: src/bundler/utils/resolveChains.js ================================================ import hasOwnProp from 'utils/hasOwnProp'; /** * Discovers 'chains' within a bundle - e.g. `import { foo } from 'foo'` may be equivalent to `import { bar } from 'bar'`, if foo.js imports `bar` and re-exports it as `foo`. Where applicable, import/export specifiers are augmented with an `origin: { module, name }` property * @param {array} modules - the bundle's array of modules * @param {object} moduleLookup - modules indexed by their ID */ export default function resolveChains ( modules, moduleLookup ) { let chains = {}; // First pass - resolving intra-module chains modules.forEach( mod => { var origin = {}; mod.imports.forEach( x => { const imported = x.module; x.specifiers.forEach( s => { if ( s.isBatch ) { // tell that module that it needs to export an object full of getters imported._exportsNamespace = true; return; // TODO can batch imports be chained? } origin[ s.as ] = `${s.name}@${imported.id}`; }); }); mod.exports.forEach( x => { if ( !x.specifiers ) return; x.specifiers.forEach( s => { if ( hasOwnProp.call( origin, s.name ) ) { chains[ `${s.as}@${mod.id}` ] = origin[ s.name ]; } else if ( s.as !== s.name ) { chains[ `${s.as}@${mod.id}` ] = `${s.name}@${mod.id}`; } }); }); }); // Second pass - assigning origins to specifiers modules.forEach( mod => { mod.imports.forEach( x => { const imported = x.module; x.specifiers.forEach( s => { if ( s.isBatch ) { return; // TODO can batch imports be chained? } setOrigin( s, `${s.name}@${imported.id}`, chains, moduleLookup ); }); }); mod.exports.forEach( x => { if ( !x.specifiers ) return; x.specifiers.forEach( s => { setOrigin( s, `${s.as}@${mod.id}`, chains, moduleLookup ); }); }); }); } function setOrigin ( specifier, hash, chains, moduleLookup ) { let isChained; while ( hasOwnProp.call( chains, hash ) ) { hash = chains[ hash ]; isChained = true; } if ( isChained ) { const [ name, moduleId ] = hash.split( '@' ); specifier.origin = { module: moduleLookup[ moduleId ], name }; } } ================================================ FILE: src/bundler/utils/sortModules.js ================================================ import hasOwnProp from 'utils/hasOwnProp'; import walk from 'utils/ast/walk'; /** * Sorts an array of modules such that dependencies come before their dependents, handling complex cases of cyclical dependencies * @param {object} entry - the bundle's 'entry module' * @returns {array} - the sorted module list */ export default function sortModules ( entry ) { let seen = {}; let ordered = []; let hasCycles; let strongDeps = {}; let stronglyDependsOn = {}; function visit ( mod ) { const { id } = mod; seen[ id ] = true; strongDeps[ id ] = []; stronglyDependsOn[ id ] = {}; mod.imports.forEach( x => { const imported = x.module; if ( imported.isExternal || imported.isSkipped ) return; // if `mod` references a binding from `imported` at the top // level (i.e. outside function bodies), we say that `mod` // strongly depends on `imported. If two modules depend on // each other, this helps us order them such that if a // strongly depends on b, and b weakly depends on a, b // goes first if ( referencesAtTopLevel( mod, imported ) ) { strongDeps[ id ].push( imported ); } if ( hasOwnProp.call( seen, imported.id ) ) { // we need to prevent an infinite loop, and note that // we need to check for strong/weak dependency relationships hasCycles = true; return; } visit( imported ); }); // add second (and third...) order dependencies function addStrongDependencies ( dependency ) { if ( hasOwnProp.call( stronglyDependsOn[ id ], dependency.id ) ) return; stronglyDependsOn[ id ][ dependency.id ] = true; strongDeps[ dependency.id ].forEach( addStrongDependencies ); } strongDeps[ id ].forEach( addStrongDependencies ); ordered.push( mod ); } visit( entry ); let unordered; if ( hasCycles ) { unordered = ordered; ordered = []; // unordered is actually semi-ordered, as [ fewer dependencies ... more dependencies ] unordered.forEach( x => { // ensure strong dependencies of x that don't strongly depend on x go first strongDeps[ x.id ].forEach( place ); function place ( dep ) { if ( !stronglyDependsOn[ dep.id ][ x.id ] && !~ordered.indexOf( dep ) ) { strongDeps[ dep.id ].forEach( place ); ordered.push( dep ); } } if ( !~ordered.indexOf( x ) ) { ordered.push( x ); } }); } return ordered; } function referencesAtTopLevel ( a, b ) { let bindings = []; // find out which bindings a imports from b let i = a.imports.length; while ( i-- ) { if ( a.imports[i].module === b ) { bindings.push.apply( bindings, a.imports[i].specifiers.map( x => x.as ) ); } } // see if any of those bindings are referenced at the top level let referencedAtTopLevel = false; walk( a.ast, { enter ( node ) { if ( /^Import/.test( node.type ) || ( node._scope && node._scope.parent ) ) { return this.skip(); } if ( node.type === 'Identifier' && ~bindings.indexOf( node.name ) ) { referencedAtTopLevel = true; this.abort(); } } }); return referencedAtTopLevel; } ================================================ FILE: src/esperanto.js ================================================ import chalk from 'chalk'; import hasNamedImports from 'utils/hasNamedImports'; import hasNamedExports from 'utils/hasNamedExports'; import getStandaloneModule from 'standalone/getModule'; import getBundle from 'bundler/getBundle'; import moduleBuilders from 'standalone/builders'; import bundleBuilders from 'bundler/builders'; import concat from 'bundler/builders/concat'; import { getName } from 'utils/mappers'; let deprecateMessages = { defaultOnly: 'options.defaultOnly has been deprecated, and is now standard behaviour. To use named imports/exports, pass `strict: true`.', standalone: chalk.red.bold( '[DEPRECATION NOTICE] Esperanto is no longer under active development. To convert an ES6 module to another format, consider using Babel (https://babeljs.io)' ), bundle: chalk.red.bold( '[DEPRECATION NOTICE] Esperanto is no longer under active development. To bundle ES6 modules, consider using Rollup (https://github.com/rollup/rollup). See https://github.com/rollup/rollup/wiki/Migrating-from-Esperanto for help migrating' ) }; let alreadyWarned = { defaultOnly: false, standalone: false, bundle: false }; function transpileMethod ( format ) { if ( !alreadyWarned.standalone ) { console.error( deprecateMessages.standalone ); alreadyWarned.standalone = true; } return function ( source, options = {} ) { let mod = getStandaloneModule({ source, getModuleName: options.getModuleName, strict: options.strict }); if ( 'defaultOnly' in options && !alreadyWarned.defaultOnly ) { // TODO link to a wiki page explaining this, or something console.error( deprecateMessages.defaultOnly ); alreadyWarned.defaultOnly = true; } if ( options.absolutePaths && !options.amdName ) { throw new Error( 'You must specify an `amdName` in order to use the `absolutePaths` option' ); } let builder; if ( !options.strict ) { // ensure there are no named imports/exports. TODO link to a wiki page... if ( hasNamedImports( mod ) || hasNamedExports( mod ) ) { throw new Error( 'You must be in strict mode (pass `strict: true`) to use named imports or exports' ); } builder = moduleBuilders.defaultsMode[ format ]; } else { builder = moduleBuilders.strictMode[ format ]; } return builder( mod, options ); }; } export const toAmd = transpileMethod( 'amd' ); export const toCjs = transpileMethod( 'cjs' ); export const toUmd = transpileMethod( 'umd' ); export function bundle ( options ) { if ( !alreadyWarned.bundle ) { console.error( deprecateMessages.bundle ); alreadyWarned.bundle = true; } return getBundle( options ).then( function ( bundle ) { return { imports: bundle.externalModules.map( mod => mod.id ), exports: flattenExports( bundle.entryModule.exports ), toAmd: options => transpile( 'amd', options ), toCjs: options => transpile( 'cjs', options ), toUmd: options => transpile( 'umd', options ), concat: options => concat( bundle, options || {} ) }; function transpile ( format, options = {} ) { if ( 'defaultOnly' in options && !alreadyWarned.defaultOnly ) { // TODO link to a wiki page explaining this, or something console.error( deprecateMessages.defaultOnly ); alreadyWarned.defaultOnly = true; } let builder; if ( !options.strict ) { // ensure there are no named imports/exports if ( hasNamedExports( bundle.entryModule ) ) { throw new Error( 'Entry module can only have named exports in strict mode (pass `strict: true`)' ); } bundle.modules.forEach( mod => { mod.imports.forEach( x => { if ( x.module.isExternal && ( !x.isDefault && !x.isBatch ) ) { throw new Error( 'You can only have named external imports in strict mode (pass `strict: true`)' ); } }); }); builder = bundleBuilders.defaultsMode[ format ]; } else { builder = bundleBuilders.strictMode[ format ]; } return builder( bundle, options ); } }); } function flattenExports ( exports ) { let flattened = []; exports.forEach( x => { if ( x.isDefault ) { flattened.push( 'default' ); } else if ( x.name ) { flattened.push( x.name ); } else if ( x.specifiers ) { flattened.push.apply( flattened, x.specifiers.map( x => x.as ) ); } }); return flattened; } ================================================ FILE: src/standalone/builders/defaultsMode/amd.js ================================================ import transformExportDeclaration from './utils/transformExportDeclaration'; import packageResult from 'utils/packageResult'; import amdIntro from '../../../utils/amd/amdIntro'; export default function amd ( mod, options ) { mod.imports.forEach( x => { mod.body.remove( x.start, x.next ); }); transformExportDeclaration( mod.exports[0], mod.body ); let intro = amdIntro({ name: options.amdName, imports: mod.imports, absolutePaths: options.absolutePaths, indentStr: mod.body.getIndentString(), useStrict: options.useStrict !== false }); mod.body.trim() .indent() .prepend( intro ) .trim() .append( '\n\n});' ); return packageResult( mod, mod.body, options, 'toAmd' ); } ================================================ FILE: src/standalone/builders/defaultsMode/cjs.js ================================================ import hasOwnProp from 'utils/hasOwnProp'; import packageResult from 'utils/packageResult'; import { req } from 'utils/mappers'; export default function cjs ( mod, options ) { let seen = {}; mod.imports.forEach( x => { if ( !hasOwnProp.call( seen, x.path ) ) { let replacement = x.isEmpty ? `${req(x.path)};` : `var ${x.as} = ${req(x.path)};`; mod.body.replace( x.start, x.end, replacement ); seen[ x.path ] = true; } else { mod.body.remove( x.start, x.next ); } }); let exportDeclaration = mod.exports[0]; if ( exportDeclaration ) { switch ( exportDeclaration.type ) { case 'namedFunction': case 'namedClass': mod.body.remove( exportDeclaration.start, exportDeclaration.valueStart ); mod.body.replace( exportDeclaration.end, exportDeclaration.end, `\nmodule.exports = ${exportDeclaration.name};` ); break; default: mod.body.replace( exportDeclaration.start, exportDeclaration.valueStart, 'module.exports = ' ); break; } } if ( options.useStrict !== false ) { mod.body.prepend( "'use strict';\n\n" ).trimLines(); } return packageResult( mod, mod.body, options, 'toCjs' ); } ================================================ FILE: src/standalone/builders/defaultsMode/index.js ================================================ import amd from './amd'; import cjs from './cjs'; import umd from './umd'; export default { amd: amd, cjs: cjs, umd: umd }; ================================================ FILE: src/standalone/builders/defaultsMode/umd.js ================================================ import transformExportDeclaration from './utils/transformExportDeclaration'; import packageResult from 'utils/packageResult'; import umdIntro from 'utils/umd/umdIntro'; import requireName from 'utils/umd/requireName'; export default function umd ( mod, options ) { requireName( options ); mod.imports.forEach( x => { mod.body.remove( x.start, x.next ); }); let intro = umdIntro({ hasExports: mod.exports.length > 0, imports: mod.imports, amdName: options.amdName, absolutePaths: options.absolutePaths, name: options.name, indentStr: mod.body.getIndentString(), useStrict: options.useStrict !== false }); transformExportDeclaration( mod.exports[0], mod.body ); mod.body.indent().prepend( intro ).trimLines().append( '\n\n}));' ); return packageResult( mod, mod.body, options, 'toUmd' ); } ================================================ FILE: src/standalone/builders/defaultsMode/utils/transformExportDeclaration.js ================================================ export default function transformExportDeclaration ( declaration, body ) { if ( !declaration ) { return; } let exportedValue; switch ( declaration.type ) { case 'namedFunction': case 'namedClass': body.remove( declaration.start, declaration.valueStart ); exportedValue = declaration.name; break; case 'anonFunction': case 'anonClass': if ( declaration.isFinal ) { body.replace( declaration.start, declaration.valueStart, 'return ' ); } else { body.replace( declaration.start, declaration.valueStart, 'var __export = ' ); exportedValue = '__export'; } // add semi-colon, if necessary // TODO body.original is an implementation detail of magic-string - there // should probably be an API for this sort of thing if ( body.original[ declaration.end - 1 ] !== ';' ) { body.insert( declaration.end, ';' ); } break; case 'expression': body.remove( declaration.start, declaration.next ); exportedValue = declaration.value; break; default: throw new Error( `Unexpected export type '${declaration.type}'` ); } if ( exportedValue ) { body.append( `\nreturn ${exportedValue};` ); } } ================================================ FILE: src/standalone/builders/index.js ================================================ // TODO rewrite with named imports/exports import defaultsMode from './defaultsMode'; import strictMode from './strictMode'; export default { defaultsMode: defaultsMode, strictMode: strictMode }; ================================================ FILE: src/standalone/builders/strictMode/amd.js ================================================ import packageResult from '../../../utils/packageResult'; import transformBody from './utils/transformBody'; import amdIntro from '../../../utils/amd/amdIntro'; export default function amd ( mod, options ) { let intro = amdIntro({ name: options.amdName, absolutePaths: options.absolutePaths, imports: mod.imports, indentStr: mod.body.getIndentString(), hasExports: mod.exports.length, useStrict: options.useStrict !== false }); transformBody( mod, mod.body, { intro, outro: '\n\n});', _evilES3SafeReExports: options._evilES3SafeReExports }); return packageResult( mod, mod.body, options, 'toAmd' ); } ================================================ FILE: src/standalone/builders/strictMode/cjs.js ================================================ import packageResult from 'utils/packageResult'; import hasOwnProp from 'utils/hasOwnProp'; import transformBody from './utils/transformBody'; import { req } from 'utils/mappers'; export default function cjs ( mod, options ) { let seen = {}; // Create block of require statements let importBlock = mod.imports.map( x => { if ( !hasOwnProp.call( seen, x.path ) ) { seen[ x.path ] = true; if ( x.isEmpty ) { return `${req(x.path)};`; } return `var ${x.name} = ${req(x.path)};`; } }).filter( Boolean ).join( '\n' ); transformBody( mod, mod.body, { header: importBlock, _evilES3SafeReExports: options._evilES3SafeReExports }); if ( options.useStrict !== false ) { mod.body.prepend( "'use strict';\n\n" ).trimLines(); } return packageResult( mod, mod.body, options, 'toCjs' ); } ================================================ FILE: src/standalone/builders/strictMode/index.js ================================================ import amd from './amd'; import cjs from './cjs'; import umd from './umd'; export default { amd: amd, cjs: cjs, umd: umd }; ================================================ FILE: src/standalone/builders/strictMode/umd.js ================================================ import packageResult from 'utils/packageResult'; import umdIntro from 'utils/umd/umdIntro'; import requireName from 'utils/umd/requireName'; import transformBody from './utils/transformBody'; export default function umd ( mod, options ) { requireName( options ); let intro = umdIntro({ hasExports: mod.exports.length > 0, imports: mod.imports, amdName: options.amdName, absolutePaths: options.absolutePaths, name: options.name, indentStr: mod.body.getIndentString(), strict: true, useStrict: options.useStrict !== false }); transformBody( mod, mod.body, { intro: intro, outro: '\n\n}));', _evilES3SafeReExports: options._evilES3SafeReExports }); return packageResult( mod, mod.body, options, 'toUmd' ); } ================================================ FILE: src/standalone/builders/strictMode/utils/gatherImports.js ================================================ export default function gatherImports ( imports ) { let chains = {}; let identifierReplacements = {}; imports.forEach( x => { x.specifiers.forEach( s => { if ( s.isBatch ) { return; } let name = s.as; let replacement = x.name + ( s.isDefault ? `['default']` : `.${s.name}` ); if ( !x.passthrough ) { identifierReplacements[ name ] = replacement; } chains[ name ] = replacement; }); }); return [ chains, identifierReplacements ]; } ================================================ FILE: src/standalone/builders/strictMode/utils/getExportNames.js ================================================ export default function getExportNames ( exports ) { var result = {}; exports.forEach( x => { if ( x.isDefault ) return; if ( x.hasDeclaration ) { result[ x.name ] = x.name; return; } x.specifiers.forEach( s => { result[ s.name ] = s.as; }); }); return result; } ================================================ FILE: src/standalone/builders/strictMode/utils/getImportSummary.js ================================================ import hasOwnProp from 'utils/hasOwnProp'; export default function getImportSummary ( mod ) { let importPaths = []; let importNames = []; let seen = {}; let placeholders = 0; mod.imports.forEach( x => { if ( !hasOwnProp.call( seen, x.path ) ) { importPaths.push( x.path ); if ( x.specifiers.length ) { while ( placeholders ) { importNames.push( `__dep${importNames.length}__` ); placeholders--; } importNames.push( x.name ); } else { placeholders++; } seen[ x.path ] = true; } }); return [ importPaths, importNames ]; } ================================================ FILE: src/standalone/builders/strictMode/utils/transformBody.js ================================================ import gatherImports from './gatherImports'; import getExportNames from './getExportNames'; import getReadOnlyIdentifiers from 'utils/getReadOnlyIdentifiers'; import traverseAst from 'utils/ast/traverse'; import hasOwnProp from 'utils/hasOwnProp'; export default function transformBody ( mod, body, options ) { let [ chains, identifierReplacements ] = gatherImports( mod.imports ); let exportNames = getExportNames( mod.exports ); let [ importedBindings, importedNamespaces ] = getReadOnlyIdentifiers( mod.imports ); // ensure no conflict with `exports` identifierReplacements.exports = deconflict( 'exports', mod.ast._declared ); traverseAst( mod.ast, body, identifierReplacements, importedBindings, importedNamespaces, exportNames ); // Remove import statements from the body of the module mod.imports.forEach( x => { body.remove( x.start, x.next ); }); // Prepend require() statements (CommonJS output only) if ( options.header ) { body.prepend( options.header + '\n\n' ); } // Remove export statements (but keep declarations) mod.exports.forEach( x => { if ( x.isDefault ) { if ( /^named/.test( x.type ) ) { // export default function answer () { return 42; } body.remove( x.start, x.valueStart ); body.insert( x.end, `\nexports['default'] = ${x.name};` ); } else { // everything else body.replace( x.start, x.valueStart, 'exports[\'default\'] = ' ); } } else { switch ( x.type ) { case 'varDeclaration': // export var answer = 42; (or let) case 'namedFunction': // export function answer () {...} case 'namedClass': // export class answer {...} body.remove( x.start, x.valueStart ); break; case 'named': // export { foo, bar }; body.remove( x.start, x.next ); break; default: body.replace( x.start, x.valueStart, 'exports[\'default\'] = ' ); } } }); // Append export block (this is the same for all module types, unlike imports) let earlyExports = []; let lateExports = []; Object.keys( exportNames ).forEach( name => { var exportAs = exportNames[ name ]; if ( chains.hasOwnProperty( name ) ) { // special case - a binding from another module if ( !options._evilES3SafeReExports ) { earlyExports.push( `Object.defineProperty(exports, '${exportAs}', { enumerable: true, get: function () { return ${chains[name]}; }});` ); } else { let exportSegment = exportAs === 'default' ? "['default']" : `.${exportAs}`; lateExports.push( `exports${exportSegment} = ${chains[name]};` ); } } else if ( ~mod.ast._topLevelFunctionNames.indexOf( name ) ) { // functions should be exported early, in // case of cyclic dependencies earlyExports.push( `exports.${exportAs} = ${name};` ); } else { lateExports.push( `exports.${exportAs} = ${name};` ); } }); // Function exports should be exported immediately after 'use strict' if ( earlyExports.length ) { body.trim().prepend( earlyExports.join( '\n' ) + '\n\n' ); } // Everything else should be exported at the end if ( lateExports.length ) { body.trim().append( '\n\n' + lateExports.join( '\n' ) ); } if ( options.intro && options.outro ) { body.indent().prepend( options.intro ).trimLines().append( options.outro ); } } function deconflict ( name, declared ) { while ( hasOwnProp.call( declared, name ) ) { name = '_' + name; } return name; } ================================================ FILE: src/standalone/getModule.js ================================================ import { parse } from 'acorn'; import MagicString from 'magic-string'; import annotateAst from 'utils/ast/annotate'; import findImportsAndExports from 'utils/ast/findImportsAndExports'; import getUnscopedNames from 'utils/ast/getUnscopedNames'; import disallowConflictingImports from '../utils/disallowConflictingImports'; import hasOwnProp from 'utils/hasOwnProp'; import { default as sanitize, splitPath } from 'utils/sanitize'; const SOURCEMAPPINGURL_REGEX = /^# sourceMappingURL=/; export default function getStandaloneModule ( options ) { let code, ast; if ( typeof options.source === 'object' ) { code = options.source.code; ast = options.source.ast; } else { code = options.source; } let toRemove = []; let comments = []; let mod = { body: new MagicString( code ), ast: ast || ( parse( code, { ecmaVersion: 6, sourceType: 'module', onComment ( block, text, start, end ) { // sourceMappingURL comments should be removed if ( !block && SOURCEMAPPINGURL_REGEX.test( text ) ) { toRemove.push({ start, end }); } else { comments.push({ start, end }); } } })) }; toRemove.forEach( ({ start, end }) => mod.body.remove( start, end ) ); let { imports, exports, defaultExport } = findImportsAndExports( mod.ast, code, comments ); disallowConflictingImports( imports ); mod.imports = imports; mod.exports = exports; mod.defaultExport = defaultExport; let conflicts = {}; if ( options.strict ) { annotateAst( mod.ast, { trackAssignments: null }); // TODO there's probably an easier way to get this array Object.keys( mod.ast._declared ).concat( getUnscopedNames( mod ) ).forEach( n => { conflicts[n] = true; }); } determineImportNames( imports, options.getModuleName, conflicts ); return mod; } function determineImportNames ( imports, userFn, usedNames ) { let nameById = {}; let inferredNames = {}; imports.forEach( x => { let moduleId = x.path; let name; moduleId = x.path; // use existing value if ( hasOwnProp.call( nameById, moduleId ) ) { x.name = nameById[ moduleId ]; return; } // if user supplied a function, defer to it if ( userFn && ( name = userFn( moduleId ) ) ) { name = sanitize( name ); if ( hasOwnProp.call( usedNames, name ) ) { // TODO write a test for this throw new Error( `Naming collision: module ${moduleId} cannot be called ${name}` ); } } else { let parts = splitPath( moduleId ); let i; let prefix = ''; let candidate; do { i = parts.length; while ( i-- > 0 ) { candidate = prefix + sanitize( parts.slice( i ).join( '__' ) ); if ( !hasOwnProp.call( usedNames, candidate ) ) { name = candidate; break; } } prefix += '_'; } while ( !name ); } usedNames[ name ] = true; nameById[ moduleId ] = name; x.name = name; }); // use inferred names for default imports, wherever they // don't clash with path-based names imports.forEach( x => { if ( x.as && !hasOwnProp.call( usedNames, x.as ) ) { inferredNames[ x.path ] = x.as; } }); imports.forEach( x => { if ( hasOwnProp.call( inferredNames, x.path ) ) { x.name = inferredNames[ x.path ]; } }); } ================================================ FILE: src/utils/EsperantoError.js ================================================ var EsperantoError = function ( message, data ) { var prop; this.message = message; this.stack = (new Error()).stack; for ( prop in data ) { if ( data.hasOwnProperty( prop ) ) { this[ prop ] = data[ prop ]; } } }; EsperantoError.prototype = new Error(); EsperantoError.prototype.constructor = EsperantoError; EsperantoError.prototype.name = 'EsperantoError'; export default EsperantoError; ================================================ FILE: src/utils/amd/amdIntro.js ================================================ import getImportSummary from './getImportSummary'; import processName from './processName'; import processIds from './processIds'; export default function amdIntro ({ name, imports, hasExports, indentStr, absolutePaths, useStrict }) { let { ids, names } = getImportSummary({ name, imports, absolutePaths }); if ( hasExports ) { ids.unshift( 'exports' ); names.unshift( 'exports' ); } let intro = ` define(${processName(name)}${processIds(ids)}function (${names.join( ', ' ) }) { `; if ( useStrict ) { intro += `${indentStr}'use strict';\n\n`; } return intro; } ================================================ FILE: src/utils/amd/getImportSummary.js ================================================ import resolveId from '../resolveId'; export default function getImportSummary ({ imports, absolutePaths, name }) { let paths = []; let names = []; let seen = {}; let placeholders = 0; imports.forEach( x => { let path = x.id || x.path; // TODO unify these if ( !seen[ path ] ) { seen[ path ] = true; paths.push( path ); // TODO x could be an external module, or an internal one. // they have different shapes, resulting in the confusing // code below if ( ( x.needsDefault || x.needsNamed ) || ( x.specifiers && x.specifiers.length ) ) { while ( placeholders ) { names.push( `__dep${names.length}__` ); placeholders--; } names.push( x.name ); } else { placeholders++; } } }); let ids = absolutePaths ? paths.map( relativePath => resolveId( relativePath, name ) ) : paths.slice(); return { ids, paths, names }; } ================================================ FILE: src/utils/amd/processIds.js ================================================ import { quote } from '../mappers'; export default function processIds ( ids ) { return ids.length ? '[' + ids.map( quote ).join( ', ' ) + '], ' : ''; } ================================================ FILE: src/utils/amd/processName.js ================================================ import { quote } from '../mappers'; export default function processName ( name ) { return name ? quote( name ) + ', ' : ''; } ================================================ FILE: src/utils/ast/annotate.js ================================================ /* This module traverse a module's AST, attaching scope information to nodes as it goes, which is later used to determine which identifiers need to be rewritten to avoid collisions */ import walk from './walk'; import { getName } from '../mappers'; function Scope ( options ) { options = options || {}; this.parent = options.parent; this.names = options.params || []; } Scope.prototype = { add: function ( name ) { if (! ~this.names.indexOf( name ) ) // redeclaration of existing binding this.names.push( name ); }, contains: function ( name, ignoreTopLevel ) { if ( ignoreTopLevel && !this.parent ) { return false; } if ( ~this.names.indexOf( name ) ) { return true; } if ( this.parent ) { return this.parent.contains( name, ignoreTopLevel ); } return false; } }; export default function annotateAst ( ast, options ) { const trackAssignments = options && options.trackAssignments; let scope = new Scope(); let blockScope = new Scope(); let declared = {}; let topLevelFunctionNames = []; let templateLiteralRanges = []; let envDepth = 0; walk( ast, { enter ( node ) { if ( node.type === 'ImportDeclaration' || node.type === 'ExportSpecifier' ) { node._skip = true; } if ( node._skip ) { return this.skip(); } switch ( node.type ) { case 'FunctionExpression': case 'FunctionDeclaration': envDepth += 1; // fallthrough case 'ArrowFunctionExpression': if ( node.id ) { addToScope( node ); // If this is the root scope, this may need to be // exported early, so we make a note of it if ( !scope.parent && node.type === 'FunctionDeclaration' ) { topLevelFunctionNames.push( node.id.name ); } } let names = node.params.map( getName ); names.forEach( name => declared[ name ] = true ); scope = node._scope = new Scope({ parent: scope, params: names // TODO rest params? }); break; case 'BlockStatement': blockScope = node._blockScope = new Scope({ parent: blockScope }); break; case 'VariableDeclaration': node.declarations.forEach( node.kind === 'let' ? addToBlockScope : addToScope ); break; case 'ClassExpression': case 'ClassDeclaration': addToScope( node ); break; case 'MemberExpression': !node.computed && ( node.property._skip = true ); break; case 'Property': node.key._skip = true; break; case 'TemplateLiteral': templateLiteralRanges.push([ node.start, node.end ]); break; case 'ThisExpression': if (envDepth === 0) { node._topLevel = true; } break; case 'AssignmentExpression': assignTo( node.left ); break; case 'UpdateExpression': assignTo( node.argument ); break; } }, leave ( node ) { switch ( node.type ) { case 'FunctionExpression': case 'FunctionDeclaration': envDepth -= 1; // fallthrough case 'ArrowFunctionExpression': scope = scope.parent; break; case 'BlockStatement': blockScope = blockScope.parent; break; } } }); function assignTo ( node ) { if ( trackAssignments && node.type === 'Identifier' && node.name === trackAssignments.name ) { // This is possibly somewhat hacky. Open to alternative approaches... // It will yield false positives if `foo` in `export default foo` is shadowed ( trackAssignments._assignments || ( trackAssignments._assignments = [] ) ).push({ scope, node }); } } function addToScope ( declarator ) { var name = declarator.id.name; scope.add( name ); declared[ name ] = true; } function addToBlockScope ( declarator ) { var name = declarator.id.name; blockScope.add( name ); declared[ name ] = true; } ast._scope = scope; ast._blockScope = blockScope; ast._topLevelNames = ast._scope.names.concat( ast._blockScope.names ); ast._topLevelFunctionNames = topLevelFunctionNames; ast._declared = declared; ast._templateLiteralRanges = templateLiteralRanges; } ================================================ FILE: src/utils/ast/disallowIllegalReassignment.js ================================================ import hasOwnProp from 'utils/hasOwnProp'; var bindingMessage = 'Cannot reassign imported binding ', namespaceMessage = 'Cannot reassign imported binding of namespace '; export default function disallowIllegalReassignment ( node, importedBindings, importedNamespaces, scope ) { let assignee, isNamespaceAssignment; if ( node.type === 'AssignmentExpression' ) { assignee = node.left; } else if ( node.type === 'UpdateExpression' ) { assignee = node.argument; } else { return; // not an assignment } if ( assignee.type === 'MemberExpression' ) { assignee = assignee.object; isNamespaceAssignment = true; } if ( assignee.type !== 'Identifier' ) { return; // not assigning to a binding } let name = assignee.name; if ( hasOwnProp.call( isNamespaceAssignment ? importedNamespaces : importedBindings, name ) && !scope.contains( name ) ) { throw new Error( ( isNamespaceAssignment ? namespaceMessage : bindingMessage ) + '`' + name + '`' ); } } ================================================ FILE: src/utils/ast/findImportsAndExports.js ================================================ /** * Inspects a module and discovers/categorises import & export declarations * @param {object} ast - the result of parsing `source` with acorn * @param {string} source - the module's original source code * @param {array} comments - {start, end} position of comments * @returns {object} - { imports, exports, defaultExport } */ export default function findImportsAndExports ( ast, source, comments ) { let imports = []; let exports = []; let defaultExport; let previousDeclaration; ast.body.forEach( node => { var passthrough, declaration; if ( previousDeclaration ) { if ( previousDeclaration.node.type === 'ImportDeclaration' && node.type !== 'ImportDeclaration' ) { // For last import statement, next declaration starts at next comment or node, whichever is closest let nextComment; for ( let i = 0, len = comments.length; i < len; i++ ) { if ( comments[i].start > previousDeclaration.end ) { nextComment = comments[i]; break; } } if ( nextComment && nextComment.start < node.start ) { previousDeclaration.next = nextComment.start; } else { previousDeclaration.next = node.start; } } else { previousDeclaration.next = node.start; } if ( node.type !== 'EmptyStatement' ) { previousDeclaration = null; } } if ( node.type === 'ImportDeclaration' ) { declaration = processImport( node ); imports.push( declaration ); } else if ( node.type === 'ExportDefaultDeclaration' ) { declaration = processDefaultExport( node, source ); exports.push( declaration ); if ( defaultExport ) { throw new Error( 'Duplicate default exports' ); } defaultExport = declaration; } else if ( node.type === 'ExportNamedDeclaration' ) { declaration = processExport( node, source ); exports.push( declaration ); if ( node.source ) { // it's both an import and an export, e.g. // `export { foo } from './bar'; passthrough = processImport( node, true ); passthrough.specifiers.forEach( e => { // the import in `export { default } from 'foo';` // is a default import if ( e.name === 'default' ) { e.isDefault = true; } }); imports.push( passthrough ); declaration.passthrough = passthrough; } } if ( declaration ) { previousDeclaration = declaration; } }); // catch any trailing semicolons if ( previousDeclaration ) { previousDeclaration.next = source.length; previousDeclaration.isFinal = true; } return { imports, exports, defaultExport }; } /** * Generates a representation of an import declaration * @param {object} node - the original AST node * @param {boolean} passthrough - `true` if this is an `export { foo } from 'bar'`-style declaration * @returns {object} */ function processImport ( node, passthrough ) { var x = { module: null, // used by bundler - filled in later node: node, start: node.start, end: node.end, passthrough: !!passthrough, path: node.source.value, specifiers: node.specifiers.map( s => { if ( s.type === 'ImportNamespaceSpecifier' ) { return { isBatch: true, name: s.local.name, // TODO is this line necessary? as: s.local.name, origin: null // filled in later by bundler }; } if ( s.type === 'ImportDefaultSpecifier' ) { return { isDefault: true, name: 'default', as: s.local.name, origin: null }; } return { name: ( !!passthrough ? s.exported : s.imported ).name, as: s.local.name, origin: null }; }) }; // TODO have different types of imports - batch, default, named if ( x.specifiers.length === 0 ) { x.isEmpty = true; } else if ( x.specifiers.length === 1 && x.specifiers[0].isDefault ) { x.isDefault = true; x.as = x.specifiers[0].as; } else if ( x.specifiers.length === 1 && x.specifiers[0].isBatch ) { x.isBatch = true; x.as = x.specifiers[0].name; } else { x.isNamed = true; } return x; } function processDefaultExport ( node, source ) { const d = node.declaration; let result = { node, isDefault: true, start: node.start, end: node.end, value: source.slice( d.start, d.end ), valueStart: d.start, hasDeclaration: null, type: null, name: null }; // possible declaration types: // * FunctionExpression - `export default function () {...}` // * FunctionDeclaration - `export default function foo () {...}` // * ClassExpression - `export default class {...}` // * ClassDeclaration - `export default class Foo {...}` const match = /^(Function|Class)(Declaration)?/.exec( d.type ); if ( match ) { result.hasDeclaration = true; result.type = ( match[2] ? 'named' : 'anon' ) + match[1]; if ( match[2] ) { result.name = d.id.name; } } // if no match, we have an expression like `export default whatever` else { result.type = 'expression'; result.name = 'default'; } return result; } /** * Generates a representation of an export declaration * @param {object} node - the original AST node * @param {string} source - the original source code * @returns {object} */ function processExport ( node, source ) { let result = { node, start: node.start, end: node.end, value: null, valueStart: null, hasDeclaration: null, type: null, name: null, specifiers: null }; const d = node.declaration; if ( d ) { result.hasDeclaration = true; result.value = source.slice( d.start, d.end ); result.valueStart = d.start; // Case 1: `export var foo = 'bar'` if ( d.type === 'VariableDeclaration' ) { result.type = 'varDeclaration'; result.name = d.declarations[0].id.name; } // Case 2: `export function foo () {...}` else if ( d.type === 'FunctionDeclaration' ) { result.type = 'namedFunction'; result.name = d.id.name; } // Case 3: `export class Foo {...}` else if ( d.type === 'ClassDeclaration' ) { result.type = 'namedClass'; result.name = d.id.name; } } // Case 9: `export { foo, bar };` else { result.type = 'named'; result.specifiers = node.specifiers.map( s => { return { origin: null, // filled in later by bundler name: s.local.name, as: s.exported.name }; }); } return result; } ================================================ FILE: src/utils/ast/getUnscopedNames.js ================================================ import walk from './walk'; import hasOwnProp from 'utils/hasOwnProp'; export default function getUnscopedNames ( mod ) { var unscoped = [], importedNames, scope; function imported ( name ) { if ( !importedNames ) { importedNames = {}; mod.imports.forEach( i => { !i.passthrough && i.specifiers.forEach( s => { importedNames[ s.as ] = true; }); }); } return hasOwnProp.call( importedNames, name ); } walk( mod.ast, { enter ( node ) { // we're only interested in references, not property names etc if ( node._skip ) return this.skip(); if ( node._scope ) { scope = node._scope; } if ( node.type === 'Identifier' && !scope.contains( node.name ) && !imported( node.name ) && !~unscoped.indexOf( node.name ) ) { unscoped.push( node.name ); } }, leave ( node ) { if ( node.type === 'Program' ) { return; } if ( node._scope ) { scope = scope.parent; } } }); return unscoped; } ================================================ FILE: src/utils/ast/replaceIdentifiers.js ================================================ import hasOwnProp from 'utils/hasOwnProp'; export default function replaceIdentifiers ( body, node, identifierReplacements, scope ) { let name = node.name; let replacement = hasOwnProp.call( identifierReplacements, name ) && identifierReplacements[ name ]; // TODO unchanged identifiers shouldn't have got this far - // remove the `replacement !== name` safeguard once that's the case if ( replacement && replacement !== name && !scope.contains( name, true ) ) { // rewrite body.replace( node.start, node.end, replacement ); } } ================================================ FILE: src/utils/ast/rewriteExportAssignments.js ================================================ import hasOwnProp from 'utils/hasOwnProp'; export default function rewriteExportAssignments ( body, node, parent, exports, scope, capturedUpdates ) { let assignee; if ( node.type === 'AssignmentExpression' ) { assignee = node.left; } else if ( node.type === 'UpdateExpression' ) { assignee = node.argument; } else { return; // not an assignment } if ( assignee.type !== 'Identifier' ) { return; } let name = assignee.name; if ( scope.contains( name, true ) ) { return; // shadows an export } if ( exports && hasOwnProp.call( exports, name ) ) { let exportAs = exports[ name ]; if ( !!capturedUpdates ) { capturedUpdates.push({ name, exportAs }); return; } // special case - increment/decrement operators if ( node.operator === '++' || node.operator === '--' ) { let prefix = ``; let suffix = `, exports.${exportAs} = ${name}`; if ( parent.type !== 'ExpressionStatement' ) { if ( !node.prefix ) { suffix += `, ${name} ${node.operator === '++' ? '-' : '+'} 1`; } prefix += `( `; suffix += ` )`; } body.insert( node.start, prefix ); body.insert( node.end, suffix ); } else { body.insert( node.start, `exports.${exportAs} = ` ); } } } ================================================ FILE: src/utils/ast/traverse.js ================================================ import walk from './walk'; import disallowIllegalReassignment from './disallowIllegalReassignment'; import replaceIdentifiers from './replaceIdentifiers'; import rewriteExportAssignments from './rewriteExportAssignments'; export default function traverseAst ( ast, body, identifierReplacements, importedBindings, importedNamespaces, exportNames ) { let scope = ast._scope; let blockScope = ast._blockScope; let capturedUpdates = null; let previousCapturedUpdates = null; walk( ast, { enter ( node, parent ) { // we're only interested in references, not property names etc if ( node._skip ) return this.skip(); if ( node._scope ) { scope = node._scope; } else if ( node._blockScope ) { blockScope = node._blockScope; } // Special case: if you have a variable declaration that updates existing // bindings as a side-effect, e.g. `var a = b++`, where `b` is an exported // value, we can't simply append `exports.b = b` to the update (as we // normally would) because that would be syntactically invalid. Instead, // we capture the change and update the export (and any others) after the // variable declaration if ( node.type === 'VariableDeclaration' ) { previousCapturedUpdates = capturedUpdates; capturedUpdates = []; return; } disallowIllegalReassignment( node, importedBindings, importedNamespaces, scope ); // Rewrite assignments to exports inside functions, to keep bindings live. // This call may mutate `capturedUpdates`, which is used elsewhere if ( scope !== ast._scope ) { rewriteExportAssignments( body, node, parent, exportNames, scope, capturedUpdates ); } if ( node.type === 'Identifier' && parent.type !== 'FunctionExpression' ) { replaceIdentifiers( body, node, identifierReplacements, scope ); } // Replace top-level this with undefined ES6 8.1.1.5.4 if ( node.type === 'ThisExpression' && node._topLevel ) { body.replace( node.start, node.end, 'undefined' ); } }, leave ( node ) { // Special case - see above if ( node.type === 'VariableDeclaration' ) { if ( capturedUpdates.length ) { body.insert( node.end, capturedUpdates.map( exportCapturedUpdate ).join( '' ) ); } capturedUpdates = previousCapturedUpdates; } if ( node._scope ) { scope = scope.parent; } else if ( node._blockScope ) { blockScope = blockScope.parent; } } }); } function exportCapturedUpdate ( c ) { return ` exports.${c.exportAs} = ${c.name};`; } ================================================ FILE: src/utils/ast/walk.js ================================================ let shouldSkip; let shouldAbort; export default function walk ( ast, { enter, leave }) { shouldAbort = false; visit( ast, null, enter, leave ); } let context = { skip: () => shouldSkip = true, abort: () => shouldAbort = true }; let childKeys = {}; let toString = Object.prototype.toString; function isArray ( thing ) { return toString.call( thing ) === '[object Array]'; } function visit ( node, parent, enter, leave ) { if ( !node || shouldAbort ) return; if ( enter ) { shouldSkip = false; enter.call( context, node, parent ); if ( shouldSkip || shouldAbort ) return; } let keys = childKeys[ node.type ] || ( childKeys[ node.type ] = Object.keys( node ).filter( key => typeof node[ key ] === 'object' ) ); let key, value, i, j; i = keys.length; while ( i-- ) { key = keys[i]; value = node[ key ]; if ( isArray( value ) ) { j = value.length; while ( j-- ) { visit( value[j], node, enter, leave ); } } else if ( value && value.type ) { visit( value, node, enter, leave ); } } if ( leave && !shouldAbort ) { leave( node, parent ); } } ================================================ FILE: src/utils/builtins.js ================================================ // from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects // we add `exports` to this list, to avoid conflicts export default 'Array ArrayBuffer DataView Date Error EvalError Float32Array Float64Array Function Generator GeneratorFunction Infinity Int16Array Int32Array Int8Array InternalError Intl Iterator JSON Map Math NaN Number Object ParallelArray Promise Proxy RangeError ReferenceError Reflect RegExp Set StopIteration String Symbol SyntaxError TypeError TypedArray URIError Uint16Array Uint32Array Uint8Array Uint8ClampedArray WeakMap WeakSet decodeURI decodeURIComponent encodeURI encodeURIComponent escape eval exports isFinite isNaN null parseFloat parseInt undefined unescape uneval'.split( ' ' ); ================================================ FILE: src/utils/disallowConflictingImports.js ================================================ import hasOwnProp from './hasOwnProp'; export default function disallowConflictingImports ( imports ) { let usedNames = {}; imports.forEach( x => { if ( x.passthrough ) return; if ( x.as ) { checkName( x.as ); } else { x.specifiers.forEach( checkSpecifier ); } }); function checkSpecifier ( s ) { checkName( s.as ); } function checkName ( name ) { if ( hasOwnProp.call( usedNames, name ) ) { throw new SyntaxError( `Duplicated import ('${name}')` ); } usedNames[ name ] = true; } } ================================================ FILE: src/utils/getReadOnlyIdentifiers.js ================================================ /** * Scans an array of imports, and determines which identifiers are readonly, and which cannot be assigned to. For example you cannot `import foo from 'foo'` then do `foo = 42`, nor can you `import * as foo from 'foo'` then do `foo.answer = 42` * @param {array} imports - the array of imports * @returns {array} [ importedBindings, importedNamespaces ] */ export default function getReadOnlyIdentifiers ( imports ) { var importedBindings = {}, importedNamespaces = {}; imports.forEach( x => { if ( x.passthrough ) return; x.specifiers.forEach( s => { if ( s.isBatch ) { importedNamespaces[ s.as ] = true; } else { importedBindings[ s.as ] = true; } }); }); return [ importedBindings, importedNamespaces ]; } ================================================ FILE: src/utils/hasNamedExports.js ================================================ export default function hasNamedExports ( mod ) { var i = mod.exports.length; while ( i-- ) { if ( !mod.exports[i].isDefault ) { return true; } } } ================================================ FILE: src/utils/hasNamedImports.js ================================================ export default function hasNamedImports ( mod ) { var i = mod.imports.length; while ( i-- ) { if ( mod.imports[i].isNamed ) { return true; } } } ================================================ FILE: src/utils/hasOwnProp.js ================================================ var hasOwnProp = Object.prototype.hasOwnProperty; export default hasOwnProp; ================================================ FILE: src/utils/mappers.js ================================================ export function getId ( m ) { return m.id; } export function getName ( m ) { return m.name; } export function quote ( str ) { return "'" + JSON.stringify(str).slice(1, -1).replace(/'/g, "\\'") + "'"; } export function req ( path ) { return `require(${quote(path)})`; } export function globalify ( name ) { if ( /^__dep\d+__$/.test( name ) ) { return 'undefined'; } else { return `global.${name}`; } } ================================================ FILE: src/utils/packageResult.js ================================================ import walk from './ast/walk'; import { splitPath } from 'utils/sanitize'; const ABSOLUTE_PATH = /^(?:[A-Z]:)?[\/\\]/i; let warned = {}; export default function packageResult ( bundleOrModule, body, options, methodName, isBundle ) { // wrap output if ( options.banner ) body.prepend( options.banner ); if ( options.footer ) body.append( options.footer ); let code = body.toString(); let map; if ( !!options.sourceMap ) { if ( options.sourceMap !== 'inline' && !options.sourceMapFile ) { throw new Error( 'You must provide `sourceMapFile` option' ); } if ( !isBundle && !options.sourceMapSource ) { throw new Error( 'You must provide `sourceMapSource` option' ); } let sourceMapFile; if ( options.sourceMap === 'inline' ) { sourceMapFile = null; } else { sourceMapFile = ABSOLUTE_PATH.test( options.sourceMapFile ) ? options.sourceMapFile : './' + splitPath( options.sourceMapFile ).pop(); } if ( isBundle ) { markBundleSourcemapLocations( bundleOrModule ); } else { markModuleSourcemapLocations( bundleOrModule ); } map = body.generateMap({ includeContent: true, file: sourceMapFile, source: ( sourceMapFile && !isBundle ) ? getRelativePath( sourceMapFile, options.sourceMapSource ) : null }); if ( options.sourceMap === 'inline' ) { code += '\n//# sourceMa' + 'ppingURL=' + map.toUrl(); map = null; } else { code += '\n//# sourceMa' + 'ppingURL=' + sourceMapFile + '.map'; } } else { map = null; } return { code, map, toString () { if ( !warned[ methodName ] ) { console.log( `Warning: esperanto.${methodName}() returns an object with a 'code' property. You should use this instead of using the returned value directly` ); warned[ methodName ] = true; } return code; } }; } function getRelativePath ( from, to ) { var fromParts, toParts, i; fromParts = splitPath( from ); toParts = splitPath( to ); fromParts.pop(); // get dirname while ( fromParts[0] === '.' ) { fromParts.shift(); } while ( fromParts[0] === toParts[0] ) { fromParts.shift(); toParts.shift(); } if ( fromParts.length ) { i = fromParts.length; while ( i-- ) fromParts[i] = '..'; return fromParts.concat( toParts ).join( '/' ); } else { toParts.unshift( '.' ); return toParts.join( '/' ); } } function markBundleSourcemapLocations ( bundle ) { bundle.modules.forEach( mod => { walk( mod.ast, { enter: node => { mod.body.addSourcemapLocation( node.start ); } }); }); } function markModuleSourcemapLocations ( mod ) { walk( mod.ast, { enter: node => { mod.body.addSourcemapLocation( node.start ); } }); } ================================================ FILE: src/utils/promiseSequence.js ================================================ import { Promise } from 'sander'; export default function promiseSequence ( arr, callback ) { const len = arr.length; let results = new Array( len ); let promise = Promise.resolve(); function next ( i ) { return promise .then( () => callback( arr[i], i ) ) .then( result => results[i] = result ); } let i; for ( i = 0; i < len; i += 1 ) { promise = next( i ); } return promise.then( () => results ); } ================================================ FILE: src/utils/resolveId.js ================================================ import { splitPath } from 'utils/sanitize'; /** * Resolves an importPath relative to the module that is importing it * @param {string} importPath - the (possibly relative) path of an imported module * @param {string} importerPath - the (relative to `base`) path of the importing module * @returns {string} */ export default function resolveId ( importPath, importerPath ) { var resolved, importerParts, importParts; if ( importPath[0] !== '.' ) { resolved = importPath; } else { importerParts = splitPath( importerPath ); importParts = splitPath( importPath ); if ( importParts[0] === '.' ) { importParts.shift(); } importerParts.pop(); // get dirname while ( importParts[0] === '..' ) { importParts.shift(); importerParts.pop(); } while ( importParts[0] === '.' ) { importParts.shift(); } resolved = importerParts.concat( importParts ).join( '/' ); } return resolved; } export function resolveAgainst ( importerPath ) { return function ( importPath ) { return resolveId( importPath, importerPath ); }; } ================================================ FILE: src/utils/sanitize.js ================================================ const RESERVED = 'break case class catch const continue debugger default delete do else export extends finally for function if import in instanceof let new return super switch this throw try typeof var void while with yield'.split( ' ' ); const INVALID_CHAR = /[^a-zA-Z0-9_$]/g; const INVALID_LEADING_CHAR = /[^a-zA-Z_$]/; /** * Generates a sanitized (i.e. valid identifier) name from a module ID * @param {string} id - a module ID, or part thereof * @returns {string} */ export default function sanitize ( name ) { name = name.replace( INVALID_CHAR, '_' ); if ( INVALID_LEADING_CHAR.test( name[0] ) || ~RESERVED.indexOf( name ) ) { name = `_${name}`; } return name; } var pathSplitRE = /\/|\\/; export function splitPath ( path ) { return path.split( pathSplitRE ); } ================================================ FILE: src/utils/umd/requireName.js ================================================ import EsperantoError from 'utils/EsperantoError'; export default function requireName ( options ) { if ( !options.name ) { throw new EsperantoError( 'You must supply a `name` option for UMD modules', { code: 'MISSING_NAME' }); } } ================================================ FILE: src/utils/umd/umdIntro.js ================================================ import { globalify, req } from 'utils/mappers'; import processName from '../amd/processName'; import processIds from '../amd/processIds'; import getImportSummary from '../amd/getImportSummary'; export default function umdIntro ({ amdName, name, hasExports, imports, absolutePaths, externalDefaults, indentStr, strict, useStrict }) { const useStrictPragma = useStrict ? ` 'use strict';` : ''; let intro; if ( !hasExports && !imports.length ) { intro = `(function (factory) { !(typeof exports === 'object' && typeof module !== 'undefined') && typeof define === 'function' && define.amd ? define(${processName(amdName)}factory) : factory() }(function () {${useStrictPragma} `; } else { let { ids, paths, names } = getImportSummary({ imports, name: amdName, absolutePaths }); let amdExport, cjsExport, globalExport, defaultsBlock; if ( strict ) { cjsExport = `factory(${( hasExports ? [ 'exports' ] : [] ).concat( paths.map( req ) ).join( ', ' )})`; let globalDeps = ( hasExports ? [ `(global.${name} = {})` ] : [] ).concat( names.map( globalify ) ).join( ', ' ); globalExport = `factory(${globalDeps})`; if ( hasExports ) { ids.unshift( 'exports' ); names.unshift( 'exports' ); } amdExport = `define(${processName(amdName)}${processIds(ids)}factory)`; defaultsBlock = ''; if ( externalDefaults && externalDefaults.length > 0 ) { defaultsBlock = externalDefaults.map( x => '\t' + ( x.needsNamed ? `var ${x.name}__default` : x.name ) + ` = ('default' in ${x.name} ? ${x.name}['default'] : ${x.name});` ).join('\n') + '\n\n'; } } else { amdExport = `define(${processName(amdName)}${processIds(ids)}factory)`; cjsExport = ( hasExports ? 'module.exports = ' : '' ) + `factory(${paths.map( req ).join( ', ' )})`; globalExport = ( hasExports ? `global.${name} = ` : '' ) + `factory(${names.map( globalify ).join( ', ' )})`; defaultsBlock = ''; } intro = `(function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? ${cjsExport} : typeof define === 'function' && define.amd ? ${amdExport} : ${globalExport} }(this, function (${names.join( ', ' )}) {${useStrictPragma} ${defaultsBlock}`; } return intro.replace( /^\t\t\t/gm, '' ).replace( /\t/g, indentStr ); } ================================================ FILE: test/.jshintrc ================================================ { "boss": true, "unused": true, "undef": true, "esnext": true, "globals": { "process": true, "require": true, "module": true, "__dirname": true, "define": true, "describe": true, "it": true, "before": true, "setTimeout": true, "console": true, "window": true } } ================================================ FILE: test/bundle/index.js ================================================ var path = require( 'path' ); var assert = require( 'assert' ); var sander = require( 'sander' ); var makeWhitespaceVisible = require( '../utils/makeWhitespaceVisible' ); var esperanto = require( '../../' ); Promise = sander.Promise; global.assert = assert; module.exports = function () { return new Promise( function ( fulfil ) { var start; describe( 'esperanto.bundle()', function () { var profiles; this.timeout( 20000 ); before( function () { if ( process.env.BUILD_TIMEOUT ) { this.timeout( parseInt( process.env.BUILD_TIMEOUT ) ); } sander.rimrafSync( 'es6-module-transpiler-tests/bundled-output' ); start = Date.now(); }); after( function () { fulfil( Date.now() - start ); }); describe( 'ES6 module semantics tests from es6-module-transpiler:', function () { sander.readdirSync( __dirname, '../es6-module-transpiler-tests/input' ).forEach( function ( dir ) { var config, cjs; config = require( '../es6-module-transpiler-tests/input/' + dir + '/_config' ); it( dir, function () { // Create CommonJS modules, then require the entry module return esperanto.bundle({ base: path.resolve( 'es6-module-transpiler-tests/input', dir ), entry: config.entry }) .then( function ( bundle ) { cjs = bundle.toCjs({ strict: true }).code; return sander.writeFile( 'es6-module-transpiler-tests/bundled-output', dir + '.js', cjs ); }) .then( function () { var missingError; try { require( path.resolve( 'es6-module-transpiler-tests/bundled-output', dir ) ); if ( config.expectedError ) { missingError = true; } } catch( err ) { if ( !config.expectedError || !~err.message.indexOf( config.expectedError ) ) { console.log( 'bundle>>>\n%s\n<<<', cjs ); throw err; } } if ( missingError ) { console.log( 'bundle>>>\n%s\n<<<', cjs ); throw new Error( 'Expected error "' + config.expectedError + '"' ); } }, function ( err ) { if ( !config.expectedError || !~err.message.indexOf( config.expectedError ) ) { console.log( 'bundle>>>\n%s\n<<<', cjs ); throw err; } }); }); }); }); profiles = [ { description: 'bundle.concat()', method: 'concat', outputdir: 'concat' }, { description: 'bundle.toAmd()', method: 'toAmd', outputdir: 'amdDefaults' }, { description: 'bundle.toUmd()', method: 'toUmd', outputdir: 'umdDefaults', options: { name: 'myModule' } }, { description: 'bundle.toCjs()', method: 'toCjs', outputdir: 'cjsDefaults' }, { description: 'bundle.toAmd({ strict: true })', method: 'toAmd', outputdir: 'amd', options: { strict: true } }, { description: 'bundle.toUmd({ strict: true })', method: 'toUmd', outputdir: 'umd', options: { strict: true, name: 'myModule' } }, { description: 'bundle.toCjs({ strict: true })', method: 'toCjs', outputdir: 'cjs', options: { strict: true } } ]; profiles.forEach( function ( profile ) { describe( profile.description + ':', function () { sander.readdirSync( __dirname, 'input' ) .filter( Number ) // filter out .DS_Store and assorted crap .forEach( function ( dir ) { var config = require( './input/' + dir + '/_config' ); ( config.solo ? it.only : it )( dir + ': ' + config.description, function () { return esperanto.bundle({ base: path.resolve( 'bundle/input', dir ), entry: config.entry || 'main', skip: config.skip, names: config.names, transform: config.transform, resolvePath: config.resolvePath, modules: config.modules }).then( function ( bundle ) { var options, transpiled, actual; options = profile.options || {}; if ( ( bundle.imports.length && !config.imports ) || ( bundle.exports.length && !config.exports ) ) { throw new Error( 'config is missing imports/exports (expected ' + JSON.stringify( bundle.imports ) + ', ' + JSON.stringify( bundle.exports ) + ')' ); } if ( config.imports || bundle.imports.length ) { assert.deepEqual( bundle.imports.sort(), config.imports.sort() ); } if ( config.exports || bundle.exports.length ) { assert.deepEqual( bundle.exports.sort(), config.exports.sort() ); } transpiled = bundle[ profile.method ]({ strict: options.strict, name: options.name, amdName: config.amdName, banner: config.banner, footer: config.footer, useStrict: config.useStrict, sourceMap: config.sourceMap }); if ( config.error ) { throw new Error( 'Expected error but none was raised' ); } actual = makeWhitespaceVisible( transpiled.code ); // necessary for CI if ( config.sourceMap ) { actual = actual.replace( /base64,.+/, 'base64,xyz' ); } return sander.readFile( 'bundle/output/', profile.outputdir, dir + '.js' ).then( String ).then( function ( str ) { var expected = makeWhitespaceVisible( str ); if ( config.strict && !options.strict ) { throw new Error( 'Test should fail in non-strict mode' ); } assert.equal( actual, expected, 'Expected\n>\n' + actual + '\n>\n\nto match\n\n>\n' + expected + '\n>' ); }).catch( function ( err ) { if ( err.code === 'ENOENT' ) { assert.equal( actual, '', 'Expected\n>\n' + actual + '\n>\n\nto match non-existent file' ); } else { throw err; } }); }).catch( function ( err ) { // strict mode tests should fail if ( /strict mode/.test( err.message ) && config.strict ) { return; } if ( /bundles that have no imports\/exports/.test( err.message ) && profile.method === 'concat' ) { return; } if ( !config.error ) { throw err; } if ( config.error instanceof RegExp ) { if ( !config.error.test( err.message ) ) { throw err; } } else if ( !config.error( err ) ) { throw err; } }); }); }); }); }); }); }); }; ================================================ FILE: test/bundle/input/01/_config.js ================================================ module.exports = { description: 'bundles a simple collection of modules' }; ================================================ FILE: test/bundle/input/01/foo.js ================================================ var message = 'yes'; export default message; ================================================ FILE: test/bundle/input/01/main.js ================================================ import foo from './foo'; console.log( foo ); ================================================ FILE: test/bundle/input/02/_config.js ================================================ module.exports = { description: 'bundles modules in index.js files' }; ================================================ FILE: test/bundle/input/02/foo/index.js ================================================ var message = 'yes'; export default message; ================================================ FILE: test/bundle/input/02/main.js ================================================ import foo from './foo'; console.log( foo ); ================================================ FILE: test/bundle/input/03/_config.js ================================================ module.exports = { description: 'allows external imports', imports: [ 'external' ] }; ================================================ FILE: test/bundle/input/03/foo.js ================================================ var bar = 'yes'; export default bar; ================================================ FILE: test/bundle/input/03/main.js ================================================ import foo from './foo'; import external from 'external'; console.log( external( foo ) ); ================================================ FILE: test/bundle/input/04/_config.js ================================================ module.exports = { description: 'exports a default export', exports: [ 'default' ] }; ================================================ FILE: test/bundle/input/04/foo.js ================================================ export var answer = 42; ================================================ FILE: test/bundle/input/04/main.js ================================================ import { answer } from './foo'; export default answer * 2; ================================================ FILE: test/bundle/input/05/_config.js ================================================ module.exports = { description: 'exports named exports', strict: true, exports: [ 'four', 'five', 'six' ] }; ================================================ FILE: test/bundle/input/05/main.js ================================================ import { one, two, three } from './numbers'; export var four = one + 3; export var five = two + 3; export var six = three + 3; four = 99; ================================================ FILE: test/bundle/input/05/numbers.js ================================================ export var one = 1; export var two = 2; export var three = 3; ================================================ FILE: test/bundle/input/06/_config.js ================================================ module.exports = { description: 'gives legal names to nested imports', imports: [ 'utils/external' ] }; ================================================ FILE: test/bundle/input/06/main.js ================================================ import message from 'nested/foo'; import external from 'utils/external'; console.log( message ); ================================================ FILE: test/bundle/input/06/nested/foo.js ================================================ export default 'this is a message'; ================================================ FILE: test/bundle/input/07/_config.js ================================================ module.exports = { description: 'modules can be skipped', skip: [ 'bar' ] }; ================================================ FILE: test/bundle/input/07/bar.js ================================================ export default 'this is bar'; ================================================ FILE: test/bundle/input/07/foo.js ================================================ export default 'this is foo'; ================================================ FILE: test/bundle/input/07/main.js ================================================ import foo from 'foo'; import bar from 'bar'; function logFoo () { console.log( foo ); } function logBar () { console.log( bar ); } ================================================ FILE: test/bundle/input/08/_config.js ================================================ module.exports = { description: 'external module names are guessed (affects UMD only)', imports: [ 'external' ] }; ================================================ FILE: test/bundle/input/08/main.js ================================================ import ImplicitlyNamed from 'external'; ================================================ FILE: test/bundle/input/09/_config.js ================================================ module.exports = { description: 'external module names can be specified (affects UMD only)', imports: [ 'external' ], names: { external: 'Correct' } }; ================================================ FILE: test/bundle/input/09/main.js ================================================ import ExplicitlyNamed from 'external'; ================================================ FILE: test/bundle/input/10/_config.js ================================================ module.exports = { description: 'does not affect ES6 classes', exports: [ 'default' ] }; ================================================ FILE: test/bundle/input/10/main.js ================================================ export default class Foo { constructor( str ) { this.str = str; } toString() { return this.str; } } ================================================ FILE: test/bundle/input/11/_config.js ================================================ module.exports = { description: 'exports chains correctly in strict mode', strict: true, exports: [ 'foo', 'bar', 'baz', 'qux' ] }; ================================================ FILE: test/bundle/input/11/a.js ================================================ export var foo = 1; export var bar = 2; foo = 3; ================================================ FILE: test/bundle/input/11/b.js ================================================ export default 4; ================================================ FILE: test/bundle/input/11/main.js ================================================ import { foo, bar } from './a'; import baz from './b'; var qux = 5; qux = 6; export { foo, bar, baz, qux }; ================================================ FILE: test/bundle/input/12/_config.js ================================================ module.exports = { description: 'throws an error if a non-exported identifier is imported', error: /does not export/ }; ================================================ FILE: test/bundle/input/12/foo.js ================================================ var bar = 'not exported'; ================================================ FILE: test/bundle/input/12/main.js ================================================ import { bar } from './foo'; ================================================ FILE: test/bundle/input/13/_config.js ================================================ module.exports = { description: 'throw error with file and location error if acorn cannot parse', error: function ( err ) { return err.file === require( 'path' ).resolve( __dirname, 'main.js' ) && err.loc.line === 1 && err.loc.column === 4; } }; ================================================ FILE: test/bundle/input/13/main.js ================================================ var 42 = answer; ================================================ FILE: test/bundle/input/14/_config.js ================================================ module.exports = { description: 'handles default imports from external modules correctly', imports: [ 'external' ] }; ================================================ FILE: test/bundle/input/14/main.js ================================================ import foo from './external'; foo(); ================================================ FILE: test/bundle/input/15/_config.js ================================================ module.exports = { description: 'handles named imports from external modules correctly', imports: [ 'external' ], strict: true }; ================================================ FILE: test/bundle/input/15/main.js ================================================ import { foo } from './external'; foo(); ================================================ FILE: test/bundle/input/16/_config.js ================================================ module.exports = { description: 'handles conflicting imports' }; ================================================ FILE: test/bundle/input/16/a.js ================================================ export default function a () { console.log( 'a' ); } ================================================ FILE: test/bundle/input/16/b.js ================================================ import a from './c'; export default function () { // a but actually c a(); } ================================================ FILE: test/bundle/input/16/c.js ================================================ export default function a () { console.log( 'a but actually c' ); } ================================================ FILE: test/bundle/input/16/main.js ================================================ import a from './a'; import b from './b'; function foo () { a(); } ================================================ FILE: test/bundle/input/17/_config.js ================================================ module.exports = { description: 'handles shadowed renamed imports' }; ================================================ FILE: test/bundle/input/17/foo.js ================================================ export function a ( message ) { console.log( message ); } ================================================ FILE: test/bundle/input/17/main.js ================================================ import { a as b } from './foo'; b(); (function () { var a = 'c'; b( a ); }()); ================================================ FILE: test/bundle/input/18/_config.js ================================================ module.exports = { description: 'renames imports that conflict with existing variable names' }; ================================================ FILE: test/bundle/input/18/bar.js ================================================ export default function () { doThing(); } var doThing = function ( item ) { console.log( 'doing bar thing' ); } ================================================ FILE: test/bundle/input/18/doThing.js ================================================ export default function () { console.log( 'doing foo thing' ); } ================================================ FILE: test/bundle/input/18/foo.js ================================================ import doThing from './doThing'; export default function () { doThing(); } ================================================ FILE: test/bundle/input/18/main.js ================================================ import foo from './foo'; import bar from './bar'; // foo(); // bar(); ================================================ FILE: test/bundle/input/19/_config.js ================================================ module.exports = { description: 'handles hasOwnProperty edge case (default imports)' }; ================================================ FILE: test/bundle/input/19/hasOwnProperty.js ================================================ var hasOwnProperty = Object.prototype.hasOwnProperty; export default hasOwnProperty; ================================================ FILE: test/bundle/input/19/main.js ================================================ import hasOwnProperty from './hasOwnProperty'; console.log( hasOwnProperty.call({ foo: 'bar' }, 'foo' ) ); ================================================ FILE: test/bundle/input/20/_config.js ================================================ module.exports = { description: 'handles hasOwnProperty edge case (named imports)', exports: [ 'default' ] }; ================================================ FILE: test/bundle/input/20/main.js ================================================ import { hasOwnProperty } from './objectUtils'; export default function () { console.log( hasOwnProperty.call({ foo: 'bar' }, 'foo' ) ); } ================================================ FILE: test/bundle/input/20/objectUtils.js ================================================ export var hasOwnProperty = Object.prototype.hasOwnProperty; ================================================ FILE: test/bundle/input/21/_config.js ================================================ module.exports = { description: 'handles member assignments of named imports' }; ================================================ FILE: test/bundle/input/21/config.js ================================================ export const config = {}; ================================================ FILE: test/bundle/input/21/main.js ================================================ import { config } from './config'; config.async = true; ================================================ FILE: test/bundle/input/22/_config.js ================================================ module.exports = { description: 'handles named exports of default imports', strict: true, exports: [ 'foo' ] }; ================================================ FILE: test/bundle/input/22/foo.js ================================================ export default function foo () { console.log( 'fooing' ); } ================================================ FILE: test/bundle/input/22/main.js ================================================ import foo from './foo'; // foo foo(); export { foo }; ================================================ FILE: test/bundle/input/23/_config.js ================================================ module.exports = { description: 'throws error if module imports itself', error: /cannot import itself/ }; ================================================ FILE: test/bundle/input/23/foo.js ================================================ import { baz } from './foo'; export function bar () { baz(); } export function baz () { console.log( 'bazzing' ); } ================================================ FILE: test/bundle/input/23/main.js ================================================ import { bar } from './foo'; bar(); ================================================ FILE: test/bundle/input/24/_config.js ================================================ module.exports = { description: 'adds a banner/footer to bundle', banner: '/* this is a banner */\n', footer: '\n/* this is a footer */' }; ================================================ FILE: test/bundle/input/24/bar.js ================================================ export default function bar () { console.log( 'baring' ); } ================================================ FILE: test/bundle/input/24/foo.js ================================================ export default function foo () { console.log( 'fooing' ); } ================================================ FILE: test/bundle/input/24/main.js ================================================ import foo from './foo'; import bar from './bar'; foo(); bar(); ================================================ FILE: test/bundle/input/25/_config.js ================================================ module.exports = { description: 'creates a named AMD module', amdName: 'myModule' }; ================================================ FILE: test/bundle/input/25/foo.js ================================================ export default function () { console.log( 'fooing' ); } ================================================ FILE: test/bundle/input/25/main.js ================================================ import foo from 'foo'; foo(); ================================================ FILE: test/bundle/input/26/_config.js ================================================ module.exports = { description: 'transforms input sources', transform: function ( source ) { return source.replace( /foo/g, 'bar' ); } }; ================================================ FILE: test/bundle/input/26/bar.js ================================================ export default function foo () { console.log( 'fooing' ); } ================================================ FILE: test/bundle/input/26/main.js ================================================ import foo from 'foo'; foo(); ================================================ FILE: test/bundle/input/27/_config.js ================================================ module.exports = { description: 'correctly infers indentation with single-line edge case' }; ================================================ FILE: test/bundle/input/27/bar.js ================================================ export default 'this is bar'; ================================================ FILE: test/bundle/input/27/foo.js ================================================ export default 'this is foo'; ================================================ FILE: test/bundle/input/27/main.js ================================================ import foo from 'foo'; import bar from 'bar'; function logFoo () { console.log( foo ); } function logBar () { console.log( bar ); } ================================================ FILE: test/bundle/input/28/_config.js ================================================ module.exports = { description: 'environment GetThisBinding is always undefined' }; ================================================ FILE: test/bundle/input/28/foo.js ================================================ export default () => this; ================================================ FILE: test/bundle/input/28/main.js ================================================ import foo from 'foo'; assert.strictEqual( this, undefined ); var ctx = {}; var arrow = (x => assert.strictEqual( this, undefined )); var fn = function () { assert.strictEqual( this, ctx ); }; arrow.call(ctx); fn.call(ctx); assert.strictEqual(foo(), undefined); ================================================ FILE: test/bundle/input/29/_config.js ================================================ module.exports = { description: 'both named and default bindings can be imported from an external module', imports: [ 'foo' ], strict: true }; ================================================ FILE: test/bundle/input/29/main.js ================================================ import foo, { bar } from './foo'; foo(); bar(); ================================================ FILE: test/bundle/input/30/_config.js ================================================ module.exports = { description: 'batch import from external module', imports: [ 'foo' ] }; ================================================ FILE: test/bundle/input/30/main.js ================================================ import * as foo from 'foo'; foo.bar(); ================================================ FILE: test/bundle/input/31/_config.js ================================================ module.exports = { description: 'renames identifiers consistently' }; ================================================ FILE: test/bundle/input/31/exportedX.js ================================================ export default function someOtherName () {} ================================================ FILE: test/bundle/input/31/main.js ================================================ import x from './exportedX'; import './notExportedX'; x(); ================================================ FILE: test/bundle/input/31/notExportedX.js ================================================ function x () {} ================================================ FILE: test/bundle/input/32/_config.js ================================================ module.exports = { description: 'transformer can return an empty string', transform: function () { return ''; } }; ================================================ FILE: test/bundle/input/32/main.js ================================================ /* this will be discarded */ ================================================ FILE: test/bundle/input/33/Math.js ================================================ export function add ( a, b ) { return a + b; } export function multiply ( a, b ) { return a * b; } ================================================ FILE: test/bundle/input/33/Promise.js ================================================ var Promise = function () {}; Promise.prototype = { keep () { this.state = 'kept'; }, break () { this.state = 'broken'; } }; export default Promise; ================================================ FILE: test/bundle/input/33/_config.js ================================================ module.exports = { description: 'Module names do not shadow built-ins' }; ================================================ FILE: test/bundle/input/33/foo.js ================================================ var num = Math.max( 1, 2, 3 ); var resolved = Promise.resolve( num ); export default function foo () { return resolved; } ================================================ FILE: test/bundle/input/33/main.js ================================================ import Promise from './Promise'; import * as Math from './Math'; import foo from './foo'; var promise = new Promise(); promise.keep(); console.log( Math.add( 40, 2 ) ); ================================================ FILE: test/bundle/input/34/_config.js ================================================ module.exports = { description: 'avoids conflict between exports and existing variables', exports: [ 'default' ] }; ================================================ FILE: test/bundle/input/34/foo.js ================================================ var exports = {}; exports.bar = function () { console.log( 'exports should be renamed' ); }; export default exports; ================================================ FILE: test/bundle/input/34/main.js ================================================ import foo from './foo'; foo.bar(); export default 'whatever'; ================================================ FILE: test/bundle/input/35/_config.js ================================================ var path = require( 'path' ); var Promise = require( 'sander' ).Promise; var resolve = require( 'resolve' ); module.exports = { description: 'External module paths can be resolved with resolvePath option', resolvePath: function ( importee, importer ) { return new Promise( function ( fulfil, reject ) { var callback = function ( err, result ) { if ( err ) { reject( err ); } else { fulfil( result ); } }; resolve( importee, { basedir: path.dirname( importer ), moduleDirectory: 'js_modules', // to avoid faffing with .gitignore packageFilter: function ( pkg ) { if ( pkg[ 'jsnext:main' ] ) { pkg.main = pkg[ 'jsnext:main' ]; } return pkg; } }, callback ); }); } }; ================================================ FILE: test/bundle/input/35/js_modules/a.js ================================================ export default function a () { console.log( 'I am module a' ); } ================================================ FILE: test/bundle/input/35/js_modules/c.js ================================================ export default function c () { console.log( 'I am module c' ); } ================================================ FILE: test/bundle/input/35/js_modules/external/js_modules/b.js ================================================ import c from 'c'; export default function b () { console.log( 'I am module b' ); c(); } ================================================ FILE: test/bundle/input/35/js_modules/external/package.json ================================================ { "name": "external", "version": "0.1.0", "main": "dist/external.js", "jsnext:main": "src/external.js" } ================================================ FILE: test/bundle/input/35/js_modules/external/src/external.js ================================================ import a from 'a'; import b from 'b'; export default function external () { console.log( 'I am an external dependency' ); a(); b(); } ================================================ FILE: test/bundle/input/35/main.js ================================================ import external from 'external'; external(); ================================================ FILE: test/bundle/input/36/_config.js ================================================ var path = require( 'path' ); var Promise = require( 'sander' ).Promise; var resolve = require( 'resolve' ); module.exports = { description: 'External module paths can be resolved with resolvePath option', resolvePath: function ( importee, importer ) { return new Promise( function ( fulfil, reject ) { var callback = function ( err, result ) { if ( err ) { reject( err ); } else { fulfil( result ); } }; resolve( importee, { basedir: path.dirname( importer ), moduleDirectory: 'js_modules', // to avoid faffing with .gitignore packageFilter: function ( pkg ) { if ( pkg[ 'jsnext:main' ] ) { pkg.main = pkg[ 'jsnext:main' ]; } return pkg; } }, callback ); }); } }; ================================================ FILE: test/bundle/input/36/js_modules/external/package.json ================================================ { "name": "external", "version": "0.1.0", "main": "dist/external.js", "jsnext:main": "src/external.js" } ================================================ FILE: test/bundle/input/36/js_modules/external/src/dependsOnExternal.js ================================================ import external from './external'; export default function dependsOnExternal () { console.log( external.message ); } ================================================ FILE: test/bundle/input/36/js_modules/external/src/external.js ================================================ import dependsOnExternal from './dependsOnExternal'; export default function external () { dependsOnExternal(); } external.message = 'don\'t try this at home'; ================================================ FILE: test/bundle/input/36/main.js ================================================ import external from 'external'; external(); ================================================ FILE: test/bundle/input/37/_config.js ================================================ module.exports = { description: 'Clashes with external dependency names are handled', imports: [ 'moment' ] }; ================================================ FILE: test/bundle/input/37/a.js ================================================ var x = 'wut'; export default x; ================================================ FILE: test/bundle/input/37/main.js ================================================ import x from "moment"; import a from './a'; ================================================ FILE: test/bundle/input/38/_config.js ================================================ module.exports = { description: 'Export reassignments are deconflicted' }; ================================================ FILE: test/bundle/input/38/foo.js ================================================ export default notActuallyFoo; function notActuallyFoo () { foo(); } function foo () { console.log( 'actually foo' ); } ================================================ FILE: test/bundle/input/38/main.js ================================================ import foo from './foo'; foo(); ================================================ FILE: test/bundle/input/39/_config.js ================================================ module.exports = { description: 'avoids naming collisions between imports', error: /Duplicated import \('x'\)/ }; ================================================ FILE: test/bundle/input/39/bar.js ================================================ export default function () {} ================================================ FILE: test/bundle/input/39/foo.js ================================================ export default function () {} ================================================ FILE: test/bundle/input/39/main.js ================================================ import x from './foo'; import x from './bar'; x(); ================================================ FILE: test/bundle/input/40/_config.js ================================================ module.exports = { description: 'removes existing sourcemap comments' }; ================================================ FILE: test/bundle/input/40/foo.js ================================================ export default function foo () { console.log( 'foo' ); } //# sourceMappingURL=foo.js.map ================================================ FILE: test/bundle/input/40/main.js ================================================ import foo from './foo'; foo(); //# sourceMappingURL=main.js.map ================================================ FILE: test/bundle/input/42/_config.js ================================================ module.exports = { description: 'removes comments without blowing up' }; ================================================ FILE: test/bundle/input/42/foo.js ================================================ function foo () { console.log( 'foo' ); } export { foo }; //# sourceMappingURL=foo.js.map ================================================ FILE: test/bundle/input/42/main.js ================================================ import { foo } from './foo'; foo(); //# sourceMappingURL=main.js.map ================================================ FILE: test/bundle/input/43/_config.js ================================================ module.exports = { description: 'bundles class with super (#129)', imports: [ 'bar' ] }; ================================================ FILE: test/bundle/input/43/main.js ================================================ import Bar from 'bar'; class Foo extends Bar { constructor() { super(); console.log('Foo constructed'); } } ================================================ FILE: test/bundle/input/44/_config.js ================================================ module.exports = { description: 'avoids conflicts between imports and declarations not in root scope', imports: [ 'foo', 'bar' ] }; ================================================ FILE: test/bundle/input/44/a.js ================================================ import foo from 'foo'; ================================================ FILE: test/bundle/input/44/b.js ================================================ import foo from 'bar'; (function () { var bar = 'nope'; foo(); })(); ================================================ FILE: test/bundle/input/44/main.js ================================================ import './a'; import './b'; ================================================ FILE: test/bundle/input/45/_config.js ================================================ module.exports = { description: 'uses supplied code', modules: { 'main.js': 'import foo from \'./foo\';\nfoo();', 'foo/index.js': 'import bar from \'./bar\';\nexport default function foo () {\n\tconsole.log( bar );\n}', 'foo/bar.js': 'export default 42;' } }; ================================================ FILE: test/bundle/input/46/_config.js ================================================ module.exports = { description: 'uses supplied AST', modules: { 'main.js': 'import foo from \'./foo\';\nfoo();', // the code points to './bar' but the AST points to './baz', so we // can check the AST is being used 'foo/index.js': { code: 'import bar from \'./bar\';\nexport default function foo () {\n\tconsole.log( bar );\n}', ast: { start: 0, body: [ { start: 0, specifiers: [{ start: 7, local: { start: 7, name: "bar", type: "Identifier", end: 10 }, type: "ImportDefaultSpecifier", end: 10 }], source: { start: 16, value: "./baz", raw: "\'./baz\'", type: "Literal", end: 23 }, type: "ImportDeclaration", end: 24 }, { start: 25, declaration: { start: 40, id: { start: 49, name: "foo", type: "Identifier", end: 52 }, generator: false, expression: false, params: [], body: { start: 56, body: [{ start: 59, expression: { start: 59, callee: { start: 59, object: { start: 59, name: "console", type: "Identifier", end: 66 }, property: { start: 67, name: "log", type: "Identifier", end: 70 }, computed: false, type: "MemberExpression", end: 70 }, arguments: [ { start: 72, name: "bar", type: "Identifier", end: 75 } ], type: "CallExpression", end: 77 }, type: "ExpressionStatement", end: 78 }], type: "BlockStatement", end: 80 }, type: "FunctionDeclaration", end: 80 }, type: "ExportDefaultDeclaration", end: 80 }], sourceType: "module", type: "Program", end: 80 } }, 'foo/baz.js': 'export default 42;' } }; ================================================ FILE: test/bundle/input/47/_config.js ================================================ module.exports = { description: 'omits use strict if necessary', useStrict: false }; ================================================ FILE: test/bundle/input/47/main.js ================================================ implicitGlobal = 'lol'; ================================================ FILE: test/bundle/input/48/_config.js ================================================ module.exports = { description: 'handles resolvePath failure', resolvePath: function ( importee ) { if ( importee[0] !== '.' ) return null; return importee; }, imports: [ 'external' ] }; ================================================ FILE: test/bundle/input/48/main.js ================================================ import external from 'external'; external(); ================================================ FILE: test/bundle/input/49/_config.js ================================================ module.exports = { description: 'generates inline sourcemap', sourceMap: 'inline' }; ================================================ FILE: test/bundle/input/49/foo.js ================================================ export default function foo () { console.log( 'foo' ); } ================================================ FILE: test/bundle/input/49/main.js ================================================ import foo from './foo'; foo(); ================================================ FILE: test/bundle/input/50/A.js ================================================ import B from './B'; export default class A { constructor () { console.log( 'creating A' ); } b () { return new B(); } } ================================================ FILE: test/bundle/input/50/B.js ================================================ import A from './A'; export default class B extends A { constructor () { console.log( 'creating B' ); } } ================================================ FILE: test/bundle/input/50/C.js ================================================ import D from './D'; export default class C extends D { constructor () { console.log( 'creating C' ); } } ================================================ FILE: test/bundle/input/50/D.js ================================================ import C from './C'; export default class D { constructor () { console.log( 'creating D' ); } c () { return new C(); } } ================================================ FILE: test/bundle/input/50/_config.js ================================================ module.exports = { description: 'cyclical dependency order is resolved based on need (#152)', //solo: true }; ================================================ FILE: test/bundle/input/50/main.js ================================================ import A from './A'; import B from './B'; import C from './C'; import D from './D'; new A().b(); new B(); new C(); new D().c(); ================================================ FILE: test/bundle/input/51/_config.js ================================================ module.exports = { description: 'leaves trailing .js in external package name', imports: [ 'highlight.js' ] }; ================================================ FILE: test/bundle/input/51/foo.js ================================================ export default 42; ================================================ FILE: test/bundle/input/51/main.js ================================================ import highlight from 'highlight.js'; import foo from './foo.js'; ================================================ FILE: test/bundle/input/52/_config.js ================================================ var path = require( 'path' ); module.exports = { description: 'correctly renames bindings from modules referred to by local and external-ish modules', resolvePath: function ( importee ) { return path.resolve( __dirname, 'external', importee.slice( 4 ) ) + '.js'; } }; ================================================ FILE: test/bundle/input/52/bar.js ================================================ import baz from 'ext/baz'; // bar.js console.log( 'baz', baz ); ================================================ FILE: test/bundle/input/52/external/baz.js ================================================ export default function () { // baz.js }; ================================================ FILE: test/bundle/input/52/external/foo.js ================================================ import not_baz from './baz'; // foo.js ================================================ FILE: test/bundle/input/52/main.js ================================================ import 'ext/foo'; import './bar'; // main.js ================================================ FILE: test/bundle/input/53/_config.js ================================================ module.exports = { description: 'allows modules to depend on entry module', exports: [ 'default' ] }; ================================================ FILE: test/bundle/input/53/foo.js ================================================ import main from './main'; export default function () { console.log( 'foo' ); } ================================================ FILE: test/bundle/input/53/main.js ================================================ import foo from './foo'; foo(); export default function () { console.log( 'main' ); } ================================================ FILE: test/bundle/input/54/_config.js ================================================ module.exports = { description: 'allows multiple modules to share an external package', imports: [ 'bluebird' ] }; ================================================ FILE: test/bundle/input/54/foo.js ================================================ import Promise from 'bluebird'; export default 'foo'; ================================================ FILE: test/bundle/input/54/main.js ================================================ import Promise from 'bluebird'; import foo from './foo'; ================================================ FILE: test/bundle/input/55/A.js ================================================ import B from './B'; import C from './C'; class A { b () { return new B(); } c () { return new C(); } } export default A; ================================================ FILE: test/bundle/input/55/B.js ================================================ import A from './A'; class B extends A {} export default B; ================================================ FILE: test/bundle/input/55/C.js ================================================ import A from './A'; class C extends A {} export default C; ================================================ FILE: test/bundle/input/55/_config.js ================================================ module.exports = { description: 'handles more complex mutually dependent module scenario (#157)' }; ================================================ FILE: test/bundle/input/55/main.js ================================================ import A from './A'; ================================================ FILE: test/bundle/input/56/_config.js ================================================ module.exports = { description: 'default exports are not live' }; ================================================ FILE: test/bundle/input/56/foo.js ================================================ var foo = 42; export default foo; foo = 99; foo += 1; foo++; ================================================ FILE: test/bundle/input/56/main.js ================================================ import foo from './foo'; console.log( foo ); // 42 ================================================ FILE: test/bundle/input/57/_config.js ================================================ module.exports = { description: 'correctly exports x as y inside a bundle' }; ================================================ FILE: test/bundle/input/57/foo.js ================================================ var x = 42; export { x as y }; ================================================ FILE: test/bundle/input/57/main.js ================================================ import * as foo from './foo'; console.log( foo.y ); ================================================ FILE: test/bundle/input/58/_config.js ================================================ module.exports = { description: 'correctly exports x as y from a bundle', exports: [ 'y' ], strict: true }; ================================================ FILE: test/bundle/input/58/main.js ================================================ var x = 42; export { x as y }; ================================================ FILE: test/bundle/input/59/_config.js ================================================ module.exports = { description: 'correctly handles renamed exports within a bundle' }; ================================================ FILE: test/bundle/input/59/foo.js ================================================ var foo = 'foo'; export { foo as bar }; ================================================ FILE: test/bundle/input/59/main.js ================================================ import { bar } from './foo'; console.log( bar ); // 'foo' ================================================ FILE: test/bundle/input/60/_config.js ================================================ module.exports = { description: 'preserves comments after imports' }; ================================================ FILE: test/bundle/input/60/bar.js ================================================ var bar = 'bar'; export { bar }; ================================================ FILE: test/bundle/input/60/foo.js ================================================ var foo = 'foo'; export { foo }; ================================================ FILE: test/bundle/input/60/main.js ================================================ import { foo } from './foo'; import { bar } from './bar'; // Preserve comments after imports console.log( foo ); ================================================ FILE: test/bundle/output/amd/01.js ================================================ define(function () { 'use strict'; var message = 'yes'; var foo = message; console.log( foo ); }); ================================================ FILE: test/bundle/output/amd/02.js ================================================ define(function () { 'use strict'; var message = 'yes'; var foo = message; console.log( foo ); }); ================================================ FILE: test/bundle/output/amd/03.js ================================================ define(['external'], function (external) { 'use strict'; external = ('default' in external ? external['default'] : external); var bar = 'yes'; var foo = bar; console.log( external( foo ) ); }); ================================================ FILE: test/bundle/output/amd/04.js ================================================ define(['exports'], function (exports) { 'use strict'; var answer = 42; var main = answer * 2; exports['default'] = main; }); ================================================ FILE: test/bundle/output/amd/05.js ================================================ define(['exports'], function (exports) { 'use strict'; var one = 1; var two = 2; var three = 3; var four = one + 3; var five = two + 3; var six = three + 3; four = 99; exports.four = four; exports.five = five; exports.six = six; }); ================================================ FILE: test/bundle/output/amd/06.js ================================================ define(['utils/external'], function (external) { 'use strict'; external = ('default' in external ? external['default'] : external); var message = 'this is a message'; console.log( message ); }); ================================================ FILE: test/bundle/output/amd/07.js ================================================ define(function () { 'use strict'; var foo = 'this is foo'; function logFoo () { console.log( foo ); } function logBar () { console.log( bar ); } }); ================================================ FILE: test/bundle/output/amd/08.js ================================================ define(['external'], function (ImplicitlyNamed) { 'use strict'; ImplicitlyNamed = ('default' in ImplicitlyNamed ? ImplicitlyNamed['default'] : ImplicitlyNamed); }); ================================================ FILE: test/bundle/output/amd/09.js ================================================ define(['external'], function (Correct) { 'use strict'; Correct = ('default' in Correct ? Correct['default'] : Correct); }); ================================================ FILE: test/bundle/output/amd/10.js ================================================ define(['exports'], function (exports) { 'use strict'; class Foo { constructor( str ) { this.str = str; } toString() { return this.str; } } exports['default'] = Foo; }); ================================================ FILE: test/bundle/output/amd/11.js ================================================ define(['exports'], function (exports) { 'use strict'; var foo = 1; var bar = 2; foo = 3; exports.foo = foo; exports.bar = bar; var baz = 4; exports.baz = baz; var qux = 5; qux = 6; exports.qux = qux; }); ================================================ FILE: test/bundle/output/amd/14.js ================================================ define(['external'], function (foo) { 'use strict'; foo = ('default' in foo ? foo['default'] : foo); foo(); }); ================================================ FILE: test/bundle/output/amd/15.js ================================================ define(['external'], function (external) { 'use strict'; external.foo(); }); ================================================ FILE: test/bundle/output/amd/16.js ================================================ define(function () { 'use strict'; function _a__a () { console.log( 'a' ); } function c__a () { console.log( 'a but actually c' ); } var b = function () { // a but actually c c__a(); } function foo () { _a__a(); } }); ================================================ FILE: test/bundle/output/amd/17.js ================================================ define(function () { 'use strict'; function foo__a ( message ) { console.log( message ); } foo__a(); (function () { var a = 'c'; foo__a( a ); }()); }); ================================================ FILE: test/bundle/output/amd/18.js ================================================ define(function () { 'use strict'; var _doThing = function () { console.log( 'doing foo thing' ); } var foo = function () { _doThing(); } var bar = function () { doThing(); } var doThing = function ( item ) { console.log( 'doing bar thing' ); } }); ================================================ FILE: test/bundle/output/amd/19.js ================================================ define(function () { 'use strict'; var hasOwnProperty = Object.prototype.hasOwnProperty; console.log( hasOwnProperty.call({ foo: 'bar' }, 'foo' ) ); }); ================================================ FILE: test/bundle/output/amd/20.js ================================================ define(['exports'], function (exports) { 'use strict'; var hasOwnProperty = Object.prototype.hasOwnProperty; var main = function () { console.log( hasOwnProperty.call({ foo: 'bar' }, 'foo' ) ); } exports['default'] = main; }); ================================================ FILE: test/bundle/output/amd/21.js ================================================ define(function () { 'use strict'; const config = {}; config.async = true; }); ================================================ FILE: test/bundle/output/amd/22.js ================================================ define(['exports'], function (exports) { 'use strict'; function foo () { console.log( 'fooing' ); } exports.foo = foo; // foo foo(); }); ================================================ FILE: test/bundle/output/amd/24.js ================================================ /* this is a banner */ define(function () { 'use strict'; function foo () { console.log( 'fooing' ); } function bar () { console.log( 'baring' ); } foo(); bar(); }); /* this is a footer */ ================================================ FILE: test/bundle/output/amd/25.js ================================================ define('myModule', function () { 'use strict'; var foo = function () { console.log( 'fooing' ); } foo(); }); ================================================ FILE: test/bundle/output/amd/26.js ================================================ define(function () { 'use strict'; function bar () { console.log( 'baring' ); } bar(); }); ================================================ FILE: test/bundle/output/amd/27.js ================================================ define(function () { 'use strict'; var foo = 'this is foo'; var bar = 'this is bar'; function logFoo () { console.log( foo ); } function logBar () { console.log( bar ); } }); ================================================ FILE: test/bundle/output/amd/28.js ================================================ define(function () { 'use strict'; var foo = () => undefined; assert.strictEqual( undefined, undefined ); var ctx = {}; var arrow = (x => assert.strictEqual( undefined, undefined )); var fn = function () { assert.strictEqual( this, ctx ); }; arrow.call(ctx); fn.call(ctx); assert.strictEqual(foo(), undefined); }); ================================================ FILE: test/bundle/output/amd/29.js ================================================ define(['foo'], function (foo) { 'use strict'; var foo__default = ('default' in foo ? foo['default'] : foo); foo__default(); foo.bar(); }); ================================================ FILE: test/bundle/output/amd/30.js ================================================ define(['foo'], function (foo) { 'use strict'; foo.bar(); }); ================================================ FILE: test/bundle/output/amd/31.js ================================================ define(function () { 'use strict'; function someOtherName () {} function x () {} someOtherName(); }); ================================================ FILE: test/bundle/output/amd/32.js ================================================ define(function () { 'use strict'; }); ================================================ FILE: test/bundle/output/amd/33.js ================================================ define(function () { 'use strict'; var _Promise__Promise = function () {}; _Promise__Promise.prototype = { keep () { this.state = 'kept'; }, break () { this.state = 'broken'; } }; var _Promise = _Promise__Promise; var _Math = { get add () { return add; }, get multiply () { return multiply; } }; function add ( a, b ) { return a + b; } function multiply ( a, b ) { return a * b; } var num = Math.max( 1, 2, 3 ); var resolved = Promise.resolve( num ); function foo () { return resolved; } var promise = new _Promise(); promise.keep(); console.log( _Math.add( 40, 2 ) ); }); ================================================ FILE: test/bundle/output/amd/34.js ================================================ define(['exports'], function (exports) { 'use strict'; var foo__exports = {}; foo__exports.bar = function () { console.log( 'exports should be renamed' ); }; var foo = foo__exports; foo.bar(); var main = 'whatever'; exports['default'] = main; }); ================================================ FILE: test/bundle/output/amd/35.js ================================================ define(function () { 'use strict'; function a () { console.log( 'I am module a' ); } function c () { console.log( 'I am module c' ); } function b () { console.log( 'I am module b' ); c(); } function external () { console.log( 'I am an external dependency' ); a(); b(); } external(); }); ================================================ FILE: test/bundle/output/amd/36.js ================================================ define(function () { 'use strict'; function dependsOnExternal () { console.log( external.message ); } function external () { dependsOnExternal(); } external.message = 'don\'t try this at home'; external(); }); ================================================ FILE: test/bundle/output/amd/37.js ================================================ define(['moment'], function (x) { 'use strict'; x = ('default' in x ? x['default'] : x); var a__x = 'wut'; var a = a__x; }); ================================================ FILE: test/bundle/output/amd/38.js ================================================ define(function () { 'use strict'; var _foo = notActuallyFoo; function notActuallyFoo () { foo(); } function foo () { console.log( 'actually foo' ); } _foo(); }); ================================================ FILE: test/bundle/output/amd/40.js ================================================ define(function () { 'use strict'; function foo () { console.log( 'foo' ); } foo(); }); ================================================ FILE: test/bundle/output/amd/42.js ================================================ define(function () { 'use strict'; function foo () { console.log( 'foo' ); } foo(); }); ================================================ FILE: test/bundle/output/amd/43.js ================================================ define(['bar'], function (Bar) { 'use strict'; Bar = ('default' in Bar ? Bar['default'] : Bar); class Foo extends Bar { constructor() { super(); console.log('Foo constructed'); } } }); ================================================ FILE: test/bundle/output/amd/44.js ================================================ define(['foo', 'bar'], function (foo, _bar) { 'use strict'; foo = ('default' in foo ? foo['default'] : foo); _bar = ('default' in _bar ? _bar['default'] : _bar); (function () { var bar = 'nope'; _bar(); })(); }); ================================================ FILE: test/bundle/output/amd/45.js ================================================ define(function () { 'use strict'; var bar = 42; function foo () { console.log( bar ); } foo(); }); ================================================ FILE: test/bundle/output/amd/46.js ================================================ define(function () { 'use strict'; var bar = 42; function foo () { console.log( bar ); } foo(); }); ================================================ FILE: test/bundle/output/amd/47.js ================================================ define(function () { implicitGlobal = 'lol'; }); ================================================ FILE: test/bundle/output/amd/48.js ================================================ define(['external'], function (external) { 'use strict'; external = ('default' in external ? external['default'] : external); external(); }); ================================================ FILE: test/bundle/output/amd/49.js ================================================ define(function () { 'use strict'; function foo () { console.log( 'foo' ); } foo(); }); //# sourceMappingURL=data:application/json;charset=utf-8;base64,xyz ================================================ FILE: test/bundle/output/amd/50.js ================================================ define(function () { 'use strict'; class A { constructor () { console.log( 'creating A' ); } b () { return new B(); } } class B extends A { constructor () { console.log( 'creating B' ); } } class D { constructor () { console.log( 'creating D' ); } c () { return new C(); } } class C extends D { constructor () { console.log( 'creating C' ); } } new A().b(); new B(); new C(); new D().c(); }); ================================================ FILE: test/bundle/output/amd/51.js ================================================ define(['highlight.js'], function (highlight) { 'use strict'; highlight = ('default' in highlight ? highlight['default'] : highlight); var foo = 42; }); ================================================ FILE: test/bundle/output/amd/52.js ================================================ define(function () { 'use strict'; var not_baz = function () { // baz.js }; // bar.js console.log( 'baz', not_baz ); }); ================================================ FILE: test/bundle/output/amd/53.js ================================================ define(['exports'], function (exports) { 'use strict'; var foo = function () { console.log( 'foo' ); } foo(); var main = function () { console.log( 'main' ); } exports['default'] = main; }); ================================================ FILE: test/bundle/output/amd/54.js ================================================ define(['bluebird'], function (bluebird) { 'use strict'; bluebird = ('default' in bluebird ? bluebird['default'] : bluebird); var foo = 'foo'; }); ================================================ FILE: test/bundle/output/amd/55.js ================================================ define(function () { 'use strict'; class A { b () { return new B(); } c () { return new C(); } } class B extends A {} class C extends A {} }); ================================================ FILE: test/bundle/output/amd/56.js ================================================ define(function () { 'use strict'; var foo = 42; var _foo = foo; foo = 99; foo += 1; foo++; console.log( _foo ); // 42 }); ================================================ FILE: test/bundle/output/amd/57.js ================================================ define(function () { 'use strict'; var foo = { get y () { return x; } }; var x = 42; console.log( foo.y ); }); ================================================ FILE: test/bundle/output/amd/58.js ================================================ define(['exports'], function (exports) { 'use strict'; var x = 42; exports.y = x; }); ================================================ FILE: test/bundle/output/amd/59.js ================================================ define(function () { 'use strict'; var foo = 'foo'; console.log( foo ); // 'foo' }); ================================================ FILE: test/bundle/output/amd/60.js ================================================ define(function () { 'use strict'; var foo = 'foo'; var bar = 'bar'; // Preserve comments after imports console.log( foo ); }); ================================================ FILE: test/bundle/output/amdDefaults/01.js ================================================ define(function () { 'use strict'; var message = 'yes'; var foo = message; console.log( foo ); }); ================================================ FILE: test/bundle/output/amdDefaults/02.js ================================================ define(function () { 'use strict'; var message = 'yes'; var foo = message; console.log( foo ); }); ================================================ FILE: test/bundle/output/amdDefaults/03.js ================================================ define(['external'], function (external) { 'use strict'; var bar = 'yes'; var foo = bar; console.log( external( foo ) ); }); ================================================ FILE: test/bundle/output/amdDefaults/04.js ================================================ define(function () { 'use strict'; var answer = 42; var main = answer * 2; return main; }); ================================================ FILE: test/bundle/output/amdDefaults/06.js ================================================ define(['utils/external'], function (external) { 'use strict'; var message = 'this is a message'; console.log( message ); }); ================================================ FILE: test/bundle/output/amdDefaults/07.js ================================================ define(function () { 'use strict'; var foo = 'this is foo'; function logFoo () { console.log( foo ); } function logBar () { console.log( bar ); } }); ================================================ FILE: test/bundle/output/amdDefaults/08.js ================================================ define(['external'], function (ImplicitlyNamed) { 'use strict'; }); ================================================ FILE: test/bundle/output/amdDefaults/09.js ================================================ define(['external'], function (Correct) { 'use strict'; }); ================================================ FILE: test/bundle/output/amdDefaults/10.js ================================================ define(function () { 'use strict'; class Foo { constructor( str ) { this.str = str; } toString() { return this.str; } } return Foo; }); ================================================ FILE: test/bundle/output/amdDefaults/14.js ================================================ define(['external'], function (foo) { 'use strict'; foo(); }); ================================================ FILE: test/bundle/output/amdDefaults/16.js ================================================ define(function () { 'use strict'; function _a__a () { console.log( 'a' ); } function c__a () { console.log( 'a but actually c' ); } var b = function () { // a but actually c c__a(); } function foo () { _a__a(); } }); ================================================ FILE: test/bundle/output/amdDefaults/17.js ================================================ define(function () { 'use strict'; function foo__a ( message ) { console.log( message ); } foo__a(); (function () { var a = 'c'; foo__a( a ); }()); }); ================================================ FILE: test/bundle/output/amdDefaults/18.js ================================================ define(function () { 'use strict'; var _doThing = function () { console.log( 'doing foo thing' ); } var foo = function () { _doThing(); } var bar = function () { doThing(); } var doThing = function ( item ) { console.log( 'doing bar thing' ); } }); ================================================ FILE: test/bundle/output/amdDefaults/19.js ================================================ define(function () { 'use strict'; var hasOwnProperty = Object.prototype.hasOwnProperty; console.log( hasOwnProperty.call({ foo: 'bar' }, 'foo' ) ); }); ================================================ FILE: test/bundle/output/amdDefaults/20.js ================================================ define(function () { 'use strict'; var hasOwnProperty = Object.prototype.hasOwnProperty; var main = function () { console.log( hasOwnProperty.call({ foo: 'bar' }, 'foo' ) ); } return main; }); ================================================ FILE: test/bundle/output/amdDefaults/21.js ================================================ define(function () { 'use strict'; const config = {}; config.async = true; }); ================================================ FILE: test/bundle/output/amdDefaults/24.js ================================================ /* this is a banner */ define(function () { 'use strict'; function foo () { console.log( 'fooing' ); } function bar () { console.log( 'baring' ); } foo(); bar(); }); /* this is a footer */ ================================================ FILE: test/bundle/output/amdDefaults/25.js ================================================ define('myModule', function () { 'use strict'; var foo = function () { console.log( 'fooing' ); } foo(); }); ================================================ FILE: test/bundle/output/amdDefaults/26.js ================================================ define(function () { 'use strict'; function bar () { console.log( 'baring' ); } bar(); }); ================================================ FILE: test/bundle/output/amdDefaults/27.js ================================================ define(function () { 'use strict'; var foo = 'this is foo'; var bar = 'this is bar'; function logFoo () { console.log( foo ); } function logBar () { console.log( bar ); } }); ================================================ FILE: test/bundle/output/amdDefaults/28.js ================================================ define(function () { 'use strict'; var foo = () => undefined; assert.strictEqual( undefined, undefined ); var ctx = {}; var arrow = (x => assert.strictEqual( undefined, undefined )); var fn = function () { assert.strictEqual( this, ctx ); }; arrow.call(ctx); fn.call(ctx); assert.strictEqual(foo(), undefined); }); ================================================ FILE: test/bundle/output/amdDefaults/30.js ================================================ define(['foo'], function (foo) { 'use strict'; foo.bar(); }); ================================================ FILE: test/bundle/output/amdDefaults/31.js ================================================ define(function () { 'use strict'; function someOtherName () {} function x () {} someOtherName(); }); ================================================ FILE: test/bundle/output/amdDefaults/32.js ================================================ define(function () { 'use strict'; }); ================================================ FILE: test/bundle/output/amdDefaults/33.js ================================================ define(function () { 'use strict'; var _Promise__Promise = function () {}; _Promise__Promise.prototype = { keep () { this.state = 'kept'; }, break () { this.state = 'broken'; } }; var _Promise = _Promise__Promise; var _Math = { get add () { return add; }, get multiply () { return multiply; } }; function add ( a, b ) { return a + b; } function multiply ( a, b ) { return a * b; } var num = Math.max( 1, 2, 3 ); var resolved = Promise.resolve( num ); function foo () { return resolved; } var promise = new _Promise(); promise.keep(); console.log( _Math.add( 40, 2 ) ); }); ================================================ FILE: test/bundle/output/amdDefaults/34.js ================================================ define(function () { 'use strict'; var foo__exports = {}; foo__exports.bar = function () { console.log( 'exports should be renamed' ); }; var foo = foo__exports; foo.bar(); var main = 'whatever'; return main; }); ================================================ FILE: test/bundle/output/amdDefaults/35.js ================================================ define(function () { 'use strict'; function a () { console.log( 'I am module a' ); } function c () { console.log( 'I am module c' ); } function b () { console.log( 'I am module b' ); c(); } function external () { console.log( 'I am an external dependency' ); a(); b(); } external(); }); ================================================ FILE: test/bundle/output/amdDefaults/36.js ================================================ define(function () { 'use strict'; function dependsOnExternal () { console.log( external.message ); } function external () { dependsOnExternal(); } external.message = 'don\'t try this at home'; external(); }); ================================================ FILE: test/bundle/output/amdDefaults/37.js ================================================ define(['moment'], function (x) { 'use strict'; var a__x = 'wut'; var a = a__x; }); ================================================ FILE: test/bundle/output/amdDefaults/38.js ================================================ define(function () { 'use strict'; var _foo = notActuallyFoo; function notActuallyFoo () { foo(); } function foo () { console.log( 'actually foo' ); } _foo(); }); ================================================ FILE: test/bundle/output/amdDefaults/40.js ================================================ define(function () { 'use strict'; function foo () { console.log( 'foo' ); } foo(); }); ================================================ FILE: test/bundle/output/amdDefaults/42.js ================================================ define(function () { 'use strict'; function foo () { console.log( 'foo' ); } foo(); }); ================================================ FILE: test/bundle/output/amdDefaults/43.js ================================================ define(['bar'], function (Bar) { 'use strict'; class Foo extends Bar { constructor() { super(); console.log('Foo constructed'); } } }); ================================================ FILE: test/bundle/output/amdDefaults/44.js ================================================ define(['foo', 'bar'], function (foo, _bar) { 'use strict'; (function () { var bar = 'nope'; _bar(); })(); }); ================================================ FILE: test/bundle/output/amdDefaults/45.js ================================================ define(function () { 'use strict'; var bar = 42; function foo () { console.log( bar ); } foo(); }); ================================================ FILE: test/bundle/output/amdDefaults/46.js ================================================ define(function () { 'use strict'; var bar = 42; function foo () { console.log( bar ); } foo(); }); ================================================ FILE: test/bundle/output/amdDefaults/47.js ================================================ define(function () { implicitGlobal = 'lol'; }); ================================================ FILE: test/bundle/output/amdDefaults/48.js ================================================ define(['external'], function (external) { 'use strict'; external(); }); ================================================ FILE: test/bundle/output/amdDefaults/49.js ================================================ define(function () { 'use strict'; function foo () { console.log( 'foo' ); } foo(); }); //# sourceMappingURL=data:application/json;charset=utf-8;base64,xyz ================================================ FILE: test/bundle/output/amdDefaults/50.js ================================================ define(function () { 'use strict'; class A { constructor () { console.log( 'creating A' ); } b () { return new B(); } } class B extends A { constructor () { console.log( 'creating B' ); } } class D { constructor () { console.log( 'creating D' ); } c () { return new C(); } } class C extends D { constructor () { console.log( 'creating C' ); } } new A().b(); new B(); new C(); new D().c(); }); ================================================ FILE: test/bundle/output/amdDefaults/51.js ================================================ define(['highlight.js'], function (highlight) { 'use strict'; var foo = 42; }); ================================================ FILE: test/bundle/output/amdDefaults/52.js ================================================ define(function () { 'use strict'; var not_baz = function () { // baz.js }; // bar.js console.log( 'baz', not_baz ); }); ================================================ FILE: test/bundle/output/amdDefaults/53.js ================================================ define(function () { 'use strict'; var foo = function () { console.log( 'foo' ); } foo(); var main = function () { console.log( 'main' ); } return main; }); ================================================ FILE: test/bundle/output/amdDefaults/54.js ================================================ define(['bluebird'], function (bluebird) { 'use strict'; var foo = 'foo'; }); ================================================ FILE: test/bundle/output/amdDefaults/55.js ================================================ define(function () { 'use strict'; class A { b () { return new B(); } c () { return new C(); } } class B extends A {} class C extends A {} }); ================================================ FILE: test/bundle/output/amdDefaults/56.js ================================================ define(function () { 'use strict'; var foo = 42; var _foo = foo; foo = 99; foo += 1; foo++; console.log( _foo ); // 42 }); ================================================ FILE: test/bundle/output/amdDefaults/57.js ================================================ define(function () { 'use strict'; var foo = { get y () { return x; } }; var x = 42; console.log( foo.y ); }); ================================================ FILE: test/bundle/output/amdDefaults/59.js ================================================ define(function () { 'use strict'; var foo = 'foo'; console.log( foo ); // 'foo' }); ================================================ FILE: test/bundle/output/amdDefaults/60.js ================================================ define(function () { 'use strict'; var foo = 'foo'; var bar = 'bar'; // Preserve comments after imports console.log( foo ); }); ================================================ FILE: test/bundle/output/cjs/01.js ================================================ 'use strict'; var message = 'yes'; var foo = message; console.log( foo ); ================================================ FILE: test/bundle/output/cjs/02.js ================================================ 'use strict'; var message = 'yes'; var foo = message; console.log( foo ); ================================================ FILE: test/bundle/output/cjs/03.js ================================================ 'use strict'; var external = require('external'); external = ('default' in external ? external['default'] : external); var bar = 'yes'; var foo = bar; console.log( external( foo ) ); ================================================ FILE: test/bundle/output/cjs/04.js ================================================ 'use strict'; var answer = 42; var main = answer * 2; exports['default'] = main; ================================================ FILE: test/bundle/output/cjs/05.js ================================================ 'use strict'; var one = 1; var two = 2; var three = 3; var four = one + 3; var five = two + 3; var six = three + 3; four = 99; exports.four = four; exports.five = five; exports.six = six; ================================================ FILE: test/bundle/output/cjs/06.js ================================================ 'use strict'; var external = require('utils/external'); external = ('default' in external ? external['default'] : external); var message = 'this is a message'; console.log( message ); ================================================ FILE: test/bundle/output/cjs/07.js ================================================ 'use strict'; var foo = 'this is foo'; function logFoo () { console.log( foo ); } function logBar () { console.log( bar ); } ================================================ FILE: test/bundle/output/cjs/08.js ================================================ 'use strict'; var ImplicitlyNamed = require('external'); ImplicitlyNamed = ('default' in ImplicitlyNamed ? ImplicitlyNamed['default'] : ImplicitlyNamed); ================================================ FILE: test/bundle/output/cjs/09.js ================================================ 'use strict'; var Correct = require('external'); Correct = ('default' in Correct ? Correct['default'] : Correct); ================================================ FILE: test/bundle/output/cjs/10.js ================================================ 'use strict'; class Foo { constructor( str ) { this.str = str; } toString() { return this.str; } } exports['default'] = Foo; ================================================ FILE: test/bundle/output/cjs/11.js ================================================ 'use strict'; var foo = 1; var bar = 2; foo = 3; exports.foo = foo; exports.bar = bar; var baz = 4; exports.baz = baz; var qux = 5; qux = 6; exports.qux = qux; ================================================ FILE: test/bundle/output/cjs/14.js ================================================ 'use strict'; var foo = require('external'); foo = ('default' in foo ? foo['default'] : foo); foo(); ================================================ FILE: test/bundle/output/cjs/15.js ================================================ 'use strict'; var external = require('external'); external.foo(); ================================================ FILE: test/bundle/output/cjs/16.js ================================================ 'use strict'; function _a__a () { console.log( 'a' ); } function c__a () { console.log( 'a but actually c' ); } var b = function () { // a but actually c c__a(); } function foo () { _a__a(); } ================================================ FILE: test/bundle/output/cjs/17.js ================================================ 'use strict'; function foo__a ( message ) { console.log( message ); } foo__a(); (function () { var a = 'c'; foo__a( a ); }()); ================================================ FILE: test/bundle/output/cjs/18.js ================================================ 'use strict'; var _doThing = function () { console.log( 'doing foo thing' ); } var foo = function () { _doThing(); } var bar = function () { doThing(); } var doThing = function ( item ) { console.log( 'doing bar thing' ); } ================================================ FILE: test/bundle/output/cjs/19.js ================================================ 'use strict'; var hasOwnProperty = Object.prototype.hasOwnProperty; console.log( hasOwnProperty.call({ foo: 'bar' }, 'foo' ) ); ================================================ FILE: test/bundle/output/cjs/20.js ================================================ 'use strict'; var hasOwnProperty = Object.prototype.hasOwnProperty; var main = function () { console.log( hasOwnProperty.call({ foo: 'bar' }, 'foo' ) ); } exports['default'] = main; ================================================ FILE: test/bundle/output/cjs/21.js ================================================ 'use strict'; const config = {}; config.async = true; ================================================ FILE: test/bundle/output/cjs/22.js ================================================ 'use strict'; function foo () { console.log( 'fooing' ); } exports.foo = foo; // foo foo(); ================================================ FILE: test/bundle/output/cjs/24.js ================================================ /* this is a banner */ 'use strict'; function foo () { console.log( 'fooing' ); } function bar () { console.log( 'baring' ); } foo(); bar(); /* this is a footer */ ================================================ FILE: test/bundle/output/cjs/25.js ================================================ 'use strict'; var foo = function () { console.log( 'fooing' ); } foo(); ================================================ FILE: test/bundle/output/cjs/26.js ================================================ 'use strict'; function bar () { console.log( 'baring' ); } bar(); ================================================ FILE: test/bundle/output/cjs/27.js ================================================ 'use strict'; var foo = 'this is foo'; var bar = 'this is bar'; function logFoo () { console.log( foo ); } function logBar () { console.log( bar ); } ================================================ FILE: test/bundle/output/cjs/28.js ================================================ 'use strict'; var foo = () => undefined; assert.strictEqual( undefined, undefined ); var ctx = {}; var arrow = (x => assert.strictEqual( undefined, undefined )); var fn = function () { assert.strictEqual( this, ctx ); }; arrow.call(ctx); fn.call(ctx); assert.strictEqual(foo(), undefined); ================================================ FILE: test/bundle/output/cjs/29.js ================================================ 'use strict'; var foo = require('foo'); var foo__default = ('default' in foo ? foo['default'] : foo); foo__default(); foo.bar(); ================================================ FILE: test/bundle/output/cjs/30.js ================================================ 'use strict'; var foo = require('foo'); foo.bar(); ================================================ FILE: test/bundle/output/cjs/31.js ================================================ 'use strict'; function someOtherName () {} function x () {} someOtherName(); ================================================ FILE: test/bundle/output/cjs/32.js ================================================ 'use strict'; ================================================ FILE: test/bundle/output/cjs/33.js ================================================ 'use strict'; var _Promise__Promise = function () {}; _Promise__Promise.prototype = { keep () { this.state = 'kept'; }, break () { this.state = 'broken'; } }; var _Promise = _Promise__Promise; var _Math = { get add () { return add; }, get multiply () { return multiply; } }; function add ( a, b ) { return a + b; } function multiply ( a, b ) { return a * b; } var num = Math.max( 1, 2, 3 ); var resolved = Promise.resolve( num ); function foo () { return resolved; } var promise = new _Promise(); promise.keep(); console.log( _Math.add( 40, 2 ) ); ================================================ FILE: test/bundle/output/cjs/34.js ================================================ 'use strict'; var foo__exports = {}; foo__exports.bar = function () { console.log( 'exports should be renamed' ); }; var foo = foo__exports; foo.bar(); var main = 'whatever'; exports['default'] = main; ================================================ FILE: test/bundle/output/cjs/35.js ================================================ 'use strict'; function a () { console.log( 'I am module a' ); } function c () { console.log( 'I am module c' ); } function b () { console.log( 'I am module b' ); c(); } function external () { console.log( 'I am an external dependency' ); a(); b(); } external(); ================================================ FILE: test/bundle/output/cjs/36.js ================================================ 'use strict'; function dependsOnExternal () { console.log( external.message ); } function external () { dependsOnExternal(); } external.message = 'don\'t try this at home'; external(); ================================================ FILE: test/bundle/output/cjs/37.js ================================================ 'use strict'; var x = require('moment'); x = ('default' in x ? x['default'] : x); var a__x = 'wut'; var a = a__x; ================================================ FILE: test/bundle/output/cjs/38.js ================================================ 'use strict'; var _foo = notActuallyFoo; function notActuallyFoo () { foo(); } function foo () { console.log( 'actually foo' ); } _foo(); ================================================ FILE: test/bundle/output/cjs/40.js ================================================ 'use strict'; function foo () { console.log( 'foo' ); } foo(); ================================================ FILE: test/bundle/output/cjs/42.js ================================================ 'use strict'; function foo () { console.log( 'foo' ); } foo(); ================================================ FILE: test/bundle/output/cjs/43.js ================================================ 'use strict'; var Bar = require('bar'); Bar = ('default' in Bar ? Bar['default'] : Bar); class Foo extends Bar { constructor() { super(); console.log('Foo constructed'); } } ================================================ FILE: test/bundle/output/cjs/44.js ================================================ 'use strict'; var foo = require('foo'); foo = ('default' in foo ? foo['default'] : foo); var _bar = require('bar'); _bar = ('default' in _bar ? _bar['default'] : _bar); (function () { var bar = 'nope'; _bar(); })(); ================================================ FILE: test/bundle/output/cjs/45.js ================================================ 'use strict'; var bar = 42; function foo () { console.log( bar ); } foo(); ================================================ FILE: test/bundle/output/cjs/46.js ================================================ 'use strict'; var bar = 42; function foo () { console.log( bar ); } foo(); ================================================ FILE: test/bundle/output/cjs/47.js ================================================ implicitGlobal = 'lol'; ================================================ FILE: test/bundle/output/cjs/48.js ================================================ 'use strict'; var external = require('external'); external = ('default' in external ? external['default'] : external); external(); ================================================ FILE: test/bundle/output/cjs/49.js ================================================ 'use strict'; function foo () { console.log( 'foo' ); } foo(); //# sourceMappingURL=data:application/json;charset=utf-8;base64,xyz ================================================ FILE: test/bundle/output/cjs/50.js ================================================ 'use strict'; class A { constructor () { console.log( 'creating A' ); } b () { return new B(); } } class B extends A { constructor () { console.log( 'creating B' ); } } class D { constructor () { console.log( 'creating D' ); } c () { return new C(); } } class C extends D { constructor () { console.log( 'creating C' ); } } new A().b(); new B(); new C(); new D().c(); ================================================ FILE: test/bundle/output/cjs/51.js ================================================ 'use strict'; var highlight = require('highlight.js'); highlight = ('default' in highlight ? highlight['default'] : highlight); var foo = 42; ================================================ FILE: test/bundle/output/cjs/52.js ================================================ 'use strict'; var not_baz = function () { // baz.js }; // bar.js console.log( 'baz', not_baz ); ================================================ FILE: test/bundle/output/cjs/53.js ================================================ 'use strict'; var foo = function () { console.log( 'foo' ); } foo(); var main = function () { console.log( 'main' ); } exports['default'] = main; ================================================ FILE: test/bundle/output/cjs/54.js ================================================ 'use strict'; var bluebird = require('bluebird'); bluebird = ('default' in bluebird ? bluebird['default'] : bluebird); var foo = 'foo'; ================================================ FILE: test/bundle/output/cjs/55.js ================================================ 'use strict'; class A { b () { return new B(); } c () { return new C(); } } class B extends A {} class C extends A {} ================================================ FILE: test/bundle/output/cjs/56.js ================================================ 'use strict'; var foo = 42; var _foo = foo; foo = 99; foo += 1; foo++; console.log( _foo ); // 42 ================================================ FILE: test/bundle/output/cjs/57.js ================================================ 'use strict'; var foo = { get y () { return x; } }; var x = 42; console.log( foo.y ); ================================================ FILE: test/bundle/output/cjs/58.js ================================================ 'use strict'; var x = 42; exports.y = x; ================================================ FILE: test/bundle/output/cjs/59.js ================================================ 'use strict'; var foo = 'foo'; console.log( foo ); // 'foo' ================================================ FILE: test/bundle/output/cjs/60.js ================================================ 'use strict'; var foo = 'foo'; var bar = 'bar'; // Preserve comments after imports console.log( foo ); ================================================ FILE: test/bundle/output/cjsDefaults/01.js ================================================ 'use strict'; var message = 'yes'; var foo = message; console.log( foo ); ================================================ FILE: test/bundle/output/cjsDefaults/02.js ================================================ 'use strict'; var message = 'yes'; var foo = message; console.log( foo ); ================================================ FILE: test/bundle/output/cjsDefaults/03.js ================================================ 'use strict'; var external = require('external'); var bar = 'yes'; var foo = bar; console.log( external( foo ) ); ================================================ FILE: test/bundle/output/cjsDefaults/04.js ================================================ 'use strict'; var answer = 42; var main = answer * 2; module.exports = main; ================================================ FILE: test/bundle/output/cjsDefaults/06.js ================================================ 'use strict'; var external = require('utils/external'); var message = 'this is a message'; console.log( message ); ================================================ FILE: test/bundle/output/cjsDefaults/07.js ================================================ 'use strict'; var foo = 'this is foo'; function logFoo () { console.log( foo ); } function logBar () { console.log( bar ); } ================================================ FILE: test/bundle/output/cjsDefaults/08.js ================================================ 'use strict'; var ImplicitlyNamed = require('external'); ================================================ FILE: test/bundle/output/cjsDefaults/09.js ================================================ 'use strict'; var Correct = require('external'); ================================================ FILE: test/bundle/output/cjsDefaults/10.js ================================================ 'use strict'; class Foo { constructor( str ) { this.str = str; } toString() { return this.str; } } module.exports = Foo; ================================================ FILE: test/bundle/output/cjsDefaults/14.js ================================================ 'use strict'; var foo = require('external'); foo(); ================================================ FILE: test/bundle/output/cjsDefaults/16.js ================================================ 'use strict'; function _a__a () { console.log( 'a' ); } function c__a () { console.log( 'a but actually c' ); } var b = function () { // a but actually c c__a(); } function foo () { _a__a(); } ================================================ FILE: test/bundle/output/cjsDefaults/17.js ================================================ 'use strict'; function foo__a ( message ) { console.log( message ); } foo__a(); (function () { var a = 'c'; foo__a( a ); }()); ================================================ FILE: test/bundle/output/cjsDefaults/18.js ================================================ 'use strict'; var _doThing = function () { console.log( 'doing foo thing' ); } var foo = function () { _doThing(); } var bar = function () { doThing(); } var doThing = function ( item ) { console.log( 'doing bar thing' ); } ================================================ FILE: test/bundle/output/cjsDefaults/19.js ================================================ 'use strict'; var hasOwnProperty = Object.prototype.hasOwnProperty; console.log( hasOwnProperty.call({ foo: 'bar' }, 'foo' ) ); ================================================ FILE: test/bundle/output/cjsDefaults/20.js ================================================ 'use strict'; var hasOwnProperty = Object.prototype.hasOwnProperty; var main = function () { console.log( hasOwnProperty.call({ foo: 'bar' }, 'foo' ) ); } module.exports = main; ================================================ FILE: test/bundle/output/cjsDefaults/21.js ================================================ 'use strict'; const config = {}; config.async = true; ================================================ FILE: test/bundle/output/cjsDefaults/24.js ================================================ /* this is a banner */ 'use strict'; function foo () { console.log( 'fooing' ); } function bar () { console.log( 'baring' ); } foo(); bar(); /* this is a footer */ ================================================ FILE: test/bundle/output/cjsDefaults/25.js ================================================ 'use strict'; var foo = function () { console.log( 'fooing' ); } foo(); ================================================ FILE: test/bundle/output/cjsDefaults/26.js ================================================ 'use strict'; function bar () { console.log( 'baring' ); } bar(); ================================================ FILE: test/bundle/output/cjsDefaults/27.js ================================================ 'use strict'; var foo = 'this is foo'; var bar = 'this is bar'; function logFoo () { console.log( foo ); } function logBar () { console.log( bar ); } ================================================ FILE: test/bundle/output/cjsDefaults/28.js ================================================ 'use strict'; var foo = () => undefined; assert.strictEqual( undefined, undefined ); var ctx = {}; var arrow = (x => assert.strictEqual( undefined, undefined )); var fn = function () { assert.strictEqual( this, ctx ); }; arrow.call(ctx); fn.call(ctx); assert.strictEqual(foo(), undefined); ================================================ FILE: test/bundle/output/cjsDefaults/30.js ================================================ 'use strict'; var foo = require('foo'); foo.bar(); ================================================ FILE: test/bundle/output/cjsDefaults/31.js ================================================ 'use strict'; function someOtherName () {} function x () {} someOtherName(); ================================================ FILE: test/bundle/output/cjsDefaults/32.js ================================================ 'use strict'; ================================================ FILE: test/bundle/output/cjsDefaults/33.js ================================================ 'use strict'; var _Promise__Promise = function () {}; _Promise__Promise.prototype = { keep () { this.state = 'kept'; }, break () { this.state = 'broken'; } }; var _Promise = _Promise__Promise; var _Math = { get add () { return add; }, get multiply () { return multiply; } }; function add ( a, b ) { return a + b; } function multiply ( a, b ) { return a * b; } var num = Math.max( 1, 2, 3 ); var resolved = Promise.resolve( num ); function foo () { return resolved; } var promise = new _Promise(); promise.keep(); console.log( _Math.add( 40, 2 ) ); ================================================ FILE: test/bundle/output/cjsDefaults/34.js ================================================ 'use strict'; var foo__exports = {}; foo__exports.bar = function () { console.log( 'exports should be renamed' ); }; var foo = foo__exports; foo.bar(); var main = 'whatever'; module.exports = main; ================================================ FILE: test/bundle/output/cjsDefaults/35.js ================================================ 'use strict'; function a () { console.log( 'I am module a' ); } function c () { console.log( 'I am module c' ); } function b () { console.log( 'I am module b' ); c(); } function external () { console.log( 'I am an external dependency' ); a(); b(); } external(); ================================================ FILE: test/bundle/output/cjsDefaults/36.js ================================================ 'use strict'; function dependsOnExternal () { console.log( external.message ); } function external () { dependsOnExternal(); } external.message = 'don\'t try this at home'; external(); ================================================ FILE: test/bundle/output/cjsDefaults/37.js ================================================ 'use strict'; var x = require('moment'); var a__x = 'wut'; var a = a__x; ================================================ FILE: test/bundle/output/cjsDefaults/38.js ================================================ 'use strict'; var _foo = notActuallyFoo; function notActuallyFoo () { foo(); } function foo () { console.log( 'actually foo' ); } _foo(); ================================================ FILE: test/bundle/output/cjsDefaults/40.js ================================================ 'use strict'; function foo () { console.log( 'foo' ); } foo(); ================================================ FILE: test/bundle/output/cjsDefaults/42.js ================================================ 'use strict'; function foo () { console.log( 'foo' ); } foo(); ================================================ FILE: test/bundle/output/cjsDefaults/43.js ================================================ 'use strict'; var Bar = require('bar'); class Foo extends Bar { constructor() { super(); console.log('Foo constructed'); } } ================================================ FILE: test/bundle/output/cjsDefaults/44.js ================================================ 'use strict'; var foo = require('foo'); var _bar = require('bar'); (function () { var bar = 'nope'; _bar(); })(); ================================================ FILE: test/bundle/output/cjsDefaults/45.js ================================================ 'use strict'; var bar = 42; function foo () { console.log( bar ); } foo(); ================================================ FILE: test/bundle/output/cjsDefaults/46.js ================================================ 'use strict'; var bar = 42; function foo () { console.log( bar ); } foo(); ================================================ FILE: test/bundle/output/cjsDefaults/47.js ================================================ implicitGlobal = 'lol'; ================================================ FILE: test/bundle/output/cjsDefaults/48.js ================================================ 'use strict'; var external = require('external'); external(); ================================================ FILE: test/bundle/output/cjsDefaults/49.js ================================================ 'use strict'; function foo () { console.log( 'foo' ); } foo(); //# sourceMappingURL=data:application/json;charset=utf-8;base64,xyz ================================================ FILE: test/bundle/output/cjsDefaults/50.js ================================================ 'use strict'; class A { constructor () { console.log( 'creating A' ); } b () { return new B(); } } class B extends A { constructor () { console.log( 'creating B' ); } } class D { constructor () { console.log( 'creating D' ); } c () { return new C(); } } class C extends D { constructor () { console.log( 'creating C' ); } } new A().b(); new B(); new C(); new D().c(); ================================================ FILE: test/bundle/output/cjsDefaults/51.js ================================================ 'use strict'; var highlight = require('highlight.js'); var foo = 42; ================================================ FILE: test/bundle/output/cjsDefaults/52.js ================================================ 'use strict'; var not_baz = function () { // baz.js }; // bar.js console.log( 'baz', not_baz ); ================================================ FILE: test/bundle/output/cjsDefaults/53.js ================================================ 'use strict'; var foo = function () { console.log( 'foo' ); } foo(); var main = function () { console.log( 'main' ); } module.exports = main; ================================================ FILE: test/bundle/output/cjsDefaults/54.js ================================================ 'use strict'; var bluebird = require('bluebird'); var foo = 'foo'; ================================================ FILE: test/bundle/output/cjsDefaults/55.js ================================================ 'use strict'; class A { b () { return new B(); } c () { return new C(); } } class B extends A {} class C extends A {} ================================================ FILE: test/bundle/output/cjsDefaults/56.js ================================================ 'use strict'; var foo = 42; var _foo = foo; foo = 99; foo += 1; foo++; console.log( _foo ); // 42 ================================================ FILE: test/bundle/output/cjsDefaults/57.js ================================================ 'use strict'; var foo = { get y () { return x; } }; var x = 42; console.log( foo.y ); ================================================ FILE: test/bundle/output/cjsDefaults/59.js ================================================ 'use strict'; var foo = 'foo'; console.log( foo ); // 'foo' ================================================ FILE: test/bundle/output/cjsDefaults/60.js ================================================ 'use strict'; var foo = 'foo'; var bar = 'bar'; // Preserve comments after imports console.log( foo ); ================================================ FILE: test/bundle/output/concat/01.js ================================================ (function () { 'use strict'; var message = 'yes'; var foo = message; console.log( foo ); })(); ================================================ FILE: test/bundle/output/concat/02.js ================================================ (function () { 'use strict'; var message = 'yes'; var foo = message; console.log( foo ); })(); ================================================ FILE: test/bundle/output/concat/07.js ================================================ (function () { 'use strict'; var foo = 'this is foo'; function logFoo () { console.log( foo ); } function logBar () { console.log( bar ); } })(); ================================================ FILE: test/bundle/output/concat/16.js ================================================ (function () { 'use strict'; function _a__a () { console.log( 'a' ); } function c__a () { console.log( 'a but actually c' ); } var b = function () { // a but actually c c__a(); } function foo () { _a__a(); } })(); ================================================ FILE: test/bundle/output/concat/17.js ================================================ (function () { 'use strict'; function foo__a ( message ) { console.log( message ); } foo__a(); (function () { var a = 'c'; foo__a( a ); }()); })(); ================================================ FILE: test/bundle/output/concat/18.js ================================================ (function () { 'use strict'; var _doThing = function () { console.log( 'doing foo thing' ); } var foo = function () { _doThing(); } var bar = function () { doThing(); } var doThing = function ( item ) { console.log( 'doing bar thing' ); } })(); ================================================ FILE: test/bundle/output/concat/19.js ================================================ (function () { 'use strict'; var hasOwnProperty = Object.prototype.hasOwnProperty; console.log( hasOwnProperty.call({ foo: 'bar' }, 'foo' ) ); })(); ================================================ FILE: test/bundle/output/concat/21.js ================================================ (function () { 'use strict'; const config = {}; config.async = true; })(); ================================================ FILE: test/bundle/output/concat/24.js ================================================ /* this is a banner */ (function () { 'use strict'; function foo () { console.log( 'fooing' ); } function bar () { console.log( 'baring' ); } foo(); bar(); })(); /* this is a footer */ ================================================ FILE: test/bundle/output/concat/25.js ================================================ (function () { 'use strict'; var foo = function () { console.log( 'fooing' ); } foo(); })(); ================================================ FILE: test/bundle/output/concat/26.js ================================================ (function () { 'use strict'; function bar () { console.log( 'baring' ); } bar(); })(); ================================================ FILE: test/bundle/output/concat/27.js ================================================ (function () { 'use strict'; var foo = 'this is foo'; var bar = 'this is bar'; function logFoo () { console.log( foo ); } function logBar () { console.log( bar ); } })(); ================================================ FILE: test/bundle/output/concat/28.js ================================================ (function () { 'use strict'; var foo = () => undefined; assert.strictEqual( undefined, undefined ); var ctx = {}; var arrow = (x => assert.strictEqual( undefined, undefined )); var fn = function () { assert.strictEqual( this, ctx ); }; arrow.call(ctx); fn.call(ctx); assert.strictEqual(foo(), undefined); })(); ================================================ FILE: test/bundle/output/concat/31.js ================================================ (function () { 'use strict'; function someOtherName () {} function x () {} someOtherName(); })(); ================================================ FILE: test/bundle/output/concat/32.js ================================================ (function () { 'use strict'; })(); ================================================ FILE: test/bundle/output/concat/33.js ================================================ (function () { 'use strict'; var _Promise__Promise = function () {}; _Promise__Promise.prototype = { keep () { this.state = 'kept'; }, break () { this.state = 'broken'; } }; var _Promise = _Promise__Promise; var _Math = { get add () { return add; }, get multiply () { return multiply; } }; function add ( a, b ) { return a + b; } function multiply ( a, b ) { return a * b; } var num = Math.max( 1, 2, 3 ); var resolved = Promise.resolve( num ); function foo () { return resolved; } var promise = new _Promise(); promise.keep(); console.log( _Math.add( 40, 2 ) ); })(); ================================================ FILE: test/bundle/output/concat/35.js ================================================ (function () { 'use strict'; function a () { console.log( 'I am module a' ); } function c () { console.log( 'I am module c' ); } function b () { console.log( 'I am module b' ); c(); } function external () { console.log( 'I am an external dependency' ); a(); b(); } external(); })(); ================================================ FILE: test/bundle/output/concat/36.js ================================================ (function () { 'use strict'; function dependsOnExternal () { console.log( external.message ); } function external () { dependsOnExternal(); } external.message = 'don\'t try this at home'; external(); })(); ================================================ FILE: test/bundle/output/concat/38.js ================================================ (function () { 'use strict'; var _foo = notActuallyFoo; function notActuallyFoo () { foo(); } function foo () { console.log( 'actually foo' ); } _foo(); })(); ================================================ FILE: test/bundle/output/concat/40.js ================================================ (function () { 'use strict'; function foo () { console.log( 'foo' ); } foo(); })(); ================================================ FILE: test/bundle/output/concat/42.js ================================================ (function () { 'use strict'; function foo () { console.log( 'foo' ); } foo(); })(); ================================================ FILE: test/bundle/output/concat/45.js ================================================ (function () { 'use strict'; var bar = 42; function foo () { console.log( bar ); } foo(); })(); ================================================ FILE: test/bundle/output/concat/46.js ================================================ (function () { 'use strict'; var bar = 42; function foo () { console.log( bar ); } foo(); })(); ================================================ FILE: test/bundle/output/concat/47.js ================================================ (function () { 'use strict'; implicitGlobal = 'lol'; })(); ================================================ FILE: test/bundle/output/concat/49.js ================================================ (function () { 'use strict'; function foo () { console.log( 'foo' ); } foo(); })(); //# sourceMappingURL=data:application/json;charset=utf-8;base64,xyz ================================================ FILE: test/bundle/output/concat/50.js ================================================ (function () { 'use strict'; class A { constructor () { console.log( 'creating A' ); } b () { return new B(); } } class B extends A { constructor () { console.log( 'creating B' ); } } class D { constructor () { console.log( 'creating D' ); } c () { return new C(); } } class C extends D { constructor () { console.log( 'creating C' ); } } new A().b(); new B(); new C(); new D().c(); })(); ================================================ FILE: test/bundle/output/concat/52.js ================================================ (function () { 'use strict'; var not_baz = function () { // baz.js }; // bar.js console.log( 'baz', not_baz ); })(); ================================================ FILE: test/bundle/output/concat/55.js ================================================ (function () { 'use strict'; class A { b () { return new B(); } c () { return new C(); } } class B extends A {} class C extends A {} })(); ================================================ FILE: test/bundle/output/concat/56.js ================================================ (function () { 'use strict'; var foo = 42; var _foo = foo; foo = 99; foo += 1; foo++; console.log( _foo ); // 42 })(); ================================================ FILE: test/bundle/output/concat/57.js ================================================ (function () { 'use strict'; var foo = { get y () { return x; } }; var x = 42; console.log( foo.y ); })(); ================================================ FILE: test/bundle/output/concat/59.js ================================================ (function () { 'use strict'; var foo = 'foo'; console.log( foo ); // 'foo' })(); ================================================ FILE: test/bundle/output/concat/60.js ================================================ (function () { 'use strict'; var foo = 'foo'; var bar = 'bar'; // Preserve comments after imports console.log( foo ); })(); ================================================ FILE: test/bundle/output/umd/01.js ================================================ (function (factory) { !(typeof exports === 'object' && typeof module !== 'undefined') && typeof define === 'function' && define.amd ? define(factory) : factory() }(function () { 'use strict'; var message = 'yes'; var foo = message; console.log( foo ); })); ================================================ FILE: test/bundle/output/umd/02.js ================================================ (function (factory) { !(typeof exports === 'object' && typeof module !== 'undefined') && typeof define === 'function' && define.amd ? define(factory) : factory() }(function () { 'use strict'; var message = 'yes'; var foo = message; console.log( foo ); })); ================================================ FILE: test/bundle/output/umd/03.js ================================================ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('external')) : typeof define === 'function' && define.amd ? define(['external'], factory) : factory(global.external) }(this, function (external) { 'use strict'; external = ('default' in external ? external['default'] : external); var bar = 'yes'; var foo = bar; console.log( external( foo ) ); })); ================================================ FILE: test/bundle/output/umd/04.js ================================================ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'], factory) : factory((global.myModule = {})) }(this, function (exports) { 'use strict'; var answer = 42; var main = answer * 2; exports['default'] = main; })); ================================================ FILE: test/bundle/output/umd/05.js ================================================ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'], factory) : factory((global.myModule = {})) }(this, function (exports) { 'use strict'; var one = 1; var two = 2; var three = 3; var four = one + 3; var five = two + 3; var six = three + 3; four = 99; exports.four = four; exports.five = five; exports.six = six; })); ================================================ FILE: test/bundle/output/umd/06.js ================================================ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('utils/external')) : typeof define === 'function' && define.amd ? define(['utils/external'], factory) : factory(global.external) }(this, function (external) { 'use strict'; external = ('default' in external ? external['default'] : external); var message = 'this is a message'; console.log( message ); })); ================================================ FILE: test/bundle/output/umd/07.js ================================================ (function (factory) { !(typeof exports === 'object' && typeof module !== 'undefined') && typeof define === 'function' && define.amd ? define(factory) : factory() }(function () { 'use strict'; var foo = 'this is foo'; function logFoo () { console.log( foo ); } function logBar () { console.log( bar ); } })); ================================================ FILE: test/bundle/output/umd/08.js ================================================ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('external')) : typeof define === 'function' && define.amd ? define(['external'], factory) : factory(global.ImplicitlyNamed) }(this, function (ImplicitlyNamed) { 'use strict'; ImplicitlyNamed = ('default' in ImplicitlyNamed ? ImplicitlyNamed['default'] : ImplicitlyNamed); })); ================================================ FILE: test/bundle/output/umd/09.js ================================================ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('external')) : typeof define === 'function' && define.amd ? define(['external'], factory) : factory(global.Correct) }(this, function (Correct) { 'use strict'; Correct = ('default' in Correct ? Correct['default'] : Correct); })); ================================================ FILE: test/bundle/output/umd/10.js ================================================ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'], factory) : factory((global.myModule = {})) }(this, function (exports) { 'use strict'; class Foo { constructor( str ) { this.str = str; } toString() { return this.str; } } exports['default'] = Foo; })); ================================================ FILE: test/bundle/output/umd/11.js ================================================ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'], factory) : factory((global.myModule = {})) }(this, function (exports) { 'use strict'; var foo = 1; var bar = 2; foo = 3; exports.foo = foo; exports.bar = bar; var baz = 4; exports.baz = baz; var qux = 5; qux = 6; exports.qux = qux; })); ================================================ FILE: test/bundle/output/umd/14.js ================================================ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('external')) : typeof define === 'function' && define.amd ? define(['external'], factory) : factory(global.foo) }(this, function (foo) { 'use strict'; foo = ('default' in foo ? foo['default'] : foo); foo(); })); ================================================ FILE: test/bundle/output/umd/15.js ================================================ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('external')) : typeof define === 'function' && define.amd ? define(['external'], factory) : factory(global.external) }(this, function (external) { 'use strict'; external.foo(); })); ================================================ FILE: test/bundle/output/umd/16.js ================================================ (function (factory) { !(typeof exports === 'object' && typeof module !== 'undefined') && typeof define === 'function' && define.amd ? define(factory) : factory() }(function () { 'use strict'; function _a__a () { console.log( 'a' ); } function c__a () { console.log( 'a but actually c' ); } var b = function () { // a but actually c c__a(); } function foo () { _a__a(); } })); ================================================ FILE: test/bundle/output/umd/17.js ================================================ (function (factory) { !(typeof exports === 'object' && typeof module !== 'undefined') && typeof define === 'function' && define.amd ? define(factory) : factory() }(function () { 'use strict'; function foo__a ( message ) { console.log( message ); } foo__a(); (function () { var a = 'c'; foo__a( a ); }()); })); ================================================ FILE: test/bundle/output/umd/18.js ================================================ (function (factory) { !(typeof exports === 'object' && typeof module !== 'undefined') && typeof define === 'function' && define.amd ? define(factory) : factory() }(function () { 'use strict'; var _doThing = function () { console.log( 'doing foo thing' ); } var foo = function () { _doThing(); } var bar = function () { doThing(); } var doThing = function ( item ) { console.log( 'doing bar thing' ); } })); ================================================ FILE: test/bundle/output/umd/19.js ================================================ (function (factory) { !(typeof exports === 'object' && typeof module !== 'undefined') && typeof define === 'function' && define.amd ? define(factory) : factory() }(function () { 'use strict'; var hasOwnProperty = Object.prototype.hasOwnProperty; console.log( hasOwnProperty.call({ foo: 'bar' }, 'foo' ) ); })); ================================================ FILE: test/bundle/output/umd/20.js ================================================ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'], factory) : factory((global.myModule = {})) }(this, function (exports) { 'use strict'; var hasOwnProperty = Object.prototype.hasOwnProperty; var main = function () { console.log( hasOwnProperty.call({ foo: 'bar' }, 'foo' ) ); } exports['default'] = main; })); ================================================ FILE: test/bundle/output/umd/21.js ================================================ (function (factory) { !(typeof exports === 'object' && typeof module !== 'undefined') && typeof define === 'function' && define.amd ? define(factory) : factory() }(function () { 'use strict'; const config = {}; config.async = true; })); ================================================ FILE: test/bundle/output/umd/22.js ================================================ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'], factory) : factory((global.myModule = {})) }(this, function (exports) { 'use strict'; function foo () { console.log( 'fooing' ); } exports.foo = foo; // foo foo(); })); ================================================ FILE: test/bundle/output/umd/24.js ================================================ /* this is a banner */ (function (factory) { !(typeof exports === 'object' && typeof module !== 'undefined') && typeof define === 'function' && define.amd ? define(factory) : factory() }(function () { 'use strict'; function foo () { console.log( 'fooing' ); } function bar () { console.log( 'baring' ); } foo(); bar(); })); /* this is a footer */ ================================================ FILE: test/bundle/output/umd/25.js ================================================ (function (factory) { !(typeof exports === 'object' && typeof module !== 'undefined') && typeof define === 'function' && define.amd ? define('myModule', factory) : factory() }(function () { 'use strict'; var foo = function () { console.log( 'fooing' ); } foo(); })); ================================================ FILE: test/bundle/output/umd/26.js ================================================ (function (factory) { !(typeof exports === 'object' && typeof module !== 'undefined') && typeof define === 'function' && define.amd ? define(factory) : factory() }(function () { 'use strict'; function bar () { console.log( 'baring' ); } bar(); })); ================================================ FILE: test/bundle/output/umd/27.js ================================================ (function (factory) { !(typeof exports === 'object' && typeof module !== 'undefined') && typeof define === 'function' && define.amd ? define(factory) : factory() }(function () { 'use strict'; var foo = 'this is foo'; var bar = 'this is bar'; function logFoo () { console.log( foo ); } function logBar () { console.log( bar ); } })); ================================================ FILE: test/bundle/output/umd/28.js ================================================ (function (factory) { !(typeof exports === 'object' && typeof module !== 'undefined') && typeof define === 'function' && define.amd ? define(factory) : factory() }(function () { 'use strict'; var foo = () => undefined; assert.strictEqual( undefined, undefined ); var ctx = {}; var arrow = (x => assert.strictEqual( undefined, undefined )); var fn = function () { assert.strictEqual( this, ctx ); }; arrow.call(ctx); fn.call(ctx); assert.strictEqual(foo(), undefined); })); ================================================ FILE: test/bundle/output/umd/29.js ================================================ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('foo')) : typeof define === 'function' && define.amd ? define(['foo'], factory) : factory(global.foo) }(this, function (foo) { 'use strict'; var foo__default = ('default' in foo ? foo['default'] : foo); foo__default(); foo.bar(); })); ================================================ FILE: test/bundle/output/umd/30.js ================================================ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('foo')) : typeof define === 'function' && define.amd ? define(['foo'], factory) : factory(global.foo) }(this, function (foo) { 'use strict'; foo.bar(); })); ================================================ FILE: test/bundle/output/umd/31.js ================================================ (function (factory) { !(typeof exports === 'object' && typeof module !== 'undefined') && typeof define === 'function' && define.amd ? define(factory) : factory() }(function () { 'use strict'; function someOtherName () {} function x () {} someOtherName(); })); ================================================ FILE: test/bundle/output/umd/32.js ================================================ (function (factory) { !(typeof exports === 'object' && typeof module !== 'undefined') && typeof define === 'function' && define.amd ? define(factory) : factory() }(function () { 'use strict'; })); ================================================ FILE: test/bundle/output/umd/33.js ================================================ (function (factory) { !(typeof exports === 'object' && typeof module !== 'undefined') && typeof define === 'function' && define.amd ? define(factory) : factory() }(function () { 'use strict'; var _Promise__Promise = function () {}; _Promise__Promise.prototype = { keep () { this.state = 'kept'; }, break () { this.state = 'broken'; } }; var _Promise = _Promise__Promise; var _Math = { get add () { return add; }, get multiply () { return multiply; } }; function add ( a, b ) { return a + b; } function multiply ( a, b ) { return a * b; } var num = Math.max( 1, 2, 3 ); var resolved = Promise.resolve( num ); function foo () { return resolved; } var promise = new _Promise(); promise.keep(); console.log( _Math.add( 40, 2 ) ); })); ================================================ FILE: test/bundle/output/umd/34.js ================================================ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'], factory) : factory((global.myModule = {})) }(this, function (exports) { 'use strict'; var foo__exports = {}; foo__exports.bar = function () { console.log( 'exports should be renamed' ); }; var foo = foo__exports; foo.bar(); var main = 'whatever'; exports['default'] = main; })); ================================================ FILE: test/bundle/output/umd/35.js ================================================ (function (factory) { !(typeof exports === 'object' && typeof module !== 'undefined') && typeof define === 'function' && define.amd ? define(factory) : factory() }(function () { 'use strict'; function a () { console.log( 'I am module a' ); } function c () { console.log( 'I am module c' ); } function b () { console.log( 'I am module b' ); c(); } function external () { console.log( 'I am an external dependency' ); a(); b(); } external(); })); ================================================ FILE: test/bundle/output/umd/36.js ================================================ (function (factory) { !(typeof exports === 'object' && typeof module !== 'undefined') && typeof define === 'function' && define.amd ? define(factory) : factory() }(function () { 'use strict'; function dependsOnExternal () { console.log( external.message ); } function external () { dependsOnExternal(); } external.message = 'don\'t try this at home'; external(); })); ================================================ FILE: test/bundle/output/umd/37.js ================================================ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('moment')) : typeof define === 'function' && define.amd ? define(['moment'], factory) : factory(global.x) }(this, function (x) { 'use strict'; x = ('default' in x ? x['default'] : x); var a__x = 'wut'; var a = a__x; })); ================================================ FILE: test/bundle/output/umd/38.js ================================================ (function (factory) { !(typeof exports === 'object' && typeof module !== 'undefined') && typeof define === 'function' && define.amd ? define(factory) : factory() }(function () { 'use strict'; var _foo = notActuallyFoo; function notActuallyFoo () { foo(); } function foo () { console.log( 'actually foo' ); } _foo(); })); ================================================ FILE: test/bundle/output/umd/40.js ================================================ (function (factory) { !(typeof exports === 'object' && typeof module !== 'undefined') && typeof define === 'function' && define.amd ? define(factory) : factory() }(function () { 'use strict'; function foo () { console.log( 'foo' ); } foo(); })); ================================================ FILE: test/bundle/output/umd/42.js ================================================ (function (factory) { !(typeof exports === 'object' && typeof module !== 'undefined') && typeof define === 'function' && define.amd ? define(factory) : factory() }(function () { 'use strict'; function foo () { console.log( 'foo' ); } foo(); })); ================================================ FILE: test/bundle/output/umd/43.js ================================================ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('bar')) : typeof define === 'function' && define.amd ? define(['bar'], factory) : factory(global.Bar) }(this, function (Bar) { 'use strict'; Bar = ('default' in Bar ? Bar['default'] : Bar); class Foo extends Bar { constructor() { super(); console.log('Foo constructed'); } } })); ================================================ FILE: test/bundle/output/umd/44.js ================================================ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('foo'), require('bar')) : typeof define === 'function' && define.amd ? define(['foo', 'bar'], factory) : factory(global.foo, global._bar) }(this, function (foo, _bar) { 'use strict'; foo = ('default' in foo ? foo['default'] : foo); _bar = ('default' in _bar ? _bar['default'] : _bar); (function () { var bar = 'nope'; _bar(); })(); })); ================================================ FILE: test/bundle/output/umd/45.js ================================================ (function (factory) { !(typeof exports === 'object' && typeof module !== 'undefined') && typeof define === 'function' && define.amd ? define(factory) : factory() }(function () { 'use strict'; var bar = 42; function foo () { console.log( bar ); } foo(); })); ================================================ FILE: test/bundle/output/umd/46.js ================================================ (function (factory) { !(typeof exports === 'object' && typeof module !== 'undefined') && typeof define === 'function' && define.amd ? define(factory) : factory() }(function () { 'use strict'; var bar = 42; function foo () { console.log( bar ); } foo(); })); ================================================ FILE: test/bundle/output/umd/47.js ================================================ (function (factory) { !(typeof exports === 'object' && typeof module !== 'undefined') && typeof define === 'function' && define.amd ? define(factory) : factory() }(function () { implicitGlobal = 'lol'; })); ================================================ FILE: test/bundle/output/umd/48.js ================================================ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('external')) : typeof define === 'function' && define.amd ? define(['external'], factory) : factory(global.external) }(this, function (external) { 'use strict'; external = ('default' in external ? external['default'] : external); external(); })); ================================================ FILE: test/bundle/output/umd/49.js ================================================ (function (factory) { !(typeof exports === 'object' && typeof module !== 'undefined') && typeof define === 'function' && define.amd ? define(factory) : factory() }(function () { 'use strict'; function foo () { console.log( 'foo' ); } foo(); })); //# sourceMappingURL=data:application/json;charset=utf-8;base64,xyz ================================================ FILE: test/bundle/output/umd/50.js ================================================ (function (factory) { !(typeof exports === 'object' && typeof module !== 'undefined') && typeof define === 'function' && define.amd ? define(factory) : factory() }(function () { 'use strict'; class A { constructor () { console.log( 'creating A' ); } b () { return new B(); } } class B extends A { constructor () { console.log( 'creating B' ); } } class D { constructor () { console.log( 'creating D' ); } c () { return new C(); } } class C extends D { constructor () { console.log( 'creating C' ); } } new A().b(); new B(); new C(); new D().c(); })); ================================================ FILE: test/bundle/output/umd/51.js ================================================ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('highlight.js')) : typeof define === 'function' && define.amd ? define(['highlight.js'], factory) : factory(global.highlight) }(this, function (highlight) { 'use strict'; highlight = ('default' in highlight ? highlight['default'] : highlight); var foo = 42; })); ================================================ FILE: test/bundle/output/umd/52.js ================================================ (function (factory) { !(typeof exports === 'object' && typeof module !== 'undefined') && typeof define === 'function' && define.amd ? define(factory) : factory() }(function () { 'use strict'; var not_baz = function () { // baz.js }; // bar.js console.log( 'baz', not_baz ); })); ================================================ FILE: test/bundle/output/umd/53.js ================================================ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'], factory) : factory((global.myModule = {})) }(this, function (exports) { 'use strict'; var foo = function () { console.log( 'foo' ); } foo(); var main = function () { console.log( 'main' ); } exports['default'] = main; })); ================================================ FILE: test/bundle/output/umd/54.js ================================================ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('bluebird')) : typeof define === 'function' && define.amd ? define(['bluebird'], factory) : factory(global.bluebird) }(this, function (bluebird) { 'use strict'; bluebird = ('default' in bluebird ? bluebird['default'] : bluebird); var foo = 'foo'; })); ================================================ FILE: test/bundle/output/umd/55.js ================================================ (function (factory) { !(typeof exports === 'object' && typeof module !== 'undefined') && typeof define === 'function' && define.amd ? define(factory) : factory() }(function () { 'use strict'; class A { b () { return new B(); } c () { return new C(); } } class B extends A {} class C extends A {} })); ================================================ FILE: test/bundle/output/umd/56.js ================================================ (function (factory) { !(typeof exports === 'object' && typeof module !== 'undefined') && typeof define === 'function' && define.amd ? define(factory) : factory() }(function () { 'use strict'; var foo = 42; var _foo = foo; foo = 99; foo += 1; foo++; console.log( _foo ); // 42 })); ================================================ FILE: test/bundle/output/umd/57.js ================================================ (function (factory) { !(typeof exports === 'object' && typeof module !== 'undefined') && typeof define === 'function' && define.amd ? define(factory) : factory() }(function () { 'use strict'; var foo = { get y () { return x; } }; var x = 42; console.log( foo.y ); })); ================================================ FILE: test/bundle/output/umd/58.js ================================================ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'], factory) : factory((global.myModule = {})) }(this, function (exports) { 'use strict'; var x = 42; exports.y = x; })); ================================================ FILE: test/bundle/output/umd/59.js ================================================ (function (factory) { !(typeof exports === 'object' && typeof module !== 'undefined') && typeof define === 'function' && define.amd ? define(factory) : factory() }(function () { 'use strict'; var foo = 'foo'; console.log( foo ); // 'foo' })); ================================================ FILE: test/bundle/output/umd/60.js ================================================ (function (factory) { !(typeof exports === 'object' && typeof module !== 'undefined') && typeof define === 'function' && define.amd ? define(factory) : factory() }(function () { 'use strict'; var foo = 'foo'; var bar = 'bar'; // Preserve comments after imports console.log( foo ); })); ================================================ FILE: test/bundle/output/umdDefaults/01.js ================================================ (function (factory) { !(typeof exports === 'object' && typeof module !== 'undefined') && typeof define === 'function' && define.amd ? define(factory) : factory() }(function () { 'use strict'; var message = 'yes'; var foo = message; console.log( foo ); })); ================================================ FILE: test/bundle/output/umdDefaults/02.js ================================================ (function (factory) { !(typeof exports === 'object' && typeof module !== 'undefined') && typeof define === 'function' && define.amd ? define(factory) : factory() }(function () { 'use strict'; var message = 'yes'; var foo = message; console.log( foo ); })); ================================================ FILE: test/bundle/output/umdDefaults/03.js ================================================ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('external')) : typeof define === 'function' && define.amd ? define(['external'], factory) : factory(global.external) }(this, function (external) { 'use strict'; var bar = 'yes'; var foo = bar; console.log( external( foo ) ); })); ================================================ FILE: test/bundle/output/umdDefaults/04.js ================================================ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : global.myModule = factory() }(this, function () { 'use strict'; var answer = 42; var main = answer * 2; return main; })); ================================================ FILE: test/bundle/output/umdDefaults/06.js ================================================ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('utils/external')) : typeof define === 'function' && define.amd ? define(['utils/external'], factory) : factory(global.external) }(this, function (external) { 'use strict'; var message = 'this is a message'; console.log( message ); })); ================================================ FILE: test/bundle/output/umdDefaults/07.js ================================================ (function (factory) { !(typeof exports === 'object' && typeof module !== 'undefined') && typeof define === 'function' && define.amd ? define(factory) : factory() }(function () { 'use strict'; var foo = 'this is foo'; function logFoo () { console.log( foo ); } function logBar () { console.log( bar ); } })); ================================================ FILE: test/bundle/output/umdDefaults/08.js ================================================ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('external')) : typeof define === 'function' && define.amd ? define(['external'], factory) : factory(global.ImplicitlyNamed) }(this, function (ImplicitlyNamed) { 'use strict'; })); ================================================ FILE: test/bundle/output/umdDefaults/09.js ================================================ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('external')) : typeof define === 'function' && define.amd ? define(['external'], factory) : factory(global.Correct) }(this, function (Correct) { 'use strict'; })); ================================================ FILE: test/bundle/output/umdDefaults/10.js ================================================ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : global.myModule = factory() }(this, function () { 'use strict'; class Foo { constructor( str ) { this.str = str; } toString() { return this.str; } } return Foo; })); ================================================ FILE: test/bundle/output/umdDefaults/14.js ================================================ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('external')) : typeof define === 'function' && define.amd ? define(['external'], factory) : factory(global.foo) }(this, function (foo) { 'use strict'; foo(); })); ================================================ FILE: test/bundle/output/umdDefaults/16.js ================================================ (function (factory) { !(typeof exports === 'object' && typeof module !== 'undefined') && typeof define === 'function' && define.amd ? define(factory) : factory() }(function () { 'use strict'; function _a__a () { console.log( 'a' ); } function c__a () { console.log( 'a but actually c' ); } var b = function () { // a but actually c c__a(); } function foo () { _a__a(); } })); ================================================ FILE: test/bundle/output/umdDefaults/17.js ================================================ (function (factory) { !(typeof exports === 'object' && typeof module !== 'undefined') && typeof define === 'function' && define.amd ? define(factory) : factory() }(function () { 'use strict'; function foo__a ( message ) { console.log( message ); } foo__a(); (function () { var a = 'c'; foo__a( a ); }()); })); ================================================ FILE: test/bundle/output/umdDefaults/18.js ================================================ (function (factory) { !(typeof exports === 'object' && typeof module !== 'undefined') && typeof define === 'function' && define.amd ? define(factory) : factory() }(function () { 'use strict'; var _doThing = function () { console.log( 'doing foo thing' ); } var foo = function () { _doThing(); } var bar = function () { doThing(); } var doThing = function ( item ) { console.log( 'doing bar thing' ); } })); ================================================ FILE: test/bundle/output/umdDefaults/19.js ================================================ (function (factory) { !(typeof exports === 'object' && typeof module !== 'undefined') && typeof define === 'function' && define.amd ? define(factory) : factory() }(function () { 'use strict'; var hasOwnProperty = Object.prototype.hasOwnProperty; console.log( hasOwnProperty.call({ foo: 'bar' }, 'foo' ) ); })); ================================================ FILE: test/bundle/output/umdDefaults/20.js ================================================ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : global.myModule = factory() }(this, function () { 'use strict'; var hasOwnProperty = Object.prototype.hasOwnProperty; var main = function () { console.log( hasOwnProperty.call({ foo: 'bar' }, 'foo' ) ); } return main; })); ================================================ FILE: test/bundle/output/umdDefaults/21.js ================================================ (function (factory) { !(typeof exports === 'object' && typeof module !== 'undefined') && typeof define === 'function' && define.amd ? define(factory) : factory() }(function () { 'use strict'; const config = {}; config.async = true; })); ================================================ FILE: test/bundle/output/umdDefaults/24.js ================================================ /* this is a banner */ (function (factory) { !(typeof exports === 'object' && typeof module !== 'undefined') && typeof define === 'function' && define.amd ? define(factory) : factory() }(function () { 'use strict'; function foo () { console.log( 'fooing' ); } function bar () { console.log( 'baring' ); } foo(); bar(); })); /* this is a footer */ ================================================ FILE: test/bundle/output/umdDefaults/25.js ================================================ (function (factory) { !(typeof exports === 'object' && typeof module !== 'undefined') && typeof define === 'function' && define.amd ? define('myModule', factory) : factory() }(function () { 'use strict'; var foo = function () { console.log( 'fooing' ); } foo(); })); ================================================ FILE: test/bundle/output/umdDefaults/26.js ================================================ (function (factory) { !(typeof exports === 'object' && typeof module !== 'undefined') && typeof define === 'function' && define.amd ? define(factory) : factory() }(function () { 'use strict'; function bar () { console.log( 'baring' ); } bar(); })); ================================================ FILE: test/bundle/output/umdDefaults/27.js ================================================ (function (factory) { !(typeof exports === 'object' && typeof module !== 'undefined') && typeof define === 'function' && define.amd ? define(factory) : factory() }(function () { 'use strict'; var foo = 'this is foo'; var bar = 'this is bar'; function logFoo () { console.log( foo ); } function logBar () { console.log( bar ); } })); ================================================ FILE: test/bundle/output/umdDefaults/28.js ================================================ (function (factory) { !(typeof exports === 'object' && typeof module !== 'undefined') && typeof define === 'function' && define.amd ? define(factory) : factory() }(function () { 'use strict'; var foo = () => undefined; assert.strictEqual( undefined, undefined ); var ctx = {}; var arrow = (x => assert.strictEqual( undefined, undefined )); var fn = function () { assert.strictEqual( this, ctx ); }; arrow.call(ctx); fn.call(ctx); assert.strictEqual(foo(), undefined); })); ================================================ FILE: test/bundle/output/umdDefaults/30.js ================================================ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('foo')) : typeof define === 'function' && define.amd ? define(['foo'], factory) : factory(global.foo) }(this, function (foo) { 'use strict'; foo.bar(); })); ================================================ FILE: test/bundle/output/umdDefaults/31.js ================================================ (function (factory) { !(typeof exports === 'object' && typeof module !== 'undefined') && typeof define === 'function' && define.amd ? define(factory) : factory() }(function () { 'use strict'; function someOtherName () {} function x () {} someOtherName(); })); ================================================ FILE: test/bundle/output/umdDefaults/32.js ================================================ (function (factory) { !(typeof exports === 'object' && typeof module !== 'undefined') && typeof define === 'function' && define.amd ? define(factory) : factory() }(function () { 'use strict'; })); ================================================ FILE: test/bundle/output/umdDefaults/33.js ================================================ (function (factory) { !(typeof exports === 'object' && typeof module !== 'undefined') && typeof define === 'function' && define.amd ? define(factory) : factory() }(function () { 'use strict'; var _Promise__Promise = function () {}; _Promise__Promise.prototype = { keep () { this.state = 'kept'; }, break () { this.state = 'broken'; } }; var _Promise = _Promise__Promise; var _Math = { get add () { return add; }, get multiply () { return multiply; } }; function add ( a, b ) { return a + b; } function multiply ( a, b ) { return a * b; } var num = Math.max( 1, 2, 3 ); var resolved = Promise.resolve( num ); function foo () { return resolved; } var promise = new _Promise(); promise.keep(); console.log( _Math.add( 40, 2 ) ); })); ================================================ FILE: test/bundle/output/umdDefaults/34.js ================================================ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : global.myModule = factory() }(this, function () { 'use strict'; var foo__exports = {}; foo__exports.bar = function () { console.log( 'exports should be renamed' ); }; var foo = foo__exports; foo.bar(); var main = 'whatever'; return main; })); ================================================ FILE: test/bundle/output/umdDefaults/35.js ================================================ (function (factory) { !(typeof exports === 'object' && typeof module !== 'undefined') && typeof define === 'function' && define.amd ? define(factory) : factory() }(function () { 'use strict'; function a () { console.log( 'I am module a' ); } function c () { console.log( 'I am module c' ); } function b () { console.log( 'I am module b' ); c(); } function external () { console.log( 'I am an external dependency' ); a(); b(); } external(); })); ================================================ FILE: test/bundle/output/umdDefaults/36.js ================================================ (function (factory) { !(typeof exports === 'object' && typeof module !== 'undefined') && typeof define === 'function' && define.amd ? define(factory) : factory() }(function () { 'use strict'; function dependsOnExternal () { console.log( external.message ); } function external () { dependsOnExternal(); } external.message = 'don\'t try this at home'; external(); })); ================================================ FILE: test/bundle/output/umdDefaults/37.js ================================================ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('moment')) : typeof define === 'function' && define.amd ? define(['moment'], factory) : factory(global.x) }(this, function (x) { 'use strict'; var a__x = 'wut'; var a = a__x; })); ================================================ FILE: test/bundle/output/umdDefaults/38.js ================================================ (function (factory) { !(typeof exports === 'object' && typeof module !== 'undefined') && typeof define === 'function' && define.amd ? define(factory) : factory() }(function () { 'use strict'; var _foo = notActuallyFoo; function notActuallyFoo () { foo(); } function foo () { console.log( 'actually foo' ); } _foo(); })); ================================================ FILE: test/bundle/output/umdDefaults/40.js ================================================ (function (factory) { !(typeof exports === 'object' && typeof module !== 'undefined') && typeof define === 'function' && define.amd ? define(factory) : factory() }(function () { 'use strict'; function foo () { console.log( 'foo' ); } foo(); })); ================================================ FILE: test/bundle/output/umdDefaults/42.js ================================================ (function (factory) { !(typeof exports === 'object' && typeof module !== 'undefined') && typeof define === 'function' && define.amd ? define(factory) : factory() }(function () { 'use strict'; function foo () { console.log( 'foo' ); } foo(); })); ================================================ FILE: test/bundle/output/umdDefaults/43.js ================================================ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('bar')) : typeof define === 'function' && define.amd ? define(['bar'], factory) : factory(global.Bar) }(this, function (Bar) { 'use strict'; class Foo extends Bar { constructor() { super(); console.log('Foo constructed'); } } })); ================================================ FILE: test/bundle/output/umdDefaults/44.js ================================================ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('foo'), require('bar')) : typeof define === 'function' && define.amd ? define(['foo', 'bar'], factory) : factory(global.foo, global._bar) }(this, function (foo, _bar) { 'use strict'; (function () { var bar = 'nope'; _bar(); })(); })); ================================================ FILE: test/bundle/output/umdDefaults/45.js ================================================ (function (factory) { !(typeof exports === 'object' && typeof module !== 'undefined') && typeof define === 'function' && define.amd ? define(factory) : factory() }(function () { 'use strict'; var bar = 42; function foo () { console.log( bar ); } foo(); })); ================================================ FILE: test/bundle/output/umdDefaults/46.js ================================================ (function (factory) { !(typeof exports === 'object' && typeof module !== 'undefined') && typeof define === 'function' && define.amd ? define(factory) : factory() }(function () { 'use strict'; var bar = 42; function foo () { console.log( bar ); } foo(); })); ================================================ FILE: test/bundle/output/umdDefaults/47.js ================================================ (function (factory) { !(typeof exports === 'object' && typeof module !== 'undefined') && typeof define === 'function' && define.amd ? define(factory) : factory() }(function () { implicitGlobal = 'lol'; })); ================================================ FILE: test/bundle/output/umdDefaults/48.js ================================================ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('external')) : typeof define === 'function' && define.amd ? define(['external'], factory) : factory(global.external) }(this, function (external) { 'use strict'; external(); })); ================================================ FILE: test/bundle/output/umdDefaults/49.js ================================================ (function (factory) { !(typeof exports === 'object' && typeof module !== 'undefined') && typeof define === 'function' && define.amd ? define(factory) : factory() }(function () { 'use strict'; function foo () { console.log( 'foo' ); } foo(); })); //# sourceMappingURL=data:application/json;charset=utf-8;base64,xyz ================================================ FILE: test/bundle/output/umdDefaults/50.js ================================================ (function (factory) { !(typeof exports === 'object' && typeof module !== 'undefined') && typeof define === 'function' && define.amd ? define(factory) : factory() }(function () { 'use strict'; class A { constructor () { console.log( 'creating A' ); } b () { return new B(); } } class B extends A { constructor () { console.log( 'creating B' ); } } class D { constructor () { console.log( 'creating D' ); } c () { return new C(); } } class C extends D { constructor () { console.log( 'creating C' ); } } new A().b(); new B(); new C(); new D().c(); })); ================================================ FILE: test/bundle/output/umdDefaults/51.js ================================================ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('highlight.js')) : typeof define === 'function' && define.amd ? define(['highlight.js'], factory) : factory(global.highlight) }(this, function (highlight) { 'use strict'; var foo = 42; })); ================================================ FILE: test/bundle/output/umdDefaults/52.js ================================================ (function (factory) { !(typeof exports === 'object' && typeof module !== 'undefined') && typeof define === 'function' && define.amd ? define(factory) : factory() }(function () { 'use strict'; var not_baz = function () { // baz.js }; // bar.js console.log( 'baz', not_baz ); })); ================================================ FILE: test/bundle/output/umdDefaults/53.js ================================================ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : global.myModule = factory() }(this, function () { 'use strict'; var foo = function () { console.log( 'foo' ); } foo(); var main = function () { console.log( 'main' ); } return main; })); ================================================ FILE: test/bundle/output/umdDefaults/54.js ================================================ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('bluebird')) : typeof define === 'function' && define.amd ? define(['bluebird'], factory) : factory(global.bluebird) }(this, function (bluebird) { 'use strict'; var foo = 'foo'; })); ================================================ FILE: test/bundle/output/umdDefaults/55.js ================================================ (function (factory) { !(typeof exports === 'object' && typeof module !== 'undefined') && typeof define === 'function' && define.amd ? define(factory) : factory() }(function () { 'use strict'; class A { b () { return new B(); } c () { return new C(); } } class B extends A {} class C extends A {} })); ================================================ FILE: test/bundle/output/umdDefaults/56.js ================================================ (function (factory) { !(typeof exports === 'object' && typeof module !== 'undefined') && typeof define === 'function' && define.amd ? define(factory) : factory() }(function () { 'use strict'; var foo = 42; var _foo = foo; foo = 99; foo += 1; foo++; console.log( _foo ); // 42 })); ================================================ FILE: test/bundle/output/umdDefaults/57.js ================================================ (function (factory) { !(typeof exports === 'object' && typeof module !== 'undefined') && typeof define === 'function' && define.amd ? define(factory) : factory() }(function () { 'use strict'; var foo = { get y () { return x; } }; var x = 42; console.log( foo.y ); })); ================================================ FILE: test/bundle/output/umdDefaults/59.js ================================================ (function (factory) { !(typeof exports === 'object' && typeof module !== 'undefined') && typeof define === 'function' && define.amd ? define(factory) : factory() }(function () { 'use strict'; var foo = 'foo'; console.log( foo ); // 'foo' })); ================================================ FILE: test/bundle/output/umdDefaults/60.js ================================================ (function (factory) { !(typeof exports === 'object' && typeof module !== 'undefined') && typeof define === 'function' && define.amd ? define(factory) : factory() }(function () { 'use strict'; var foo = 'foo'; var bar = 'bar'; // Preserve comments after imports console.log( foo ); })); ================================================ FILE: test/es6-module-transpiler-tests/README.md ================================================ These tests are taken from the [esnext/es6-module-transpiler](https://github.com/esnext/es6-module-transpiler/tree/master/test/examples) test suite. Unlike the other tests in this project, which ensure that converted modules have the correct *form*, these tests ensure that the *semantics* of ES6 modules are faithfully represented. I'm grateful to the es6-module-transpiler project for producing these test cases and making them available under an [Apache 2.0 license](https://github.com/esnext/es6-module-transpiler/blob/master/LICENSE), and in particular to [Thomas Boyt](https://github.com/thomasboyt) for [pointing me towards them](https://news.ycombinator.com/item?id=8198649). ================================================ FILE: test/es6-module-transpiler-tests/bundled-output/bare-import.js ================================================ 'use strict'; global.sideEffectyValue = 99; assert.equal(global.sideEffectyValue, 99); ================================================ FILE: test/es6-module-transpiler-tests/bundled-output/bindings.js ================================================ 'use strict'; var count = 0; function incr() { count++; } assert.equal(count, 0); incr(); assert.equal(count, 1); ================================================ FILE: test/es6-module-transpiler-tests/bundled-output/cycles-defaults.js ================================================ 'use strict'; var b = { b: 2, get a() { return a.a; } }; var a = { a: 1, get b() { return b.b; } }; assert.equal(a.a, 1); assert.equal(a.b, 2); assert.equal(b.a, 1); assert.equal(b.b, 2); ================================================ FILE: test/es6-module-transpiler-tests/bundled-output/cycles-immediate.js ================================================ 'use strict'; function nextOdd(n) { return isEven(n) ? n + 1 : n + 2; } /** * We go through these gymnastics to eager-bind to isEven. This is done to * ensure that both this module and the 'evens' module eagerly use something * from the other. */ var isOdd = (function(isEven) { return function(n) { return !isEven(n); }; })(isEven); /** * We go through these gymnastics to eager-bind to nextOdd. This is done to * ensure that both this module and the 'odds' module eagerly use something * from the other. */ var nextEven = (function() { return function(n) { var no = nextOdd(n); return (no === n + 2) ? no - 1 : no; }; })(nextOdd); function isEven(n) { return n % 2 === 0; } /** * The 'evens' and 'odds' modules are configured in such a way that they both * have two exported functions: isEven, nextEven, isOdd, and nextOdd. Normally * these four functions could be in any order regardless of which depends on * which because of JavaScript function hoisting. * * For the purposes of our test we need to prevent function hoisting, so it has * been arranged that two of them will be function expressions assigned to * variables. Specifically, isOdd and nextEven both eagerly evaluate their * dependencies (i.e. isEven and nextOdd). This allows us to test that exported * function declarations are available before what would be a module's * "execute" step, per the spec. */ assert.equal(nextEven(1), 2); assert.equal(nextOdd(1), 3); assert.ok(isOdd(1)); assert.ok(!isOdd(0)); assert.ok(isEven(0)); assert.ok(!isEven(1)); ================================================ FILE: test/es6-module-transpiler-tests/bundled-output/cycles.js ================================================ 'use strict'; function geta() { return a; } var b = 2; function getb() { return b; } var a = 1; assert.equal(geta(), 1); assert.equal(a, 1); assert.equal(getb(), 2); assert.equal(b, 2); ================================================ FILE: test/es6-module-transpiler-tests/bundled-output/export-and-import-reference-share-var.js ================================================ 'use strict'; var a = 1; assert.equal(a, 1); // This variable declaration is going to be altered because `b` needs to be // re-written. We need to make sure that the `a` re-writing and the unaffected // `c` declarator are not being clobbered by that alteration. var a_ = a, b = 9, c = 'c'; assert.equal(a, 1); assert.equal(a_, 1); assert.equal(b, 9); assert.equal(c, 'c'); exports.b = b; ================================================ FILE: test/es6-module-transpiler-tests/bundled-output/export-default-function.js ================================================ 'use strict'; var fn1 = function () { return 1; } assert.equal(fn1(), 1); assert.equal(fn1(), 1); ================================================ FILE: test/es6-module-transpiler-tests/bundled-output/export-default-named-function.js ================================================ 'use strict'; function foo() { return 1; } function callsFoo() { return foo(); } assert.strictEqual(foo(), 1); assert.strictEqual(callsFoo(), 1); ================================================ FILE: test/es6-module-transpiler-tests/bundled-output/export-default.js ================================================ 'use strict'; var a = 42; function change() { a++; } assert.equal(a, 42); var value = a; // Any replacement for the `export default` above needs to happen in the same // location. It cannot be done, say, at the end of the file. Otherwise the new // value of `a` will be used and will be incorrect. a = 0; assert.equal(a, 0); assert.equal(value, 42); change(); assert.equal( value, 42, 'default export should not be bound' ); ================================================ FILE: test/es6-module-transpiler-tests/bundled-output/export-from-default.js ================================================ 'use strict'; var first = 1; assert.equal(first, 1); ================================================ FILE: test/es6-module-transpiler-tests/bundled-output/export-from.js ================================================ 'use strict'; var first__a = 1; assert.equal(typeof a, 'undefined'); assert.equal(first__a, 1); ================================================ FILE: test/es6-module-transpiler-tests/bundled-output/export-function.js ================================================ 'use strict'; function foo() { return 121; } assert.equal(foo(), 121); assert.equal(foo(), 121); ================================================ FILE: test/es6-module-transpiler-tests/bundled-output/export-list.js ================================================ 'use strict'; var a = 1; var b = 2; function incr() { var c = a++; // Capture `a++` to force us to use a temporary variable. b++; } assert.equal(a, 1); assert.equal(b, 2); incr(); assert.equal(a, 2); assert.equal(b, 3); ================================================ FILE: test/es6-module-transpiler-tests/bundled-output/export-mixins.js ================================================ 'use strict'; var exporter = 1; var bar = 2; assert.equal(exporter, 1); assert.equal(bar, 2); ================================================ FILE: test/es6-module-transpiler-tests/bundled-output/export-var.js ================================================ 'use strict'; var a = 1; assert.equal(a, 1); assert.equal(a, 1); ================================================ FILE: test/es6-module-transpiler-tests/bundled-output/import-as.js ================================================ 'use strict'; var exporter__a = 'a'; var exporter__b = 'b'; var exporter = 'DEF'; assert.equal(exporter__a, 'a'); assert.equal(exporter__b, 'b'); assert.equal(exporter, 'DEF'); ================================================ FILE: test/es6-module-transpiler-tests/bundled-output/import-chain.js ================================================ 'use strict'; var value = 42; assert.equal(value, 42); ================================================ FILE: test/es6-module-transpiler-tests/bundled-output/import-order.js ================================================ 'use strict'; global.myGlobalFunction = function(){ return 42; }; global.sideEffectyOutput = global.myGlobalFunction(); assert.equal(global.sideEffectyOutput, 42); ================================================ FILE: test/es6-module-transpiler-tests/bundled-output/module-level-declarations.js ================================================ 'use strict'; var a = 1; assert.equal(a, 1); assert.equal(getA(), 1); function getA() { return a; } ================================================ FILE: test/es6-module-transpiler-tests/bundled-output/named-function-expression.js ================================================ 'use strict'; var a = 1; var getA = function getA() { var a = 2; return a; }; assert.strictEqual(a, 1); assert.strictEqual(getA(), 2); ================================================ FILE: test/es6-module-transpiler-tests/bundled-output/namespaces.js ================================================ 'use strict'; var exporter = { get a () { return a; }, get b () { return b; }, get default () { return exporter__default; } }; var a = 'a'; var b = 'b'; var exporter__default = 'DEF'; assert.equal(exporter['default'], 'DEF'); assert.equal(exporter.b, 'b'); assert.equal(exporter.a, 'a'); var keys = []; for (var key in exporter) { keys.push(key); } assert.deepEqual(keys.sort(), ['a', 'b', 'default']); ================================================ FILE: test/es6-module-transpiler-tests/bundled-output/re-export-default-import.js ================================================ 'use strict'; function hi() { return 'hi'; } /* jshint esnext:true */ assert.equal(hi(), 'hi'); ================================================ FILE: test/es6-module-transpiler-tests/bundled-output/this-binding-undefined.js ================================================ 'use strict'; assert.strictEqual( undefined, undefined ); var ctx = {}; var fn = function () { assert.strictEqual( this, ctx ); }; fn.call(ctx); ================================================ FILE: test/es6-module-transpiler-tests/input/bare-import/_config.js ================================================ module.exports = { entry: 'importer' }; ================================================ FILE: test/es6-module-transpiler-tests/input/bare-import/exporter.js ================================================ global.sideEffectyValue = 99; ================================================ FILE: test/es6-module-transpiler-tests/input/bare-import/importer.js ================================================ import './exporter'; assert.equal(global.sideEffectyValue, 99); ================================================ FILE: test/es6-module-transpiler-tests/input/bindings/_config.js ================================================ module.exports = { entry: 'importer' }; ================================================ FILE: test/es6-module-transpiler-tests/input/bindings/exporter.js ================================================ export var count = 0; export function incr() { count++; } ================================================ FILE: test/es6-module-transpiler-tests/input/bindings/importer.js ================================================ import { count, incr } from './exporter'; assert.equal(count, 0); incr(); assert.equal(count, 1); ================================================ FILE: test/es6-module-transpiler-tests/input/cycles/_config.js ================================================ module.exports = { entry: 'c' }; ================================================ FILE: test/es6-module-transpiler-tests/input/cycles/a.js ================================================ import { b } from './b'; export function getb() { return b; } export var a = 1; ================================================ FILE: test/es6-module-transpiler-tests/input/cycles/b.js ================================================ import { a } from './a'; export function geta() { return a; } export var b = 2; ================================================ FILE: test/es6-module-transpiler-tests/input/cycles/c.js ================================================ import { a, getb } from './a'; import { b, geta } from './b'; assert.equal(geta(), 1); assert.equal(a, 1); assert.equal(getb(), 2); assert.equal(b, 2); ================================================ FILE: test/es6-module-transpiler-tests/input/cycles-defaults/_config.js ================================================ module.exports = { entry: 'importer' }; ================================================ FILE: test/es6-module-transpiler-tests/input/cycles-defaults/a.js ================================================ import b from './b'; export default { a: 1, get b() { return b.b; } }; ================================================ FILE: test/es6-module-transpiler-tests/input/cycles-defaults/b.js ================================================ import a from './a'; export default { b: 2, get a() { return a.a; } }; ================================================ FILE: test/es6-module-transpiler-tests/input/cycles-defaults/importer.js ================================================ import a from './a'; import b from './b'; assert.equal(a.a, 1); assert.equal(a.b, 2); assert.equal(b.a, 1); assert.equal(b.b, 2); ================================================ FILE: test/es6-module-transpiler-tests/input/cycles-immediate/_config.js ================================================ module.exports = { entry: 'main' }; ================================================ FILE: test/es6-module-transpiler-tests/input/cycles-immediate/evens.js ================================================ import { nextOdd } from './odds'; /** * We go through these gymnastics to eager-bind to nextOdd. This is done to * ensure that both this module and the 'odds' module eagerly use something * from the other. */ export var nextEven = (function() { return function(n) { var no = nextOdd(n); return (no === n + 2) ? no - 1 : no; }; })(nextOdd); export function isEven(n) { return n % 2 === 0; } ================================================ FILE: test/es6-module-transpiler-tests/input/cycles-immediate/main.js ================================================ /** * The 'evens' and 'odds' modules are configured in such a way that they both * have two exported functions: isEven, nextEven, isOdd, and nextOdd. Normally * these four functions could be in any order regardless of which depends on * which because of JavaScript function hoisting. * * For the purposes of our test we need to prevent function hoisting, so it has * been arranged that two of them will be function expressions assigned to * variables. Specifically, isOdd and nextEven both eagerly evaluate their * dependencies (i.e. isEven and nextOdd). This allows us to test that exported * function declarations are available before what would be a module's * "execute" step, per the spec. */ import { nextEven, isEven } from './evens'; import { nextOdd, isOdd } from './odds'; assert.equal(nextEven(1), 2); assert.equal(nextOdd(1), 3); assert.ok(isOdd(1)); assert.ok(!isOdd(0)); assert.ok(isEven(0)); assert.ok(!isEven(1)); ================================================ FILE: test/es6-module-transpiler-tests/input/cycles-immediate/odds.js ================================================ import { isEven } from './evens'; export function nextOdd(n) { return isEven(n) ? n + 1 : n + 2; } /** * We go through these gymnastics to eager-bind to isEven. This is done to * ensure that both this module and the 'evens' module eagerly use something * from the other. */ export var isOdd = (function(isEven) { return function(n) { return !isEven(n); }; })(isEven); ================================================ FILE: test/es6-module-transpiler-tests/input/duplicate-import-fails/_config.js ================================================ module.exports = { entry: 'importer', expectedError: 'Duplicated import (\'a\')' }; ================================================ FILE: test/es6-module-transpiler-tests/input/duplicate-import-fails/exporter.js ================================================ export var a = 1; ================================================ FILE: test/es6-module-transpiler-tests/input/duplicate-import-fails/importer.js ================================================ /* error: type=SyntaxError message="expected one declaration for `a`, at importer.js:7:14 but found 2" */ import { a } from './exporter'; import { a } from './exporter'; assert.equal(a, 1); ================================================ FILE: test/es6-module-transpiler-tests/input/duplicate-import-specifier-fails/_config.js ================================================ module.exports = { entry: 'importer', expectedError: 'Duplicated import (\'a\')' }; ================================================ FILE: test/es6-module-transpiler-tests/input/duplicate-import-specifier-fails/exporter.js ================================================ export var a = 1; ================================================ FILE: test/es6-module-transpiler-tests/input/duplicate-import-specifier-fails/importer.js ================================================ /* error: type=SyntaxError message="expected one declaration for `a`, at importer.js:5:14 but found 2" */ import { a, a } from './exporter'; assert.equal(a, 1); ================================================ FILE: test/es6-module-transpiler-tests/input/export-and-import-reference-share-var/_config.js ================================================ module.exports = { entry: 'second' }; ================================================ FILE: test/es6-module-transpiler-tests/input/export-and-import-reference-share-var/first.js ================================================ export var a = 1; assert.equal(a, 1); ================================================ FILE: test/es6-module-transpiler-tests/input/export-and-import-reference-share-var/second.js ================================================ import { a } from './first'; // This variable declaration is going to be altered because `b` needs to be // re-written. We need to make sure that the `a` re-writing and the unaffected // `c` declarator are not being clobbered by that alteration. var a_ = a, b = 9, c = 'c'; assert.equal(a, 1); assert.equal(a_, 1); assert.equal(b, 9); assert.equal(c, 'c'); export { b }; ================================================ FILE: test/es6-module-transpiler-tests/input/export-default/_config.js ================================================ module.exports = { entry: 'importer' }; ================================================ FILE: test/es6-module-transpiler-tests/input/export-default/exporter.js ================================================ var a = 42; export function change() { a++; } assert.equal(a, 42); export default a; // Any replacement for the `export default` above needs to happen in the same // location. It cannot be done, say, at the end of the file. Otherwise the new // value of `a` will be used and will be incorrect. a = 0; assert.equal(a, 0); ================================================ FILE: test/es6-module-transpiler-tests/input/export-default/importer.js ================================================ import value from './exporter'; import { change } from './exporter'; assert.equal(value, 42); change(); assert.equal( value, 42, 'default export should not be bound' ); ================================================ FILE: test/es6-module-transpiler-tests/input/export-default-function/_config.js ================================================ module.exports = { entry: 'importer' }; ================================================ FILE: test/es6-module-transpiler-tests/input/export-default-function/exporter.js ================================================ export default function () { return 1; } ================================================ FILE: test/es6-module-transpiler-tests/input/export-default-function/importer.js ================================================ import fn1 from './exporter'; import { default as fn2 } from './exporter'; assert.equal(fn1(), 1); assert.equal(fn2(), 1); ================================================ FILE: test/es6-module-transpiler-tests/input/export-default-named-function/_config.js ================================================ module.exports = { entry: 'importer' }; ================================================ FILE: test/es6-module-transpiler-tests/input/export-default-named-function/exporter.js ================================================ export default function foo() { return 1; } export function callsFoo() { return foo(); } ================================================ FILE: test/es6-module-transpiler-tests/input/export-default-named-function/importer.js ================================================ import foo, { callsFoo } from './exporter'; assert.strictEqual(foo(), 1); assert.strictEqual(callsFoo(), 1); ================================================ FILE: test/es6-module-transpiler-tests/input/export-from/_config.js ================================================ module.exports = { entry: 'third' }; ================================================ FILE: test/es6-module-transpiler-tests/input/export-from/first.js ================================================ export var a = 1; ================================================ FILE: test/es6-module-transpiler-tests/input/export-from/second.js ================================================ export { a } from './first'; // This `a` reference should not be re-written because this export is not // creating a local binding. assert.equal(typeof a, 'undefined'); ================================================ FILE: test/es6-module-transpiler-tests/input/export-from/third.js ================================================ import { a } from './second'; assert.equal(a, 1); ================================================ FILE: test/es6-module-transpiler-tests/input/export-from-default/_config.js ================================================ module.exports = { entry: 'third' }; ================================================ FILE: test/es6-module-transpiler-tests/input/export-from-default/first.js ================================================ export default 1; ================================================ FILE: test/es6-module-transpiler-tests/input/export-from-default/second.js ================================================ export { default } from './first'; ================================================ FILE: test/es6-module-transpiler-tests/input/export-from-default/third.js ================================================ import a from './second'; assert.equal(a, 1); ================================================ FILE: test/es6-module-transpiler-tests/input/export-function/_config.js ================================================ module.exports = { entry: 'importer' }; ================================================ FILE: test/es6-module-transpiler-tests/input/export-function/exporter.js ================================================ export function foo() { return 121; } assert.equal(foo(), 121); ================================================ FILE: test/es6-module-transpiler-tests/input/export-function/importer.js ================================================ import { foo } from './exporter'; assert.equal(foo(), 121); ================================================ FILE: test/es6-module-transpiler-tests/input/export-list/_config.js ================================================ module.exports = { entry: 'importer' }; ================================================ FILE: test/es6-module-transpiler-tests/input/export-list/exporter.js ================================================ var a = 1; var b = 2; function incr() { var c = a++; // Capture `a++` to force us to use a temporary variable. b++; } export { a, b, incr }; ================================================ FILE: test/es6-module-transpiler-tests/input/export-list/importer.js ================================================ import { a, b, incr } from './exporter'; assert.equal(a, 1); assert.equal(b, 2); incr(); assert.equal(a, 2); assert.equal(b, 3); ================================================ FILE: test/es6-module-transpiler-tests/input/export-mixins/_config.js ================================================ module.exports = { entry: 'importer' }; ================================================ FILE: test/es6-module-transpiler-tests/input/export-mixins/exporter.js ================================================ export default 1; export var bar = 2; ================================================ FILE: test/es6-module-transpiler-tests/input/export-mixins/importer.js ================================================ import foo, { bar } from './exporter'; assert.equal(foo, 1); assert.equal(bar, 2); ================================================ FILE: test/es6-module-transpiler-tests/input/export-not-at-top-level-fails/_config.js ================================================ module.exports = { entry: 'index', expectedError: "import' and 'export' may only appear at the top level" }; ================================================ FILE: test/es6-module-transpiler-tests/input/export-not-at-top-level-fails/index.js ================================================ function foo() { /* error: type=Error message="Line 5: Unexpected reserved word" */ export { foo }; } ================================================ FILE: test/es6-module-transpiler-tests/input/export-var/_config.js ================================================ module.exports = { entry: 'importer' }; ================================================ FILE: test/es6-module-transpiler-tests/input/export-var/exporter.js ================================================ export var a = 1; assert.equal(a, 1); ================================================ FILE: test/es6-module-transpiler-tests/input/export-var/importer.js ================================================ import { a } from './exporter'; assert.equal(a, 1); ================================================ FILE: test/es6-module-transpiler-tests/input/import-as/_config.js ================================================ module.exports = { entry: 'importer' }; ================================================ FILE: test/es6-module-transpiler-tests/input/import-as/exporter.js ================================================ export var a = 'a'; export var b = 'b'; export default 'DEF'; ================================================ FILE: test/es6-module-transpiler-tests/input/import-as/importer.js ================================================ import { a as b, b as a, default as def } from './exporter'; assert.equal(b, 'a'); assert.equal(a, 'b'); assert.equal(def, 'DEF'); ================================================ FILE: test/es6-module-transpiler-tests/input/import-chain/_config.js ================================================ module.exports = { entry: 'third' }; ================================================ FILE: test/es6-module-transpiler-tests/input/import-chain/first.js ================================================ export var value = 42; ================================================ FILE: test/es6-module-transpiler-tests/input/import-chain/second.js ================================================ import { value } from './first'; export { value }; ================================================ FILE: test/es6-module-transpiler-tests/input/import-chain/third.js ================================================ import { value } from './second'; assert.equal(value, 42); ================================================ FILE: test/es6-module-transpiler-tests/input/import-not-at-top-level-fails/_config.js ================================================ module.exports = { entry: 'index', expectedError: "import' and 'export' may only appear at the top level" }; ================================================ FILE: test/es6-module-transpiler-tests/input/import-not-at-top-level-fails/index.js ================================================ function foo() { /* error: type=Error message="Line 5: Unexpected reserved word" */ import foo from './index'; } ================================================ FILE: test/es6-module-transpiler-tests/input/import-order/_config.js ================================================ module.exports = { entry: 'importer' }; ================================================ FILE: test/es6-module-transpiler-tests/input/import-order/consumer.js ================================================ global.sideEffectyOutput = global.myGlobalFunction(); ================================================ FILE: test/es6-module-transpiler-tests/input/import-order/exporter.js ================================================ global.myGlobalFunction = function(){ return 42; }; ================================================ FILE: test/es6-module-transpiler-tests/input/import-order/importer.js ================================================ import './exporter'; import './consumer'; assert.equal(global.sideEffectyOutput, 42); ================================================ FILE: test/es6-module-transpiler-tests/input/module-level-declarations/_config.js ================================================ module.exports = { entry: 'mod' }; ================================================ FILE: test/es6-module-transpiler-tests/input/module-level-declarations/mod.js ================================================ var a = 1; assert.equal(a, 1); assert.equal(getA(), 1); function getA() { return a; } ================================================ FILE: test/es6-module-transpiler-tests/input/named-function-expression/_config.js ================================================ module.exports = { entry: 'importer' }; ================================================ FILE: test/es6-module-transpiler-tests/input/named-function-expression/exporter.js ================================================ export var a = 1; ================================================ FILE: test/es6-module-transpiler-tests/input/named-function-expression/importer.js ================================================ import { a } from './exporter'; var getA = function getA() { var a = 2; return a; }; assert.strictEqual(a, 1); assert.strictEqual(getA(), 2); ================================================ FILE: test/es6-module-transpiler-tests/input/namespace-reassign-import-fails/_config.js ================================================ module.exports = { entry: 'importer', expectedError: 'Cannot reassign imported binding of namespace `exp`' }; ================================================ FILE: test/es6-module-transpiler-tests/input/namespace-reassign-import-fails/exporter.js ================================================ export var foo = 1; ================================================ FILE: test/es6-module-transpiler-tests/input/namespace-reassign-import-fails/importer.js ================================================ import * as exp from './exporter'; /* error: type=SyntaxError message="Cannot reassign imported binding `foo` at importer.js:6:1" */ exp.foo = 2; ================================================ FILE: test/es6-module-transpiler-tests/input/namespace-update-import-fails/_config.js ================================================ module.exports = { entry: 'importer', expectedError: 'Cannot reassign imported binding of namespace `exp`' }; ================================================ FILE: test/es6-module-transpiler-tests/input/namespace-update-import-fails/exporter.js ================================================ export var foo = 1; ================================================ FILE: test/es6-module-transpiler-tests/input/namespace-update-import-fails/importer.js ================================================ import * as exp from './exporter'; /* error: type=SyntaxError message="Cannot reassign imported binding of namespace `exp` at importer.js:6:1" */ exp['foo']++; ================================================ FILE: test/es6-module-transpiler-tests/input/namespaces/_config.js ================================================ module.exports = { entry: 'importer' }; ================================================ FILE: test/es6-module-transpiler-tests/input/namespaces/exporter.js ================================================ export var a = 'a'; export var b = 'b'; export default 'DEF'; ================================================ FILE: test/es6-module-transpiler-tests/input/namespaces/importer.js ================================================ import * as foo from './exporter'; assert.equal(foo['default'], 'DEF'); assert.equal(foo.b, 'b'); assert.equal(foo.a, 'a'); var keys = []; for (var key in foo) { keys.push(key); } assert.deepEqual(keys.sort(), ['a', 'b', 'default']); ================================================ FILE: test/es6-module-transpiler-tests/input/re-export-default-import/_config.js ================================================ module.exports = { entry: 'third' }; ================================================ FILE: test/es6-module-transpiler-tests/input/re-export-default-import/first.js ================================================ export default function hi() { return 'hi'; } ================================================ FILE: test/es6-module-transpiler-tests/input/re-export-default-import/second.js ================================================ /* jshint esnext:true */ import hi from './first'; export { hi }; ================================================ FILE: test/es6-module-transpiler-tests/input/re-export-default-import/third.js ================================================ import { hi } from './second'; assert.equal(hi(), 'hi'); ================================================ FILE: test/es6-module-transpiler-tests/input/reassign-import-fails/_config.js ================================================ module.exports = { entry: 'importer', expectedError: 'Cannot reassign imported binding `x`' }; ================================================ FILE: test/es6-module-transpiler-tests/input/reassign-import-fails/exporter.js ================================================ export var x = 1; ================================================ FILE: test/es6-module-transpiler-tests/input/reassign-import-fails/importer.js ================================================ import { x } from './exporter'; (function() { for(var x = 0; x < 1; x++){} for(var x = 0; x < 1; x++){} }); /* error: type=SyntaxError message="Cannot reassign imported binding `x` at importer.js:11:1" */ x = 10; ================================================ FILE: test/es6-module-transpiler-tests/input/reassign-import-not-at-top-level-fails/_config.js ================================================ module.exports = { entry: 'importer', expectedError: 'Cannot reassign imported binding `x`' }; ================================================ FILE: test/es6-module-transpiler-tests/input/reassign-import-not-at-top-level-fails/exporter.js ================================================ export var x = 1; ================================================ FILE: test/es6-module-transpiler-tests/input/reassign-import-not-at-top-level-fails/importer.js ================================================ import { x } from './exporter'; export function foo () { var x = 1; } export function bar () { /* error: type=SyntaxError message="Cannot reassign imported binding `x` at importer.js:10:3" */ x = 1; } ================================================ FILE: test/es6-module-transpiler-tests/input/this-binding-undefined/_config.js ================================================ module.exports = { entry: 'mod' }; ================================================ FILE: test/es6-module-transpiler-tests/input/this-binding-undefined/mod.js ================================================ assert.strictEqual( this, undefined ); var ctx = {}; var fn = function () { assert.strictEqual( this, ctx ); }; fn.call(ctx); ================================================ FILE: test/es6-module-transpiler-tests/input/update-expression-of-import-fails/_config.js ================================================ module.exports = { entry: 'importer', expectedError: 'Cannot reassign imported binding `a`' }; ================================================ FILE: test/es6-module-transpiler-tests/input/update-expression-of-import-fails/exporter.js ================================================ export var a = 0; ================================================ FILE: test/es6-module-transpiler-tests/input/update-expression-of-import-fails/importer.js ================================================ import { a } from './exporter'; /* error: type=SyntaxError message="Cannot reassign imported binding `a` at importer.js:6:1" */ a++; ================================================ FILE: test/es6-module-transpiler-tests/output/bare-import/exporter.js ================================================ 'use strict'; global.sideEffectyValue = 99; ================================================ FILE: test/es6-module-transpiler-tests/output/bare-import/importer.js ================================================ 'use strict'; require('./exporter'); assert.equal(global.sideEffectyValue, 99); ================================================ FILE: test/es6-module-transpiler-tests/output/bindings/exporter.js ================================================ 'use strict'; exports.incr = incr; var count = 0; function incr() { count++, exports.count = count; } exports.count = count; ================================================ FILE: test/es6-module-transpiler-tests/output/bindings/importer.js ================================================ 'use strict'; var exporter = require('./exporter'); assert.equal(exporter.count, 0); exporter.incr(); assert.equal(exporter.count, 1); ================================================ FILE: test/es6-module-transpiler-tests/output/cycles/a.js ================================================ 'use strict'; exports.getb = getb; var b = require('./b'); function getb() { return b.b; } var a = 1; exports.a = a; ================================================ FILE: test/es6-module-transpiler-tests/output/cycles/b.js ================================================ 'use strict'; exports.geta = geta; var a = require('./a'); function geta() { return a.a; } var b = 2; exports.b = b; ================================================ FILE: test/es6-module-transpiler-tests/output/cycles/c.js ================================================ 'use strict'; var a = require('./a'); var b = require('./b'); assert.equal(b.geta(), 1); assert.equal(a.a, 1); assert.equal(a.getb(), 2); assert.equal(b.b, 2); ================================================ FILE: test/es6-module-transpiler-tests/output/cycles-defaults/a.js ================================================ 'use strict'; var b = require('./b'); exports['default'] = { a: 1, get b() { return b['default'].b; } }; ================================================ FILE: test/es6-module-transpiler-tests/output/cycles-defaults/b.js ================================================ 'use strict'; var a = require('./a'); exports['default'] = { b: 2, get a() { return a['default'].a; } }; ================================================ FILE: test/es6-module-transpiler-tests/output/cycles-defaults/importer.js ================================================ 'use strict'; var a = require('./a'); var b = require('./b'); assert.equal(a['default'].a, 1); assert.equal(a['default'].b, 2); assert.equal(b['default'].a, 1); assert.equal(b['default'].b, 2); ================================================ FILE: test/es6-module-transpiler-tests/output/cycles-immediate/evens.js ================================================ 'use strict'; exports.isEven = isEven; var odds = require('./odds'); /** * We go through these gymnastics to eager-bind to nextOdd. This is done to * ensure that both this module and the 'odds' module eagerly use something * from the other. */ var nextEven = (function() { return function(n) { var no = odds.nextOdd(n); return (no === n + 2) ? no - 1 : no; }; })(odds.nextOdd); function isEven(n) { return n % 2 === 0; } exports.nextEven = nextEven; ================================================ FILE: test/es6-module-transpiler-tests/output/cycles-immediate/main.js ================================================ 'use strict'; var evens = require('./evens'); var odds = require('./odds'); /** * The 'evens' and 'odds' modules are configured in such a way that they both * have two exported functions: isEven, nextEven, isOdd, and nextOdd. Normally * these four functions could be in any order regardless of which depends on * which because of JavaScript function hoisting. * * For the purposes of our test we need to prevent function hoisting, so it has * been arranged that two of them will be function expressions assigned to * variables. Specifically, isOdd and nextEven both eagerly evaluate their * dependencies (i.e. isEven and nextOdd). This allows us to test that exported * function declarations are available before what would be a module's * "execute" step, per the spec. */ assert.equal(evens.nextEven(1), 2); assert.equal(odds.nextOdd(1), 3); assert.ok(odds.isOdd(1)); assert.ok(!odds.isOdd(0)); assert.ok(evens.isEven(0)); assert.ok(!evens.isEven(1)); ================================================ FILE: test/es6-module-transpiler-tests/output/cycles-immediate/odds.js ================================================ 'use strict'; exports.nextOdd = nextOdd; var evens = require('./evens'); function nextOdd(n) { return evens.isEven(n) ? n + 1 : n + 2; } /** * We go through these gymnastics to eager-bind to isEven. This is done to * ensure that both this module and the 'evens' module eagerly use something * from the other. */ var isOdd = (function(isEven) { return function(n) { return !isEven(n); }; })(evens.isEven); exports.isOdd = isOdd; ================================================ FILE: test/es6-module-transpiler-tests/output/duplicate-import-fails/exporter.js ================================================ 'use strict'; var a = 1; exports.a = a; ================================================ FILE: test/es6-module-transpiler-tests/output/duplicate-import-specifier-fails/exporter.js ================================================ 'use strict'; var a = 1; exports.a = a; ================================================ FILE: test/es6-module-transpiler-tests/output/export-and-import-reference-share-var/first.js ================================================ 'use strict'; var a = 1; assert.equal(a, 1); exports.a = a; ================================================ FILE: test/es6-module-transpiler-tests/output/export-and-import-reference-share-var/second.js ================================================ 'use strict'; var first = require('./first'); // This variable declaration is going to be altered because `b` needs to be // re-written. We need to make sure that the `a` re-writing and the unaffected // `c` declarator are not being clobbered by that alteration. var a_ = first.a, b = 9, c = 'c'; assert.equal(first.a, 1); assert.equal(a_, 1); assert.equal(b, 9); assert.equal(c, 'c'); exports.b = b; ================================================ FILE: test/es6-module-transpiler-tests/output/export-default/exporter.js ================================================ 'use strict'; exports.change = change; var a = 42; function change() { a++; } assert.equal(a, 42); exports['default'] = a; // Any replacement for the `export default` above needs to happen in the same // location. It cannot be done, say, at the end of the file. Otherwise the new // value of `a` will be used and will be incorrect. a = 0; assert.equal(a, 0); ================================================ FILE: test/es6-module-transpiler-tests/output/export-default/importer.js ================================================ 'use strict'; var value = require('./exporter'); assert.equal(value['default'], 42); value.change(); assert.equal( value['default'], 42, 'default export should not be bound' ); ================================================ FILE: test/es6-module-transpiler-tests/output/export-default-function/exporter.js ================================================ 'use strict'; exports['default'] = function () { return 1; } ================================================ FILE: test/es6-module-transpiler-tests/output/export-default-function/importer.js ================================================ 'use strict'; var fn1 = require('./exporter'); assert.equal(fn1['default'](), 1); assert.equal(fn1.default(), 1); ================================================ FILE: test/es6-module-transpiler-tests/output/export-default-named-function/exporter.js ================================================ 'use strict'; exports.callsFoo = callsFoo; function foo() { return 1; } exports['default'] = foo; function callsFoo() { return foo(); } ================================================ FILE: test/es6-module-transpiler-tests/output/export-default-named-function/importer.js ================================================ 'use strict'; var exporter = require('./exporter'); assert.strictEqual(exporter['default'](), 1); assert.strictEqual(exporter.callsFoo(), 1); ================================================ FILE: test/es6-module-transpiler-tests/output/export-from/first.js ================================================ 'use strict'; var a = 1; exports.a = a; ================================================ FILE: test/es6-module-transpiler-tests/output/export-from/second.js ================================================ 'use strict'; Object.defineProperty(exports, 'a', { enumerable: true, get: function () { return first.a; }}); var first = require('./first'); assert.equal(typeof a, 'undefined'); ================================================ FILE: test/es6-module-transpiler-tests/output/export-from/third.js ================================================ 'use strict'; var second = require('./second'); assert.equal(second.a, 1); ================================================ FILE: test/es6-module-transpiler-tests/output/export-from-default/first.js ================================================ 'use strict'; exports['default'] = 1; ================================================ FILE: test/es6-module-transpiler-tests/output/export-from-default/second.js ================================================ 'use strict'; Object.defineProperty(exports, 'default', { enumerable: true, get: function () { return first['default']; }}); var first = require('./first'); ================================================ FILE: test/es6-module-transpiler-tests/output/export-from-default/third.js ================================================ 'use strict'; var a = require('./second'); assert.equal(a['default'], 1); ================================================ FILE: test/es6-module-transpiler-tests/output/export-function/exporter.js ================================================ 'use strict'; exports.foo = foo; function foo() { return 121; } assert.equal(foo(), 121); ================================================ FILE: test/es6-module-transpiler-tests/output/export-function/importer.js ================================================ 'use strict'; var exporter = require('./exporter'); assert.equal(exporter.foo(), 121); ================================================ FILE: test/es6-module-transpiler-tests/output/export-list/exporter.js ================================================ 'use strict'; exports.incr = incr; var a = 1; var b = 2; function incr() { var c = a++; exports.a = a; // Capture `a++` to force us to use a temporary variable. b++, exports.b = b; } exports.a = a; exports.b = b; ================================================ FILE: test/es6-module-transpiler-tests/output/export-list/importer.js ================================================ 'use strict'; var exporter = require('./exporter'); assert.equal(exporter.a, 1); assert.equal(exporter.b, 2); exporter.incr(); assert.equal(exporter.a, 2); assert.equal(exporter.b, 3); ================================================ FILE: test/es6-module-transpiler-tests/output/export-mixins/exporter.js ================================================ 'use strict'; exports['default'] = 1; var bar = 2; exports.bar = bar; ================================================ FILE: test/es6-module-transpiler-tests/output/export-mixins/importer.js ================================================ 'use strict'; var exporter = require('./exporter'); assert.equal(exporter['default'], 1); assert.equal(exporter.bar, 2); ================================================ FILE: test/es6-module-transpiler-tests/output/export-var/exporter.js ================================================ 'use strict'; var a = 1; assert.equal(a, 1); exports.a = a; ================================================ FILE: test/es6-module-transpiler-tests/output/export-var/importer.js ================================================ 'use strict'; var exporter = require('./exporter'); assert.equal(exporter.a, 1); ================================================ FILE: test/es6-module-transpiler-tests/output/import-as/exporter.js ================================================ 'use strict'; var a = 'a'; var b = 'b'; exports['default'] = 'DEF'; exports.a = a; exports.b = b; ================================================ FILE: test/es6-module-transpiler-tests/output/import-as/importer.js ================================================ 'use strict'; var exporter = require('./exporter'); assert.equal(exporter.a, 'a'); assert.equal(exporter.b, 'b'); assert.equal(exporter.default, 'DEF'); ================================================ FILE: test/es6-module-transpiler-tests/output/import-chain/first.js ================================================ 'use strict'; var value = 42; exports.value = value; ================================================ FILE: test/es6-module-transpiler-tests/output/import-chain/second.js ================================================ 'use strict'; Object.defineProperty(exports, 'value', { enumerable: true, get: function () { return first.value; }}); var first = require('./first'); ================================================ FILE: test/es6-module-transpiler-tests/output/import-chain/third.js ================================================ 'use strict'; var second = require('./second'); assert.equal(second.value, 42); ================================================ FILE: test/es6-module-transpiler-tests/output/import-order/consumer.js ================================================ 'use strict'; global.sideEffectyOutput = global.myGlobalFunction(); ================================================ FILE: test/es6-module-transpiler-tests/output/import-order/exporter.js ================================================ 'use strict'; global.myGlobalFunction = function(){ return 42; }; ================================================ FILE: test/es6-module-transpiler-tests/output/import-order/importer.js ================================================ 'use strict'; require('./exporter'); require('./consumer'); assert.equal(global.sideEffectyOutput, 42); ================================================ FILE: test/es6-module-transpiler-tests/output/module-level-declarations/mod.js ================================================ 'use strict'; var a = 1; assert.equal(a, 1); assert.equal(getA(), 1); function getA() { return a; } ================================================ FILE: test/es6-module-transpiler-tests/output/named-function-expression/exporter.js ================================================ 'use strict'; var a = 1; exports.a = a; ================================================ FILE: test/es6-module-transpiler-tests/output/named-function-expression/importer.js ================================================ 'use strict'; var exporter = require('./exporter'); var getA = function getA() { var a = 2; return a; }; assert.strictEqual(exporter.a, 1); assert.strictEqual(getA(), 2); ================================================ FILE: test/es6-module-transpiler-tests/output/namespace-reassign-import-fails/exporter.js ================================================ 'use strict'; var foo = 1; exports.foo = foo; ================================================ FILE: test/es6-module-transpiler-tests/output/namespace-update-import-fails/exporter.js ================================================ 'use strict'; var foo = 1; exports.foo = foo; ================================================ FILE: test/es6-module-transpiler-tests/output/namespaces/exporter.js ================================================ 'use strict'; var a = 'a'; var b = 'b'; exports['default'] = 'DEF'; exports.a = a; exports.b = b; ================================================ FILE: test/es6-module-transpiler-tests/output/namespaces/importer.js ================================================ 'use strict'; var foo = require('./exporter'); assert.equal(foo['default'], 'DEF'); assert.equal(foo.b, 'b'); assert.equal(foo.a, 'a'); var keys = []; for (var key in foo) { keys.push(key); } assert.deepEqual(keys.sort(), ['a', 'b', 'default']); ================================================ FILE: test/es6-module-transpiler-tests/output/re-export-default-import/first.js ================================================ 'use strict'; function hi() { return 'hi'; } exports['default'] = hi; ================================================ FILE: test/es6-module-transpiler-tests/output/re-export-default-import/second.js ================================================ 'use strict'; Object.defineProperty(exports, 'hi', { enumerable: true, get: function () { return hi['default']; }}); var hi = require('./first'); /* jshint esnext:true */ ================================================ FILE: test/es6-module-transpiler-tests/output/re-export-default-import/third.js ================================================ 'use strict'; var second = require('./second'); assert.equal(second.hi(), 'hi'); ================================================ FILE: test/es6-module-transpiler-tests/output/reassign-import-fails/exporter.js ================================================ 'use strict'; var x = 1; exports.x = x; ================================================ FILE: test/es6-module-transpiler-tests/output/reassign-import-not-at-top-level-fails/exporter.js ================================================ 'use strict'; var x = 1; exports.x = x; ================================================ FILE: test/es6-module-transpiler-tests/output/this-binding-undefined/mod.js ================================================ 'use strict'; assert.strictEqual( undefined, undefined ); var ctx = {}; var fn = function () { assert.strictEqual( this, ctx ); }; fn.call(ctx); ================================================ FILE: test/es6-module-transpiler-tests/output/update-expression-of-import-fails/exporter.js ================================================ 'use strict'; var a = 0; exports.a = a; ================================================ FILE: test/fastMode/index.js ================================================ var assert = require( 'assert' ); var sander = require( 'sander' ); var makeWhitespaceVisible = require( '../utils/makeWhitespaceVisible' ); var esperanto = require( '../../' ); var Promise = sander.Promise; module.exports = function () { return new Promise( function ( fulfil ) { describe( 'fast mode', function () { var tests, start; this.timeout( 20000 ); tests = [ { file: 'earlyExport', description: 'transpiles exports that are not the final statement' }, { file: 'emptyImport', description: 'transpiles empty imports with no exports' }, { file: 'emptyImportWithDefaultExport', description: 'transpiles empty imports with default exports' }, { file: 'escapedSource', description: 'preserves character escapes in source strings' }, { file: 'exportAnonFunction', description: 'transpiled anonymous default function exports' }, { file: 'exportDefault', description: 'transpiles default exports' }, { file: 'exportFunction', description: 'transpiles named default function exports' }, { file: 'importAll', description: 'transpiles `import * as foo from "foo"`' }, { file: 'importDefault', description: 'transpiles default imports' }, { file: 'multipleImports', description: 'transpiles multiple imports' }, { file: 'trailingEmptyImport', description: 'transpiles trailing empty imports' }, { file: 'banner', description: 'adds a banner' }, { file: 'footer', description: 'adds a footer' }, { file: 'bannerAndFooter', description: 'adds a banner and a footer' }, { file: 'namedAmdModule', description: 'creates a named AMD module if amdName is passed' } ]; var tests = sander.readdirSync( __dirname, '../samples' ).map( function ( dir ) { var config = require( '../samples/' + dir + '/_config' ), source = sander.readFileSync( __dirname, '../samples', dir, 'source.js' ).toString(); if ( config.ast ) { source = { code: source, ast: config.ast }; } return { id: dir, config: config, source: source }; }); before( function () { if ( process.env.BUILD_TIMEOUT ) { this.timeout( parseInt( process.env.BUILD_TIMEOUT ) ); } start = Date.now(); }); after( function () { fulfil( Date.now() - start ); }); describe( 'esperanto.toAmd()', function () { runTests( 'amd', 'toAmd' ); }); describe( 'esperanto.toCjs()', function () { runTests( 'cjs', 'toCjs' ); }); describe( 'esperanto.toUmd()', function () { runTests( 'umd', 'toUmd' ); }); function runTests ( dir, method ) { tests.forEach( function ( t ) { if ( t.config.strict ) return; ( t.config.solo ? it.only : it )( t.config.description, function () { var transpiled; try { transpiled = esperanto[ method ]( t.source, { name: t.config.name || 'myModule', amdName: t.config.amdName, absolutePaths: t.config.absolutePaths, banner: t.config.banner, footer: t.config.footer, useStrict: t.config.useStrict }); } catch ( err ) { if ( t.config.expectedError && ~err.message.indexOf( t.config.expectedError ) ) { return; } throw err; } if ( t.config.expectedError ) { throw new Error( 'Expected error: ' + t.config.expectedError ); } var actual = makeWhitespaceVisible( transpiled.code ); return sander.readFile( 'fastMode/output/' + dir, t.id + '.js' ).then( String ).then( function ( str ) { var expected = makeWhitespaceVisible( str ); assert.equal( actual, expected, 'Expected\n>\n' + actual + '\n>\n\nto match\n\n>\n' + expected + '\n>' ); }).catch( function ( err ) { if ( err.code === 'ENOENT' ) { assert.equal( actual, '', 'Expected\n>\n' + actual + '\n>\n\nto match non-existent file' ); } else { throw err; } }); }); }); } }); }); }; ================================================ FILE: test/fastMode/output/amd/absolutePaths.js ================================================ define('my/nested/module', ['foo', 'my/bar', 'my/nested/baz', 'my/qux'], function (foo, bar, baz, qux) { 'use strict'; }); ================================================ FILE: test/fastMode/output/amd/banner.js ================================================ /* this is a banner */ define(['whatever'], function (whatever) { 'use strict'; whatever(); return 'someExport'; }); ================================================ FILE: test/fastMode/output/amd/bannerAndFooter.js ================================================ /* this is a banner */ define(['whatever'], function (whatever) { 'use strict'; whatever(); return 'someExport'; }); /* this is a footer */ ================================================ FILE: test/fastMode/output/amd/constructor.js ================================================ define(function () { 'use strict'; return function () { var constructor; constructor = 42; }; }); ================================================ FILE: test/fastMode/output/amd/earlyExport.js ================================================ define(function () { 'use strict'; function foo () { console.log( 'fooing' ); } return foo; }); ================================================ FILE: test/fastMode/output/amd/emptyImport.js ================================================ define(['polyfills', 'foo'], function (__dep0__, bar) { 'use strict'; }); ================================================ FILE: test/fastMode/output/amd/emptyImportWithDefaultExport.js ================================================ define(['foo', 'polyfills'], function (foo) { 'use strict'; return 'baz'; }); ================================================ FILE: test/fastMode/output/amd/escapedSource.js ================================================ define(['fo\no'], function (foo) { 'use strict'; }); ================================================ FILE: test/fastMode/output/amd/exportAnonFunction.js ================================================ define(function () { 'use strict'; return function () { console.log( 'I am anonymous' ); }; }); ================================================ FILE: test/fastMode/output/amd/exportClassWithSuper.js ================================================ define(['bar'], function (Bar) { 'use strict'; class Foo extends Bar { constructor() { super(); console.log('Foo constructed'); } } }); ================================================ FILE: test/fastMode/output/amd/exportDefault.js ================================================ define(function () { 'use strict'; return 'foo'; }); ================================================ FILE: test/fastMode/output/amd/exportFunction.js ================================================ define(function () { 'use strict'; function foo ( str ) { return str.toUpperCase(); } return foo; }); ================================================ FILE: test/fastMode/output/amd/footer.js ================================================ define(['whatever'], function (whatever) { 'use strict'; whatever(); return 'someExport'; }); /* this is a footer */ ================================================ FILE: test/fastMode/output/amd/importAll.js ================================================ define(['fs'], function (fs) { 'use strict'; }); ================================================ FILE: test/fastMode/output/amd/importDefault.js ================================================ define(['foo'], function (foo) { 'use strict'; console.log( foo ); }); ================================================ FILE: test/fastMode/output/amd/intermediateSourcemaps.js ================================================ define(function () { 'use strict'; var answer = 42; }); ================================================ FILE: test/fastMode/output/amd/multipleImports.js ================================================ define(['foo', 'bar', 'baz'], function (foo, bar, baz) { 'use strict'; var qux = foo( bar( baz ) ); return qux; }); ================================================ FILE: test/fastMode/output/amd/namedAmdModule.js ================================================ define('myModule', ['foo'], function (foo) { 'use strict'; foo(); }); ================================================ FILE: test/fastMode/output/amd/preparsed.js ================================================ define(['./bar'], function (foo) { 'use strict'; }); ================================================ FILE: test/fastMode/output/amd/sparseArray.js ================================================ define(function () { 'use strict'; [1,,3,4] }); ================================================ FILE: test/fastMode/output/amd/trailingEmptyImport.js ================================================ define(['foo', 'polyfills'], function (foo) { 'use strict'; }); ================================================ FILE: test/fastMode/output/amd/useStrictFalse.js ================================================ define(function () { implicitGlobal = 'lol'; }); ================================================ FILE: test/fastMode/output/cjs/absolutePaths.js ================================================ 'use strict'; var foo = require('../../foo'); var bar = require('../bar'); var baz = require('./baz'); var qux = require('./../qux'); ================================================ FILE: test/fastMode/output/cjs/banner.js ================================================ /* this is a banner */ 'use strict'; var whatever = require('whatever'); whatever(); module.exports = 'someExport'; ================================================ FILE: test/fastMode/output/cjs/bannerAndFooter.js ================================================ /* this is a banner */ 'use strict'; var whatever = require('whatever'); whatever(); module.exports = 'someExport'; /* this is a footer */ ================================================ FILE: test/fastMode/output/cjs/constructor.js ================================================ 'use strict'; module.exports = function () { var constructor; constructor = 42; } ================================================ FILE: test/fastMode/output/cjs/earlyExport.js ================================================ 'use strict'; module.exports = foo; function foo () { console.log( 'fooing' ); } ================================================ FILE: test/fastMode/output/cjs/emptyImport.js ================================================ 'use strict'; require('polyfills'); var bar = require('foo'); ================================================ FILE: test/fastMode/output/cjs/emptyImportWithDefaultExport.js ================================================ 'use strict'; var foo = require('foo'); require('polyfills'); module.exports = 'baz'; ================================================ FILE: test/fastMode/output/cjs/escapedSource.js ================================================ 'use strict'; var foo = require('fo\no'); ================================================ FILE: test/fastMode/output/cjs/exportAnonFunction.js ================================================ 'use strict'; module.exports = function () { console.log( 'I am anonymous' ); } ================================================ FILE: test/fastMode/output/cjs/exportClassWithSuper.js ================================================ 'use strict'; var Bar = require('bar'); class Foo extends Bar { constructor() { super(); console.log('Foo constructed'); } } ================================================ FILE: test/fastMode/output/cjs/exportDefault.js ================================================ 'use strict'; module.exports = 'foo'; ================================================ FILE: test/fastMode/output/cjs/exportFunction.js ================================================ 'use strict'; function foo ( str ) { return str.toUpperCase(); } module.exports = foo; ================================================ FILE: test/fastMode/output/cjs/footer.js ================================================ 'use strict'; var whatever = require('whatever'); whatever(); module.exports = 'someExport'; /* this is a footer */ ================================================ FILE: test/fastMode/output/cjs/importAll.js ================================================ 'use strict'; var fs = require('fs'); ================================================ FILE: test/fastMode/output/cjs/importDefault.js ================================================ 'use strict'; var foo = require('foo'); console.log( foo ); ================================================ FILE: test/fastMode/output/cjs/intermediateSourcemaps.js ================================================ 'use strict'; var answer = 42; ================================================ FILE: test/fastMode/output/cjs/multipleImports.js ================================================ 'use strict'; var foo = require('foo'); var bar = require('bar'); var baz = require('baz'); var qux = foo( bar( baz ) ); module.exports = qux; ================================================ FILE: test/fastMode/output/cjs/namedAmdModule.js ================================================ 'use strict'; var foo = require('foo'); foo(); ================================================ FILE: test/fastMode/output/cjs/preparsed.js ================================================ 'use strict'; var foo = require('./bar'); ================================================ FILE: test/fastMode/output/cjs/sparseArray.js ================================================ 'use strict'; [1,,3,4] ================================================ FILE: test/fastMode/output/cjs/trailingEmptyImport.js ================================================ 'use strict'; var foo = require('foo'); require('polyfills'); ================================================ FILE: test/fastMode/output/cjs/useStrictFalse.js ================================================ implicitGlobal = 'lol'; ================================================ FILE: test/fastMode/output/umd/absolutePaths.js ================================================ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../foo'), require('../bar'), require('./baz'), require('./../qux')) : typeof define === 'function' && define.amd ? define('my/nested/module', ['foo', 'my/bar', 'my/nested/baz', 'my/qux'], factory) : factory(global.foo, global.bar, global.baz, global.qux) }(this, function (foo, bar, baz, qux) { 'use strict'; })); ================================================ FILE: test/fastMode/output/umd/banner.js ================================================ /* this is a banner */ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('whatever')) : typeof define === 'function' && define.amd ? define(['whatever'], factory) : global.myModule = factory(global.whatever) }(this, function (whatever) { 'use strict'; whatever(); return 'someExport'; })); ================================================ FILE: test/fastMode/output/umd/bannerAndFooter.js ================================================ /* this is a banner */ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('whatever')) : typeof define === 'function' && define.amd ? define(['whatever'], factory) : global.myModule = factory(global.whatever) }(this, function (whatever) { 'use strict'; whatever(); return 'someExport'; })); /* this is a footer */ ================================================ FILE: test/fastMode/output/umd/constructor.js ================================================ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : global.myModule = factory() }(this, function () { 'use strict'; return function () { var constructor; constructor = 42; }; })); ================================================ FILE: test/fastMode/output/umd/earlyExport.js ================================================ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : global.myModule = factory() }(this, function () { 'use strict'; function foo () { console.log( 'fooing' ); } return foo; })); ================================================ FILE: test/fastMode/output/umd/emptyImport.js ================================================ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('polyfills'), require('foo')) : typeof define === 'function' && define.amd ? define(['polyfills', 'foo'], factory) : factory(undefined, global.bar) }(this, function (__dep0__, bar) { 'use strict'; })); ================================================ FILE: test/fastMode/output/umd/emptyImportWithDefaultExport.js ================================================ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('foo'), require('polyfills')) : typeof define === 'function' && define.amd ? define(['foo', 'polyfills'], factory) : global.myModule = factory(global.foo) }(this, function (foo) { 'use strict'; return 'baz'; })); ================================================ FILE: test/fastMode/output/umd/escapedSource.js ================================================ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('fo\no')) : typeof define === 'function' && define.amd ? define(['fo\no'], factory) : factory(global.foo) }(this, function (foo) { 'use strict'; })); ================================================ FILE: test/fastMode/output/umd/exportAnonFunction.js ================================================ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : global.myModule = factory() }(this, function () { 'use strict'; return function () { console.log( 'I am anonymous' ); }; })); ================================================ FILE: test/fastMode/output/umd/exportClassWithSuper.js ================================================ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('bar')) : typeof define === 'function' && define.amd ? define(['bar'], factory) : factory(global.Bar) }(this, function (Bar) { 'use strict'; class Foo extends Bar { constructor() { super(); console.log('Foo constructed'); } } })); ================================================ FILE: test/fastMode/output/umd/exportDefault.js ================================================ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : global.myModule = factory() }(this, function () { 'use strict'; return 'foo'; })); ================================================ FILE: test/fastMode/output/umd/exportFunction.js ================================================ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : global.myModule = factory() }(this, function () { 'use strict'; function foo ( str ) { return str.toUpperCase(); } return foo; })); ================================================ FILE: test/fastMode/output/umd/footer.js ================================================ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('whatever')) : typeof define === 'function' && define.amd ? define(['whatever'], factory) : global.myModule = factory(global.whatever) }(this, function (whatever) { 'use strict'; whatever(); return 'someExport'; })); /* this is a footer */ ================================================ FILE: test/fastMode/output/umd/importAll.js ================================================ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('fs')) : typeof define === 'function' && define.amd ? define(['fs'], factory) : factory(global.fs) }(this, function (fs) { 'use strict'; })); ================================================ FILE: test/fastMode/output/umd/importDefault.js ================================================ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('foo')) : typeof define === 'function' && define.amd ? define(['foo'], factory) : factory(global.foo) }(this, function (foo) { 'use strict'; console.log( foo ); })); ================================================ FILE: test/fastMode/output/umd/intermediateSourcemaps.js ================================================ (function (factory) { !(typeof exports === 'object' && typeof module !== 'undefined') && typeof define === 'function' && define.amd ? define(factory) : factory() }(function () { 'use strict'; var answer = 42; })); ================================================ FILE: test/fastMode/output/umd/multipleImports.js ================================================ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('foo'), require('bar'), require('baz')) : typeof define === 'function' && define.amd ? define(['foo', 'bar', 'baz'], factory) : global.myModule = factory(global.foo, global.bar, global.baz) }(this, function (foo, bar, baz) { 'use strict'; var qux = foo( bar( baz ) ); return qux; })); ================================================ FILE: test/fastMode/output/umd/namedAmdModule.js ================================================ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('foo')) : typeof define === 'function' && define.amd ? define('myModule', ['foo'], factory) : factory(global.foo) }(this, function (foo) { 'use strict'; foo(); })); ================================================ FILE: test/fastMode/output/umd/preparsed.js ================================================ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('./bar')) : typeof define === 'function' && define.amd ? define(['./bar'], factory) : factory(global.foo) }(this, function (foo) { 'use strict'; })); ================================================ FILE: test/fastMode/output/umd/sparseArray.js ================================================ (function (factory) { !(typeof exports === 'object' && typeof module !== 'undefined') && typeof define === 'function' && define.amd ? define(factory) : factory() }(function () { 'use strict'; [1,,3,4] })); ================================================ FILE: test/fastMode/output/umd/trailingEmptyImport.js ================================================ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('foo'), require('polyfills')) : typeof define === 'function' && define.amd ? define(['foo', 'polyfills'], factory) : factory(global.foo) }(this, function (foo) { 'use strict'; })); ================================================ FILE: test/fastMode/output/umd/useStrictFalse.js ================================================ (function (factory) { !(typeof exports === 'object' && typeof module !== 'undefined') && typeof define === 'function' && define.amd ? define(factory) : factory() }(function () { implicitGlobal = 'lol'; })); ================================================ FILE: test/samples/absolutePaths/_config.js ================================================ module.exports = { description: 'resolves relative paths for AMD/UMD exports, if specified, but not CJS', amdName: 'my/nested/module', absolutePaths: true }; ================================================ FILE: test/samples/absolutePaths/source.js ================================================ import foo from '../../foo'; import bar from '../bar'; import baz from './baz'; import qux from './../qux'; ================================================ FILE: test/samples/banner/_config.js ================================================ module.exports = { description: 'adds a banner', banner: '/* this is a banner */\n' }; ================================================ FILE: test/samples/banner/source.js ================================================ import whatever from 'whatever'; whatever(); export default 'someExport'; ================================================ FILE: test/samples/bannerAndFooter/_config.js ================================================ module.exports = { description: 'adds a banner and a footer', banner: '/* this is a banner */\n', footer: '\n/* this is a footer */' }; ================================================ FILE: test/samples/bannerAndFooter/source.js ================================================ import whatever from 'whatever'; whatever(); export default 'someExport'; ================================================ FILE: test/samples/clashingDefaultImports/_config.js ================================================ module.exports = { description: 'avoids naming collisions with default imports', expectedError: 'Duplicated import (\'x\')' }; ================================================ FILE: test/samples/clashingDefaultImports/source.js ================================================ import x from 'foo'; import x from 'bar'; x(); ================================================ FILE: test/samples/clashingFunctionArguments/_config.js ================================================ module.exports = { description: 'prevents function arguments from shadowing imports', strict: true }; ================================================ FILE: test/samples/clashingFunctionArguments/source.js ================================================ import { foo } from 'x/y/z'; export function bar ( z ) { return foo( z ); } ================================================ FILE: test/samples/clashingMixedImports/_config.js ================================================ module.exports = { //solo: true, description: 'deconflicts when naming imports based on filename', strict: true }; ================================================ FILE: test/samples/clashingMixedImports/source.js ================================================ import { something } from 'duplicated'; import duplicated from 'elsewhere'; export default function() { return [something, duplicated]; } ================================================ FILE: test/samples/clashingNamedDefaultImports/_config.js ================================================ module.exports = { description: 'avoids naming collisions with mixed named/default imports', strict: true, expectedError: 'Duplicated import (\'x\')' }; ================================================ FILE: test/samples/clashingNamedDefaultImports/source.js ================================================ import { x } from 'foo'; import x from 'bar'; x(); ================================================ FILE: test/samples/clashingNamedImports/_config.js ================================================ module.exports = { description: 'avoids naming collisions with named imports', strict: true, expectedError: 'Duplicated import (\'x\')' }; ================================================ FILE: test/samples/clashingNamedImports/source.js ================================================ import { x } from 'foo'; import { x } from 'bar'; x(); ================================================ FILE: test/samples/clashingNames/_config.js ================================================ module.exports = { description: 'avoids naming collisions', strict: true }; ================================================ FILE: test/samples/clashingNames/source.js ================================================ import { bar } from 'foo'; var foo = 'should not clash'; bar(); ================================================ FILE: test/samples/clashingObjectProperties/_config.js ================================================ module.exports = { description: 'functions are not illegally/unnecessarily renamed as object properties (#122)', strict: true }; ================================================ FILE: test/samples/clashingObjectProperties/source.js ================================================ import { foo } from './foo'; var obj = { foo: function foo () {} }; foo(); ================================================ FILE: test/samples/conditionalExport/_config.js ================================================ module.exports = { description: 'correctly exports when binding is updated inside a block', strict: true }; ================================================ FILE: test/samples/conditionalExport/source.js ================================================ var foo = function () {}; var bar = 'a'; if ( false ) { foo = function () { bar = 'b'; }; } export { foo, bar }; ================================================ FILE: test/samples/constructor/_config.js ================================================ module.exports = { description: 'handles `constructor` edge case' }; ================================================ FILE: test/samples/constructor/source.js ================================================ export default function () { var constructor; constructor = 42; } ================================================ FILE: test/samples/duplicateImportFalsePositive/_config.js ================================================ module.exports = { description: 'allows imports to be re-exported', strict: true }; ================================================ FILE: test/samples/duplicateImportFalsePositive/source.js ================================================ import { foo } from 'bar'; export { foo } from 'bar'; ================================================ FILE: test/samples/duplicateImports/_config.js ================================================ module.exports = { description: 'de-duplicates imports', strict: true }; ================================================ FILE: test/samples/duplicateImports/source.js ================================================ import { bar } from 'foo'; import { baz } from 'foo'; bar(); baz(); ================================================ FILE: test/samples/earlyExport/_config.js ================================================ module.exports = { description: 'transpiles exports that are not the final statement' }; ================================================ FILE: test/samples/earlyExport/source.js ================================================ export default foo; function foo () { console.log( 'fooing' ); } ================================================ FILE: test/samples/emptyImport/_config.js ================================================ module.exports = { description: 'transpiles empty imports with no exports' }; ================================================ FILE: test/samples/emptyImport/source.js ================================================ import 'polyfills'; import bar from 'foo'; ================================================ FILE: test/samples/emptyImportWithDefaultExport/_config.js ================================================ module.exports = { description: 'transpiles empty imports with default exports' }; ================================================ FILE: test/samples/emptyImportWithDefaultExport/source.js ================================================ import foo from 'foo'; import 'polyfills'; export default 'baz'; ================================================ FILE: test/samples/escapedSource/_config.js ================================================ module.exports = { description: 'preserves character escapes in source strings' }; ================================================ FILE: test/samples/escapedSource/source.js ================================================ import foo from 'fo\no'; ================================================ FILE: test/samples/exportAnonFunction/_config.js ================================================ module.exports = { description: 'transpiled anonymous default function exports' }; ================================================ FILE: test/samples/exportAnonFunction/source.js ================================================ export default function () { console.log( 'I am anonymous' ); } ================================================ FILE: test/samples/exportClass/_config.js ================================================ module.exports = { description: 'transpiles named class exports as late exports', strict: true }; ================================================ FILE: test/samples/exportClass/source.js ================================================ export class Point {} ================================================ FILE: test/samples/exportClassWithSuper/_config.js ================================================ module.exports = { description: 'bundles class with super (#129)' }; ================================================ FILE: test/samples/exportClassWithSuper/source.js ================================================ import Bar from 'bar'; class Foo extends Bar { constructor() { super(); console.log('Foo constructed'); } } ================================================ FILE: test/samples/exportDefault/_config.js ================================================ module.exports = { description: 'transpiles default exports' }; ================================================ FILE: test/samples/exportDefault/source.js ================================================ export default 'foo'; ================================================ FILE: test/samples/exportFunction/_config.js ================================================ module.exports = { description: 'transpiles named default function exports' }; ================================================ FILE: test/samples/exportFunction/source.js ================================================ export default function foo ( str ) { return str.toUpperCase(); } ================================================ FILE: test/samples/exportInlineFunction/_config.js ================================================ module.exports = { description: 'transpiles named inline function exports', strict: true }; ================================================ FILE: test/samples/exportInlineFunction/source.js ================================================ export function foo ( str ) { return str.toUpperCase(); } ================================================ FILE: test/samples/exportLet/_config.js ================================================ module.exports = { description: 'transpiles named inline let exports', strict: true }; ================================================ FILE: test/samples/exportLet/source.js ================================================ export let answer = 41; answer++; ================================================ FILE: test/samples/exportNamed/_config.js ================================================ module.exports = { description: 'transpiles named exports', strict: true }; ================================================ FILE: test/samples/exportNamed/source.js ================================================ var foo = 'bar', answer = 42; export { foo, answer }; ================================================ FILE: test/samples/exportNamedCollidesWithFunctionExpression/_config.js ================================================ module.exports = { description: 'does not interpret named function expressions as early-exportable', amdName: 'foo', strict: true }; ================================================ FILE: test/samples/exportNamedCollidesWithFunctionExpression/source.js ================================================ var foo = "bar"; if (false) { someFunction = function foo() { }; } export { foo }; ================================================ FILE: test/samples/exportNamedFromNamedImportES3/_config.js ================================================ module.exports = { description: 'does not use Object.defineProperty when using _evilES3SafeReExports option', amdName: 'foo', strict: true, _evilES3SafeReExports: true }; ================================================ FILE: test/samples/exportNamedFromNamedImportES3/source.js ================================================ import { foo as bar } from "foo"; export { bar }; ================================================ FILE: test/samples/exportNamedFunction/_config.js ================================================ module.exports = { description: 'named functions are exported early', strict: true }; ================================================ FILE: test/samples/exportNamedFunction/source.js ================================================ function foo() {} function bar() {} function baz() {} export { foo, bar, baz }; ================================================ FILE: test/samples/exportVar/_config.js ================================================ module.exports = { description: 'transpiles named inline variable exports', strict: true }; ================================================ FILE: test/samples/exportVar/source.js ================================================ export var foo = 'bar'; foo = 'baz'; ================================================ FILE: test/samples/footer/_config.js ================================================ module.exports = { description: 'adds a footer', footer: '\n/* this is a footer */' }; ================================================ FILE: test/samples/footer/source.js ================================================ import whatever from 'whatever'; whatever(); export default 'someExport'; ================================================ FILE: test/samples/hasExportsVariable/_config.js ================================================ module.exports = { description: 'avoids conflict between exports and existing variables', strict: true } ================================================ FILE: test/samples/hasExportsVariable/source.js ================================================ var exports = {}; exports.foo = 'bar'; export default exports; ================================================ FILE: test/samples/importAll/_config.js ================================================ module.exports = { description: 'transpiles `import * as foo from "foo"`' }; ================================================ FILE: test/samples/importAll/source.js ================================================ import * as fs from 'fs'; ================================================ FILE: test/samples/importDefault/_config.js ================================================ module.exports = { description: 'transpiles default imports' }; ================================================ FILE: test/samples/importDefault/source.js ================================================ import foo from 'foo'; console.log( foo ); ================================================ FILE: test/samples/importNamed/_config.js ================================================ module.exports = { description: 'transpiles named imports', strict: true }; ================================================ FILE: test/samples/importNamed/source.js ================================================ import { foo, bar } from 'baz'; ================================================ FILE: test/samples/intermediateSourcemaps/_config.js ================================================ module.exports = { description: 'removes existing sourcemap comments' }; ================================================ FILE: test/samples/intermediateSourcemaps/source.js ================================================ var answer = 42; //# sourceMappingURL=this/should/be/removed.js.map ================================================ FILE: test/samples/mixedImports/_config.js ================================================ module.exports = { description: 'transpiles mixed named/default imports', strict: true }; ================================================ FILE: test/samples/mixedImports/source.js ================================================ import asap, { later } from 'asap'; ================================================ FILE: test/samples/multipleImports/_config.js ================================================ module.exports = { description: 'transpiles multiple imports' }; ================================================ FILE: test/samples/multipleImports/source.js ================================================ import foo from 'foo'; import bar from 'bar'; import baz from 'baz'; var qux = foo( bar( baz ) ); export default qux; ================================================ FILE: test/samples/namedAmdModule/_config.js ================================================ module.exports = { description: 'creates a named AMD module if amdName is passed', amdName: 'myModule' }; ================================================ FILE: test/samples/namedAmdModule/source.js ================================================ import foo from 'foo'; foo(); ================================================ FILE: test/samples/preparsed/_config.js ================================================ module.exports = { description: 'uses existing AST', ast: { start: 0, body: [{ start: 0, specifiers: [{ start: 7, local: { start: 7, name: 'foo', type: 'Identifier', end: 10 }, type: 'ImportDefaultSpecifier', end: 10 }], source: { start: 16, value: './bar', // this is different from the original source raw: '\'./bar\'', // and should show up in the results... type: 'Literal', end: 23 }, type: 'ImportDeclaration', end: 24 }], sourceType: 'module', type: 'Program', end: 24 } }; ================================================ FILE: test/samples/preparsed/source.js ================================================ import foo from './foo'; ================================================ FILE: test/samples/reExportES3/_config.js ================================================ module.exports = { description: 'safe re-export to default when using _evilES3SafeReExports', strict: true, _evilES3SafeReExports: true }; ================================================ FILE: test/samples/reExportES3/source.js ================================================ export { default } from 'foo'; ================================================ FILE: test/samples/renamedExport/_config.js ================================================ module.exports = { description: 'transpiles renamed exports', strict: true }; ================================================ FILE: test/samples/renamedExport/source.js ================================================ var a = 42; export { a as answer }; ================================================ FILE: test/samples/renamedImport/_config.js ================================================ module.exports = { description: 'transpiles renamed imports', strict: true }; ================================================ FILE: test/samples/renamedImport/source.js ================================================ import { unlink as rm } from 'fs'; ================================================ FILE: test/samples/safeCommentRemoval/_config.js ================================================ module.exports = { description: 'removes comments without blowing up', strict: true }; ================================================ FILE: test/samples/safeCommentRemoval/source.js ================================================ var foo = 42; export { foo }; //# sourceMappingURL=to/be/removed.js.map ================================================ FILE: test/samples/shadowedExport/_config.js ================================================ module.exports = { description: 'references to declarations shadowing exports are not treated as export references', strict: true }; ================================================ FILE: test/samples/shadowedExport/source.js ================================================ export function foo () { } function bar() { var foo; foo = "qux"; } ================================================ FILE: test/samples/shadowedImport/_config.js ================================================ module.exports = { description: 'handles shadowed imports', strict: true }; ================================================ FILE: test/samples/shadowedImport/source.js ================================================ import { a } from 'foo'; a(); (function () { var foo = 'bar'; a(); }()) ================================================ FILE: test/samples/sparseArray/_config.js ================================================ module.exports = { description: 'tree walker handles sparse arrays (#144)' }; ================================================ FILE: test/samples/sparseArray/source.js ================================================ [1,,3,4] ================================================ FILE: test/samples/trailingEmptyImport/_config.js ================================================ module.exports = { description: 'transpiles trailing empty imports' }; ================================================ FILE: test/samples/trailingEmptyImport/source.js ================================================ import foo from 'foo'; import 'polyfills'; ================================================ FILE: test/samples/unscopedNameConflicts/_config.js ================================================ module.exports = { description: 'avoids conflict with unscoped names', strict: true }; ================================================ FILE: test/samples/unscopedNameConflicts/source.js ================================================ import { find } from './mod/path/location'; find(); console.log(location.href); ================================================ FILE: test/samples/updateExportInArgument/_config.js ================================================ module.exports = { description: 'correctly wraps generated sequence expressions', strict: true }; ================================================ FILE: test/samples/updateExportInArgument/source.js ================================================ var a = 100; function decr () { console.log( '%d bottles of beer on the wall', --a ); console.log( '%d bottles of beer', a-- ); } export { a as num, decr }; ================================================ FILE: test/samples/updateExpressionInFunction/_config.js ================================================ module.exports = { description: 'correctly reassigns bindings via an update expression inside a function', strict: true }; ================================================ FILE: test/samples/updateExpressionInFunction/source.js ================================================ var a = 1; function incr () { var b = a++; console.log( 'incremented from %s to %s', b, a ); } export { a as num, incr }; ================================================ FILE: test/samples/useStrictFalse/_config.js ================================================ module.exports = { description: 'omits use strict if necessary', useStrict: false }; ================================================ FILE: test/samples/useStrictFalse/source.js ================================================ implicitGlobal = 'lol'; ================================================ FILE: test/sourcemaps/bundle/foo.js ================================================ var message = 'yeah!'; export default message; ================================================ FILE: test/sourcemaps/bundle/main.js ================================================ import foo from './foo'; console.log( foo ); ================================================ FILE: test/sourcemaps/index.js ================================================ var path = require( 'path' ); var assert = require( 'assert' ); var SourceMapConsumer = require( 'source-map' ).SourceMapConsumer; var esperanto = require( '../../' ); var Promise = require( 'sander' ).Promise; module.exports = function () { return new Promise( function ( fulfil ) { var start; describe( 'sourcemap', function () { this.timeout( 20000 ); before( function () { if ( process.env.BUILD_TIMEOUT ) { this.timeout( parseInt( process.env.BUILD_TIMEOUT ) ); } start = Date.now(); }); after( function () { fulfil( Date.now() - start ); }); describe( 'standalone', function () { var sample, tests; sample = [ 'var answer = 42;', 'console.log("the answer is %s", answer);' ].join( '\n' ); tests = [ { method: 'toAmd' }, { method: 'toCjs' }, { method: 'toUmd' } ]; tests.forEach( function ( t ) { it( 'is generated by ' + t.method, function () { var result, charIndex, acc, generatedLoc, smc, lines, line, loc, i; result = esperanto[ t.method ]( sample, { sourceMap: true, sourceMapFile: 'output.js', sourceMapSource: 'input.js', name: 'myModule' }); // find the location of 'console' in the generated code... charIndex = result.code.indexOf( 'console' ); acc = 0; lines = result.code.split( '\n' ); for ( i = 0; i < lines.length; i += 1 ) { line = lines[i]; if ( acc + line.length > charIndex ) { generatedLoc = { line: i + 1, column: charIndex - acc }; break; } acc += line.length + 1; } // ...then ensure it corresponds to line 2 (one-based), column 0 (zero-based) smc = new SourceMapConsumer( result.map ); loc = smc.originalPositionFor( generatedLoc ); assert.equal( loc.line, 2 ); assert.equal( loc.column, 0 ); }); }); it( 'accepts an absolute path for sourceMapFile', function () { var result = esperanto.toAmd( sample, { sourceMap: true, sourceMapFile: '/path/to/output.js', sourceMapSource: 'input.js', name: 'myModule' }); assert.ok( /sourceMappingURL=\/path\/to\/output.js/.test( result.code ) ); }); it( 'does not require a sourceMapFile for `sourceMap: "inline"`', function() { var result = esperanto.toAmd( sample, { sourceMap: 'inline', sourceMapSource: 'input.js', name: 'myModule' }); }); }); describe( 'bundler', function () { it( 'should create sourcemap', function () { return esperanto.bundle({ base: path.join( __dirname, 'bundle' ), entry: 'main' }).then( function ( bundle ) { var converted, smc, loc; converted = bundle.toCjs({ sourceMap: true, sourceMapFile: path.join( __dirname, 'bundle.js' ) }); smc = new SourceMapConsumer( converted.map ); loc = smc.originalPositionFor({ line: 3, column: 14 }); assert.equal( loc.line, 1 ); assert.equal( loc.column, 14 ); assert.equal( loc.source, 'bundle/foo.js' ); loc = smc.originalPositionFor({ line: 6, column: 8 }); assert.equal( loc.line, 2 ); assert.equal( loc.column, 8 ); assert.equal( loc.source, 'bundle/main.js' ); }); }); }); }); }); }; ================================================ FILE: test/strictMode/index.js ================================================ var path = require( 'path' ); var assert = require( 'assert' ); var sander = require( 'sander' ); var makeWhitespaceVisible = require( '../utils/makeWhitespaceVisible' ); var esperanto = require( '../../' ); var Promise = sander.Promise; global.assert = assert; module.exports = function () { return new Promise( function ( fulfil ) { var start; describe( 'strict mode', function () { this.timeout( 20000 ); var tests = sander.readdirSync( __dirname, '../samples' ).map( function ( dir ) { var config = require( '../samples/' + dir + '/_config' ), source = sander.readFileSync( __dirname, '../samples', dir, 'source.js' ).toString(); if ( config.ast ) { source = { code: source, ast: config.ast }; } return { id: dir, config: config, source: source }; }); before( function () { if ( process.env.BUILD_TIMEOUT ) { this.timeout( parseInt( process.env.BUILD_TIMEOUT ) ); } sander.rimrafSync( 'es6-module-transpiler-tests/output' ); start = Date.now(); }); after( function () { fulfil( Date.now() - start ); }); describe( 'esperanto.toAmd()', function () { runTests( 'amd', 'toAmd' ); }); describe( 'esperanto.toCjs()', function () { runTests( 'cjs', 'toCjs' ); }); describe( 'esperanto.toUmd()', function () { runTests( 'umd', 'toUmd' ); }); function runTests ( dir, method ) { tests.forEach( function ( t ) { ( t.config.solo ? it.only : it )( t.config.description, function () { var transpiled; try { transpiled = esperanto[ method ]( t.source, { name: 'myModule', strict: true, amdName: t.config.amdName, absolutePaths: t.config.absolutePaths, banner: t.config.banner, footer: t.config.footer, _evilES3SafeReExports: t.config._evilES3SafeReExports, useStrict: t.config.useStrict }); } catch ( err ) { if ( t.config.expectedError && ~err.message.indexOf( t.config.expectedError ) ) { return; } throw err; } if ( t.config.expectedError ) { throw new Error( 'Expected error: ' + t.config.expectedError ); } var actual = makeWhitespaceVisible( transpiled.code ); return sander.readFile( 'strictMode/output/' + dir, t.id + '.js' ).then( String ).then( function ( str ) { var expected = makeWhitespaceVisible( str ); assert.equal( actual, expected, 'Expected\n>\n' + actual + '\n>\n\nto match\n\n>\n' + expected + '\n>' ); }, function ( err ) { if ( err.code === 'ENOENT' ) { assert.equal( actual, '', 'Expected\n>\n' + actual + '\n>\n\nto match non-existent file' ); } else { throw err; } }); }); }); } describe( 'ES6 module semantics tests from es6-module-transpiler:', function () { sander.readdirSync( __dirname, '../es6-module-transpiler-tests/input' ).forEach( function ( dir ) { var config = require( '../es6-module-transpiler-tests/input/' + dir + '/_config' ); ( config.solo ? it.only : it )( dir, function () { // Create CommonJS modules, then require the entry module return sander.readdir( 'es6-module-transpiler-tests/input', dir ).then( function ( files ) { var promises = files.map( function ( file ) { if ( file === '_config.js' ) return; return sander.readFile( 'es6-module-transpiler-tests/input', dir, file ).then( String ).then( function ( source ) { var transpiled = esperanto.toCjs( source, { strict: true }); return sander.writeFile( 'es6-module-transpiler-tests/output', dir, file, transpiled.code ); }); }); return Promise.all( promises ); }) .then( function () { var missingError; try { require( path.resolve( 'es6-module-transpiler-tests/output', dir, config.entry ) ); if ( config.expectedError ) { missingError = true; } } catch( err ) { if ( !config.expectedError || !~err.message.indexOf( config.expectedError ) ) { throw err; } } if ( missingError ) { throw new Error( 'Expected error "' + config.expectedError + '"' ); } }) .catch( function ( err ) { if ( !config.expectedError || !~err.message.indexOf( config.expectedError ) ) { throw err; } }); }); }); }); }); }); }; ================================================ FILE: test/strictMode/output/amd/absolutePaths.js ================================================ define('my/nested/module', ['foo', 'my/bar', 'my/nested/baz', 'my/qux'], function (foo, bar, baz, qux) { 'use strict'; }); ================================================ FILE: test/strictMode/output/amd/banner.js ================================================ /* this is a banner */ define(['exports', 'whatever'], function (exports, whatever) { 'use strict'; whatever['default'](); exports['default'] = 'someExport'; }); ================================================ FILE: test/strictMode/output/amd/bannerAndFooter.js ================================================ /* this is a banner */ define(['exports', 'whatever'], function (exports, whatever) { 'use strict'; whatever['default'](); exports['default'] = 'someExport'; }); /* this is a footer */ ================================================ FILE: test/strictMode/output/amd/clashingFunctionArguments.js ================================================ define(['exports', 'x/y/z'], function (exports, y__z) { 'use strict'; exports.bar = bar; function bar ( z ) { return y__z.foo( z ); } }); ================================================ FILE: test/strictMode/output/amd/clashingMixedImports.js ================================================ define(['exports', 'duplicated', 'elsewhere'], function (exports, duplicated, elsewhere) { 'use strict'; exports['default'] = function() { return [duplicated.something, elsewhere['default']]; } }); ================================================ FILE: test/strictMode/output/amd/clashingNames.js ================================================ define(['foo'], function (_foo) { 'use strict'; var foo = 'should not clash'; _foo.bar(); }); ================================================ FILE: test/strictMode/output/amd/clashingObjectProperties.js ================================================ define(['./foo'], function (___foo) { 'use strict'; var obj = { foo: function foo () {} }; ___foo.foo(); }); ================================================ FILE: test/strictMode/output/amd/conditionalExport.js ================================================ define(['exports'], function (exports) { 'use strict'; var foo = function () {}; var bar = 'a'; if ( false ) { foo = function () { exports.bar = bar = 'b'; }; } exports.foo = foo; exports.bar = bar; }); ================================================ FILE: test/strictMode/output/amd/constructor.js ================================================ define(['exports'], function (exports) { 'use strict'; exports['default'] = function () { var constructor; constructor = 42; } }); ================================================ FILE: test/strictMode/output/amd/duplicateImportFalsePositive.js ================================================ define(['exports', 'bar'], function (exports, bar) { 'use strict'; Object.defineProperty(exports, 'foo', { enumerable: true, get: function () { return bar.foo; }}); }); ================================================ FILE: test/strictMode/output/amd/duplicateImports.js ================================================ define(['foo'], function (foo) { 'use strict'; foo.bar(); foo.baz(); }); ================================================ FILE: test/strictMode/output/amd/earlyExport.js ================================================ define(['exports'], function (exports) { 'use strict'; exports['default'] = foo; function foo () { console.log( 'fooing' ); } }); ================================================ FILE: test/strictMode/output/amd/emptyImport.js ================================================ define(['polyfills', 'foo'], function (__dep0__, bar) { 'use strict'; }); ================================================ FILE: test/strictMode/output/amd/emptyImportWithDefaultExport.js ================================================ define(['exports', 'foo', 'polyfills'], function (exports, foo) { 'use strict'; exports['default'] = 'baz'; }); ================================================ FILE: test/strictMode/output/amd/escapedSource.js ================================================ define(['fo\no'], function (foo) { 'use strict'; }); ================================================ FILE: test/strictMode/output/amd/exportAnonFunction.js ================================================ define(['exports'], function (exports) { 'use strict'; exports['default'] = function () { console.log( 'I am anonymous' ); } }); ================================================ FILE: test/strictMode/output/amd/exportClass.js ================================================ define(['exports'], function (exports) { 'use strict'; class Point {} exports.Point = Point; }); ================================================ FILE: test/strictMode/output/amd/exportClassWithSuper.js ================================================ define(['bar'], function (Bar) { 'use strict'; class Foo extends Bar['default'] { constructor() { super(); console.log('Foo constructed'); } } }); ================================================ FILE: test/strictMode/output/amd/exportDefault.js ================================================ define(['exports'], function (exports) { 'use strict'; exports['default'] = 'foo'; }); ================================================ FILE: test/strictMode/output/amd/exportFunction.js ================================================ define(['exports'], function (exports) { 'use strict'; function foo ( str ) { return str.toUpperCase(); } exports['default'] = foo; }); ================================================ FILE: test/strictMode/output/amd/exportInlineFunction.js ================================================ define(['exports'], function (exports) { 'use strict'; exports.foo = foo; function foo ( str ) { return str.toUpperCase(); } }); ================================================ FILE: test/strictMode/output/amd/exportLet.js ================================================ define(['exports'], function (exports) { 'use strict'; let answer = 41; answer++; exports.answer = answer; }); ================================================ FILE: test/strictMode/output/amd/exportNamed.js ================================================ define(['exports'], function (exports) { 'use strict'; var foo = 'bar', answer = 42; exports.foo = foo; exports.answer = answer; }); ================================================ FILE: test/strictMode/output/amd/exportNamedCollidesWithFunctionExpression.js ================================================ define('foo', ['exports'], function (exports) { 'use strict'; var foo = "bar"; if (false) { someFunction = function foo() { }; } exports.foo = foo; }); ================================================ FILE: test/strictMode/output/amd/exportNamedFromNamedImportES3.js ================================================ define('foo', ['exports', 'foo'], function (exports, foo) { 'use strict'; exports.bar = foo.foo; }); ================================================ FILE: test/strictMode/output/amd/exportNamedFunction.js ================================================ define(['exports'], function (exports) { 'use strict'; exports.foo = foo; exports.bar = bar; exports.baz = baz; function foo() {} function bar() {} function baz() {} }); ================================================ FILE: test/strictMode/output/amd/exportVar.js ================================================ define(['exports'], function (exports) { 'use strict'; var foo = 'bar'; foo = 'baz'; exports.foo = foo; }); ================================================ FILE: test/strictMode/output/amd/footer.js ================================================ define(['exports', 'whatever'], function (exports, whatever) { 'use strict'; whatever['default'](); exports['default'] = 'someExport'; }); /* this is a footer */ ================================================ FILE: test/strictMode/output/amd/hasExportsVariable.js ================================================ define(['exports'], function (exports) { 'use strict'; var _exports = {}; _exports.foo = 'bar'; exports['default'] = _exports; }); ================================================ FILE: test/strictMode/output/amd/importAll.js ================================================ define(['fs'], function (fs) { 'use strict'; }); ================================================ FILE: test/strictMode/output/amd/importDefault.js ================================================ define(['foo'], function (foo) { 'use strict'; console.log( foo['default'] ); }); ================================================ FILE: test/strictMode/output/amd/importNamed.js ================================================ define(['baz'], function (baz) { 'use strict'; }); ================================================ FILE: test/strictMode/output/amd/intermediateSourcemaps.js ================================================ define(function () { 'use strict'; var answer = 42; }); ================================================ FILE: test/strictMode/output/amd/mixedImports.js ================================================ define(['asap'], function (asap) { 'use strict'; }); ================================================ FILE: test/strictMode/output/amd/multipleImports.js ================================================ define(['exports', 'foo', 'bar', 'baz'], function (exports, foo, bar, baz) { 'use strict'; var qux = foo['default']( bar['default']( baz['default'] ) ); exports['default'] = qux; }); ================================================ FILE: test/strictMode/output/amd/namedAmdModule.js ================================================ define('myModule', ['foo'], function (foo) { 'use strict'; foo['default'](); }); ================================================ FILE: test/strictMode/output/amd/preparsed.js ================================================ define(['./bar'], function (foo) { 'use strict'; }); ================================================ FILE: test/strictMode/output/amd/reExportES3.js ================================================ define(['exports', 'foo'], function (exports, foo) { 'use strict'; exports['default'] = foo['default']; }); ================================================ FILE: test/strictMode/output/amd/renamedExport.js ================================================ define(['exports'], function (exports) { 'use strict'; var a = 42; exports.answer = a; }); ================================================ FILE: test/strictMode/output/amd/renamedImport.js ================================================ define(['fs'], function (fs) { 'use strict'; }); ================================================ FILE: test/strictMode/output/amd/safeCommentRemoval.js ================================================ define(['exports'], function (exports) { 'use strict'; var foo = 42; exports.foo = foo; }); ================================================ FILE: test/strictMode/output/amd/shadowedExport.js ================================================ define(['exports'], function (exports) { 'use strict'; exports.foo = foo; function foo () { } function bar() { var foo; foo = "qux"; } }); ================================================ FILE: test/strictMode/output/amd/shadowedImport.js ================================================ define(['foo'], function (_foo) { 'use strict'; _foo.a(); (function () { var foo = 'bar'; _foo.a(); }()) }); ================================================ FILE: test/strictMode/output/amd/sparseArray.js ================================================ define(function () { 'use strict'; [1,,3,4] }); ================================================ FILE: test/strictMode/output/amd/trailingEmptyImport.js ================================================ define(['foo', 'polyfills'], function (foo) { 'use strict'; }); ================================================ FILE: test/strictMode/output/amd/unscopedNameConflicts.js ================================================ define(['./mod/path/location'], function (path__location) { 'use strict'; path__location.find(); console.log(location.href); }); ================================================ FILE: test/strictMode/output/amd/updateExportInArgument.js ================================================ define(['exports'], function (exports) { 'use strict'; exports.decr = decr; var a = 100; function decr () { console.log( '%d bottles of beer on the wall', ( --a, exports.num = a ) ); console.log( '%d bottles of beer', ( a--, exports.num = a, a + 1 ) ); } exports.num = a; }); ================================================ FILE: test/strictMode/output/amd/updateExpressionInFunction.js ================================================ define(['exports'], function (exports) { 'use strict'; exports.incr = incr; var a = 1; function incr () { var b = a++; exports.num = a; console.log( 'incremented from %s to %s', b, a ); } exports.num = a; }); ================================================ FILE: test/strictMode/output/amd/useStrictFalse.js ================================================ define(function () { implicitGlobal = 'lol'; }); ================================================ FILE: test/strictMode/output/cjs/absolutePaths.js ================================================ 'use strict'; var foo = require('../../foo'); var bar = require('../bar'); var baz = require('./baz'); var qux = require('./../qux'); ================================================ FILE: test/strictMode/output/cjs/banner.js ================================================ /* this is a banner */ 'use strict'; var whatever = require('whatever'); whatever['default'](); exports['default'] = 'someExport'; ================================================ FILE: test/strictMode/output/cjs/bannerAndFooter.js ================================================ /* this is a banner */ 'use strict'; var whatever = require('whatever'); whatever['default'](); exports['default'] = 'someExport'; /* this is a footer */ ================================================ FILE: test/strictMode/output/cjs/clashingFunctionArguments.js ================================================ 'use strict'; exports.bar = bar; var y__z = require('x/y/z'); function bar ( z ) { return y__z.foo( z ); } ================================================ FILE: test/strictMode/output/cjs/clashingMixedImports.js ================================================ 'use strict'; var duplicated = require('duplicated'); var elsewhere = require('elsewhere'); exports['default'] = function() { return [duplicated.something, elsewhere['default']]; } ================================================ FILE: test/strictMode/output/cjs/clashingNames.js ================================================ 'use strict'; var _foo = require('foo'); var foo = 'should not clash'; _foo.bar(); ================================================ FILE: test/strictMode/output/cjs/clashingObjectProperties.js ================================================ 'use strict'; var ___foo = require('./foo'); var obj = { foo: function foo () {} }; ___foo.foo(); ================================================ FILE: test/strictMode/output/cjs/conditionalExport.js ================================================ 'use strict'; var foo = function () {}; var bar = 'a'; if ( false ) { foo = function () { exports.bar = bar = 'b'; }; } exports.foo = foo; exports.bar = bar; ================================================ FILE: test/strictMode/output/cjs/constructor.js ================================================ 'use strict'; exports['default'] = function () { var constructor; constructor = 42; } ================================================ FILE: test/strictMode/output/cjs/duplicateImportFalsePositive.js ================================================ 'use strict'; Object.defineProperty(exports, 'foo', { enumerable: true, get: function () { return bar.foo; }}); var bar = require('bar'); ================================================ FILE: test/strictMode/output/cjs/duplicateImports.js ================================================ 'use strict'; var foo = require('foo'); foo.bar(); foo.baz(); ================================================ FILE: test/strictMode/output/cjs/earlyExport.js ================================================ 'use strict'; exports['default'] = foo; function foo () { console.log( 'fooing' ); } ================================================ FILE: test/strictMode/output/cjs/emptyImport.js ================================================ 'use strict'; require('polyfills'); var bar = require('foo'); ================================================ FILE: test/strictMode/output/cjs/emptyImportWithDefaultExport.js ================================================ 'use strict'; var foo = require('foo'); require('polyfills'); exports['default'] = 'baz'; ================================================ FILE: test/strictMode/output/cjs/escapedSource.js ================================================ 'use strict'; var foo = require('fo\no'); ================================================ FILE: test/strictMode/output/cjs/exportAnonFunction.js ================================================ 'use strict'; exports['default'] = function () { console.log( 'I am anonymous' ); } ================================================ FILE: test/strictMode/output/cjs/exportClass.js ================================================ 'use strict'; class Point {} exports.Point = Point; ================================================ FILE: test/strictMode/output/cjs/exportClassWithSuper.js ================================================ 'use strict'; var Bar = require('bar'); class Foo extends Bar['default'] { constructor() { super(); console.log('Foo constructed'); } } ================================================ FILE: test/strictMode/output/cjs/exportDefault.js ================================================ 'use strict'; exports['default'] = 'foo'; ================================================ FILE: test/strictMode/output/cjs/exportFunction.js ================================================ 'use strict'; function foo ( str ) { return str.toUpperCase(); } exports['default'] = foo; ================================================ FILE: test/strictMode/output/cjs/exportInlineFunction.js ================================================ 'use strict'; exports.foo = foo; function foo ( str ) { return str.toUpperCase(); } ================================================ FILE: test/strictMode/output/cjs/exportLet.js ================================================ 'use strict'; let answer = 41; answer++; exports.answer = answer; ================================================ FILE: test/strictMode/output/cjs/exportNamed.js ================================================ 'use strict'; var foo = 'bar', answer = 42; exports.foo = foo; exports.answer = answer; ================================================ FILE: test/strictMode/output/cjs/exportNamedCollidesWithFunctionExpression.js ================================================ 'use strict'; var foo = "bar"; if (false) { someFunction = function foo() { }; } exports.foo = foo; ================================================ FILE: test/strictMode/output/cjs/exportNamedFromNamedImportES3.js ================================================ 'use strict'; var foo = require('foo'); exports.bar = foo.foo; ================================================ FILE: test/strictMode/output/cjs/exportNamedFunction.js ================================================ 'use strict'; exports.foo = foo; exports.bar = bar; exports.baz = baz; function foo() {} function bar() {} function baz() {} ================================================ FILE: test/strictMode/output/cjs/exportVar.js ================================================ 'use strict'; var foo = 'bar'; foo = 'baz'; exports.foo = foo; ================================================ FILE: test/strictMode/output/cjs/footer.js ================================================ 'use strict'; var whatever = require('whatever'); whatever['default'](); exports['default'] = 'someExport'; /* this is a footer */ ================================================ FILE: test/strictMode/output/cjs/hasExportsVariable.js ================================================ 'use strict'; var _exports = {}; _exports.foo = 'bar'; exports['default'] = _exports; ================================================ FILE: test/strictMode/output/cjs/importAll.js ================================================ 'use strict'; var fs = require('fs'); ================================================ FILE: test/strictMode/output/cjs/importDefault.js ================================================ 'use strict'; var foo = require('foo'); console.log( foo['default'] ); ================================================ FILE: test/strictMode/output/cjs/importNamed.js ================================================ 'use strict'; var baz = require('baz'); ================================================ FILE: test/strictMode/output/cjs/intermediateSourcemaps.js ================================================ 'use strict'; var answer = 42; ================================================ FILE: test/strictMode/output/cjs/mixedImports.js ================================================ 'use strict'; var asap = require('asap'); ================================================ FILE: test/strictMode/output/cjs/multipleImports.js ================================================ 'use strict'; var foo = require('foo'); var bar = require('bar'); var baz = require('baz'); var qux = foo['default']( bar['default']( baz['default'] ) ); exports['default'] = qux; ================================================ FILE: test/strictMode/output/cjs/namedAmdModule.js ================================================ 'use strict'; var foo = require('foo'); foo['default'](); ================================================ FILE: test/strictMode/output/cjs/preparsed.js ================================================ 'use strict'; var foo = require('./bar'); ================================================ FILE: test/strictMode/output/cjs/reExportES3.js ================================================ 'use strict'; var foo = require('foo'); exports['default'] = foo['default']; ================================================ FILE: test/strictMode/output/cjs/renamedExport.js ================================================ 'use strict'; var a = 42; exports.answer = a; ================================================ FILE: test/strictMode/output/cjs/renamedImport.js ================================================ 'use strict'; var fs = require('fs'); ================================================ FILE: test/strictMode/output/cjs/safeCommentRemoval.js ================================================ 'use strict'; var foo = 42; exports.foo = foo; ================================================ FILE: test/strictMode/output/cjs/shadowedExport.js ================================================ 'use strict'; exports.foo = foo; function foo () { } function bar() { var foo; foo = "qux"; } ================================================ FILE: test/strictMode/output/cjs/shadowedImport.js ================================================ 'use strict'; var _foo = require('foo'); _foo.a(); (function () { var foo = 'bar'; _foo.a(); }()) ================================================ FILE: test/strictMode/output/cjs/sparseArray.js ================================================ 'use strict'; [1,,3,4] ================================================ FILE: test/strictMode/output/cjs/trailingEmptyImport.js ================================================ 'use strict'; var foo = require('foo'); require('polyfills'); ================================================ FILE: test/strictMode/output/cjs/unscopedNameConflicts.js ================================================ 'use strict'; var path__location = require('./mod/path/location'); path__location.find(); console.log(location.href); ================================================ FILE: test/strictMode/output/cjs/updateExportInArgument.js ================================================ 'use strict'; exports.decr = decr; var a = 100; function decr () { console.log( '%d bottles of beer on the wall', ( --a, exports.num = a ) ); console.log( '%d bottles of beer', ( a--, exports.num = a, a + 1 ) ); } exports.num = a; ================================================ FILE: test/strictMode/output/cjs/updateExpressionInFunction.js ================================================ 'use strict'; exports.incr = incr; var a = 1; function incr () { var b = a++; exports.num = a; console.log( 'incremented from %s to %s', b, a ); } exports.num = a; ================================================ FILE: test/strictMode/output/cjs/useStrictFalse.js ================================================ implicitGlobal = 'lol'; ================================================ FILE: test/strictMode/output/umd/absolutePaths.js ================================================ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../foo'), require('../bar'), require('./baz'), require('./../qux')) : typeof define === 'function' && define.amd ? define('my/nested/module', ['foo', 'my/bar', 'my/nested/baz', 'my/qux'], factory) : factory(global.foo, global.bar, global.baz, global.qux) }(this, function (foo, bar, baz, qux) { 'use strict'; })); ================================================ FILE: test/strictMode/output/umd/banner.js ================================================ /* this is a banner */ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('whatever')) : typeof define === 'function' && define.amd ? define(['exports', 'whatever'], factory) : factory((global.myModule = {}), global.whatever) }(this, function (exports, whatever) { 'use strict'; whatever['default'](); exports['default'] = 'someExport'; })); ================================================ FILE: test/strictMode/output/umd/bannerAndFooter.js ================================================ /* this is a banner */ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('whatever')) : typeof define === 'function' && define.amd ? define(['exports', 'whatever'], factory) : factory((global.myModule = {}), global.whatever) }(this, function (exports, whatever) { 'use strict'; whatever['default'](); exports['default'] = 'someExport'; })); /* this is a footer */ ================================================ FILE: test/strictMode/output/umd/clashingFunctionArguments.js ================================================ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('x/y/z')) : typeof define === 'function' && define.amd ? define(['exports', 'x/y/z'], factory) : factory((global.myModule = {}), global.y__z) }(this, function (exports, y__z) { 'use strict'; exports.bar = bar; function bar ( z ) { return y__z.foo( z ); } })); ================================================ FILE: test/strictMode/output/umd/clashingMixedImports.js ================================================ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('duplicated'), require('elsewhere')) : typeof define === 'function' && define.amd ? define(['exports', 'duplicated', 'elsewhere'], factory) : factory((global.myModule = {}), global.duplicated, global.elsewhere) }(this, function (exports, duplicated, elsewhere) { 'use strict'; exports['default'] = function() { return [duplicated.something, elsewhere['default']]; } })); ================================================ FILE: test/strictMode/output/umd/clashingNames.js ================================================ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('foo')) : typeof define === 'function' && define.amd ? define(['foo'], factory) : factory(global._foo) }(this, function (_foo) { 'use strict'; var foo = 'should not clash'; _foo.bar(); })); ================================================ FILE: test/strictMode/output/umd/clashingObjectProperties.js ================================================ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('./foo')) : typeof define === 'function' && define.amd ? define(['./foo'], factory) : factory(global.___foo) }(this, function (___foo) { 'use strict'; var obj = { foo: function foo () {} }; ___foo.foo(); })); ================================================ FILE: test/strictMode/output/umd/conditionalExport.js ================================================ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'], factory) : factory((global.myModule = {})) }(this, function (exports) { 'use strict'; var foo = function () {}; var bar = 'a'; if ( false ) { foo = function () { exports.bar = bar = 'b'; }; } exports.foo = foo; exports.bar = bar; })); ================================================ FILE: test/strictMode/output/umd/constructor.js ================================================ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'], factory) : factory((global.myModule = {})) }(this, function (exports) { 'use strict'; exports['default'] = function () { var constructor; constructor = 42; } })); ================================================ FILE: test/strictMode/output/umd/duplicateImportFalsePositive.js ================================================ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('bar')) : typeof define === 'function' && define.amd ? define(['exports', 'bar'], factory) : factory((global.myModule = {}), global.bar) }(this, function (exports, bar) { 'use strict'; Object.defineProperty(exports, 'foo', { enumerable: true, get: function () { return bar.foo; }}); })); ================================================ FILE: test/strictMode/output/umd/duplicateImports.js ================================================ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('foo')) : typeof define === 'function' && define.amd ? define(['foo'], factory) : factory(global.foo) }(this, function (foo) { 'use strict'; foo.bar(); foo.baz(); })); ================================================ FILE: test/strictMode/output/umd/earlyExport.js ================================================ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'], factory) : factory((global.myModule = {})) }(this, function (exports) { 'use strict'; exports['default'] = foo; function foo () { console.log( 'fooing' ); } })); ================================================ FILE: test/strictMode/output/umd/emptyImport.js ================================================ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('polyfills'), require('foo')) : typeof define === 'function' && define.amd ? define(['polyfills', 'foo'], factory) : factory(undefined, global.bar) }(this, function (__dep0__, bar) { 'use strict'; })); ================================================ FILE: test/strictMode/output/umd/emptyImportWithDefaultExport.js ================================================ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('foo'), require('polyfills')) : typeof define === 'function' && define.amd ? define(['exports', 'foo', 'polyfills'], factory) : factory((global.myModule = {}), global.foo) }(this, function (exports, foo) { 'use strict'; exports['default'] = 'baz'; })); ================================================ FILE: test/strictMode/output/umd/escapedSource.js ================================================ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('fo\no')) : typeof define === 'function' && define.amd ? define(['fo\no'], factory) : factory(global.foo) }(this, function (foo) { 'use strict'; })); ================================================ FILE: test/strictMode/output/umd/exportAnonFunction.js ================================================ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'], factory) : factory((global.myModule = {})) }(this, function (exports) { 'use strict'; exports['default'] = function () { console.log( 'I am anonymous' ); } })); ================================================ FILE: test/strictMode/output/umd/exportClass.js ================================================ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'], factory) : factory((global.myModule = {})) }(this, function (exports) { 'use strict'; class Point {} exports.Point = Point; })); ================================================ FILE: test/strictMode/output/umd/exportClassWithSuper.js ================================================ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('bar')) : typeof define === 'function' && define.amd ? define(['bar'], factory) : factory(global.Bar) }(this, function (Bar) { 'use strict'; class Foo extends Bar['default'] { constructor() { super(); console.log('Foo constructed'); } } })); ================================================ FILE: test/strictMode/output/umd/exportDefault.js ================================================ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'], factory) : factory((global.myModule = {})) }(this, function (exports) { 'use strict'; exports['default'] = 'foo'; })); ================================================ FILE: test/strictMode/output/umd/exportFunction.js ================================================ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'], factory) : factory((global.myModule = {})) }(this, function (exports) { 'use strict'; function foo ( str ) { return str.toUpperCase(); } exports['default'] = foo; })); ================================================ FILE: test/strictMode/output/umd/exportInlineFunction.js ================================================ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'], factory) : factory((global.myModule = {})) }(this, function (exports) { 'use strict'; exports.foo = foo; function foo ( str ) { return str.toUpperCase(); } })); ================================================ FILE: test/strictMode/output/umd/exportLet.js ================================================ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'], factory) : factory((global.myModule = {})) }(this, function (exports) { 'use strict'; let answer = 41; answer++; exports.answer = answer; })); ================================================ FILE: test/strictMode/output/umd/exportNamed.js ================================================ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'], factory) : factory((global.myModule = {})) }(this, function (exports) { 'use strict'; var foo = 'bar', answer = 42; exports.foo = foo; exports.answer = answer; })); ================================================ FILE: test/strictMode/output/umd/exportNamedCollidesWithFunctionExpression.js ================================================ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define('foo', ['exports'], factory) : factory((global.myModule = {})) }(this, function (exports) { 'use strict'; var foo = "bar"; if (false) { someFunction = function foo() { }; } exports.foo = foo; })); ================================================ FILE: test/strictMode/output/umd/exportNamedFromNamedImportES3.js ================================================ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('foo')) : typeof define === 'function' && define.amd ? define('foo', ['exports', 'foo'], factory) : factory((global.myModule = {}), global.foo) }(this, function (exports, foo) { 'use strict'; exports.bar = foo.foo; })); ================================================ FILE: test/strictMode/output/umd/exportNamedFunction.js ================================================ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'], factory) : factory((global.myModule = {})) }(this, function (exports) { 'use strict'; exports.foo = foo; exports.bar = bar; exports.baz = baz; function foo() {} function bar() {} function baz() {} })); ================================================ FILE: test/strictMode/output/umd/exportVar.js ================================================ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'], factory) : factory((global.myModule = {})) }(this, function (exports) { 'use strict'; var foo = 'bar'; foo = 'baz'; exports.foo = foo; })); ================================================ FILE: test/strictMode/output/umd/footer.js ================================================ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('whatever')) : typeof define === 'function' && define.amd ? define(['exports', 'whatever'], factory) : factory((global.myModule = {}), global.whatever) }(this, function (exports, whatever) { 'use strict'; whatever['default'](); exports['default'] = 'someExport'; })); /* this is a footer */ ================================================ FILE: test/strictMode/output/umd/hasExportsVariable.js ================================================ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'], factory) : factory((global.myModule = {})) }(this, function (exports) { 'use strict'; var _exports = {}; _exports.foo = 'bar'; exports['default'] = _exports; })); ================================================ FILE: test/strictMode/output/umd/importAll.js ================================================ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('fs')) : typeof define === 'function' && define.amd ? define(['fs'], factory) : factory(global.fs) }(this, function (fs) { 'use strict'; })); ================================================ FILE: test/strictMode/output/umd/importDefault.js ================================================ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('foo')) : typeof define === 'function' && define.amd ? define(['foo'], factory) : factory(global.foo) }(this, function (foo) { 'use strict'; console.log( foo['default'] ); })); ================================================ FILE: test/strictMode/output/umd/importNamed.js ================================================ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('baz')) : typeof define === 'function' && define.amd ? define(['baz'], factory) : factory(global.baz) }(this, function (baz) { 'use strict'; })); ================================================ FILE: test/strictMode/output/umd/intermediateSourcemaps.js ================================================ (function (factory) { !(typeof exports === 'object' && typeof module !== 'undefined') && typeof define === 'function' && define.amd ? define(factory) : factory() }(function () { 'use strict'; var answer = 42; })); ================================================ FILE: test/strictMode/output/umd/mixedImports.js ================================================ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('asap')) : typeof define === 'function' && define.amd ? define(['asap'], factory) : factory(global.asap) }(this, function (asap) { 'use strict'; })); ================================================ FILE: test/strictMode/output/umd/multipleImports.js ================================================ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('foo'), require('bar'), require('baz')) : typeof define === 'function' && define.amd ? define(['exports', 'foo', 'bar', 'baz'], factory) : factory((global.myModule = {}), global.foo, global.bar, global.baz) }(this, function (exports, foo, bar, baz) { 'use strict'; var qux = foo['default']( bar['default']( baz['default'] ) ); exports['default'] = qux; })); ================================================ FILE: test/strictMode/output/umd/namedAmdModule.js ================================================ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('foo')) : typeof define === 'function' && define.amd ? define('myModule', ['foo'], factory) : factory(global.foo) }(this, function (foo) { 'use strict'; foo['default'](); })); ================================================ FILE: test/strictMode/output/umd/preparsed.js ================================================ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('./bar')) : typeof define === 'function' && define.amd ? define(['./bar'], factory) : factory(global.foo) }(this, function (foo) { 'use strict'; })); ================================================ FILE: test/strictMode/output/umd/reExportES3.js ================================================ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('foo')) : typeof define === 'function' && define.amd ? define(['exports', 'foo'], factory) : factory((global.myModule = {}), global.foo) }(this, function (exports, foo) { 'use strict'; exports['default'] = foo['default']; })); ================================================ FILE: test/strictMode/output/umd/renamedExport.js ================================================ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'], factory) : factory((global.myModule = {})) }(this, function (exports) { 'use strict'; var a = 42; exports.answer = a; })); ================================================ FILE: test/strictMode/output/umd/renamedImport.js ================================================ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('fs')) : typeof define === 'function' && define.amd ? define(['fs'], factory) : factory(global.fs) }(this, function (fs) { 'use strict'; })); ================================================ FILE: test/strictMode/output/umd/safeCommentRemoval.js ================================================ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'], factory) : factory((global.myModule = {})) }(this, function (exports) { 'use strict'; var foo = 42; exports.foo = foo; })); ================================================ FILE: test/strictMode/output/umd/shadowedExport.js ================================================ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'], factory) : factory((global.myModule = {})) }(this, function (exports) { 'use strict'; exports.foo = foo; function foo () { } function bar() { var foo; foo = "qux"; } })); ================================================ FILE: test/strictMode/output/umd/shadowedImport.js ================================================ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('foo')) : typeof define === 'function' && define.amd ? define(['foo'], factory) : factory(global._foo) }(this, function (_foo) { 'use strict'; _foo.a(); (function () { var foo = 'bar'; _foo.a(); }()) })); ================================================ FILE: test/strictMode/output/umd/sparseArray.js ================================================ (function (factory) { !(typeof exports === 'object' && typeof module !== 'undefined') && typeof define === 'function' && define.amd ? define(factory) : factory() }(function () { 'use strict'; [1,,3,4] })); ================================================ FILE: test/strictMode/output/umd/trailingEmptyImport.js ================================================ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('foo'), require('polyfills')) : typeof define === 'function' && define.amd ? define(['foo', 'polyfills'], factory) : factory(global.foo) }(this, function (foo) { 'use strict'; })); ================================================ FILE: test/strictMode/output/umd/unscopedNameConflicts.js ================================================ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('./mod/path/location')) : typeof define === 'function' && define.amd ? define(['./mod/path/location'], factory) : factory(global.path__location) }(this, function (path__location) { 'use strict'; path__location.find(); console.log(location.href); })); ================================================ FILE: test/strictMode/output/umd/updateExportInArgument.js ================================================ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'], factory) : factory((global.myModule = {})) }(this, function (exports) { 'use strict'; exports.decr = decr; var a = 100; function decr () { console.log( '%d bottles of beer on the wall', ( --a, exports.num = a ) ); console.log( '%d bottles of beer', ( a--, exports.num = a, a + 1 ) ); } exports.num = a; })); ================================================ FILE: test/strictMode/output/umd/updateExpressionInFunction.js ================================================ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'], factory) : factory((global.myModule = {})) }(this, function (exports) { 'use strict'; exports.incr = incr; var a = 1; function incr () { var b = a++; exports.num = a; console.log( 'incremented from %s to %s', b, a ); } exports.num = a; })); ================================================ FILE: test/strictMode/output/umd/useStrictFalse.js ================================================ (function (factory) { !(typeof exports === 'object' && typeof module !== 'undefined') && typeof define === 'function' && define.amd ? define(factory) : factory() }(function () { implicitGlobal = 'lol'; })); ================================================ FILE: test/test.js ================================================ require( 'source-map-support' ).install(); process.chdir( __dirname ); var testModules = [ 'fastMode', 'strictMode', 'bundle', 'sourcemaps' ]; var results = testModules.map( function ( mod ) { return require( './' + mod )(); }); require( 'sander' ).Promise.all( results ).then( function ( completionTimes ) { testModules.forEach( function ( mod, i ) { console.log( 'completed %s in %sms', mod, completionTimes[i] ); }); }); ================================================ FILE: test/utils/generate.js ================================================ var path = require( 'path' ); var sander = require( 'sander' ); var esperanto = require( '../../' ); var Promise = sander.Promise; process.chdir( __dirname ); generateFastModeOutput(); generateStrictModeOutput(); generateBundleOutput(); function generateFastModeOutput () { var profiles = [ { outputdir: 'amd', method: 'toAmd' }, { outputdir: 'cjs', method: 'toCjs' }, { outputdir: 'umd', method: 'toUmd', options: { name: 'myModule' } } ]; return cleanup().then( buildAll ).catch( function ( err ) { console.log( 'err', err ); }); function cleanup () { return sander.rimraf( '../fastMode/output' ); } function buildAll () { return sander.readdir( '../samples' ).then( function ( samples ) { return Promise.all( samples.map( build ) ); }); } function build ( sample ) { return sander.readFile( '../samples', sample, 'source.js' ).then( String ).then( function ( source ) { var config = require( '../samples/' + sample + '/_config' ), promises; if ( config.strict ) return; if ( config.ast ) { source = { code: source, ast: config.ast }; } promises = profiles.map( function ( profile ) { var transpiled = esperanto[ profile.method ]( source, { name: profile.options && profile.options.name, amdName: config.amdName, absolutePaths: config.absolutePaths, strict: profile.options && profile.options.strict, banner: config.banner, footer: config.footer, useStrict: config.useStrict }); return sander.writeFile( '../fastMode/output', profile.outputdir, sample + '.js', transpiled.code ); }); return Promise.all( promises ); }); } } function generateStrictModeOutput () { var profiles = [ { outputdir: 'amd', method: 'toAmd', options: { strict: true } }, { outputdir: 'cjs', method: 'toCjs', options: { strict: true } }, { outputdir: 'umd', method: 'toUmd', options: { strict: true, name: 'myModule' } } ]; return cleanup().then( buildAll ).catch( function ( err ) { console.log( 'err', err ); }); function cleanup () { return sander.rimraf( '../strictMode/output' ); } function buildAll () { return sander.readdir( '../samples' ).then( function ( samples ) { return Promise.all( samples.map( build ) ); }); } function build ( sample ) { return sander.readFile( '../samples', sample, 'source.js' ).then( String ).then( function ( source ) { var config = require( '../samples/' + sample + '/_config' ), promises; if ( config.ast ) { source = { code: source, ast: config.ast }; } promises = profiles.map( function ( profile ) { var transpiled = esperanto[ profile.method ]( source, { name: profile.options && profile.options.name, amdName: config.amdName, absolutePaths: config.absolutePaths, strict: profile.options && profile.options.strict, banner: config.banner, footer: config.footer, _evilES3SafeReExports: config._evilES3SafeReExports, useStrict: config.useStrict }); return sander.writeFile( '../strictMode/output', profile.outputdir, sample + '.js', transpiled.code ); }); return Promise.all( promises ); }); } } function generateBundleOutput () { var profiles = [ { description: 'bundle.concat()', method: 'concat', outputdir: 'concat' }, { description: 'bundle.toAmd()', method: 'toAmd', outputdir: 'amdDefaults' }, { description: 'bundle.toCjs()', method: 'toCjs', outputdir: 'cjsDefaults' }, { description: 'bundle.toUmd()', method: 'toUmd', outputdir: 'umdDefaults', options: { name: 'myModule' } }, { description: 'bundle.toAmd({ strict: true })', method: 'toAmd', outputdir: 'amd', options: { strict: true } }, { description: 'bundle.toCjs({ strict: true })', method: 'toCjs', outputdir: 'cjs', options: { strict: true } }, { description: 'bundle.toUmd({ strict: true })', method: 'toUmd', outputdir: 'umd', options: { strict: true, name: 'myModule' } } ]; return cleanup().then( buildAll ).catch( function ( err ) { console.log( 'err', err ); }); function cleanup () { return sander.rimraf( '../bundle/output' ); } function buildAll () { return sander.readdir( '../bundle/input' ).then( function ( sourceBundles ) { return Promise.all( sourceBundles.map( build ) ); }); } function build ( sourceBundle ) { var config; if ( /DS_Store/.test( sourceBundle ) ) return; config = require( '../bundle/input/' + sourceBundle + '/_config' ); var promises = profiles.map( function ( profile ) { return esperanto.bundle({ base: path.join( '../bundle/input', sourceBundle ), entry: 'main', skip: config.skip, names: config.names, transform: config.transform, resolvePath: config.resolvePath, modules: config.modules }).then( function ( bundle ) { try { var transpiled = bundle[ profile.method ]({ strict: profile.options && profile.options.strict, name: profile.options && profile.options.name, amdName: config.amdName, banner: config.banner, footer: config.footer, useStrict: config.useStrict, sourceMap: config.sourceMap }); // necessary for CI if ( config.sourceMap ) { transpiled.code = transpiled.code.replace( /base64,.+/, 'base64,xyz' ); } return sander.writeFile( '../bundle/output', profile.outputdir, sourceBundle + '.js', transpiled.code ); } catch ( err ) { // some modules can't be transpiled with defaultOnly if ( !/strict mode/.test( err.message ) && !/bundles that have no imports/.test( err.message ) ) { setTimeout( function () { throw err; }); } } }); }); return Promise.all( promises ); } } ================================================ FILE: test/utils/makeWhitespaceVisible.js ================================================ module.exports = function makeWhitespaceVisible ( str ) { return str.replace( /\r?\n/g, '¶\n' ).replace( /^\t+/gm, function ( match ) { // replace leading tabs return match.replace( /\t/g, '--->' ); }).replace( /^( +)/gm, function ( match, $1 ) { // replace leading spaces return $1.replace( / /g, '*' ); }).replace( /\t+$/gm, function ( match ) { // replace trailing tabs return match.replace( /\t/g, '--->' ); }).replace( /( +)$/gm, function ( match, $1 ) { // replace trailing spaces return $1.replace( / /g, '*' ); }); };