Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Token has only one originalLocation #265

Merged
merged 2 commits into from
Jun 15, 2024

Conversation

mizdra
Copy link
Owner

@mizdra mizdra commented Jun 15, 2024

Breaking Changes

The token has only one originalLocation

Previously, a token returned Locator#load could have multiple OriginalLocation.

const filePath = resolve('example/02-import/2.css'); // Convert to absolute path
const result = await locator.load(filePath);

assert.deepEqual(result, {
  dependencies: ['/path/to/1.css'],
  tokens: [
    {
      name: 'a',
      originalLocations: [
        {
          filePath: '/path/to/1.css',
          start: { line: 1, column: 1 },
          end: { line: 1, column: 2 },
        },
        {
          filePath: '/path/to/1.css',
          start: { line: 2, column: 1 },
          end: { line: 2, column: 2 },
        },
      ],
    },
  ],
});

From now on, each token will have one OriginalLocation.

const filePath = resolve('example/02-import/2.css'); // Convert to absolute path
const result = await locator.load(filePath);

assert.deepEqual(result, {
  dependencies: ['/path/to/1.css'],
  tokens: [
    {
      name: 'a',
      originalLocation: {
        filePath: '/path/to/1.css',
        start: { line: 1, column: 1 },
        end: { line: 1, column: 2 },
      },
    },
    {
      name: 'a',
      originalLocation: {
        filePath: '/path/to/1.css',
        start: { line: 2, column: 1 },
        end: { line: 2, column: 2 },
      },
    },
  ],
});

Locator#load is part of the experimental Programmable API. Therefore, this change is shipped as a minor update.

@mizdra mizdra added the Type: Change Change existing functionality. label Jun 15, 2024
@mizdra mizdra marked this pull request as ready for review June 15, 2024 09:09
@mizdra mizdra mentioned this pull request Jun 15, 2024
@mizdra mizdra merged commit 85ecbb5 into main Jun 15, 2024
6 checks passed
@mizdra mizdra deleted the token-has-only-one-original-location branch June 15, 2024 09:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Change Change existing functionality.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant