-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
28 changed files
with
360 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,6 @@ The project is still under development, so it possible dependents on unstable Rs | |
|
||
Current unstable versions are: | ||
|
||
<!-- | Package | Version | Link | | ||
| ------------ | ------------------------------------------------------- | --------------------------------------------------------- | | ||
| @rspack/core | @rspack/[email protected] | [PR](https://github.com/webpack/webpack/pull/11751/files) | --> | ||
| Package | Link | | ||
| ------------ | ------------------------------------------------------- | | ||
| @rspack/core | [PR](https://github.com/web-infra-dev/rspack/pull/7210) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
import { expect, test } from 'vitest'; | ||
import { buildAndGetEntryJsResults } from '#shared'; | ||
import { buildAndGetJsResults } from '#shared'; | ||
|
||
test('source.alias', async () => { | ||
const fixturePath = __dirname; | ||
const { contents } = await buildAndGetEntryJsResults(fixturePath); | ||
const { entries } = await buildAndGetJsResults(fixturePath); | ||
|
||
expect(contents.esm).toContain('hello world'); | ||
expect(contents.cjs).toContain('hello world'); | ||
expect(entries.esm).toContain('hello world'); | ||
expect(entries.cjs).toContain('hello world'); | ||
|
||
// simple artifacts check | ||
expect(contents.esm).toMatchSnapshot(); | ||
expect(contents.cjs).toMatchSnapshot(); | ||
expect(entries.esm).toMatchSnapshot(); | ||
expect(entries.cjs).toMatchSnapshot(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
import { extname, join } from 'node:path'; | ||
import { expect, test } from 'vitest'; | ||
import { buildAndGetEntryJsResults } from '#shared'; | ||
import { buildAndGetJsResults } from '#shared'; | ||
|
||
test('autoExtension generate .mjs in build artifacts with esm format when type is commonjs', async () => { | ||
const fixturePath = join(__dirname, 'type-commonjs'); | ||
const { files } = await buildAndGetEntryJsResults(fixturePath); | ||
expect(extname(files.esm!)).toEqual('.mjs'); | ||
expect(extname(files.cjs!)).toEqual('.js'); | ||
const { entryFiles } = await buildAndGetJsResults(fixturePath); | ||
expect(extname(entryFiles.esm!)).toEqual('.mjs'); | ||
expect(extname(entryFiles.cjs!)).toEqual('.js'); | ||
}); | ||
|
||
test('autoExtension generate .cjs in build artifacts with cjs format when type is module', async () => { | ||
const fixturePath = join(__dirname, 'type-module'); | ||
const { files } = await buildAndGetEntryJsResults(fixturePath); | ||
expect(extname(files.esm!)).toEqual('.js'); | ||
expect(extname(files.cjs!)).toEqual('.cjs'); | ||
const { entryFiles } = await buildAndGetJsResults(fixturePath); | ||
expect(extname(entryFiles.esm!)).toEqual('.js'); | ||
expect(extname(entryFiles.cjs!)).toEqual('.cjs'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { defineConfig } from '@rslib/core'; | ||
import { generateBundleCjsConfig, generateBundleEsmConfig } from '#shared'; | ||
|
||
export default defineConfig({ | ||
lib: [ | ||
generateBundleEsmConfig(__dirname, { | ||
bundle: false, | ||
}), | ||
generateBundleCjsConfig(__dirname, { | ||
bundle: false, | ||
}), | ||
], | ||
source: { | ||
entry: { | ||
main: ['./src/**'], | ||
}, | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export * from './utils/numbers'; | ||
export * from './utils/strings'; | ||
export * from './sum'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { num1, num2, num3 } from './utils/numbers'; | ||
import { str1, str2, str3 } from './utils/strings'; | ||
|
||
export const numSum = num1 + num2 + num3; | ||
export const strSum = str1 + str2 + str3; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export const num1 = 1; | ||
export const num2 = 2; | ||
export const num3 = 3; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export const str1 = 'str1'; | ||
export const str2 = 'str2'; | ||
export const str3 = 'str3'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"extends": "@rslib/tsconfig/base", | ||
"compilerOptions": { | ||
"baseUrl": "./" | ||
}, | ||
"include": ["src"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { join } from 'node:path'; | ||
import { expect, test } from 'vitest'; | ||
import { buildAndGetJsResults } from '#shared'; | ||
|
||
test('bundle: false', async () => { | ||
const fixturePath = join(__dirname, 'basic'); | ||
const { files } = await buildAndGetJsResults(fixturePath); | ||
|
||
// TODO: record file paths with inline snapshot | ||
// need to add path serialization | ||
expect(files.esm?.length).toBe(4); | ||
expect(files.cjs?.length).toBe(4); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
import { expect, test } from 'vitest'; | ||
import { buildAndGetEntryJsResults } from '#shared'; | ||
import { buildAndGetJsResults } from '#shared'; | ||
|
||
test('source.define', async () => { | ||
const fixturePath = __dirname; | ||
const { contents } = await buildAndGetEntryJsResults(fixturePath); | ||
const { entries } = await buildAndGetJsResults(fixturePath); | ||
|
||
expect(contents.esm).not.toContain('console.info(VERSION)'); | ||
expect(contents.esm).toContain('1.0.0'); | ||
expect(entries.esm).not.toContain('console.info(VERSION)'); | ||
expect(entries.esm).toContain('1.0.0'); | ||
|
||
expect(contents.cjs).not.toContain('console.info(VERSION)'); | ||
expect(contents.cjs).toContain('1.0.0'); | ||
expect(entries.cjs).not.toContain('console.info(VERSION)'); | ||
expect(entries.cjs).toContain('1.0.0'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
import { join } from 'node:path'; | ||
import { expect, test } from 'vitest'; | ||
import { buildAndGetEntryJsResults } from '#shared'; | ||
import { buildAndGetJsResults } from '#shared'; | ||
|
||
test('should fail to build when `output.target` is not "node"', async () => { | ||
const fixturePath = join(__dirname); | ||
const build = buildAndGetEntryJsResults(fixturePath); | ||
const build = buildAndGetJsResults(fixturePath); | ||
await expect(build).rejects.toThrowError('Rspack build failed!'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,24 @@ | ||
import { join } from 'node:path'; | ||
import { expect, test } from 'vitest'; | ||
import { buildAndGetEntryJsResults } from '#shared'; | ||
import { buildAndGetJsResults } from '#shared'; | ||
|
||
test('auto externalize Node.js built-in modules when `output.target` is "node"', async () => { | ||
const fixturePath = join(__dirname); | ||
const { contents } = await buildAndGetEntryJsResults(fixturePath); | ||
const { entries } = await buildAndGetJsResults(fixturePath); | ||
|
||
for (const external of [ | ||
'import * as __WEBPACK_EXTERNAL_MODULE_fs__ from "fs"', | ||
'import * as __WEBPACK_EXTERNAL_MODULE_node_assert__ from "node:assert"', | ||
'import * as __WEBPACK_EXTERNAL_MODULE_react__ from "react"', | ||
]) { | ||
expect(contents.esm).toContain(external); | ||
expect(entries.esm).toContain(external); | ||
} | ||
|
||
for (const external of [ | ||
'var external_fs_namespaceObject = require("fs");', | ||
'var external_node_assert_namespaceObject = require("node:assert");', | ||
'var external_react_namespaceObject = require("react");', | ||
]) { | ||
expect(contents.cjs).toContain(external); | ||
expect(entries.cjs).toContain(external); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
import { expect, test } from 'vitest'; | ||
import { buildAndGetEntryJsResults } from '#shared'; | ||
import { buildAndGetJsResults } from '#shared'; | ||
|
||
test('should downgrade class private method by default', async () => { | ||
const fixturePath = __dirname; | ||
const { contents } = await buildAndGetEntryJsResults(fixturePath); | ||
const { entries } = await buildAndGetJsResults(fixturePath); | ||
|
||
expect(contents.esm).toMatchSnapshot(); | ||
expect(contents.esm).not.toContain('#bar'); | ||
expect(entries.esm).toMatchSnapshot(); | ||
expect(entries.esm).not.toContain('#bar'); | ||
|
||
expect(contents.cjs).toContain('#bar'); | ||
expect(entries.cjs).toContain('#bar'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
import { expect, test } from 'vitest'; | ||
import { buildAndGetEntryJsResults } from '#shared'; | ||
import { buildAndGetJsResults } from '#shared'; | ||
|
||
test('should downgrade class private method by default', async () => { | ||
const fixturePath = __dirname; | ||
const { contents } = await buildAndGetEntryJsResults(fixturePath); | ||
const { entries } = await buildAndGetJsResults(fixturePath); | ||
|
||
expect(contents.esm).toMatchSnapshot(); | ||
expect(contents.esm).toContain('#bar'); | ||
expect(entries.esm).toMatchSnapshot(); | ||
expect(entries.esm).toContain('#bar'); | ||
|
||
expect(contents.cjs).toContain('#bar'); | ||
expect(entries.cjs).toContain('#bar'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.