Skip to content

Commit

Permalink
fix: MinimapServiceV1
Browse files Browse the repository at this point in the history
We should not mix ES and CJS modules

parcel-bundler/parcel#5531 (comment)
  • Loading branch information
aminya committed Dec 29, 2020
1 parent f276547 commit 1a4f3fa
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 6 deletions.
35 changes: 31 additions & 4 deletions lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import { Emitter, CompositeDisposable } from 'atom'
import MinimapElement from './minimap-element'
import Minimap from './minimap'
import config from './config.json'
import { deactivateAllPlugins } from './plugin-management'
import * as PluginManagement from './plugin-management'

exports.config = config
export * as config from './config.json'
export * from './plugin-management'
export { default as Minimap } from './minimap'

Expand Down Expand Up @@ -110,7 +110,7 @@ export function minimapViewProvider (model) {
export function deactivate () {
if (!active) { return }

deactivateAllPlugins()
PluginManagement.deactivateAllPlugins()

if (editorsMinimaps) {
editorsMinimaps.forEach((value, key) => {
Expand Down Expand Up @@ -358,9 +358,36 @@ function initSubscriptions () {
}))
}

// The public exports included in the service:
const MinimapServiceV1 = {
minimapViewProvider,
getConfigSchema,
onDidActivate,
onDidDeactivate,
onDidCreateMinimap,
onDidAddPlugin,
onDidRemovePlugin,
onDidActivatePlugin,
onDidDeactivatePlugin,
onDidChangePluginOrder,
minimapClass,
minimapForEditorElement,
minimapForEditor,
standAloneMinimapForEditor,
getActiveMinimap,
observeMinimaps,
registerPlugin: PluginManagement.registerPlugin,
unregisterPlugin: PluginManagement.unregisterPlugin,
togglePluginActivation: PluginManagement.togglePluginActivation,
deactivateAllPlugins: PluginManagement.deactivateAllPlugins,
activatePlugin: PluginManagement.activatePlugin,
deactivatePlugin: PluginManagement.deactivatePlugin,
getPluginsOrder: PluginManagement.getPluginsOrder
}

/**
* Returns the Minimap main module instance.
*
* @return {Main} The Minimap main module instance.
*/
export function provideMinimapServiceV1 () { return exports }
export function provideMinimapServiceV1 () { return MinimapServiceV1 }
6 changes: 4 additions & 2 deletions spec/minimap-main-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,10 @@ describe('Minimap package', () => {
})

describe('service', () => {
it('returns the minimap main module', () => {
expect(minimapPackage.provideMinimapServiceV1()).toEqual(minimapPackage)
it('returns the minimap public exports', () => {
const publicExports = Object.keys(minimapPackage.provideMinimapServiceV1())
const allExports = Object.keys(minimapPackage)
expect(publicExports.every((str) => { return allExports.includes(str) || console.log(str) } )).toBeTruthy()
})

it('creates standalone minimap with provided text editor', () => {
Expand Down

0 comments on commit 1a4f3fa

Please sign in to comment.